I am facing a problem with CSS selector. I have content in "list Items(LI)" and "list Items(LI)" having class"child". I need to style for first "list Items(LI)" with the class name ".child". only in CSS.
ul{margin:0;padding:0 32px 0 32px}
li{ color:red;}
.child{
color:green;
background:red;
width:100%;
}
li.child ~ .child{
color:#fff;
font-size:20px;
background:green;
width:10px;
}
<ul>
<li>hellow</li>
<li>hellow</li>
<li>hellow</li>
<li>hellow</li>
<li>hellow</li>
<li>hellow</li>
<li>hellow</li>
<li class="child">
This need to be Red Color
</li>
<li class="child">sub text</li>
<li class="child">sub text</li>
<li class="child">sub text</li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
.first-child, and then only apply this class to the first child in question.