To indicate the presence of textual links, browsers normally render the source anchor in a different color (usually blue) with its content having an underline.
This default behavior applies to all links, meaning any link displays in the same way regardless of which element the anchor is contained in, whether within a paragraph, a list, a table cell, or another element.
CSS allows for greater flexibility in formatting links. Using CSS attributes called pseudo-classes, authors can define hyperlink styles that may be applied globally, or for distinct needs.
For example, to set the general style of the A element for the default state of a link, we declare:
a:link {
font:bold; color:navy}
To set the style of the A element within the context of other elements, for example, for links within lists, we declare:
ul a:link {
font:bold; color:navy}
dl a:link {
font:bold; color:green}
Styles may even be defined for each distinct link state: visited, active, and hover. The following CSS declarations show how styles for anchor elements on this site are formatted.
a:link, a:visited, a:active {
font:bold; color:navy}
a:hover {
font:small-caps; color:maroon}
ul a:link, ul a:visited, ul a:active {
font-weight:600; color:#0f9;
text-decoration:none}
ul a:hover {
font:bold small-caps; color:#ff6}
dl a:link, dl a:visited, dl a:active {
font-weight:600; color:cyan;
text-decoration:none}
dl a:hover {
font:bold small-caps; color:#ff6}
For general information on CSS, please see Style Sheet Basics and Using Style Sheets.
For the complete list of attributes applicable to anchors, see the A element in the HTML Reference.