Styling a link depending on state

Note: a:hover MUST come after a:link and a:visited in the CSS definition in order to be effective.

Note: a:active MUST come after a:hover in the CSS definition in order to be effective.

Pseudo-classes and HTML Classes

Mouse over the div element below to change its background color:
Exported from Notepad++
<!DOCTYPE html> <html> <head> <style> /* unvisited link */ a:link { color: red; } /* visited link */ a:visited { color: green; } /* mouse over link */ a:hover { color: hotpink; } a.highlight:hover { color: forestgreen; font-size: 22px; } /* selected link */ a:active { color: blue; } div { background-color: green; color: white; padding: 25px; text-align: center; } div:hover { background-color: aqua; } </style> </head> <body> <p><b><a href="default.asp" target="_blank">Styling a link depending on state </a></b></p> <p><b>Note:</b> a:hover MUST come after a:link and a:visited in the CSS definition in order to be effective.</p> <p><b>Note:</b> a:active MUST come after a:hover in the CSS definition in order to be effective.</p> <p><a class="highlight" href="css_syntax.asp">Pseudo-classes and HTML Classes</a></p> <div>Mouse over the div element below to change its background color:</div> </body> </html>