Cascading Style Sheets (CSS) allow you to specify the format, placement, and (in some cases) the behavior of text, images, and other elements on a Web page. In theory, CSS allows you to completely control the appearance of you pages across browsers.
That's the theory. In practice, browsers implement the CSS standards unevenly or not at all. Fortunately, the most recent browsers are supporting CSS more effectively than third- and fourth-generation browsers.
Cascading Style Sheets separate appearance from function in HTML documents. That is, they allow you to use simpler HTML markup in your documents. Consider the following examples of passages of text, modified so that they appear in a specific font and color. One uses the <FONT> tag to control the appearance of the text. The other uses an external Cascading Style Sheet to accomplish the same thing:
This text is formatted with the <FONT> tag so that it will appear as an example.
This text is formatted with CSS so that it will appear as an example.
The code for these examples follows:
<p><FONT FACE="Verdana,Geneva,Arial,Helvetica,sans-serif" SIZE="2" COLOR="Olive">This text is formatted with the <FONT> tag so that it will appear as an example.</FONT></p> <p class="example">This text is formatted with CSS so that it will appear as an example.</p>
With CSS, you can create one or more external style sheets that are linked to a file in the <HEAD> element. You can also specify styles within a document. Finally, you can specify styles within a tag, using the STYLE attribute.
Many excellent books and Web sites are devoted to discussions of CSS. Rather than replicate their work here, I have created a CSS Links page that provides access to informative sites and articles on the Web, online tutorials and workshops, CSS software tools, and CSS FAQs and specifications.
|