The CSS community has gained significant experience with the CSS2
specification since it became a recommendation in 1998. Errors in the
CSS2 specification have subsequently been corrected via the
publication of various errata, but there has not yet been an
opportunity for the specification to be changed based on experience
gained.
While many of these issues will be addressed by the upcoming CSS3
specifications, the current state of affairs hinders the
implementation and interoperability of CSS2. The CSS 2.1 specification
attempts to address this situation by:
Maintaining compatibility with those portions of CSS2 that are
widely accepted and implemented.
Incorporating all published CSS2 errata.
Where implementations overwhelmingly differ from the CSS2
specification, modifying the specification to be in accordance with
generally accepted practice.
Removing CSS2 features which, by virtue of not having been
implemented, have been rejected by the CSS community. CSS2.1 aims to
reflect what CSS features are reasonably widely implemented for HTML
and XML languages in general (rather than only for a
particular XML language, or only for HTML).
Removing CSS2 features that will be obsoleted by CSS3, thus
encouraging adoption of the proposed CSS3 features in their place.
Adding a (very) small number of new
property values, when implementation experience has shown that
they are needed for implementing CSS2.
Thus, while it is not the case that a CSS2 stylesheet is
necessarily forwards-compatible with CSS 2.1, it is the case that a
stylesheet restricting itself to CSS 2.1 features is more likely to
find a compliant user agent today and to preserve forwards
compatibility in the future. While breaking forward compatibility is
not desirable, we believe the advantages to the revisions in CSS 2.1
are worthwhile.
CSS 2.1 is derived from and is intended to replace CSS2. Some
parts of CSS2 are unchanged in CSS 2.1, some parts have been
altered, and some parts removed. The removed portions may be used in a
future CSS3 specification. Implementations may refer to CSS2 for the
definitions of features that have been removed, but for other features
CSS 2.1 is the normative reference.
This specification has been written with two types of readers in
mind: CSS authors and CSS implementors. We hope the specification will
provide authors with the tools they need to write efficient,
attractive, and accessible documents, without overexposing them to
CSS's implementation details. Implementors, however, should find all
they need to build conforming user
agents.
The specification begins with a general presentation of CSS and
becomes more and more technical and specific towards the end. For
quick access to information, a general table of contents,
specific tables of contents at the beginning of each section,
and an index provide easy navigation, in both the electronic
and printed versions.
The specification has been written with two modes of presentation
in mind: electronic and printed. Although the two presentations will
no doubt be similar, readers will find some differences. For example,
links will not work in the printed version (obviously), and page
numbers will not appear in the electronic version. In case of a
discrepancy, the electronic version is considered the authoritative
version of the document.
The specification is organized into the following sections:
Section 2: An introduction to CSS2.1
The introduction includes a brief tutorial on CSS2.1 and
a discussion of design principles behind CSS2.1.
Sections 3 - 20: CSS 2.1 reference manual.
The bulk of the reference manual consists of the CSS 2.1 language
reference. This reference defines what may go into a CSS 2.1 style sheet
(syntax, properties, property values) and how user agents must
interpret these style sheets in order to claim conformance.
basic data types, which appear between "<" and ">" (e.g.,
<length>, <percentage>, etc.). In the electronic version
of the document, each instance of a basic data type links to its
definition.
types that have the same range of values as a property bearing
the same name (e.g., <'border-width'>
<'background-attachment'>, etc.). In this case, the type name
is the property name (complete with quotes) between "<" and ">"
(e.g., <'border-width'>). Such a type does not
include the value 'inherit'. In the electronic version of the
document, each instance of this type of non-terminal links to the
corresponding property definition.
non-terminals that do not share the same name as a property. In this
case, the non-terminal name appears between "<" and ">", as in
<border-width>. Notice the distinction between
<border-width> and <'border-width'>; the latter is defined
in terms of the former. The definition of a non-terminal is located
near its first appearance in the specification. In the electronic
version of the document, each instance of this type of value links to
the corresponding value definition.
Other words in these definitions are keywords that must appear
literally, without quotes (e.g., red). The slash (/) and the comma (,)
must also appear literally.
Values may be arranged as follows:
Several juxtaposed words mean that all of them must occur, in the
given order.
A bar (|) separates two or more alternatives:
exactly one of them must occur.
A double bar (||) separates
two or more options: one or more of them must occur, in any order.
Brackets ([ ]) are for grouping.
Juxtaposition is stronger than the double bar, and the double bar
is stronger than the bar. Thus, the following lines are equivalent:
a b | c || d e
[ a b ] | [ c || [ d e ]]
Every type, keyword, or bracketed group may be followed by one of
the following modifiers:
An asterisk (*) indicates that the preceding type, word, or group
occurs zero or more times.
A plus (+) indicates that the preceding type, word, or group
occurs one or more times.
A question mark (?) indicates that the preceding type, word, or
group is optional.
A pair of numbers in curly braces ({A,B}) indicates that the
preceding type, word, or group occurs at least A and at most
B times.
The following examples illustrate different value types:
Value types are specified in terms of tokens, as described in Appendix G.2. As the grammar allows spaces
between tokens in the components of the expr production,
spaces may appear between tokens in values.
Note: In many cases, spaces will in fact be
required between tokens in order to distinguish them from
each other. For example, the value '1em2em' would be parsed as a
single DIMEN token with the number '1' and the identifier
'em2em', which is an invalid unit. In this case, a space would be
required before the '2' to get this parsed as the two lengths '1em'
and '2em'.
This part specifies the property's initial value. If the property
is inherited, this is the value that is given to the root element of
the document tree. Please consult
the section on the cascade for information
about the interaction between style sheet-specified, inherited, and
initial values.
This part lists the elements to which the property applies. All
elements are considered to have all properties, but some properties
have no rendering effect on some types of elements. For example, the 'clear' property only affects block-level elements.
This part indicates whether the value of the property is inherited
from an ancestor element. Please consult the section on the cascade for information about the
interaction between style sheet-specified, inherited, and initial
values.
This part indicates how percentages should be interpreted, if they occur in
the value of the property. If "N/A" appears here, it means that the
property does not accept percentages as values.
Most images in the electronic version of this specification are
accompanied by "long descriptions" of what they represent. A link to
the long description is denoted by a "[D]" after the image.
Images and long descriptions are informative only.
We would like to thank the following people who, through their
input and feedback on the www-style mailing list, have helped us with
the creation of this specification: Andrew Clover, Bernd Mielke, C.
Bottelier, Christian Roth, Christoph Päper, Claus Färber,
Coises, Craig Saila, Darren Ferguson, Dylan Schiemann, Etan Wexler,
George Lund, James Craig, Jan Eirik Olufsen, Jan Roland Eriksson,
Joris Huizer, Joshua Prowse, Kai Lahmann, Kevin Smith, Lachlan Cannon,
Lars Knoll, Lauri Raittila, Mark Gallagher, Michael Day,
Peter Sheerin, Rijk van Geijtenbeek, Robin Berjon,
Scott Montgomery, Shelby Moore, Stuart Ballard, Tom Gilder, Vadim
Plessky, and the Open eBook Publication Structure Working Group
Editors. We would also like to thank Glenn Adams and Susan Lesch, who
helped proofread this document.
In addition, we would like to extend special thanks to fantasai,
Ada Chan, and Boris Zbarsky, who have contributed significant
time to CSS2.1, and to Kimberly Blessing, for help with the
editing.
Documents on the W3C site are
provided by the copyright holders under the following license. By
obtaining, using and/or copying this document, or the W3C document
from which this statement is linked, you agree that you have read,
understood, and will comply with the following terms and
conditions:
Public documents on the W3C site are provided by the copyright holders
under the following license. The software or Document Type Definitions (DTDs)
associated with W3C specifications are governed by the Software
Notice. By using and/or copying this document, or the W3C document from
which this statement is linked, you (the licensee) agree that you have read,
understood, and will comply with the following terms and conditions:
Permission to use, copy, and distribute the contents of this document, or
the W3C document from which this statement is linked, in any medium for any
purpose and without fee or royalty is hereby granted, provided that you
include the following on ALL copies of the document, or portions
thereof, that you use:
When space permits, inclusion of the full text of this NOTICE
should be provided. We request that authorship attribution be provided in any
software, documents, or other items or products that you create pursuant to
the implementation of the contents of this document, or any portion
thereof.
No right to create modifications or derivatives of W3C documents is
granted pursuant to this license. However, if additional requirements
(documented in the Copyright
FAQ) are satisfied,
the right to create modifications or derivatives is sometimes granted by the
W3C to individuals complying with those requirements.
THIS DOCUMENT IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO
REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED
TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
NON-INFRINGEMENT, OR TITLE; THAT THE CONTENTS OF THE DOCUMENT ARE SUITABLE
FOR ANY PURPOSE; NOR THAT THE IMPLEMENTATION OF SUCH CONTENTS WILL NOT
INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE DOCUMENT OR THE
PERFORMANCE OR IMPLEMENTATION OF THE CONTENTS THEREOF.
The name and trademarks of copyright holders may NOT be used in
advertising or publicity pertaining to this document or its contents without
specific, written prior permission. Title to copyright in this document will
at all times remain with copyright holders.