bannermuseum

Consistency is one of the keys to an effective website. The easiest way to maintain consistency throughout your pages is the use of Cascading Style Sheets (CSS).

readRead Chapter 7 by Rob Huddleston in HTML, XHTML, & CSS.

The Terminology

Let's explore the rules associated with Cascading Style Sheets. Each style has two parts. The selector determines which elements the formatting will affect. The declarations are made up of one or more properties and define what formatting will be applied.

In the example below h1 is the selector and {color: green; } is the declaration. The property is color and green is the value. Properties accept different types of values such as numbers, integers, relative values, percentages, URLs, or colors.

The most common mistakes involve punctuation.

Example

/* This is my simple style sheet. */
h1 {color: green;}

Cascades

The word cascading comes from the way that your CSS handles conflicting styles. According to Castro there are three things that determine how styles are handled: inheritance, specificity, and location.

Inheritance determines what happens when you don't specific a rule.

Specificity is used when more than one rule applies. The more specific the selector, the stronger the rule. The id attributes are most specific and would override the body or paragraph element.

Location makes the final determination of what style is applied. Rules that appear later have more weight. Rules that apply locally in the HTML override those in the CSS. For example, you might decide to apply boldface in the HTML. This would override the settings in the external CSS.

The Options

You can use CSS two ways: internal and external. First, you can enter the style tags at the top of a single document or within a single document. These are called an internal style rules and will help you maintain consistency within a document. Second, you can create a separate document called an external style sheet that can be attached to a single document or a series of pages such as a website.

readRead the Quick Reference Chart (PDF) by Bill Henning.
readRead the CSS Syntax of a Style: Internal or External (PDF) by Bill Henning.
readRead the CSS Syntax of a Style: Inline (PDF) by Bill Henning.


| eduscapes | IUPUI Online Courses | Teacher Tap | 42explore | escrapbooking | About Us | Contact Us | ©2006-2011 Annette Lamb and Larry Johnson