/blog/articles/

Make an element inside a hidden element visible with CSS

Let's imagine the following scenario: You have an element that should be hidden but one of the elements inside it should be visible. I'm sure everyone has had this problem before and tried to force it with opacity. At least I did. But that's not possible. As soon as you set an element to opacity: 0; all of it's children will forever be invisible.

Same with display: none;. You can't set a children back to display: block;.

But a while back I learned that visibility actually behaves differently. You can set visibility: hidden; for a parent element and show a children element with visibility: visible.

Hope this helps!

Martin Wolf

Hi, I’m Martin Wolf, a Freelance Frontend Web Developer from Germany.
I believe in hard work and sharing what I know.

Contact me

Interested in working with me? Fantastic! The best way to get in touch is by email (hello@martinwolf.org). I’m looking forward to hearing from you.