Sunday, 9 July 2017

Hide empty html tags in website using :empty pseudo-class

Sometimes the empty tags can create the alignment or spacing issues, which looks odd to the viewers.

To fix this issue we have a pseudo-class called :empty

You can use this property as below example in your style:

p:empty{ display: none; }

You can also try in the codpen at this link Edit on codepen 

Reference sites:
https://css-tricks.com/almanac/selectors/e/empty/
https://developer.mozilla.org/en-US/docs/Web/CSS/:empty

Load disqus comments

0 comments