Oct. 13, 2023, 9:52 a.m. | Daniel Zotti

DEV Community dev.to

I just bumped into this Kevin Powell's video and it blew my mind! 😱


😠 How many times did I have to use JavaScript to hide an HTML element just because it was empty?


😎 With the :empty pseudo class it became as simple as adding :empty to a selector!



#task-list:empty {
display:none;
}



This code means that the element with ID task-list will be hidden if it has no children. Children can be either element …

code css hide html javascript list mind powell simple video webdev

Senior Machine Learning Engineer

@ GPTZero | Toronto, Canada

ML/AI Engineer / NLP Expert - Custom LLM Development (x/f/m)

@ HelloBetter | Remote

Doctoral Researcher (m/f/div) in Automated Processing of Bioimages

@ Leibniz Institute for Natural Product Research and Infection Biology (Leibniz-HKI) | Jena

Seeking Developers and Engineers for AI T-Shirt Generator Project

@ Chevon Hicks | Remote

GN SONG MT Market Research Data Analyst 11

@ Accenture | Bengaluru, BDC7A

GN SONG MT Market Research Data Analyst 09

@ Accenture | Bengaluru, BDC7A