|
Cascading Style Sheets (CSS) aren't complicated; they are just text files that contain formatting instructions for common HTML tags such as paragraphs, headings, lists, tables and so on. You create the style sheet and add it to all your pages. When you use a tag, the browser checks the style sheet to see how to format that tag and then does its best to display the tag the way you asked it to. Basically, style sheets allow you to define your house style. You only need to describe once how to you want headings, paragraphs, lists and so on to look. Just like in a word processing or desktop publishing package (well not quite, but it is step forward). Can't I just use HTML? Well, yes, but HTML doesn’t give you as much choice about how browsers format your page. To be fair, it was never meant to. It was supposed to define the structure of a page while the browser decided how the page should look. But, we weren’t happy to let this happen. We wanted to do what we could do with our word processors. So, we got lots of new tags and attributes to let us control the appearance of our pages but your choice is still limited. You can set headings (<h1>, <h2>…), make text bold (<b>) or italic (<i>), define lists (<ul>, <ol>, <li>) but you can't control the absolute position of things on the page, the font size, spacing, and colour. Normally, you have to bodge things and convert text to graphics, create complicated table layouts, use pictures for white space, and so on. Style sheets solve a lot of these problems. If you want more details, the best place to look for the most up-to-date and detailed CSS specification is on the W3C’s site. You can find it at http://www.w3.org/TR/REC-CSS2. CSS will become even more important when XHTML arrives because some of the current HTML tags and attributes will disappear (including <font>) and you'll have to use CSS properties instead. |
More information Using Cascading style sheets What does a style sheet look like? Adding styles to your web pages Adding comments to your style sheet Browser support for CSS properties |