html - Change color of text in a tag? -
.myactive{ background:white; color: red; } .navbar > li > a:hover, .navbar > li > a:focus{ background: ; color: #333; }
<ul class="navbar"> <li> <a href="index.html">home</a></li> <li> <a href="#">categories</a></li> <li> <a href="#">about us</a></li> <li class="myactive"> <a href="#">contact</a></li> </ul>
i want change color of text in <a>
tag write class change background of li tag it's not changed color text in li.
after little research understand need add <span>
text. don't understand why need this, <a>
, <span>
inline elements.
.navbar > li > a:hover, .navbar > li > a:focus{ background: white; color: #333; }
and why pseudo class focus work ?
assuming html this
<ul> <li><a href="http://www.thesite.net>this site</a></li> </ul>
to change text colour of link css simple
li a{ color: red;}
i recommend adding hover colour:
li a:hover{color: blue;}
Comments
Post a Comment