pexichdu pexichdu - 2 months ago 5x
CSS Question

Select only one by css

Hi I want to select the "Link" in class beers only but It always select all the links from sub-menu. I try

.beers:first-child does not work
.beers a:nth-child(1) does not work
.beers a:first-of-type (this apply to all the links of sub-menu)

<li class="beers"><a>Link</a> only here
<ul class="sub-menu">
<li ><a></a></li> not here
<li><a></a></li> not here
<li ><a></a></li>
<li ><a></a></li>

Please help me


If you want to use style for a

 .beers > a{color:green;}

If you want to use for li you have override

 li.beers{ color:green;}
 li.beers ul li{ color:black;}