by emseetech · 2y ago · 0 comments
<article-content>
<author-byline><author-byline>
<content-text></content-text>
</article-content>
This has the benefit that you can describe your markup however you'd like if it doesn't fit into the standard elements, and if you find yourself in "div soup", often times this is mitigated through class names, but using custom elements, the closing tags are much more readable than </div>
</div>
</div>And then you can register a javascript class with customElements.define to add more dynamic behavior, and the sky becomes the limit. Custom elements are like a hidden framework built right into the browser.
If you are unsure what I mean, from the article
> I show them that a span with an onclick-event might seem to be behaving like a link, but that there are many layers of UX missing when you look a bit closer: right-click on this span, and a generic context menu opens up. When on the other hand you right-click on a proper link like this one a specialised context menu opens, with all kinds of options that are specific to a link. And I show them that proper links show up when you ask your screen reader to list all the links on a page, yet spans with an onclick-event don’t. Moreover, a span doesn’t receive focus when you tab to it. And so on. My students see this and they get it. And they love the fact that by being lazy they get much more result.
[1] https://developer.mozilla.org/en-US/blog/aria-accessibility-...
But they've been worked this way for decades. Now they weren't officially added to the spec until browser support for v1 of custom components, but that was still back in 2016.
I feel like a huge door just opened on an idle Saturday morning. I need to experiment to form some opinions.
Thank you & parent poster too.
Quite a good analogy: a pool is responsible for more drownings than you'd think.
Most people in the pool of flexibility and reusability are drowning in it.
For example, if `class DropdownMenu extends HTMLSelectElement` worked, you could have full control of styling and functionality without having to recreate all the a11y support baked into `<select>`. As it stands today, this will be treated as a div and its all on you to make it accessible.
The reasoning for choosing not to support it is here: https://github.com/WebKit/standards-positions/issues/97#issu...
That kind of support is a really tough one to work around with a major browser lacking support. For certain features its not a big deal, but when it comes to extending to get full accessibility support the only substitute is avoiding the feature and rolling it all custom. It really is a shame in my opinion, extending built-ins is extremely powerful.
https://developer.mozilla.org/en-US/docs/Web/HTML/Global_att...
Why bother and try yo create half-baked non working solution if you can just use html?
Well, it easier to style, maybe. But hey, there is a class attribute.
Semantic elements are always preferred.