Using stuff like document.getElementByTagName
, you can practically create your own elements.
<arial>Hello</arial>
And then in JS..
var a = document.getElementsByTagName("arial");
for(i = 0; i < a.length; ++i)
a[i].style.fontFamily = "Arial"
And we have a custom element, easy peasy.
My question comes down to, is this bad practice? Is there some drawback I'm not noticing?
It is completely safe to use custom HTML tags in your web project. With their excellent browser support and ease of use, nothing is stopping you from using them today. Just remember to make custom tags block-level elements if you're using them for page structure.
Custom attributes are attributes that are not part of the standard HTML5 attributes but are explicitly created. They allow us to add our own information to HTML tags. These are not specific and can be used with all the HTML elements.
Custom Elements are a feature of modern browsers which allow you to modularise and install your JavaScript components into the browser itself in order to extend it in new and powerful ways. Custom Elements are HTML components which have their own self-contained markup, styling and behaviour.
Audio and Video tags are the two major addition to HTML5. It allows developers to embed a video or audio on their website. HTML5 video can use CSS and CSS3 to style the video tag. You can change the border, opacity, reflections, gradients, transitions, transformations, and even animations.
The W3C says you should not. It is bad practice.
Authors must not use elements, attributes, or attribute values that are not permitted by this specification or other applicable specifications, as doing so makes it significantly harder for the language to be extended in the future.
Furthermore, HTML5 is not XML. You should only use the elements outlined in the official spec.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With