pageSUMMARY

Discover Pseudo Classes and learn to alter the way a hyperlink appears by default.

Style Website Links by Nick Beresford Davies

Decide why you want to change the link color (and if in doubt, don't)

By default, links tend to be blue before being clicked, red when active (as you actually click it) and purple after being visited. They are also underlined by default. Although this might not fit in with your design, there's a good argument for keeping them in this recognisable format. If something is obviously a link, it's more likely to be clicked than something that isn’t, and the default color scheme is widely used and recognised by web users worldwide.

footNOTE

Usability
The most influential advocate of default link styling is the usability guru, Jacob Nielsen.

However, there will inevitably be instances where it would be impractical and highly undesirable to follow this standard formatting, such as in the tabbed menus at the top of this website. For this reason, it’s almost always necessary to change the link styling for certain elements within a site.

For the purposes of this website, we have ‘tweaked’ the colors for the main links in the body copy, keeping the recognisable blue/purple, but changing the hue slightly. Also, the links in the tabs above and menus on the left are radically different in order to suit their surroundings and function.

Here’s how we styled the links.

Create a global CSS Rule for website links

furtherREADING

Pseudo Classes
These classes are used to add special effects to some selectors, as explained at w3schools.com.

To begin with, I want to set a basic ‘pseudo class’ style for links on the website. These will be a variation on the standard blue for un-visited links and a tweaked purple hue for visited links. Veering from tradition, when a visitor ‘hovers’ their mouse over a link (and as they click on it) I want it to turn black. The underline will remain in place in all cases.

After I’ve created this style, all links will behave in this way unless otherwise specified by other css styles - more of which later.

Create four Anchor Pseudo Classes to control the links

At the bottom of the CSS Styles palette, click “New CSS Rule”.

In the New CSS Rule Pane:

Selector Type: Compound
Selector Name: Choose ‘a:link’ from the list  
Rule Definition: (select your existing style sheet from the menu)

In the CSS Rule Definition Pane:

Under Type
Color: #0066cc

These Type settings will ensure wherever a link appears, its color will be this shade of blue. By default there will be an underline so there’s no need to specifiy one.

Click OK.

Now repeat the process for ‘a:visited’ (using color #609) and ‘a:hover’ (using color #000). Obviously the a:visited attribute dictates what the link looks like when it has been visited, and the a:hover dictates what the link looks like when you roll a cursor over it. The only one of these rules we haven’t touched is ‘a:active’ which determines how the link appears as you actually click on it.

Move the rules up the CSS list

I like to keep all the global styles in a CSS document at the top of the document, and you can keep them in order within the CSS Styles palette. Just click on the a:hover style, press shift and click on the a:link style. With all three selected, you should be able to drag them up the list to just beneath the h3 style that was created earlier. If you open the CSS document from the FILES window, you see that the a: styles have all been moved up from the bottom.

Now would be an opportune moment to create the ‘Breadcrumb’ links which nest in the header DIV tag...

Style Website Links - End of Article

Go to previous article | Go to Home Page | Go to next article

Feedback required!