Helping ordinary people create extraordinary websites!
HOME TUTORIALS SCRIPTS WEB HOSTING BLOG FORUM
Get Our Newsletter
Email:

Cascading Style Sheets (CSS); Getting Started

By Will Bontrager
2003-10-01


The One Exception

The one exception is the anchor tag, often referred to as the "A" link tag, the tag you use when you create a link on a web page. The A tag can have three different styles, one for each of it's states: link, active, and visited. To see how it works, change your mysite.css style sheet file so it has these thirty lines:

BODY, TD, P, LI, BLOCKQUOTE {
font-family: arial,helvetica,sans-serif;
font-size: 14px;
color: #000000;
}

H1 {
font-size: 36px;
font-weight: bold;
text-align: center;
color: red;
background: blue;
}

A:link {
color: yellow;
background: red;
font-weight: bold;
}

A:active {
text-decoration: underline;
}

A:visited {
color: red;
background: yellow;
font-style: italic;
text-decoration: line-through;
}

With the above, your linked text will be bold, colored yellow, and with a red background. When the link is active (while it's being clicked on), it will be underlined. Once the linked page has been visited, the text will be italic and have a line through it, the text color will be red, and the background will be yellow.

Note that the "active" and "visited" behave differently in different browsers. If you specify font changes in the "active" style, the change might or might not display. Changing the font style to italic in the "visited" style causes the font to be italic; however, in some browsers the font weight remains bold as specified in the "link" style and in other browsers the font weight becomes normal.

Tutorial Pages:
» Getting Started
» A Bit More...
» Got You Wondering?
» The One Exception
» Another A Tag


Copyright 2004 Bontrager Connection, LLC


 | Bookmark
Related Tutorials:
» Planning Your Stylesheet - The Definitive Guide
» CSS Shorthand Properties
» Print Stylesheet - The Definitive Guide
» Using CSS Selectors to Highlight Unedited Form Fields
» An Introduction to CSS
» Overlapping tabbed navigation in CSS