To hide an HTML element tag without using CSS styles or using JavaScript, we can use the hidden
attribute on the HTML tag.
For example, to hide a div
HTML tag, we can use the hidden
attribute like this,
<!-- Hide div HTML tag -->
<div hidden>I'm hidden</div>
That's it! No more css display: none
CSS property or any other tricks to hide an element, you can just do it using the hidden
attribute in the HTML tag itself.
It also has better support in browsers nowadays. So no need to worry about compatibility or support issues 🎊. See hidden
attribute report on Can I Use.
See the above code live in JSBin.