CSS Link Color
Links have four states, styled with four pseudo-classes — in this
order: :link, :visited, :hover,
:active. Recolor each state below and try the demo links.
#2563EB
#7C3AED
#1D4ED8
#DC2626
Try these: Color Picker · Color Names · FAQ · Contrast Checker
Hover over a link to see its hover color; hold the mouse button down on it to see its active color.
How to style link colors in CSS: :link, :visited, :hover, and :active in LVHA order — with a live demo where you recolor all four states and try real links, plus the :visited privacy limits.
Links have four states — :link, :visited, :hover, and :active — written in LVHA order (LoVe-HAte). Recolor each state in the demo and try the links: hover one, hold the mouse down on one, and click one to see its visited color when you return.
The four link states (LVHA order)
A link is not one thing — it has four states, and CSS gives each one a
pseudo-class. They must be written in this order, or later rules will not
apply the way you expect. Remember it as LoVe-HAte:
:link, :visited, :hover,
:active.
| State | Meaning | Default browser color |
|---|---|---|
:link | Unvisited link with a destination | Blue |
:visited | Link already in the browser's history | Purple |
:hover | Mouse pointer is over the link | Same color, pointer becomes a hand |
:active | Link is being clicked (mouse button held down) | Red |
a:link { color: #2563EB; } /* unvisited */
a:visited { color: #7C3AED; } /* visited */
a:hover { color: #1D4ED8; } /* hovering */
a:active { color: #DC2626; } /* being clicked */
Source: MDN, Styling links.
Why the order matters
:link and :visited are mutually exclusive — a
link is one or the other, never both. But :hover and
:active can apply at the same time as either of them, and when
two rules have equal specificity, the one written later wins. So if
:hover came before :visited in your stylesheet, a
visited link would never show its hover color. LVHA order — link, visited,
hover, active — is the order that makes every state visible.
The :visited privacy limit
Browsers deliberately restrict what :visited can change, to
stop sites from probing your browsing history. Only color-related properties
are allowed — color, background-color,
border-color, outline-color, and a few others — and
the alpha (transparency) part is ignored. You cannot change a visited link's
layout, font, or visibility, and JavaScript cannot read whether a link is
visited ( getComputedStyle always reports the unvisited color).
That is why the demo above offers a "Preview visited" simulation button: the
real visited color only appears for links you have actually visited, which
depends on your history. Source: MDN, :visited.
Link colors and accessibility
Links need the same contrast as any other text: 4.5:1 against the background for WCAG AA. The classic blue (#0000EE) on white is 9.40:1 and passes easily, but light blues and pale purples often fail — check yours in the contrast checker. Also, never rely on color alone to mark a link: keep the underline (or add another cue), so readers who cannot tell the colors apart can still find the links. Removing the underline and relying on color is the most common link-accessibility mistake.
Frequently asked questions
How do I change link color in CSS?
Style the link states: a:link { color: #2563EB; } for unvisited links, a:visited for visited ones, a:hover for hover, and a:active for the moment of the click. Write them in LVHA order — link, visited, hover, active.
What is the LVHA order for link pseudo-classes?
:link, :visited, :hover, :active — remembered as LoVe-HAte. With equal specificity, the later rule wins, so hover and active must come after link and visited or they will never show.
Why doesn't my :visited color show?
Two common reasons: the link is not in your browser history yet (visited only applies to links you have actually visited), or your :visited rule is written before :hover or :active and gets overridden. Browsers also restrict :visited to color properties only, for privacy.
What color should links be?
The classic default is blue for unvisited links and purple for visited ones, because readers recognize them. Whatever you choose, keep the contrast at 4.5:1 or better against the background, and keep the underline so color is not the only cue.
Related tools
CSS Text Color · CSS Background Color · CSS Color Basics · Contrast Checker · Color Picker