English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
:visited CSS pseudo-class represents links that the user has visited.
Complete CSS Selector Reference Manual
Select the style of visited links:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Basic Tutorial(oldtoolbag.com)</title> <style> a:visited { background-color:lightgreen; } </style> </head> <body> <a href="//www.oldtoolbag.com">oldtoolbag.com</a> <a href="//www.baidu.com" target="_blank">baidu.com</a> <a href="//www.pcjson.com" target="_top">pcjson.com</a> <p><b>Attention:</b> The :visited selector styles links to pages you have already visited.</p> </body> </html>Test and see ‹/›
:visited adds special styles to visited links.
Tip: The :visited selector is used to set the style of visited page links. :hoverSelector for the link style when the mouse hovers over it:active Selector sets the style when you click the link.
The numbers in the table indicate the first browser version that supports the attribute.
Selector | |||||
---|---|---|---|---|---|
:visited | 4.0 | 7.0 | 2.0 | 3.1 | 9.6 |
CSS Tutorial: CSS Links
CSS Tutorial: CSS Pseudo-classes
Active, visited, unvisited, or when the mouse hovers over the link:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Basic Tutorial(oldtoolbag.com)</title> <style> a:link {color:green;} a:visited {color:green;} a:hover {color:red;} a:active {color:yellow;} </style> </head> <body> <p>Move the mouse over and click this link: <a href="//www.oldtoolbag.com/">oldtoolbag.com</a></p> </body> </html>Test and see ‹/›
Different link styles:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Basic Tutorial(oldtoolbag.com)</title> <style> a.ex1:hover,a.ex1:active {color:red;} a.ex2:hover,a.ex2:active {font-size:150%;} a.ex3:hover,a.ex3:active {background:red;} a.ex4:hover,a.ex4:active {font-family:monospace;} a.ex5:visited,a.ex5:link {text-decoration:none;} a.ex5:hover,a.ex5:active {text-decoration:underline;} </style> </head> <body> <p>Move the mouse over the link to see the style change./p> <p><a class="ex1" href="/css/">This link changes the color</a></p> <p><a class="ex2" href="/css/">This link changes the font size</a></p> <p><a class="ex3" href="/css/">This link changes the background color</a></p> <p><a class="ex4" href="/css/">This link changes the font type</a></p> <p><a class="ex5" href="/css/">This link changes the text decoration</a></p> </body> </html>Test and see ‹/›