ToC ~ Up ~ Prev ~ Next ~ Index Introduction to HTML
Last Update: 31 January 2000

2.6 What is CSS?

HTML or XHTML only divide a document up into paragraphs, lists, headings and so on, but does not really say how these things should look. Rather, a browser generally makes some assumptions about how things should look -- and we're then stuck with those choices.

This could be changed given a way of controlling how different markup elements (like headings, paragraphs, etc) look. This is the role of CSS. Cascading Style Sheets, or CSS, is a language, separate from HTML or XHTML, designed for specifying the layout or formatting properties of the various HTML elements in a document. For example, a CSS statment like the following

body { font-family:      Arial,helvetica,sans-serif;
       color:            black;
       background-color: white;
     }

means that, inside the BODY of a document, the desired font is Arial, the desired text color is black, and the desired background color for the page is white. More complicated rules let you control underlining of links, the placement of background images, the widths of margins, the colors of borders around paragraphs or headings, etc.

as an example, the page you are viewing has an "attached" style sheet to control how it looks. THis stylesheet is includded into this document using a special link element of the form:

<link rel="stylesheet" href="stylesheet.css" >

where stylesheet.css contains the CSS document. You can click on the word stylesheet.css above to see this stylesheet document.

CSS is a rich and complicated language -- in its own way just as complex as HTML. There is not much in this Website on CSS, although my book, The XHTML 1.0 Language and Design Sourcebook discusses CSS and XHTML in detail). The reference section of this Website, however, has a number of references to useful CSS information sites.


ToC ~ Up ~ Prev ~ Next ~ Index Introduction to HTML
© 1994-1998 by Ian Graham
Last Update: 31 January 2000