I have a bunch of elements with a classname
<p class="red"></p>
<div class="red"></div>
I cant seem to select the first element with the class="red" using the following CSS rule:
.red:first-child{
border:5px solid red;
}
What is wrong in this selector and how to correct it ??
UPDATE:
Thanks to the comments and I figured out that by the def, the element has to be the first child to its parent to get selected which is not the case that I have. I have the following structure:
<div class="home">
<span>blah</span>
<p class="red">first</p>
<p class="red">second</p>
<p class="red">third</p>
<p class="red">fourth</p>
</div>
and this rules fails as mentioned in the comments:
.home .red:first-child{
border:1px solid red;
}
How can i target the first child with class red