HTML Link Color

Links have four states — normal, hover, visited, and active — and each one can have its own color. Pick a color for each state below: the live link and the generated CSS update instantly, and every state is checked for contrast against the background.

This is a paragraph with a live example link inside it. Move your mouse over the link to see the hover color, and hold the mouse button down on it to see the active color.

WCAG AA needs 4.5:1 for normal text and 3:1 for large text. Every link state should pass on its own — a visited link that is too pale is still unreadable, even if the normal state passes.

How to set link color in HTML and CSS: one color per state with :link, :visited, :hover, and :active — live demo with a real link, contrast checked per state, and copyable CSS.

Links have four colors, not one: :link for normal links, :visited for clicked ones, :hover while the mouse is over the link, and :active while it is being pressed. Pick a color for each state in the demo — the CSS is written in the correct LVHA order for you.

Links have four states

A link is not one color — it is four. CSS gives each state its own pseudo-class, and the browser switches between them as the user interacts with the link:

StateSelectorWhen it applies
Normala:linkAn unvisited link, at rest
Visiteda:visitedA link the user has already clicked (the browser remembers)
Hovera:hoverWhile the mouse pointer is over the link
Activea:activeWhile the link is being clicked — between mouse-down and mouse-up

The classic default colors are blue for unvisited links and purple for visited ones. The demo above starts from a modern version of that scheme — blue #2563EB, darker blue #1D4ED8 on hover, purple #7C3AED once visited, red #DC2626 while active — and every one of those passes WCAG AA on white (5.17:1, 6.70:1, 5.70:1, and 4.83:1).

Write them in LVHA order

The four rules must appear in this order — :link, :visited, :hover, :active (remember it as “LoVe HAte”) — because all four selectors have the same specificity, so the one written later wins when two apply at once. A hovered link is also a link, so if :hover came before :link, the :link rule would override it and hover would never show. The generator above always writes them in the right order.

a:link {
  color: #2563EB;
}
a:visited {
  color: #7C3AED;
}
a:hover {
  color: #1D4ED8;
}
a:active {
  color: #DC2626;
}

The same four notations work here too

Link colors accept every color format — hex, named color, RGB, and HSL — exactly like text color. So a:hover { color: red; } and a:hover { color: rgb(220, 38, 38); } are both fine. Use hex when you need an exact brand color, and HSL when you want the hover state to be a darker version of the normal state (same hue, lower lightness).

What you cannot do with :visited

Browsers deliberately limit :visited for privacy: if a page could style visited links freely and read the result back, it could work out which sites you have visited. So browsers only allow a small set of properties on :visited — color, background-color, border-color, and outline-color — and JavaScript cannot detect whether a link is visited. That is also why the demo above shows the visited state as a separate swatch: a page cannot force a link into the visited state to show you.

Do not rely on color alone

Color-blind users may not see the difference between your normal and visited colors, and some users cannot see color differences at all. Keep the underline on links (browsers add one by default) and make the hover state do more than change color — an underline appearing, or the text darkening, is a cue everyone can see. And check every state for contrast: the demo scores all four against the background, because a visited link that is too pale is still unreadable even when the normal state passes.

Frequently asked questions

How do I change link color in HTML?

Use CSS, not an HTML attribute: a:link { color: #2563EB; } colors unvisited links. Add a:visited, a:hover, and a:active rules for the other three states, in that order (LVHA).

What is the LVHA order for link colors?

Link, Visited, Hover, Active — :link, :visited, :hover, :active. All four selectors have equal specificity, so the one written later wins when two apply at once; writing them in LVHA order is the only order where every state shows correctly.

Why is my :hover color not working?

Almost always the order: if :link comes after :hover in your stylesheet, :link wins and the hover color never appears. Put :hover after :link and :visited. Also check that another rule with higher specificity is not overriding it.

Can I make visited links a different color?

Yes: a:visited { color: #7C3AED; }. Browsers only allow color, background-color, border-color, and outline-color on :visited, for privacy — and JavaScript cannot detect whether a link has been visited.

What color should links be?

Blue is the convention users recognize — #2563EB on white passes WCAG AA at 5.17:1. Whatever you choose, keep the underline, make hover visibly different, and check every state for contrast against the background.

Related tools

Tutorials · HTML Text Color · HTML Background Color · CSS Link Color · CSS Color Basics · Contrast Checker