Let's say you have
<ul class="menu"> <li><a href="#foo1">First Item</a></li> <li><a href="#foo2">Second Item</a></li> <li><a href="#foo3">Third Item</a></li> <li><a href="#foo4">Fourth Item</a></li> <li><a href="#foo5">Fifth Item</a></li> </ul>
If you want to use an attribute selector, you should do it like
ul.menu>li>a[href="foo1"]:hover { background-color: blue; }
If you want to use a pseudo-class, you would do it like
ul.menu>li:nth-child(1)>a:hover { background-color: blue; }
If you want to use a class or id, just add the required class or ID to li in HTML and just use
ul.menu>li.class_name>a:hover { background-color: blue; } ul.menu>li.id_name>a:hover { background-color: blue; }
You probably don't need the selector to be as specific as above, and may omit ul and others. This is just an example. Keep in mind that the pseudo-class and attribute selector have varied browser support.
Jawad source share