Cascading Style Sheets (CSS)

2009 Apr 28


CSS
Rules
CSS
Comments
CSS
Keywords
Cascade
Rules
Element
Types
Element
Levels
Font
Properties
Forms Generated
Properties
Selector
Syntax
Tips
<hr>
Properties
List
Properties
Outline
Properties
Table
Properties
Text
Properties
Visual
Formatting
All
Properties
@
Directives
Aural
Units
Length
Units
Named
Colors
Interface
Styles
Aural
Media
Print
Media
Projection
Media
Non Standard
Properties
W3C CSS Specifications
CSS1 CSS2 CSS2.1
Dropped
in CSS2.1
External
Links

Note: Relative URLs in a style sheet are relative to the style sheet not the document.

Notation for property values:


CSS Rules

Each CSS rule consists of a Selector followed by a Declaration block:

CSS Rule:
Selector Declaration Block

A Declaration block consists of curly braces containing a sequence of Declarations.
A Declaration is a property followed by a colon, followed by a value, followed by a semi-colon.

h1 { color: blue; text-align: center; }

A value is one or more space separated keywords appropriate to the property. The one exception is the font property where a forward slash can separate specific keywords, e.g.:

p { font: large/256% sans-serif; }

There can optionally be other spaces in the rule. If an incorrect (i.e. unknown) property or value is used, then the declatation is ignored.


CSS Comments

CSS comments are like C/C++ comments they start with /* and end with */ and can span multiple lines.

This allows HTML style comments, <!-- ... -->, to surround CSS rules in case an old browser does not support the CSS related elements.


CSS Keywords

Keywords that can apply depend on the element and attribute. The same keyword may have different meaning for different elements or attributes.

inherit Since CSS2.1 makes the property same as parent (this is default).
Assigned styles usually override inherited styles.
none Not the same as 0
normal e.g. different for letter-spacing or font-style

Projection Media

See Cascade Rules. Projection media are like print media in that the display size is fixed. At this time only the Opera agent supports this.


External Links

Discussion groups: 1 2
Browser Issues: 1 2 3 4 5 6 7
Attributes: 1
Reference: 1 2 3 4 5 6 7 8 9
Tutorial: 1 2
Validators: 1 2
Multicolumn examples: 1 2

© 2007-2009 Prem Sobel. All Rights Reserved.