3 Definitions and document conventions


  1. Definitions
    1. Document language
    2. Element
    3. User agent (or UA)
    4. Conforming user agent
    5. Default style sheet
  2. Conventions
    1. Document language elements and attributes
    2. CSS property definitions
    3. HTML conventions

3.1 Definitions

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.

3.1.1 Document language

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 .

3.1.2 Element

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.)

3.1.3 User agent (or UA)

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.

3.1.4 Conforming user agent

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.

3.1.5 Default style sheet

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.

3.2 Conventions

3.2.1 Document language elements and attributes

3.2.2 CSS property definitions

Each CSS property definition begins with a summary of key information that resembles the following:

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:

This part of the property definition specifies the set of valid values for the property. Value types may be designated in several ways:
  1. constant values (e.g., 'auto', 'disc', etc.)
  2. 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.
  3. non-terminals 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 non-terminal name is the property name (complete with quotes) between "<" and ">" (e.g., <'border-width'>). In the electronic version of the document, each instance of this type of non-terminal links to the corresponding property definition.
  4. non-terminals that do not share the same name as a property. In this case, the non-terminal name appears between "<" and ">" (e.g., <border-width>) and its definition is located near its first appearance in the specification. In the electronic version of the document, each instance of this type of non-terminal links to the corresponding value definition.
Other words are keywords that must appear literally, without quotes. The slash (/) and the comma (,) must also appear literally.

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>
The property's default value. If the property is inherited, this is the value that is given to the root element of the document. Otherwise it is the value that the property will have if there are no style rules for it in either the user's or the designer's style sheet.
Applies to
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, 'font-style' has no effect if the element is an image.
Indicates whether the value of the property is inherited from a parent element.
Percentage values
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.

3.2.3 HTML conventions

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).