CSS :visited Selector
More "Try it Yourself" examples below.
Definition and Usage
The :visited selector is used to select visited links.
Tip: Use the :link selector to style links to unvisited pages, the :hover selector to style links when you mouse over them, and the :active selector to style links when you click on them.
Browsers limits the styles that can be set for a:visited links, due to security issues.
Allowed styles are:
- color
- background-color
- border-color (and border-color for seperate sides)
- outline color
- column-rule-color
- the color parts of fill and stroke
All other styles are inherited from a:link.
Version: | CSS1 |
---|
Browser Support
The numbers in the table specifies the first browser version that fully supports the selector.
Selector | |||||
---|---|---|---|---|---|
:visited | 4.0 | 7.0 | 2.0 | 3.1 | 9.6 |
CSS Syntax
:visited {
css declarations;
}
More Examples
Example
Select and style unvisited, visited, hover, and active links:
/* unvisited link */
a:link {
color: green;
}
/* visited link */
a:visited {
color: green;
}
/* mouse over
link */
a:hover {
color: red;
}
/*
selected link */
a:active {
color: yellow;
}
Try it yourself »
Example
Style links with different styles:
a.ex1:hover, a.ex1:active {
color: red;
}
a.ex2:hover, a.ex2:active {
font-size: 150%;
}
Try it yourself »
Related Pages
CSS tutorial: CSS Links
CSS tutorial: CSS Pseudo classes