Perhaps someone writes a browser which creates an outline of a page by showing an indented table of all headers, where the indentation level depends on the level of the header. A document in which headers are used only because they show up with a larger font will not create a correct outline for such a browser.
This is where Cascading Style Sheets come in. Style sheets specify how elements inside a HTML page should be rendered by a browser.
You must use a browser that supports style sheets to view the following examples properly.
This attribute can be used with all HTML elements inside the 'BODY' section of the document. It is used to create different classes of a element, where each class can have its own properties.
For example, lets say we have defined this style sheet:
This creates two classes for the
DIV element, "ferrari"
and "ford", each with its own colors. Then you could use these
Henry Ford's favorite color was black, so were all his cars.
For a car to be a real Ferrari it has to be red.
You can omit the element name when you define the style sheet. This means that the class is not restricted to one specific element, but can be used with every element. For example, this style sheet defines the class ".nature":
This class can now be used with all elements:
This attribute defines a unique identifier within the page. An ID is composed by an initial letter followed by letters, digits, "-" and "." characters. The letters are restricted to A-Z and a-z.
You can use this ID to set the style sheet information for the element where the ID is defined, by preceding the ID with a #, for example :
The special xyz division
This is what the W3C Recommendation "Cascading Style Sheets, level 1" says about using the ID attribute with style sheets:
By using the ID attribute as selector, one can set style properties on a per-element basis. While style sheets have been designed to augment document structure, this feature will allow authors to create documents that present well on the canvas without taking advantage of the structural elements of HTML. This use of style sheets is discouraged.
With this attribute you can place style sheet information directly with a element, so that it will be used to render the contents of this element. Using this attribute overrides style sheets from a linked style sheet, identified with the LINK element and style sheet information defined in the head of the page, using the STYLE element.
This text has its own style