CSS link style order

« View all CSS articles

July 16, 2007

CSS pseudo-classes all have equal weight. Therefore, the link styles must be declared in a specific order to work properly:

1. link
2. active
3. hover
4. visited

An easy way to remember this order is to use the mnemonic LoVeHAte.

Example
a:link {color: #ccc} /* link */
a:visited {color: #00F} /* visited link */
a:hover {color: #036} /* hover over link */
a:active {color: #060} /* active link */
References

• Eric Meyer - Link Specificity
• W3Schools Anchor Pseudo-classes