CSS stands for Cascading Style Sheet. If you are creating we content, you have probably come across it by now. What we’re going to do is to look at a CSS file and talk about each element in it: what it is, why it’s done that way, etc.
If you want to follow along, open Notepad (if you are using Windows) or TextEdit (if you are on a Macintosh) and create a new, blank file called “mycss.css” and save it to your Desktop. Now let’s fill this blank file with content.
A stylesheet is made up of rules. A rule is nothing more than the element we’re styling and the various style for that element. It looks something like this:
h1 {
font-family: Georgia, “Times New Roman”, Times, serif;
}
This rule affects the h1 tag. This is called redefining a tag. Here we want our h1 content to be of the Georgia, or Times New Roman, or Times, or the system’s default serif font. (Your viewer’s web browser will try the different font faces in that order.)
A rule contains two elements: a selector (the h1 in this case) and a declaration (everything inside the brackets).
First the selector: h1. The above rule will apply to every h1 in the html file using this stylesheet.
Within the declaration, you have two parts. The property and the value.
{
font-family: Georgia, “Times New Roman”, Times, serif;
}
The property here is font-family:. Properties always end with a colon. This property determines what font-face we use for the h1 tag. The value comes next, Georgia, “Times New Roman”, Times, serif;, and always ends with a semi-colon. The value states how the property works. Here, we say that the font-face we will use is Georgia. If that font’s not installed on a person’s computer, then it tries TImes New Roman, and so on.
You can have multiple properties in a declaration. Just make sure you end each property with a semi-colon. For example:
h1 {
font-family: Georgia, “Times New Roman”, Times, serif;
font-size: 18px;
color: #999999;
margin: 5px;
}
Here we’ve stated the font-face we want our h1 tags to use, the size of the text within that tag, the color (a very dark grey), and the margins around the text in that tag.