CSS (Cascading Style Sheets)

From DM

Revision as of 21:10, 18 February 2012 by DominiqueS (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

CSS is a simple but powerful stylesheet language which is used to render structurally encoded languages for display (see http://www.w3.org/Style/CSS/ for a description of the standard). The language is most commonly used to "style" HTML pages for display on the web, although the full specification includes instructions that in theory can be used to style markup for print and aural rendition. As of March 2005, these addition capabilities are poorly supported, however.

CSS can also be used to style XML for display directly in many contemporary browsers. In most cases, however, this approach is not recommended, as commercial HTML-oriented browsers may not understand operational elements such as those used to encode links or images (e.g. tei:figure or tei:xptr) regardless of their styling. For most XML styling, current standard practice calls for transformation to XHTML using XSLT. This XHTML output is then styled using CSS.

Browser support

CSS is supported by most contemporary browsers. Implementation can differ considerably, however, as not all browsers follow the standard accurately or completely (Microsoft Internet Explorer is particularly poor in this regard). As the standard is open to interpretation, moreover, even compliant browsers can implement specific instructions differently. Several test suites exist that allow designers to test specific instructions in their favorite browsers.

Sample instructions

CSS instructions follow a very simple format:

element_name {
   instruction_category : instruction ;

Each element can have more than one instruction. The following CSS fragment, for example, provides styling for an HTML <h1> element:

h1 {
 text-align: center;
 text-decoration: underline;
 font-family: sans-serif;

Unless this instruction is contradicted or modified by more specific instructions, all <h1> elements in the associated files will be centered, underlined, and in a sans-serif font (in this case, chosen by the system).

Useful resources

http://www.csszengarden.com/: A site showing how powerful the separation of form and content can be.

Meyer, Eric A. Cascading Style Sheets 2.0: Programmer's reference. New York: McGraw Hill, 200

Personal tools