Supported by :   My Law Forms Ltd. - Deed polls and Tenancy Agreements

Why Use Style Sheets?

Several years ago a major push was made to begin separating the presentational aspects of a website from the structural aspects of it through the use of Cascading Style Sheets (CSS). By working towards this separation a website designer can make her job easier in many ways.

In the past if a designer wanted to change the appearance of her website she would have to spend countless hours changing the attributes specified within a document such as bgcolor, color, face, and size. These attributes, and even some of their supporting tags, are now deprecated and should not be used.

Style sheets give a designer the ability to make all changes in one place. Because a CSS selector can refer to many elements in a document the entire appearance of a document can be changed with only a few alterations to the CSS. Consider the following examples:

<p><font color="#FFFFFF" face="Arial"
font size="2>This is </font><font size="4" color="#CC99CC"><b>amazing!</b></font></p>

This HTML could be easily streamlined with just a little CSS:

p {color:#fff;font-face:arial,sans-serif;
b {color:#c9c;font-size:1.8em}

The resulting HTML would look like this:

<p>This is <b>amazing!</b></p>

Isn’t that better? The HTML is all about the content now. And the markup looks so much better than before too!

This entry was posted on Sunday, March 18th, 2007 at 10:33 am and is filed under HTML help, XHTML tips. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

One Response to “Why Use Style Sheets?”

  1. freelancer says:

    Using CSS for coloring, setting sizes, etc. is more or less compatible among browsers. But when it comes to positioning using CSS… I suspect you would say it is not good, but I would rather use tables. Tables are very well compatible among browsers and I do not have to spend hours debugging why it works in one browser and does not work in another (or even another browser version). Maybe i think so because i have almost no CSS experience.

    xht: CSS should also be used for positioning, although it can be tricky to get the desired effect in all browsers, it then becomes possible to apply separate style sheets for different displays. For example: print, low-res, accessibility, etc.