Abstract

This CSS3 module describes the common values and
units that CSS properties accept and the syntax used for describing them
in CSS property definitions.

Status of this document

This section describes the status of this document at the time of
its publication. Other documents may supersede this document. A list of
current W3C publications and the latest revision of this technical report
can be found in the W3C technical reports
index at http://www.w3.org/TR/.

A Candidate Recommendation is a document that has been widely reviewed
and is ready for implementation. W3C encourages everybody to implement
this specification and return comments to the (archived) public
mailing list
www-style@w3.org (see instructions). When sending
e-mail, please put the text “css3-values” in the subject, preferably
like this: “[css3-values] …summary of
comment…”

Publication as a Candidate Recommendation does not imply endorsement by
the W3C Membership. This is a draft document and may be updated, replaced
or obsoleted by other documents at any time. It is inappropriate to cite
this document as other than work in progress.

All features described in this specification that also exist in CSS 2.1
[CSS21] are intended
to be backwards compatible. If you notice a conflict between this draft
and CSS 2.1 [CSS21], please inform the editors!

The CR period will last at least until 4 May 2013. At the time of
publication, no test suite and implementation report have yet been made.
They will be made available from the CSS test
suites page. See the section “CR exit
criteria” for details.

See the section “Changes” for changes made to
this specification since the last Candidate Recommendation.

The following features are at-risk and may be dropped during the CR
period: ‘calc()’, ‘toggle()’, ‘attr()’.

1. Introduction

The value definition field of each CSS property can contain keywords,
data types (which appear between ‘<’ and
‘>’), and information on how they can be
combined. Generic data types (<length> being the most widely
used) that can be used by many properties are described in this
specification, while more specific data types (e.g.,
<spacing-limit>) are described in the corresponding modules.

1.1. Module Interactions

This module replaces and extends the data type definitions in [CSS21] sections 1.4.2.1, 4.3, and A.2.

2. Value Definition Syntax

The syntax described here is used to define the set of valid values for
CSS properties. A property value can have one or more components.

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
the brackets. Such a type does not include CSS-wide keywords such as ‘inherit’.

non-terminals that do not share the same name as a property. In this
case, the non-terminal name appears between ‘<’ and ‘>’, as in
<spacing-limit>. Notice the distinction between
<border-width> and <‘border-width’>: the latter is defined as
the value of the ‘border-width’ property,
the former requires an explicit expansion elsewhere. The definition of a
non-terminal is located near its first appearance in the specification.

Some property value definitions also include the slash (/) and/or the
comma (,) as literals. These represent their corresponding tokens.

All CSS properties also accept the CSS-wide
keyword values ‘inherit’ and ‘initial’ as the sole component of their property
value. For readability these are not listed explicitly in the property
value syntax definitions. For example, the full value definition of ‘border-color’ is ‘[
<color>{1,4} ] | inherit | initial’ (even though it is listed
as ‘<color>{1,4}’).

Note: This implies that, in general, combining these
keywords with other component values in the same declaration results in an
invalid declaration. For example, ‘background:
url(corner.png) no-repeat, inherit;’ is invalid.

2.2. Component value
combinators

Component values can be arranged into property values as follows:

Several juxtaposed words mean that all of them must occur, in the
given order.

A double ampersand (&&) separates two or more components, all of which
must occur, in any order.

A double bar (||) separates two or more options: one or more of them
must occur, in any order.

A bar (|) separates two or more alternatives: exactly one of them must
occur.

Brackets ([ ]) are for grouping.

Juxtaposition is stronger than the double ampersand, the double
ampersand 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 f
[ a b ] | [ c || [ d && [ e f ]]]

2.3. Component value
multipliers

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.

