Skip to content
Advertisement

Show child div on mouse hover of parent – needs javascript?

I need to show a div when you house over its parent (default is for the child div to be hidden). Is the only way to do this with javascript? Thanks

Advertisement

Answer

No JS required.

.hidden {
  display: none;
}

.parent:hover .hidden {
  display: block;
}
<div class="parent">
  <p>Hello, I'm a child...</p>
  <p class="hidden">..and so am I but I'm hidden.</p>
</div>
Advertisement