About the W3C
Formatting HTML using HTML
HTML was not designed for formatting which was left to the particular browser. Originally HTML attempted to mix content and layout by providing tags which could be used to help lay out a document. What can be achieved in terms of layout with just HTML however is very limited. In effect the web developer was just using in-line styles.
As the Internet grew this limitation was overcome by the introduction of Cascading Style Sheets (CSS). These notes delve into some of the basic and more complex examples involving style sheets.
Advantages of CSS
Control layout of many documents from one single style sheet
Style rules are accessible to scripting and so can be changed dynamically
Apply different layout to different media-types, screen or print for example.
More precise control of layout
The purpose of Cascading style sheets is to separate the layout from the content, providing a much more flexible alternative. For example each time you use a <h1> tag for a page header, you want it styled the same, on every page. By using an external style sheet this can be set up just once. Furthermore if you decide to change it at some later date, only only need to change it in one place.
The term cascading refers to way in which style sheets rules are applied and initially may be a source of confusion. Because a single (HTML or XML element) may have multiple style rules applied to it, these rules are applied according to their precedence. For example an HTML page may have its own style rules enclosed within <style> … </style> tags which can override rules in the external style sheet.
Lastly, within a web page, may be in-line styles e.g. <p style=”list of style rules” >. These rules with override, or take precedence over both the local or external rules.
Style rules can be grouped together according to their function
fonts and text properties
color and background
The standards for cascading style sheets are maintained by the W3 organisation.
Cascading Style Sheets can also be used with XML (e Xtensible) Mark-up Language. Like HTML Cascading Style sheets also have their limitations. XSL is a style sheet (just for XML) that is tackling some of those issues.