Using Cascading Style Sheets

The promise of Cascading Style Sheets is to separate the structure (paragraphs, headings, lists, tables, etc.) of web content from its presentation (font, object placement, indentation, etc.). HTML describes the structure and Cascading Style Sheets control the presentation. That's the theory, anyway.

Before making style sheet rules, take a look at "Style Sheets Set Your Page Free."

Why is It Called "Cascading Style Sheets?"

A Cascading Style Sheet means multiple style sheets may be blended together to affect a page, and the closer the rule is set to the tag element, the higher the rule's priority, loosely speaking. As with anything in life there are exceptions, and the following is simplified, but conceptually it's a good place to start. Here are the levels of priority with "1" being the highest:

  1. apply the rule to an individual HTML tag
  2. embed rules for the entire page before the </head> tag
  3. link to an external style sheet (useful for site wide consistency)

I often apply a site wide style sheet by importing an external style sheet. If needed, I override it locally with embedded rules and/or applying the rule to the tag. An example would be the indenting of paragraphs. I like this as the page is easier to scan for blocks of information.

Sometimes this may not be useful (note this brief paragraph is not indented).

All I have to do is tell that particular paragraph not to indent, and the indentation is gone because highest priority is given to the HTML tag overriding the external rule. Let's look at the paragraph rule I just mentioned:

A class is a rule in the style sheet that only gets applied when it's called. I could have put the rule in the <p> tag itself:

<p style="text-indent:0em">

but I use this often enough it is easier to have the rule defined as a class in the external style sheet and call the class in the tag:

<p class="NoIndent">

Current Rules of the Style Sheet Road

What Style Sheet Rules are used in this CSS Site?

Some of the rules set in the external style sheet are:

Of course, all these settings may be overridden by the user.

When you're ready, move on to "Defining a HTML Tag."