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

AI Engineer Intern, Agents

@ Occam AI | US

AI Research Scientist

@ Vara | Berlin, Germany and Remote

Data Architect

@ University of Texas at Austin | Austin, TX

Data ETL Engineer

@ University of Texas at Austin | Austin, TX

Lead GNSS Data Scientist

@ Lurra Systems | Melbourne

Data Engineer - Takealot Group (Takealot.com | Superbalist.com | Mr D Food)

@ takealot.com | Cape Town