Understanding Style Sheets

Of course, a single style won't transform a Web page into a work of art. It may make your paragraphs red, but to infuse your Web sites with great design, you need many different styles. A collection of CSS styles comprises a style sheet. A style sheet can be one of two types— internal or external, depending on where the style information's located: in the Web page itself, or in a separate file linked to the Web page.

Internal or External—How to Choose

Most of the time, external style sheets are the way to go, since they make building Web pages easier and updating Web sites faster. They contain all your style information in a single file. With just a line of code, you attach the external style sheet to an HTML page and completely alter that page's appearance. You can revamp the look of an entire site by editing a single text file: the style sheet.

On the receiving end, external style sheets help Web pages open faster. When you use an external style sheet, your Web pages can contain only basic HTML—no byte-hogging HTML tables or <font> tags, and no internal CSS style code. Furthermore, when a Web browser downloads an external style sheet, it stores the file on your visitor's computer (in a behind-the-scenes folder called a cache) for quick access. When your visitor hops to other pages on the site that use the same external style sheet, there's no need for the browser to download the style sheet again. The browser simply pulls the external style sheet ...

Get CSS: The Missing Manual now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.