A hash mark (#) indicates that the preceding type, word, or group
occurs one or more times, separated by comma tokens.

For repeated component values (indicated by ‘*’, ‘+’, or ‘#’), UAs must support at least 20 repetitions of the
component. If a property value contains more than the supported number of
repetitions, the declaration must be ignored as if it were invalid.

2.4. Component values
and white space

Unless otherwise specified, white space and/or comments may appear
before, after, and/or between components in a property value or
subcomponents in a functional notation
that is defined using these component combinators and multipliers.

Note: In many cases, spaces will in fact be required
between components 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’.

2.5. Property value
examples

Below are some examples of properties with their corresponding value
definition fields

3. Textual Data Types

An identifier is a sequence of characters
conforming to the IDENT token in the grammar.
[CSS21] Identifiers
cannot be quoted; otherwise they would be interpreted as a string.

3.1. Pre-defined Keywords

In the value definition fields, keywords with a pre-defined meaning
appear literally. Keywords are CSS identifiers and are interpreted
case-insensitively within the ASCII range (i.e., [a-z] and [A-Z] are
equivalent).

For example, here is the value definition for the ‘border-collapse’ property:

Some properties accept arbitrary author-defined identifiers as a
component value. This generic data type is denoted by <custom-ident>, and represents any
valid CSS identifier that does not
otherwise appear as a pre-defined keyword in that property's value
definition. Such identifiers are fully case-sensitive, even in the ASCII
range (e.g. ‘example’ and ‘EXAMPLE’ are two different, unrelated user-defined
identifiers).

content: "this is a 'string'.";
content: "this is a \"string\".";
content: 'this is a "string".';
content: 'this is a \'string\'.';

It is possible to break strings over several lines, for aesthetic or
other reasons, but in such a case the newline itself has to be escaped
with a backslash (\). The newline is subsequently removed from the string.
For instance, the following two selectors are exactly the same:

Example(s):

a[title="a not s\
o very long title"] {/*...*/}
a[title="a not so very long title"] {/*...*/}

Since a string cannot directly represent a newline, to include a newline
in a string, use the escape "\A". (Hexadecimal A is the line feed
character in Unicode (U+000A), but represents the generic notion of
"newline" in CSS.)

Note that in some CSS syntactic contexts (as defined by that
context), a URL can be represented as a <string> rather than by <URL>. An example of this is the ‘@import’ rule.

Parentheses, whitespace characters, single quotes (') and double quotes
(") appearing in a URL must be escaped with a backslash so that the
resulting value is a valid URL token, e.g.
‘url(open\(parens)’, ‘url(close\)parens)’. Depending on the type of URL, it
might also be possible to write these characters as URI-escapes (e.g.
‘url(open%28parens)’ or ‘url(close%29parens)’) as described in [URI]. Alternatively a URL containing
such characters may be represented as a quoted string within the ‘url()’
notation.

In order to create modular style sheets that are not dependent on the
absolute location of a resource, authors should use relative URIs.
Relative URIs (as defined in [URI]) are resolved to full URIs using
a base URI. RFC 3986, section 3, defines the normative algorithm for
this process. For CSS style sheets, the base URI is that of the style
sheet, not that of the source document.

When a <url> appears in the computed
value of a property, it is resolved to an absolute URL, as described in
the preceding paragraph. The computed value of a URI that the UA cannot
resolve to an absolute URI is the specified value.

For example, suppose the following rule:

body { background: url("tile.png") }

is located in a style sheet designated by the URL:

http://www.example.org/style/basic.css

The background of the source document's <body> will be
tiled with whatever image is described by the resource designated by the
URL:

http://www.example.org/style/tile.png

The same image will be used regardless of the URL of the source
document containing the <body>.

4. Numeric Data Types

Properties may restrict numeric values to some range. If the value is
outside the allowed range, the declaration is invalid and must be ignored.

Integer values are denoted by <integer>. An integer is one or more decimal digits ‘0’ through ‘9’ and
corresponds to a subset of the NUMBER
token in the grammar.
The first digit of an integer may be immediately preceded by ‘-’ or ‘+’ to indicate the
integer's sign.

Number values are denoted by <number>. A number is either an <integer> or zero or more decimal
digits followed by a dot (.) followed by one or more decimal digits. It
corresponds to the NUMBER token in the
grammar.
As with integers, the first character of a number may be immediately
preceded by ‘-’ or ‘+’ to indicate the number's sign.

A percentage value is denoted by <percentage>, consists of a <number> immediately followed by a
percent sign ‘%’. It corresponds to the PERCENTAGE token in the grammar.

Percentage values are always relative to another value, for example a
length. Each property that allows percentages also defines the value to
which the percentage refers. The value may be that of another property for
the same element, a property for an ancestor element, or a value of the
formatting context (e.g., the width of a containing block). When a
percentage value is set for a property of the root element and the
percentage is defined as referring to the inherited value of some
property, the resultant value is the percentage times the initial
value of that property.

Lengths refer to distance measurements and are denoted by <length> in the property definitions.
A length is a dimension. However, for zero
lengths the unit identifier is optional (i.e. can be syntactically
represented as the <number>
‘0’).

A dimension is a number immediately followed by a unit
identifier. It corresponds to the DIMENSION token in the grammar.
[CSS21] Like
keywords, unit identifiers are case-insensitive within the ASCII range.

Properties may restrict the length value to some range. If the value is
outside the allowed range, the declaration is invalid and must be ignored.

While some properties allow negative length values, this may complicate
the formatting and there may be implementation-specific limits. If a
negative length value is allowed but cannot be supported, it must be
converted to the nearest value that can be supported.

In cases where the used length cannot be
supported, user agents must approximate it in the
actual value.

There are two types of length units: relative and absolute.

5.1. Relative lengths

Relative length
units specify a length relative to another length. Style sheets that
use relative units can more easily scale from one output environment to
another.

Aside from ‘rem’
(which refers to the font-size of the root element), the font-relative
lengths refer to the computed font metrics of the element on which they
are used. The exception is when they occur in the value of the ‘font-size’ property itself, in which case they
refer to the computed font metrics of the parent element (or the computed
font metrics corresponding to the initial values of the ‘font’ property, if the element has no parent).

em unit

Equal to the computed value of the ‘font-size’ property of the element on which it
is used.

The rule:

h1 { line-height: 1.2em }

means that the line height of h1 elements will be 20%
greater than the font size of h1 element. On the other
hand:

h1 { font-size: 1.2em }

means that the font size of h1 elements will be 20%
greater than the computed font size inherited by h1
elements.

ex unit

Equal to the font's x-height. The x-height is so called because it is
often equal to the height of the lowercase "x". However, an ‘ex’ is defined even for
fonts that do not contain an "x".

The x-height of a font can be found in different ways. Some fonts
contain reliable metrics for the x-height. If reliable font metrics are
not available, UAs may determine the x-height from the height of a
lowercase glyph. One possible heuristic is to look at how far the glyph
for the lowercase "o" extends below the baseline, and subtract that
value from the top of its bounding box. In the cases where it is
impossible or impractical to determine the x-height, a value of 0.5em
must be assumed.

ch unit

Equal to the advance measure of the "0" (ZERO, U+0030) glyph found in
the font used to render it.

rem unit

Equal to the computed value of ‘font-size’ on the root element.

When specified on the ‘font-size’
property of the root element, the ‘rem’ units refer to the property's initial
value.

The viewport-percentage lengths are relative to the size of the initial
containing block. When the height or width of the initial containing
block is changed, they are scaled accordingly. However, when the value of
‘overflow’ on the root element is ‘auto’, any scroll bars are assumed not to exist. Note that the initial containing block's size is affected by
the presence of scrollbars on the viewport.

For paged media, the exact definition of the viewport-percentage
lengths is deferred to [CSS3PAGE].

vw unit

Equal to 1% of the width of the initial containing block.

In the example below, if the width of the viewport is 200mm, the font
size of h1 elements will be 16mm (i.e. (8×200mm)/100).

5.2. Absolute lengths:
the ‘cm’, ‘mm’,
‘in’, ‘pt’, ‘pc’, ‘px’ units

The absolute length units are fixed
in relation to each other and anchored to some physical measurement. They
are mainly useful when the output environment is known. The absolute units
consist of the physical units (in, cm, mm, pt, pc) and the px unit:

For a CSS device, these dimensions are either anchored (i) by relating
the physical units to their physical measurements, or (ii) by relating the
pixel unit to the reference pixel.
For print media and similar high-resolution devices, the anchor unit
should be one of the standard physical units (inches, centimeters, etc).
For lower-resolution devices, and devices with unusual viewing distances,
it is recommended instead that the anchor unit be the pixel unit. For such
devices it is recommended that the pixel unit refer to the whole number of
device pixels that best approximates the reference pixel.

Note that if the anchor unit is the pixel unit, the physical
units might not match their physical measurements. Alternatively if the
anchor unit is a physical unit, the pixel unit might not map to a whole
number of device pixels.

Note that this definition of the pixel unit and the physical
units differs from previous versions of CSS. In particular, in previous
versions of CSS the pixel unit and the physical units were not related by
a fixed ratio: the physical units were always tied to their physical
measurements while the pixel unit would vary to most closely match the
reference pixel. (This change was made because too much existing content
relies on the assumption of 96dpi, and breaking that assumption breaks the
content.)

The reference pixel is the visual angle of
one pixel on a device with a pixel density of 96dpi and a distance from
the reader of an arm's length. For a nominal arm's length of 28 inches,
the visual angle is therefore about 0.0213 degrees. For reading at arm's
length, 1px thus corresponds to about 0.26 mm (1/96 inch).

The image below illustrates the effect of viewing distance on the size
of a reference pixel: a reading distance of 71 cm (28 inches) results in
a reference pixel of 0.26 mm, while a reading distance of 3.5 m
(12 feet) results in a reference pixel of 1.3 mm.

Showing that pixels must become larger if the viewing
distance increases

This second image illustrates the effect of a device's resolution on the
pixel unit: an area of 1px by 1px is covered by a single dot in a
low-resolution device (e.g. a typical computer display), while the same
area is covered by 16 dots in a higher resolution device (such as a
printer).

Showing that more device pixels (dots) are needed to
cover a 1px by 1px area on a high-resolution device than on a low-res one

The <resolution> unit
represents the size of a single "dot" in a graphical representation by
indicating how many of these dots fit in a CSS ‘in’, ‘cm’, or
‘px’. For uses, see e.g. the ‘resolution’ media query in [MEDIAQ] or the ‘image-resolution’ property defined in [CSS3-IMAGES].

Note that due to the 1:96 fixed ratio of CSS ‘in’ to CSS ‘px’, ‘1dppx’ is equivalent to ‘96dpi’. This corresponds to the default resolution of
images displayed in CSS: see ‘image-resolution’.

The following @media rule uses Media Queries [MEDIAQ] to assign some special
style rules to devices that use two or more device pixels per CSS
‘px’ unit:

@media (min-resolution: 2dppx) { ... }

7. Data Types Defined
Elsewhere

Some data types are defined in their own modules. The two common ones
are <color> and <image>.

The <position> data type is
defined herein as equivalent to the <‘background-position’> syntax defined in
[CSS21]. It
specifies the position of a object area (e.g. background image) inside a
positioning area (e.g. background positioning area). It is extended
in [CSS3BG]: UAs
that support CSS Backgrounds & Borders Level 3 or its successor must
interpret <position> as
defined therein.

8. Functional
Notations

A functional notation is a type of
component value that can represent more complex types or invoke special
processing. The syntax starts with the name of the function immediately
followed by a left parenthesis (i.e. a FUNCTION token)
followed by the argument(s) to the notation followed by a right
parenthesis. White space is allowed, but optional, immediately inside the
parentheses. If a function takes a list of arguments, the arguments are
separated by a comma (‘,’) with optional
whitespace before and after the comma.

The calc() function allows mathematical expressions
with addition (‘+’), subtraction (‘-’), multiplication (‘*’),
and division (‘/’) to be used as component
values. The ‘calc()’
expression represents the result of the mathematical calculation it
contains, using standard operator precedence rules. It can be used
wherever <length>, <frequency>, <angle>, <time>, <number>, or <integer> values are allowed.
Components of a ‘calc()’
expression can be literal values, ‘attr()’ or ‘calc()’ expressions, or <percentage> values that
resolve to one of the preceding types.

UAs must support ‘calc()’ expressions of at least 20 terms, where
each NUMBER, DIMENSION, or PERCENTAGE is a term. If a ‘calc()’ expression contains more
than the supported number of terms, it must be treated as if it were
invalid.

8.1.2. Type Checking

A math expression has a resolved type,
which is one of <length>, <frequency>, <angle>, <time>, <number>, or <integer>. The resolved type must be valid for where the
expression is placed; otherwise, the expression is invalid. The resolved type of the expression is
determined by the types of the values it contains. NUMBER tokens are of type <number> or <integer>. A DIMENSION token's type is given by its
unit (‘cm’ is <length>, ‘deg’ is <angle>, etc.). An ‘attr()’ expression's type is
given by its <type-or-unit> argument. If percentages are
accepted in the context in which the expression is placed, a PERCENTAGE token has the type of the
value that percentages are relative to; otherwise, a math expression
containing percentages is invalid.

Operators form sub-expressions, which gain types based on their
arguments. To make expressions simpler, operators have restrictions on the
types they accept. At each operator, the types of the left and right
argument are checked for these restrictions. If compatible, the type
resolves as described below (the following ignores precedence rules on the
operators for simplicity):

At ‘,’, ‘+’, or
‘-’, check that both sides have the same type,
or that one side is a <number>
and the other is an <integer>.
If both sides are the same type, resolve to that type. If one side is a
<number> and the other is an <integer>, resolve to <number>.

At ‘*’, check that at least one side is <number>. If both sides are <integer>, resolve to <integer>. Otherwise, resolve to
the type of the other side.

At ‘/’, check that the right side is <number>. If the left side is <integer>, resolve to <number>. Otherwise, resolve to
the type of the left side.

If an operator does not pass the above checks, the expression is
invalid. Also, division by zero is invalid. This includes both dividing by
the literal number zero, as well as any numeric expression that evaluates
to zero (as purely-numeric expressions can be evaluated without any
additional information at parse time).

Note that algebraic simplifications do not affect the
validity of the ‘calc()’
expression or its resolved type. For example, ‘calc(5px
- 5px + 10s)’ or ‘calc(0 * 5px + 10s)’
are both invalid due to the attempt to add a length and a time.

8.1.3. Computed Value

The computed value of a ‘calc()’ expression is the expression with all
components computed, with all multiplication/division subexpressions
resolved, and with all addition/subtraction subexpressions resolved where
both sides are the same type.

Where percentages are not resolved at computed value, they are not
resolved in ‘calc()’
expressions, e.g. ‘calc(100% - 100% + 1em)’
resolves to ‘calc(0% + 1em)’, not to ‘calc(1em)’. If there are special rules for computing
percentages in a value (e.g. the
‘height’ property), they apply
whenever a ‘calc()’
expression contains percentages.

Thus, the computed value of a ‘calc()’ expression can be represented as either a
number or a tuple of a dimension and a percentage.

Given the complexities of width and height calculations on table cells
and table elements, math expressions involving percentages for widths and
heights on table columns, table column groups, table rows, table row
groups, and table cells in both auto and fixed layout tables MAY be
treated as if ‘auto’ had been specified.

8.1.4. Range Checking

The value resulting from an expression must be clamped to the range
allowed in the target context.

Note this requires all contexts accepting ‘calc()’ to define their
allowable values as a closed (not open) interval.

These two are equivalent to ‘width: 0px’
since widths smaller than 0px are not allowed.

where <value> is any CSS value that is valid where the
expression is placed, and that doesn't contain any top-level commas. If
any of the values inside are not valid, then the entire ‘toggle()’ expression is
invalid. The ‘toggle()’
expression may be used as the value of any property (but must be the only
component in that property's value).

Note that because toggled values are separated by commas,
they cannot themselves include top-level commas.

The ‘toggle()’
notation is not allowed to be nested; nor may it contain ‘attr()’ or ‘calc()’ notations. Declarations
containing such constructs are invalid.

The value represented by ‘toggle()’ is determined by comparing the inherited
value I (i.e. the computed
value on the parent, or, for the root, the initial value) to the
computed values Cn returned by the n-th
argument to ‘toggle()’.
For the earliest Cn such that
Cn = I, the value returned by toggle is
Cn+1. However, if this Cn is
the last value, or if there are no Cn that equal
I, the computed value of the first value is returned instead.

The following example cycles markers for nested lists, so that a top
level list has disc-shaped markers, but nested lists use
circle, then square, then box, and
then repeat through the list of marker shapes, starting again (for the
5th list deep) with disc.

Note that ‘toggle()’ explicitly looks at the computed value of
the parent, so it works even on non-inherited properties. This is similar
to the ‘inherit’ keyword, which is works even on
non-inherited properties.

Note that the computed
value of a property is an abstract set of values, not a particular
serialization [CSS21], so comparison between
computed values should always be unambiguous and have the expected result.
For example, a Level 2 ‘background-position’ computed value is just
two offsets, each represented as an absolute length or a percentage, so
the declarations ‘background-position: top
center’ and ‘background-position: 50%
0%’ produce identical computed values. If the "Computed Value"
line of a property definition seems to define something ambiguous or
overly strict, please provide feedback so we can fix
it.

The attr() function is allowed as a component value
in properties applied to an element or pseudo-element. It returns the
value of an attribute on the element. If used on a pseudo-element, it
returns the value of the attribute on the pseudo-element's originating
element.

The computed value of the ‘attr()’ expression is the value of the attribute
with the specified name on the element, according to the rules given
below.

In CSS2.1 [CSS21], the ‘attr()’ expression always returns a string. In
CSS3, the ‘attr()’
expression can return many different types. The ‘attr()’ expression cannot return everything, for
example it cannot do counters, named strings, quotes, or keyword values
such as ‘auto’, ‘nowrap’, or ‘baseline’. This
is intentional, as the intent of the ‘attr()’ expression is not to make it possible to
describe a presentational language's formatting using CSS, but to enable
CSS to take semantic data into account.

where <attr-name> is a CSS qualified
name (the qname production in [CSS3NAMESPACE]) that
represents an attribute name. (In the absence of namespacing, this will
just be a CSS identifier.)

The optional <type-or-unit> argument is a keyword drawn
from the list below that tells the UA how to interpret the attribute
value, and defines a type for the attr() expression. If omitted, ‘string’ is implied.

The optional <fallback> argument represents a fallback
value, which is used if the named attribute is missing, or its value
cannot be parsed into the given type or is invalid/out-of-range for the
property. If it's absent, the default value for the given
<type-or-unit> (from the list below) is implied.

Note that, unlike ‘toggle()’ <value>s, an ‘attr()’ <fallback>
value may contain top-level commas, as it is always the last argument in
the functional notation.

The attr() expression is only valid if:

the attr() expression's type is valid where the attr() expression is
placed,

if the attribute name is given with a namespace prefix, the prefix is
defined

the <fallback> is valid where the attr() expression is
placed,

the <fallback> does not contain another attr()
expression,

and, if the attr() expression is not the sole component value of a
property, the <fallback> matches the attr()'s type

Note that the default value need not be of the type given, if the
attr() expression is the entire property value. For instance, if the type
required of the attribute by the author is ‘px’, the default could still be ‘auto’, like in ‘width: attr(size px,
auto);’.

If the attr() is used alongside other values to form the full property
value, however, the default value must match the attr()'s type. For
example, ‘box-shadow: attr(size px, inset) 5px 10px
blue;’ is invalid, even though it would create a valid
declaration if you substituted the attr() expression with either a
‘px’ length or the ‘inset’ keyword.

If the specified attribute exists on the element, the value of the
attribute must be parsed as required by the <type-or-unit>
argument (as defined in the list below). Unless the type is ‘string’, it must first be stripped of leading and
trailing white space. The resulting value is the attr() expression's
value. If the value did not parse as required, the attr() expression's
value is its fallback value.

The <type-or-unit> keywords are:

‘string’

The attribute value will be parsed as the contents of a CSS <string>. The default is the empty
string.

‘color’

The attribute value must parse as a HASH or IDENT CSS token, and be
successfully interpreted as a <color>. The default is ‘currentColor’.

The attribute value will be parsed as the contents of a CSS <string>. It is interpreted as a
quoted string within the ‘url()’ notation. The
default is ‘about:invalid’, which is a URI
defined (in Appendix A) to point to a
non-existent document with a generic error condition. Relative URLs must
be made absolute according to the rules of the document language as
applied to URLs originating from the element; they are not relative to
the style sheet.

The attribute value must parse as a NUMBER CSS token, and be
successfully interpreted as an <integer>. The default is
‘0’, or else the property's minimum value if
‘0’ is not valid for the property. The default
must also be used if the property in question only accepts integers
within a certain range and the attribute is out of range.

The attribute value must parse as a NUMBER CSS token, and is
interpreted as an <number>. The
default is ‘0’, or else the property's minimum
value if ‘0’ is not valid for the property.
The default must also be used if the property in question only accepts
integers within a certain range and the attribute is out of range.

‘length’

‘angle’

‘time’

‘frequency’

The attribute value must parse as a DIMENSION CSS token, and be
successfully interpreted as the specified type. The default is ‘0’ in the relevant units, or else the property's
minimum value if ‘0’ in the relevant units is
not valid for the property. The default must also be used if the property
in question only accepts values within a certain range (e.g. positive
lengths or angles from 0 to 90deg) and the attribute is out of range
(e.g. a negative length or 180deg). If the unit is a relative length, it
must be computed to an absolute length.

The attribute value must parse as a NUMBER CSS token, and is
interpreted as a dimension with the
specified unit. The default is ‘0’ in the
relevant units, or else the property's minimum value if ‘0’ in the relevant units is not valid for the
property. The default must also be used if the property in question only
accepts values within a certain range (e.g. positive lengths or angles
from 0 to 90deg) and the attribute is out of range (e.g. a negative
length or 180deg). If the unit is a relative length, it must be computed
to an absolute length.

This example shows the use of attr() to visually illustrate data in an
XML file:

Conformance

Document conventions

Conformance requirements are expressed with a combination of descriptive
assertions and RFC 2119 terminology. The key words “MUST”, “MUST
NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”,
“SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in the
normative parts of this document are to be interpreted as described in RFC
2119. However, for readability, these words do not appear in all uppercase
letters in this specification.

All of the text of this specification is normative except sections
explicitly marked as non-normative, examples, and notes. [RFC2119]

Examples in this specification are introduced with the words “for
example” or are set apart from the normative text with
class="example", like this:

This is an example of an informative example.

Informative notes begin with the word “Note” and are set apart from
the normative text with class="note", like this:

Note, this is an informative note.

Conformance classes

Conformance to CSS Values and Units Level 3 is defined for three
conformance classes:

A style sheet is conformant to CSS Values and Units Level 3 if all of
its statements that use syntax defined in this module are valid according
to the generic CSS grammar and the individual grammars of each feature
defined in this module.

A renderer is conformant to CSS Values and Units Level 3 if, in addition
to interpreting the style sheet as defined by the appropriate
specifications, it supports all the features defined CSS Values and Units
Level 3 by parsing them correctly and rendering the document accordingly.
However, the inability of a UA to correctly render a document due to
limitations of the device does not make the UA non-conformant. (For
example, a UA is not required to render color on a monochrome monitor.)

An authoring tool is conformant to CSS Values and Units Level 3 if it
writes style sheets that are syntactically correct according to the
generic CSS grammar and the individual grammars of each feature in this
module, and meet all other conformance requirements of style sheets as
described in this module.

Partial implementations

So that authors can exploit the forward-compatible parsing rules to
assign fallback values, CSS renderers must treat as
invalid (and ignore as
appropriate) any at-rules, properties, property values, keywords, and
other syntactic constructs for which they have no usable level of support.
In particular, user agents must not selectively ignore
unsupported component values and honor supported values in a single
multi-value property declaration: if any value is considered invalid (as
unsupported values must be), CSS requires that the entire declaration be
ignored.

Experimental implementations

To avoid clashes with future CSS features, the CSS2.1 specification
reserves a prefixed
syntax for proprietary and experimental extensions to CSS.

Prior to a specification reaching the Candidate Recommendation stage in
the W3C process, all implementations of a CSS feature are considered
experimental. The CSS Working Group recommends that implementations use a
vendor-prefixed syntax for such features, including those in W3C Working
Drafts. This avoids incompatibilities with future changes in the draft.

Non-experimental implementations

Once a specification reaches the Candidate Recommendation stage,
non-experimental implementations are possible, and implementors should
release an unprefixed implementation of any CR-level feature they can
demonstrate to be correctly implemented according to spec.

To establish and maintain the interoperability of CSS across
implementations, the CSS Working Group requests that non-experimental CSS
renderers submit an implementation report (and, if necessary, the
testcases used for that implementation report) to the W3C before releasing
an unprefixed implementation of any CSS features. Testcases submitted to
W3C are subject to review and correction by the CSS Working Group.

CR exit criteria

For this specification to be advanced to Proposed Recommendation, there
must be at least two independent, interoperable implementations of each
feature. Each feature may be implemented by a different set of products,
there is no requirement that all features be implemented by a single
product. For the purposes of this criterion, we define the following
terms:

independent

each implementation must be developed by a different party and cannot
share, reuse, or derive from code used by another qualifying
implementation. Sections of code that have no bearing on the
implementation of this specification are exempt from this requirement.

interoperable

passing the respective test case(s) in the official CSS test suite,
or, if the implementation is not a Web browser, an equivalent test. Every
relevant test in the test suite should have an equivalent test created if
such a user agent (UA) is to be used to claim interoperability. In
addition if such a UA is to be used to claim interoperability, then there
must one or more additional UAs which can also pass those equivalent
tests in the same way for the purpose of interoperability. The equivalent
tests must be made publicly available for the purposes of peer review.

implementation

a user agent which:

implements the specification.

is available to the general public. The implementation may be a
shipping product or other publicly available version (i.e., beta
version, preview release, or “nightly build”). Non-shipping product
releases must have implemented the feature(s) for a period of at least
one month in order to demonstrate stability.

is not experimental (i.e., a version specifically designed to pass
the test suite and is not intended for normal usage going forward).

The specification will remain Candidate Recommendation for at least six
months.