Home > Enterprise >  How to select child element using parent element id in CSS?
How to select child element using parent element id in CSS?

Time:10-09

How to select child element using parent element id in CSS? can i select like this?

#intro p {
  color: red;
}
<div id="intro">
  <p>Lorem ipsum dolor sit amet</p>
</div>

CodePudding user response:

That works fine. If you want to select direct children, you can use:

#intro > p {
  color: red;
}
  • Related