Contents
In this section, we begin the formal specification of CSS2, starting with the contract between authors, documents, users, and user agents.
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC2119]. However, for readability, these words do not appear in all upper case letters in this specification.
At times, the authors of this specification recommend good practice for authors and user agents. These recommendations are not normative and conformance with this specification does not depend on their realization. These recommendations contain the expression "We recommend ...", "This specification recommends ...", or some similar wording.
Style sheets specify the presentation of a document written in another computer language (such as HTML or XML) which, in this specification, is referred to as the document language .
The primary syntactic constructs of the document language are called elements , an SGML term (see [ISO8879]). Most CSS style sheet rules refer to these elements and specify rendering information for them. Examples of elements in HTML include "P" (for structuring paragraphs), "TABLE" (for creating tables), "OL" (for creating ordered lists), etc.
Block-level elments are those elements of the document language that, by default, are formatted visually as blocks (e.g., paragraphs). Inline elments are those elements of the document language that do not cause paragraph breaks (e.g., pieces of text, inline images, etc.)
A user agent is a computer program which interprets a document written in the document language and associated style sheets by applying the terms of this specification. A user agent may display a document, read it aloud, cause it to be printed, convert it, etc.
This section defines conformance with the CSS2 specification only. There may be other levels of CSS in the future that may require a UA to implement a different set of features in order to conform.
A user agent that elects to implement a topic (e.g., fonts, colors, aural style sheets, etc.) covered by this specification must adhere to all pertinent sections of the specification in order to be considered to conform to CSS2 for that topic. In such cases, a user agent may claim to conform to part of the CSS2 specification.
A user agent that elects to implement all topics covered by this specification and that does so in accordance with the specification may claim to conform to all of CSS2. The inability of a user agent to implement a specific topic due to the limitations of a particular device (e.g., a user agent cannot render colors on a monochrome monitor or a black and white page) does not imply non-conformance.
In addition to the previous conditions, a user agent that uses CSS2 to display documents conforms to the CSS2 specification if:
A user agent that outputs CSS2 style sheets conforms to the CSS2 specification if it outputs valid CSS2 style sheets.
A user agent that uses CSS2 to display documents and outputs CSS2 style sheets conforms to the CSS2 specification if it meets both sets of conformance requirements.
This specification also recommends, but doesn't require, that a UA observe the following rules (which refer to functionality, not user interface):
Different user interface paradigms may have their own constraints: a VR browser may rescale the document based on its "distance" from the user.
UAs may offer readers additional choices on presentation. For example, the UA may provide options for readers with visual impairments or may provide the choice to disable blinking.
Conforming user agents must apply a default style sheet (or behave as if they did) prior to all other style sheets for a document. A user agent's default style sheet generally presents elements of the document language in ways that satisfy the expectations that most people have (e.g., for visual browsers, the EM element in HTML is presented using an italic font).
If a document has associated style sheets, the default style sheet is considered along with author and user style sheets when determining how rules cascade.
User agents that don't actually use style sheets to specify default rules must behave as if they did.
See "A sample style sheet for HTML 4.0" for a recommended default style sheet for HTML 4.0 documents.
Each CSS property definition begins with a summary of key information that resembles the following:
'Property-name'
Value: | Possible constant values or value types |
---|---|
Initial: | The initial value |
Applies to: | Elements this property applies to |
Inherited: | Whether the property is inherited |
Percentage values: | How percentage values should be interpreted |
The five categories have the following meanings:
Several things juxtaposed mean that all of them must occur, in the given order. A bar (|) separates alternatives: one of them must occur. A double bar (A || B) means that either A or B or both 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 "a b | c || d e" is equivalent to "[ a b ] | [ c || [ d e ]]".
Every type, keyword, or bracketed group may be followed by one of the following modifiers:
The following examples illustrate different value types:
Value: N | NW | NE
Value: [ <length> | thick | thin ]{1,4}
Value: [<family-name> , ]* <family-name>
Value: <url>? <color> [ / <color> ]?
Value: <url> || <color>
In this specification, most of the examples refer to HTML. For clarity, HTML elements are written with upper case letters (e.g., HTML, BODY, EM, P) and HTML attributes are written with lower case letters (e.g., src, class, id).