CSS for the Newbie - Putting it all Together
(Page 2 of 5 )
So now that we know the basic syntax of CSS, let's fool around with it some. Open up a text editor and let's get busy.
Note: Remember that a CSS file is made in a text editor and contains no HTML whatsoever. Also, you must save the file with the .css extention.
Say we want to create a style sheet so that every time the user uses a <p> tag, it automatically changes the attributes of the text within. Here is how we would do it:
p {font-family:verdana;text-align:left;color:blue}
You will note in the above code that we do not place the angle brackets (<>) around our tag. And as I said above, every property is separated by a colon (:). If you wish to change more than one property, then you separate them with the semi-colon (;).
The above code is a little hard to read, and as you can imagine, it would be even harder on the eyes if we were defining an entire style sheet. A better way to write the code would be like this:
p
{
font-family: Verdana;
color: blue;
text-align: left;
}
Note that if we had used a value that consisted of more than one word, like a font name such as Times New Roman, we would encase it in quotes, like so: “Times New Roman”.
Next: Selectors...Unite! >>
More Style Sheets Articles
More By James Payne