| ▲ | jakelazaroff 13 hours ago | |||||||||||||||||||
Using custom elements as the article suggests doesn't require JavaScript, so they are "pure" HTML and CSS (though whether they count as "web components" is up to you). More to the point, all of the technologies that the term "web components" includes — custom elements, <template> tags, shadow DOM — can be used without JavaScript. <div> and <span> are semantically neutral, so I'm not sure what SEO and accessibility challenges custom elements would introduce? | ||||||||||||||||||||
| ▲ | senfiaj 12 hours ago | parent [-] | |||||||||||||||||||
My point is that defining a complex behavior for a custom tag is not possible without js. For example, you can't define a reusable 'host-element' tag and expect some additional elements (or some behavior) to automatically appear inside it each time your html includes or you create <host-element> ... </host-element>. I mean you can use something like <host-element> (html5 allows that), but it will just be an inline element, almost like <span>, but without semantics. It's not a full web component. > "shadow DOM — can be used without JavaScript" Yes, shadow DOM can be used without JS, but I was talking about web components. > "I'm not sure what SEO and accessibility challenges custom elements would introduce?" If you replace standard elements (such as 'p', 'a', 'button', etc) with custom ones it can hurt SEO and accessibility. There are very few reasons to use custom element names and attributes if they are not full web components. What's the point of using selector 'link-button[size="large"] a {...}' when you could do the same with '.link-button.large a {...}'? | ||||||||||||||||||||
| ||||||||||||||||||||