DEV Community

Cover image for How to hide an HTML element or tag without using CSS styles or JavaScript?
MELVIN GEORGE
MELVIN GEORGE

Posted on • Originally published at melvingeorge.me

How to hide an HTML element or tag without using CSS styles or JavaScript?

Originally posted here!

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>
Enter fullscreen mode Exit fullscreen mode

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.

Feel free to share if you found this useful 😃.


Top comments (0)