|
Search This Site
|
Styling Links in CSS
Links can also be styled in CSS. You can change the color of a link and even remove the default underline found underneath a link. Much of the formatting you learnt previously can also be applied when styling your links in CSS.
a: [condition] <----- The condition refers to the state of the link
a:linkA link that has not been visited. This is the link as it appears normally. Normal links appear blue and underlined. Below the color of the link is changed to green and the default line usually found beneath the link removed.
a:link
{
color: green;
text-decoration: none;
}
a:visitedA link that has been visited. When you click a link the state of that link changes from a:link ( normal ) to a:visited ( visited ). In this example the color is set to change to purple and the text that makes up the link to italics. This change will be noted if you observe the link you had just clicked again.
a:visited
{
color: purple;
font-style: italic;
}
Note: Remember that most CSS properties can be applied to your link. In this example we only apply the color and font style properties.
a:hoverMovement of the mouse over a link. When the user hovers over a link any formatting specified by a:hover will be be reflected. In this example we set the font weight to be bold.
a:hover
{
font-weight: bold;
}
a:activeA link just when it has been clicked. Below, the color and font-variant properties are applied.
a:active
{
color: #000000;
font-variant: small-caps;
}
Bringing the formatting togetherAn important thing to remember about links is that there is a layout that should be adhered to. When making the specifications in a style sheet it is important to follow the layout. The rules are like this:
style.css a:link { color: green; text-decoration: none; } a:visited { color: purple; font-style: italic; } a:hover { font-weight: bold; } a:active { color: #000000; font-variant: small-caps; }
Previous Lesson - Backgrounds
Next Lesson - The Box Model
|
|
© Copyright 2010 | All Rights Reserved
|