Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Style for every state of an a tag?

Tags:

css

Is there a way of specifying a:link, a:visited, a:hover, a:active and maybe also a:focus in one go using css?

like image 431
Tyilo Avatar asked Nov 30 '11 23:11

Tyilo


1 Answers

If you want to style all anchors; not just anchors used as links, but named anchors as well (i.e. <a name="foo"></a>) simply use the following css selector:

a

That's it.

If you don't want named anchors, but instead want to style only links that have an [href] attribute, you should use the comma-separated list of selectors:

a:link,
a:visited,
a:hover,
a:focus,
a:active {
  color: blue;
}

If you're running into specificity issues, you'll need to post some HTML code and review CSS specificity.

like image 160
zzzzBov Avatar answered Dec 07 '22 23:12

zzzzBov