Links are defined using the standard <a> tag. Normal links look like this:
Go to another page
<a href = "newPage.html">Go to another page</a>
The href value indicates the address of the new page. The text between the <a> and </a> is the text that will appear as a link on the page.
Like most XHTML elements, links have a standard appearance. For example, most browsers indicate a link by making the linked text blue and underlined. Users have gotten used to links being designated in these ways, so if you choose to change the appearance of links, you need to still be careful that the user understands the object is a link that the user can use to navigate off the page.
Since a link is simply an XHTML tag, you can apply a style to it like any other XHTML element. For example, to make all links black, use this style:
a {
color: black;
}
You can apply any style to an anchor that you wish. However, most usability experts recommend that you leave all links underlined unless they incorporate some other obvious navigation hints (perhaps they are formatted as buttons, for example.)
Anchors are special because they can have more than one state. You may want to apply different styles to the anchor if it has already been visited, or if the mouse is currently over it. The following style rules illustrate how this can be done:
a {
color: black;
}
a:visited {
color: purple;
}
a:hover {
color: white;
background-color: black;
}
Here is some code using these styles:
The anchor tag still has its own style definition, but the other states (visited and hover) can also have styles devoted to them. The visited state occurs if the user has already been to this page. (Delete your browser history and cache to make all sites "unvisited" for testing) The hover selector allows you to specify a custom style that should occur when the mouse is "hovering" over the link.
Links are an important useability feature of web pages. You must take care not to confuse the user when you apply custom styles to your links. It still must be very apparent to your users what elements can be clicked on for navigation. Consider the following tips when you build custom anchor styles: