CSS Syntax

For our current purposes, CSS must always be entered between the <style></style> tags, in the header of the HTML document. The browser must see the styles first, otherwise it won't know what to apply when it sees tags! The second really important thing to know is how to comment in CSS; all comments go between /* and */. So something /* like this */ would be a comment. Take a look at the source of this page to see some comments in the CSS.


Beyond that, all CSS follows a common format, no matter how complex or what tag it applies to, it looks like this:


dd	{			/* outside the brackets, we specify the tag */
	color: #ffffff; 	/* then we specify the attribute and value */
	}			/* then we close with another bracket */
Depending on the tag being styled, different attributes can be used - we'll cover this over the next few pages. However, keep in mind that the format is always consistent. attribute: property; -- notice the semicolon at the end of the line! As with normal HTML, colors should be specified using hex codes or special words (with hex being preferrable!).


Next Page >>