HTML and CSS Reference
In-Depth Information
3.1 Overview of Cascading Style Sheets
For years, style sheets have been used in desktop publishing to apply typographical
styles and spacing instructions to printed media. CSS provides this functionality (and
much more) for Web developers. It allows Web developers to apply typographic styles
(typeface, font size, and so on) and page layout instructions to a Web page. The CSS
Zen Garden, http://www.csszengarden.com, exemplifies the power and flexibility of
CSS. Visit this site for an example of CSS in action. Notice how the content looks dra-
matically different depending on the design (CSS style rules) you select. Although the
designs on CSS Zen Garden are created by CSS masters, at some point these designers
were just like you—starting out with CSS basics.
CSS is a flexible, cross-platform, standards-based language developed by the W3C. Its
description of CSS can be found at http://www.w3.org/Style/. Be aware that CSS, even
though it has been in use for many years, is still considered an emerging technology and
the two most popular browsers do not support it in exactly the same way. There are
CSS reference pages at http://reference.sitepoint.com/css and http://www.westciv.com/
style_master/academy/browser_support that list the way styles are supported by various
browsers and platforms. This chapter concentrates on those aspects of CSS that are well
supported by popular browsers.
Advantages of Cascading Style Sheets
There are several advantages to using CSS:
Typography and page layout can be better controlled. These features include font
size, line spacing, letter spacing, indents, margins, and element positioning.
Style is separate from structure. The format of the text and colors used on the
page can be configured and stored separately from the body section of the Web
page document.
Styles can be stored. You can store styles in a separate document and associate
them with the Web page. When the styles are modified, the XHTML remains
intact. This means that if your client decides to change the background color
from red to white you only need to change one file that contains the styles,
instead of each Web page document.
Documents are potentially smaller. The formatting is separate from the document;
therefore, the actual documents should be smaller.
Site maintenance is easier. Again, if the styles need to be changed it's possible to
complete the modifications by changing the style sheet only.
Do you see that there might be advantages to using CSS? You may be wondering if
there are any disadvantages to using CSS. In fact, there is one large disadvantage—CSS
technology is not yet uniformly supported by browsers. This disadvantage will be less
of an issue in the future as browsers comply with standards.
Types of Cascading Style Sheets
There are four methods used to incorporate CSS technology in a Web site: inline,
embedded, external, and imported.
 
Search WWH ::




Custom Search