Introduction to Cascading Style Sheets Spring 2000
CSS part 3:
There are three main types of selectors we will be using: type, contextual, attribute.
A type selector uses existing HTML tags. For example, when we applied style to the H1 tag, or the the link tag.
A contextual selector defines styles for combinations of selectors; selectors which are used in context with another selector.
There are two types of attribute selectors: class and ID. ID is used to specify something very unique, that will only be used once. Class can be used more than once, and is very helpful when creating styles.
Designating a specific class to a specific HTML tag limits the use of the style, logically, to only that HTML tag (this example would be embedded at the top of a document):
P.spooky {color: red}
will make all p tags with the attribute of class and value equal to spooky...red.
To make your classes more flexible, create generic ones (this example would be embedded at the top of a document):
.spooky {color: red}
So that you will be able to attach the class to several tags:
<p class = "spooky">halloween</p>
or
<p>When it is time for <strong class = "spooky">Halloween</strong>, my teeth begin to itch</p>
When it is time for Halloween, my teeth begin to itch
Understand the difference? Try creating some class selectors and using them on different tags.
To use the special ID attribute selector, attach it to only one thing in your document. If the word Halloween will only appear once, I could use this code:
<p ID = "spooky">Halloween</p>
In addition to providing your first choice for fonts, add two or three more choices (usually one pc and one mac), and then a generic font family (serif, sans-serif, monospaced, cursive, fantasy).