Web Design & Development

[ Web Design & Development Topics ]

Cascading Style Sheets

Using the Class Selector

First, lets say I want to specify some specific CSS that is only used when I "call" it from somewhere. First, I need to make this special code in my CSS by putting either a period (for class) or a pound sign (for id) in front of the special code like this:

.link, .link:hover {color: maroon; font-weight: bold}
.link {text-decoration: none}
.link:hover {text-decoration: underline}

Now for these I need to tell my HTML document where I want to use this special CSS by using a "class" or "id" tag. Then my source code for that link will look like one of the following:

<a href="http://www.google.com" class="link">http://www.google.com</a>

Classes and ID's can be used on all sorts of items, but a common one it is used for are links. Try visiting http://www.w3schools.com/css/css_pseudo_classes.asp to see some samples.