XML technologies / CSS / Advanced websites with CSS / Putting CSS in perspective / The benefits of CSS design / Centralized design information
(Excerpt from “CSS − Advanced websites with Cascading Stylesheets” by Rachel Andrew & Dan Shafer)
As explained, the best way to use CSS is to provide style rules in separate files .css. These external stylesheets are attached to the appropriate HTML pages through a tag <link>. All instructions controlling a website’s appearance are thus centralized rather than mixed with page content.
This lets you change page content without altering its appearance, and vice versa. Traditional web design mixes the code for these two fundamental parts through the syntax and operation of HTML tags and attributes. Changing one requires considering the other and possibly updating it as well to keep the page rendering correctly. In plain HTML, appearance and content are inseparably coupled.
In programming, separating code for different purposes and storing it in different places is called decoupling. If presentation and content are decoupled, a designer can change the website’s appearance in the file .css, while an author enters content exclusively in the file .html.
Even more important than simplifying website work and teamwork is the substantial reduction in duplicated code when using CSS. For example, displaying each paragraph’s heading in large red type in HTML requires every tag <h1> to contain a tag <font>. With CSS, font properties for all tags <h1> are defined in one place, saving considerable effort. Redesigning is also much easier: changing heading presentation requires editing one CSS rule rather than every HTML tag in every document, which would drive you crazy! The following figure illustrates the difference.
Figure: CSS centralizes the design code for an entire web page.
The figure above clearly shows that the CSS version requires less code to be loaded than the plain HTML version. This reduces users’ waiting times and online costs, particularly for professional websites with many design elements and numerous subpages.
Copyright © 2006 of the German translation, dpunkt.verlag GmbH
You may print the online version for your private use.
Otherwise, this chapter from “CSS − Anspruchsvolle Websites mit Cascading Stylesheets” is subject to the same conditions as the bound edition: the work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
dpunkt.verlag GmbH, Ringstraße 19, 69115 Heidelberg
back to top