Introduction |
CSS Principles |
Basic Concepts |
Gettysburg Revisited |
Other Resources
CSS Principles
The principle of Cascading Style Sheets is simple: let the HTML tags do their intended work. CSS achieves the separation
of style/appearance from the structure of the document. It also allows for more precise control over the appearance of the
document than that afforded by HTML additions.
What does "cascading" mean?
This simply means that there are multiple ways in which the browser will recognize formatting styles. These will be discussed
in the next lesson, but essentially there are four basic levels of importance, in which one level overrides another:
- Browser default (lowest)
- External style sheet
- Embedded style sheet
- Inline style
In this progression, external style sheet directions override the browser defaults. An external sheet, however, is overridden
by an "embedded" style sheet (directions that are written in the <HEAD> section of the HTML document. In turn,
an inline style (directives given within a tag itself) override all the others. The cascade refers to how one level supersedes
another.
Advantages
- Authors can use style sheets to control multiple pages at once. Instead of having to make code changes across
dozens of individual pages, the individual can make one change in one place that puts the changes into effect for all
the pages of a site. This improves consistency in the appearance of the website and allows for more efficient site updates.
- Authors have more control over elements. The level of formatting control with HTML attributes is rudimentary
(relative font size, color, etc.). With CSS, the author is able to specify color, borders, behaviors, sizes in at least
six units of measurement, margins, and even positioning (with CSS level 2).
- Designers can improve site performance. All the formatting code that goes into the average HTML page creates
a bigger file. CSS allows the author to reduce that average file size and, hence, improve performance. The greater the
number of pages in a site, the greater the potential gain.
- CSS is a forward-looking standard. HTML will not go away anytime soon. However, CSS is applicable to both HTML
and XML, which means that the formatting you learn today will be applicable for a long time to come.
Disadvantages
- CSS is not uniformly implemented. As with most W3C standards, there is variance between different browsers in
the amount of CSS support and the way in which the support has been implemented. Version 3.0 of Netscape Navigator, for
instance, has no support for CSS at all, as it predates the standard. Version 4 of Navigator (or Communicator for
the full version) has "buggy" support for CSS1 and almost no support for CSS2. Version 6 Navigator, on the other
hand, has excellent support for CSS1 and decent (read: unpredictable) support for CSS2. Internet Explorer and the Opera
browser have similar histories.
- CSS is better at vertical alignments than horizontal ones. From a layout (CSS2) perspective, CSS is optimized
for top-down control rather than side-to-side (e.g., multi-column) control.
Previous lesson | Next lesson