HTML and CSS Reference
In-Depth Information
CHAPTER 1
■ ■ ■
The Promise of CSS
T he ideal that Cascading Style Sheets (CSS) strives to attain is the complete separation of
content from presentation. In other words, you build, maintain, and store the core content of
your web page, web site, or application (the text, related images, forms, and so forth) sepa-
rately from the visual presentation (such as the layout, typography, and decorative images).
Those of you moving to CSS from the world of old-school web development may find
this approach quite different from what you're used to. You may be accustomed to using
(X)HTML tables as layout grids, creating margins between items by including img elements
in your (X)HTML that serve up one-pixel transparent GIF images, and specifying typefaces
using the (X)HTML font element. “Freeing your mind” from relying on those approaches
isn't easy, but most people who do are glad they did. For those of you who have used CSS since
the day you started building web sites, consider yourselves blessed—learning CSS from scratch
is easier than changing the way you think about web design.
Note Most discussion points and examples in this topic apply to both HTML and XHTML. We will use the
notation (X)HTML to indicate these cases. When things do apply specifically to HTML or XHTML and not both,
we will use the appropriate name alone, without the parenthetical (X).
The Advantages of Using CSS for Style
There are numerous real-world advantages to separating content and style, and most of you
are probably already aware of them. We'll recap, just in case.
By separating the two layers of your document, you make it simple to add, remove, or
update content without having to worry about botching up your layout. You also make it easy
to change the font used for the entire site without having to dig through your content in search
of every single <font> tag. Separating the two layers allows a web team to work efficiently; your
visual designers can focus on design while your content producers focus on content—and
neither has to worry about the other getting in their way. If you're a solo developer, you'll find
that the separation of content and presentation allows you to keep your “frames of mind” sep-
arate as well. When you need to make a change to content, you won't have to dig through
a bunch of style code to find what you're looking for.
1
Search WWH ::




Custom Search