1. -Introduction
- -This section is not normative.
- -This module defines the abstract syntax and parsing of CSS stylesheets +
++ This document is governed by the 1 August 2014 W3C Process Document. +
diff --git a/css-syntax/Overview.bs b/css-syntax/Overview.bs
index 165704d65a1..832235c8502 100644
--- a/css-syntax/Overview.bs
+++ b/css-syntax/Overview.bs
@@ -1099,7 +1099,7 @@ Consume a token
Otherwise,
if the next input code point is
- U+0073 VERTICAL LINE (|),
+ U+007C VERTICAL LINE (|),
consume it
and return a <
- Copyright © 2014 W3C® (MIT, ERCIM, Keio, Beihang), All Rights Reserved. W3C liability, trademark and document use rules apply.
+
+ Copyright © 2014 W3C® (MIT, ERCIM, Keio, Beihang), All Rights Reserved. W3C liability, trademark and document use rules apply.
This module describes, in general terms, the basic structure and syntax of CSS stylesheets. It defines, in detail, the syntax and parsing of CSS - how to turn a stream of bytes into a meaningful stylesheet. This module describes, in general terms, the basic structure and syntax of CSS stylesheets. It defines, in detail, the syntax and parsing of CSS - how to turn a stream of bytes into a meaningful stylesheet.
+
+
This is a public copy of the editors’ draft.
It is provided for discussion only and may change at any moment.
Its publication here does not imply endorsement of its contents by W3C.
Don’t cite this document other than as work in progress.
-
- The (archived) public mailing list
+
+ The (archived) public mailing list
www-style@w3.org
- (see instructions)
+ (see instructions)
is preferred for discussion of this specification.
When sending e-mail,
please put the text “css-syntax” in the subject,
preferably like this:
“[css-syntax] …summary of comment…”
-
- This document was produced by the CSS Working Group
- (part of the Style Activity).
+
+ This document was produced by the CSS Working Group
+ (part of the Style Activity).
-
+
This document was produced by a group operating under
- the 5 February 2004 W3C Patent Policy.
- W3C maintains a public list of any patent disclosures
+ the 5 February 2004 W3C Patent Policy.
+ W3C maintains a public list of any patent disclosures
made in connection with the deliverables of the group;
that page also includes instructions for disclosing a patent.
- An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s)
- must disclose the information in accordance with section 6 of the W3C Patent Policy.
+ An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s)
+ must disclose the information in accordance with section 6 of the W3C Patent Policy.
-
- This document is governed by the 1 August 2014 W3C Process Document.
- This section is not normative. This module defines the abstract syntax and parsing of CSS stylesheets
+
+ This document is governed by the 1 August 2014 W3C Process Document.
+ This section is not normative. This module defines the abstract syntax and parsing of CSS stylesheets
and other things which use CSS syntax
(such as the HTML It defines algorithms for converting a stream of Unicode code points
+
+ It defines algorithms for converting a stream of Unicode code points
(in other words, text)
into a stream of CSS tokens,
and then further into CSS objects
such as stylesheets, rules, and declarations. This module defines the syntax and parsing of CSS stylesheets.
+ This module defines the syntax and parsing of CSS stylesheets.
It supersedes the lexical scanner and grammar defined in CSS 2.1. This section is not normative. A CSS document is a series of qualified rules,
+ This section is not normative. A CSS document is a series of qualified rules,
which are usually style rules that apply CSS properties to elements,
- and at-rules,
+ and at-rules,
which define special processing rules or values for the CSS document. A qualified rule starts with a prelude
+
+ A qualified rule starts with a prelude
then has a {}-wrapped block containing a sequence of declarations.
The meaning of the prelude varies based on the context that the rule appears in -
for style rules, it’s a selector which specifies what elements the declarations will apply to.
@@ -227,116 +459,158 @@ A typical rule might look something like this: A typical rule might look something like this: In the above rule, " In the above rule, " " " At-rules are all different, but they have a basic structure in common.
- They start with an "@" code point followed by their name.
- Some at-rules are simple statements,
+
+ At-rules are all different, but they have a basic structure in common.
+ They start with an "@" code point followed by their name.
+ Some at-rules are simple statements,
with their name followed by more CSS values to specify their behavior,
and finally ended by a semicolon.
Others are blocks;
they can have CSS values following their name,
but they end with a {}-wrapped block,
- similar to a qualified rule.
- Even the contents of these blocks are specific to the given at-rule:
- sometimes they contain a sequence of declarations, like a qualified rule;
+ similar to a qualified rule.
+ Even the contents of these blocks are specific to the given at-rule:
+ sometimes they contain a sequence of declarations, like a qualified rule;
other times, they may contain additional blocks, or at-rules, or other structures altogether. Here are several examples of at-rules that illustrate the varied syntax they may contain. Here are several examples of at-rules that illustrate the varied syntax they may contain. The @import at-rule is a simple statement.
- After its name, it takes a single string or url() function to indicate the stylesheet that it should import. The @import at-rule is a simple statement.
+ After its name, it takes a single string or url() function to indicate the stylesheet that it should import. The @page at-rule consists of an optional page selector (the :left pseudoclass),
+
+ The @page at-rule consists of an optional page selector (the :left pseudoclass),
followed by a block of properties that apply to the page when printed.
In this way, it’s very similar to a normal style rule,
except that its properties don’t apply to any "element",
but rather the page itself. The @media at-rule begins with a media type
+ The @media at-rule begins with a media type
and a list of optional media queries.
Its block contains entire rules,
- which are only applied when the @medias conditions are fulfilled. Property names and at-rule names are always identifiers,
+
+ Property names and at-rule names are always identifiers,
which have to start with a letter or a hyphen followed by a letter,
and then can contain letters, numbers, hyphens, or underscores.
- You can include any code point at all,
+ You can include any code point at all,
even ones that CSS uses in its syntax,
- by escaping it. The syntax of selectors is defined in the Selectors spec.
+ Similarly, the syntax of the wide variety of CSS values is defined in the Values & Units spec.
+ The special syntaxes of individual at-rules can be found in the specs that define them. The syntax of selectors is defined in the Selectors spec.
- Similarly, the syntax of the wide variety of CSS values is defined in the Values & Units spec.
- The special syntaxes of individual at-rules can be found in the specs that define them. This section is not normative. This section is not normative. Any Unicode code point can be included in an identifier or quoted string
- by escaping it.
+
+ Any Unicode code point can be included in an identifier or quoted string
+ by escaping it.
CSS escape sequences start with a backslash (\), and continue with:
- An identifier with the value "&B"
- could be written as \26 B or \000026B.
+
+
+ An identifier with the value "&B"
+ could be written as \26 B or \000026B.
-
+
A "real" space after the escape sequence must be doubled.
- This section is not normative. When errors occur in CSS,
+ This section is not normative. When errors occur in CSS,
the parser attempts to recover gracefully,
throwing away only the minimum amount of content
before returning to parsing as normal.
@@ -345,68 +619,80 @@ The precise error-recovery behavior is detailed in the parser itself,
+
+ The precise error-recovery behavior is detailed in the parser itself,
but it’s simple enough that a short description is fairly accurate: User agents must use the parsing rules described in this specification
+
+ User agents must use the parsing rules described in this specification
to generate the CSSOM trees from text/css resources.
Together, these rules define what is referred to as the CSS parser. This specification defines the parsing rules for CSS documents,
+
+ This specification defines the parsing rules for CSS documents,
whether they are syntactically correct or not.
- Certain points in the parsing algorithm are said to be a parse errors.
+ Certain points in the parsing algorithm are said to be a parse errors.
The error handling for parse errors is well-defined:
user agents must either act as described below when encountering such problems,
or must abort processing at the first error that they encounter for which they do not wish to apply the rules described below. Conformance checkers must report at least one parse error condition to the user
+
+ Conformance checkers must report at least one parse error condition to the user
if one or more parse error conditions exist in the document
and must not report parse error conditions
if none exist in the document.
@@ -415,3021 +701,5226 @@ The input to the CSS parsing process consists of a stream of Unicode code points,
+ The input to the CSS parsing process consists of a stream of Unicode code points,
which is passed through a tokenization stage followed by a tree construction stage.
The output is a CSSStyleSheet object. Note: Implementations that do not support scripting do not have to actually create a CSSOM CSSStyleSheet object,
+
+ Note: Implementations that do not support scripting do not have to actually create a CSSOM CSSStyleSheet object,
but the CSSOM tree in such cases is still used as the model for the rest of the specification. When parsing a stylesheet,
- the stream of Unicode code points that comprises the input to the tokenization stage
+ When parsing a stylesheet,
+ the stream of Unicode code points that comprises the input to the tokenization stage
might be initially seen by the user agent as a stream of bytes
(typically coming over the network or from the local file system).
- If so, the user agent must decode these bytes into code points according to a particular character encoding. To decode the stream of bytes into a stream of code points,
- UAs must use the decode algorithm
- defined in [ENCODING],
+ To decode the stream of bytes into a stream of code points,
+ UAs must use the decode algorithm
+ defined in [ENCODING],
with the fallback encoding determined as follows. Note: The decode algorithm
+
+ Note: The decode algorithm
gives precedence to a byte order mark (BOM),
and only uses the fallback when none is found. To determine the fallback encoding: To determine the fallback encoding: where each where each The byte sequence above,
+
+ The byte sequence above,
when decoded as ASCII,
is the string " If the return value was If the return value was The bytes of the encoding declaration spell out “ The bytes of the encoding declaration spell out “ Either way, defaulting to UTF-8 is a decent answer. As well, this mimics the behavior of HTML’s Either way, defaulting to UTF-8 is a decent answer. Note: Note that the syntax of an encoding declaration looks like the syntax of an @charset rule,
+
+ As well, this mimics the behavior of HTML’s Note: Note that the syntax of an encoding declaration looks like the syntax of an @charset rule,
but it’s actually much more restrictive.
- A number of things you can do in CSS that would produce a valid @charset rule,
+ A number of things you can do in CSS that would produce a valid @charset rule,
such as using multiple spaces, comments, or single quotes,
will cause the encoding declaration to not be recognized.
This behavior keeps the encoding declaration as simple as possible,
and thus maximizes the likelihood of it being implemented correctly. Though UTF-8 is the default encoding for the web,
+ Though UTF-8 is the default encoding for the web,
and many newer web-based file formats assume or require UTF-8 encoding,
CSS was created before it was clear which encoding would win,
and thus can’t automatically assume the stylesheet is UTF-8. Stylesheet authors should author their stylesheets in UTF-8,
+
+ Stylesheet authors should author their stylesheets in UTF-8,
and ensure that either an HTTP header (or equivalent method) declares the encoding of the stylesheet to be UTF-8,
or that the referring document declares its encoding to be UTF-8.
- (In HTML, this is done by adding a If neither of these options are available,
+ If neither of these options are available,
authors should begin the stylesheet with a UTF-8 BOM
or the exact characters Document languages that refer to CSS stylesheets that are decoded from bytes
- may define an environment encoding for each such stylesheet,
+ Document languages that refer to CSS stylesheets that are decoded from bytes
+ may define an environment encoding for each such stylesheet,
which is used as a fallback when other encoding hints are not available or can not be used. The concept of environment encoding only exists for compatibility with legacy content.
- New formats and new linking mechanisms should not provide an environment encoding,
+
+ The concept of environment encoding only exists for compatibility with legacy content.
+ New formats and new linking mechanisms should not provide an environment encoding,
so the stylesheet defaults to UTF-8 instead in the absence of more explicit information. Note: [HTML] defines the environment encoding for Note: [CSSOM] defines the environment encoding for Note: [HTML] defines the environment encoding for Note: [CSS3CASCADE] defines the environment encoding for Note: [CSSOM] defines the environment encoding for Note: [CSS3CASCADE] defines the environment encoding for The input stream consists of the code points
+
+
+ The input stream consists of the code points
pushed into it as the input byte stream is decoded. Before sending the input stream to the tokenizer,
- implementations must make the following code point substitutions: Before sending the input stream to the tokenizer,
+ implementations must make the following code point substitutions: Implementations must act as if they used the following algorithms to tokenize CSS.
- To transform a stream of code points into a stream of tokens,
- repeatedly consume a token
- until an <EOF-token> is reached,
+ Implementations must act as if they used the following algorithms to tokenize CSS.
+ To transform a stream of code points into a stream of tokens,
+ repeatedly consume a token
+ until an <EOF-token> is reached,
collecting the returned tokens into a stream.
- Each call to the consume a token algorithm
+ Each call to the consume a token algorithm
returns a single token,
- so it can also be used "on-demand" to tokenize a stream of code points during parsing,
+ so it can also be used "on-demand" to tokenize a stream of code points during parsing,
if so desired. The output of the tokenization step is a stream of zero or more of the following tokens:
- <ident-token>,
- <function-token>,
- <at-keyword-token>,
- <hash-token>,
- <string-token>,
- <bad-string-token>,
- <url-token>,
- <bad-url-token>,
- <delim-token>,
- <number-token>,
- <percentage-token>,
- <dimension-token>,
- <include-match-token>,
- <dash-match-token>,
- <prefix-match-token>,
- <suffix-match-token>,
- <substring-match-token>,
- <column-token>,
- <whitespace-token>,
- <CDO-token>,
- <CDC-token>,
- <colon-token>,
- <semicolon-token>,
- <comma-token>,
- <[-token>,
- <]-token>,
- <(-token>,
- <)-token>,
- <{-token>,
- and <}-token>. The output of the tokenization step is a stream of zero or more of the following tokens:
+ <ident-token>,
+ <function-token>,
+ <at-keyword-token>,
+ <hash-token>,
+ <string-token>,
+ <bad-string-token>,
+ <url-token>,
+ <bad-url-token>,
+ <delim-token>,
+ <number-token>,
+ <percentage-token>,
+ <dimension-token>,
+ <include-match-token>,
+ <dash-match-token>,
+ <prefix-match-token>,
+ <suffix-match-token>,
+ <substring-match-token>,
+ <column-token>,
+ <whitespace-token>,
+ <CDO-token>,
+ <CDC-token>,
+ <colon-token>,
+ <semicolon-token>,
+ <comma-token>,
+ <[-token>,
+ <]-token>,
+ <(-token>,
+ <)-token>,
+ <{-token>,
+ and <}-token>. Note: The type flag of hash tokens is used in the Selectors syntax [SELECT].
- Only hash tokens with the "id" type are valid ID selectors. Note: The type flag of hash tokens is used in the Selectors syntax [SELECT].
+ Only hash tokens with the "id" type are valid ID selectors. Note: As a technical note,
- the tokenizer defined here requires only three code points of look-ahead.
+
+ Note: As a technical note,
+ the tokenizer defined here requires only three code points of look-ahead.
The tokens it produces are designed to allow Selectors to be parsed with one token of look-ahead,
and additional tokens may be added in the future to maintain this invariant. This section is non-normative. This section presents an informative view of the tokenizer,
+ This section is non-normative. This section presents an informative view of the tokenizer,
in the form of railroad diagrams.
Railroad diagrams are more compact than an explicit parser,
but often easier to read than an regular expression. These diagrams are informative and incomplete;
+
+ These diagrams are informative and incomplete;
they describe the grammar of "correct" tokens,
but do not describe error-handling at all.
They are provided solely to make it easier to get an intuitive grasp of the syntax of each token. Diagrams with names such as <foo-token> represent tokens.
+
+ Diagrams with names such as <foo-token> represent tokens.
The rest are productions referred to by other diagrams. This section defines several terms used during the tokenization phase. This section defines several terms used during the tokenization phase. The algorithms defined in this section transform a stream of code points into a stream of tokens. This section describes how to consume a token from a stream of code points.
- It will return a single token of any type. The algorithms defined in this section transform a stream of code points into a stream of tokens. Consume the next input code point. This section describes how to consume a token from a stream of code points.
+ It will return a single token of any type. Consume the next input code point. Otherwise,
- return a <delim-token>
- with its value set to the current input code point. Otherwise,
+ return a <delim-token>
+ with its value set to the current input code point. Otherwise,
- emit a <delim-token>
- with its value set to the current input code point. Otherwise,
+ emit a <delim-token>
+ with its value set to the current input code point. Otherwise,
- return a <delim-token>
- with its value set to the current input code point. Otherwise,
+ return a <delim-token>
+ with its value set to the current input code point. Otherwise,
- return a <delim-token>
- with its value set to the current input code point. Otherwise,
+ return a <delim-token>
+ with its value set to the current input code point. Otherwise,
- if the next 2 input code points are
+
+ Otherwise,
+ if the next 2 input code points are
U+002D HYPHEN-MINUS
U+003E GREATER-THAN SIGN
- (->),
+ (->),
consume them
- and return a <CDC-token>. Otherwise,
- if the input stream starts with an identifier,
- reconsume the current input code point,
- consume an ident-like token,
- and return it. Otherwise,
- return a <delim-token>
- with its value set to the current input code point. Otherwise,
+ if the input stream starts with an identifier,
+ reconsume the current input code point,
+ consume an ident-like token,
+ and return it. Otherwise,
+ return a <delim-token>
+ with its value set to the current input code point. Otherwise,
- return a <delim-token>
- with its value set to the current input code point. Otherwise,
+ return a <delim-token>
+ with its value set to the current input code point. Otherwise,
- return a <delim-token>
- with its value set to the current input code point. Otherwise,
+ return a <delim-token>
+ with its value set to the current input code point. Otherwise,
- return a <delim-token>
- with its value set to the current input code point. Otherwise,
+ return a <delim-token>
+ with its value set to the current input code point. Otherwise,
- this is a parse error.
- Return a <delim-token>
- with its value set to the current input code point. Otherwise,
+ this is a parse error.
+ Return a <delim-token>
+ with its value set to the current input code point. Otherwise,
- return a <delim-token>
- with its value set to the current input code point. Otherwise,
+ return a <delim-token>
+ with its value set to the current input code point. Otherwise,
- if the next input code point is
- U+0073 VERTICAL LINE (|),
+
+ Otherwise,
+ if the next input code point is
+ U+007C VERTICAL LINE (|),
consume it
- and return a <column-token>. Otherwise,
- return a <delim-token>
- with its value set to the current input code point. Otherwise,
+ return a <delim-token>
+ with its value set to the current input code point. Otherwise,
+ return a <delim-token>
+ with its value set to the current input code point. Otherwise,
- return a <delim-token>
- with its value set to the current input code point. This section describes how to consume comments from a stream of code points.
+ This section describes how to consume comments from a stream of code points.
It returns nothing. If the next two input code point are
+
+ If the next two input code point are
U+002F SOLIDUS (/) followed by a U+002A ASTERISK (*),
consume them
- and all following code points up to and including
+ and all following code points up to and including
the first U+002A ASTERISK (*) followed by a U+002F SOLIDUS (/),
or up to an EOF code point.
Return to the start of this step. If the preceding paragraph ended by consuming an EOF code point,
- this is a parse error. Return nothing. If the preceding paragraph ended by consuming an EOF code point,
+ this is a parse error. Return nothing. This section describes how to consume a numeric token from a stream of code points.
+ It returns either a <number-token>, <percentage-token>, or <dimension-token>. This section describes how to consume a numeric token from a stream of code points.
- It returns either a <number-token>, <percentage-token>, or <dimension-token>. If the next 3 input code points would start an identifier,
+ If the next 3 input code points would start an identifier,
then: Otherwise,
- if the next input code point is U+0025 PERCENTAGE SIGN (%),
+
+ Otherwise,
+ if the next input code point is U+0025 PERCENTAGE SIGN (%),
consume it.
- Create a <percentage-token> with the same representation and value as the returned number,
+ Create a <percentage-token> with the same representation and value as the returned number,
and return it. Otherwise,
- create a <number-token> with the same representation, value, and type flag as the returned number,
+
+ Otherwise,
+ create a <number-token> with the same representation, value, and type flag as the returned number,
and return it. This section describes how to consume an ident-like token from a stream of code points.
- It returns an <ident-token>, <function-token>, <url-token>, or <bad-url-token>. This section describes how to consume an ident-like token from a stream of code points.
+ It returns an <ident-token>, <function-token>, <url-token>, or <bad-url-token>. If the returned string’s value is an ASCII case-insensitive match for "url",
- and the next input code point is U+0028 LEFT PARENTHESIS ((),
+ If the returned string’s value is an ASCII case-insensitive match for "url",
+ and the next input code point is U+0028 LEFT PARENTHESIS ((),
consume it.
- While the next two input code points are whitespace,
- consume the next input code point.
- If the next one or two input code points are U+0022 QUOTATION MARK ("),
+ While the next two input code points are whitespace,
+ consume the next input code point.
+ If the next one or two input code points are U+0022 QUOTATION MARK ("),
U+0027 APOSTROPHE ('),
- or whitespace followed by U+0022 QUOTATION MARK (") orU+0027 APOSTROPHE ('),
- then create a <function-token>
+ or whitespace followed by U+0022 QUOTATION MARK (") orU+0027 APOSTROPHE ('),
+ then create a <function-token>
with its value set to the returned string
and return it.
Otherwise,
- consume a url token,
+ consume a url token,
and return it. Otherwise,
- if the next input code point is U+0028 LEFT PARENTHESIS ((),
+
+ Otherwise,
+ if the next input code point is U+0028 LEFT PARENTHESIS ((),
consume it.
- Create a <function-token>
+ Create a <function-token>
with its value set to the returned string
and return it. Otherwise,
- create an <ident-token>
+
+ Otherwise,
+ create an <ident-token>
with its value set to the returned string
and return it. This section describes how to consume a string token from a stream of code points.
- It returns either a <string-token> or <bad-string-token>. This section describes how to consume a string token from a stream of code points.
+ It returns either a <string-token> or <bad-string-token>. This algorithm may be called with an ending code point,
- which denotes the code point that ends the string.
+ This algorithm may be called with an ending code point,
+ which denotes the code point that ends the string.
If an ending code point is not specified,
- the current input code point is used. Initially create a <string-token> with its value set to the empty string. Repeatedly consume the next input code point from the stream: Initially create a <string-token> with its value set to the empty string. Repeatedly consume the next input code point from the stream: Otherwise,
- if the next input code point is a newline,
+
+ Otherwise,
+ if the next input code point is a newline,
consume it. Otherwise,
- (the stream starts with a valid escape)
- consume an escaped code point
- and append the returned code point to the <string-token>’s value. Otherwise,
+ (the stream starts with a valid escape)
+ consume an escaped code point
+ and append the returned code point to the <string-token>’s value. This section describes how to consume a url token from a stream of code points.
- It returns either a <url-token> or a <bad-url-token>. Note: This algorithm assumes that the initial "url(" has already been consumed. This section describes how to consume a url token from a stream of code points.
+ It returns either a <url-token> or a <bad-url-token>. Note: This algorithm assumes that the initial "url(" has already been consumed. Otherwise,
- this is a parse error.
- Consume the remnants of a bad url,
- create a <bad-url-token>,
+
+ Otherwise,
+ this is a parse error.
+ Consume the remnants of a bad url,
+ create a <bad-url-token>,
and return it. This section describes how to consume an escaped code point.
+ This section describes how to consume an escaped code point.
It assumes that the U+005C REVERSE SOLIDUS (\) has already been consumed
and that the next input code point has already been verified
- to not be a newline.
- It will return a code points. Consume the next input code point. Consume the next input code point. This section describes how to check if two code points are a valid escape.
- The algorithm described here can be called explicitly with two code points,
+ This section describes how to check if two code points are a valid escape.
+ The algorithm described here can be called explicitly with two code points,
or can be called with the input stream itself.
- In the latter case, the two code points in question are
- the current input code point
- and the next input code point,
+ In the latter case, the two code points in question are
+ the current input code point
+ and the next input code point,
in that order. Note: This algorithm will not consume any additional code point. If the first code point is not U+005C REVERSE SOLIDUS (\),
+ Note: This algorithm will not consume any additional code point. If the first code point is not U+005C REVERSE SOLIDUS (\),
return false. Otherwise,
- if the second code point is a newline,
+
+ Otherwise,
+ if the second code point is a newline,
return false. Otherwise, return true. Otherwise, return true. This section describes how to check if three code points would start an identifier.
- The algorithm described here can be called explicitly with three code points,
+
+ This section describes how to check if three code points would start an identifier.
+ The algorithm described here can be called explicitly with three code points,
or can be called with the input stream itself.
- In the latter case, the three code points in question are
- the current input code point
- and the next two input code points,
+ In the latter case, the three code points in question are
+ the current input code point
+ and the next two input code points,
in that order. Note: This algorithm will not consume any additional code points. Look at the first code point: Note: This algorithm will not consume any additional code points. Look at the first code point: This section describes how to check if three code points would start a number.
- The algorithm described here can be called explicitly with three code points,
+
+ This section describes how to check if three code points would start a number.
+ The algorithm described here can be called explicitly with three code points,
or can be called with the input stream itself.
- In the latter case, the three code points in question are
- the current input code point
- and the next two input code points,
+ In the latter case, the three code points in question are
+ the current input code point
+ and the next two input code points,
in that order. Note: This algorithm will not consume any additional code points. Look at the first code point: Note: This algorithm will not consume any additional code points. Look at the first code point: Otherwise,
- if the second code point
+
+ Otherwise,
+ if the second code point
is a U+002E FULL STOP (.)
- and the third code point
- is a digit,
+ and the third code point
+ is a digit,
return true. Otherwise, return false. Otherwise, return false. This section describes how to consume a name from a stream of code points.
+ This section describes how to consume a name from a stream of code points.
It returns a string containing
- the largest name that can be formed from adjacent code points in the stream, starting from the first. Note: This algorithm does not do the verification of the first few code points
- that are necessary to ensure the returned code points would constitute an <ident-token>.
+
+ Note: This algorithm does not do the verification of the first few code points
+ that are necessary to ensure the returned code points would constitute an <ident-token>.
If that is the intended use,
- ensure that the stream starts with an identifier
+ ensure that the stream starts with an identifier
before calling this algorithm. Let result initially be an empty string. Repeatedly consume the next input code point from the stream: Let result initially be an empty string. Repeatedly consume the next input code point from the stream: This section describes how to consume a number from a stream of code points.
+ This section describes how to consume a number from a stream of code points.
It returns a 3-tuple of
a string representation,
a numeric value,
and a type flag which is either "integer" or "number". Note: This algorithm does not do the verification of the first few code points
+
+ Note: This algorithm does not do the verification of the first few code points
that are necessary to ensure a number can be obtained from the stream.
- Ensure that the stream starts with a number
+ Ensure that the stream starts with a number
before calling this algorithm. Execute the following steps in order: Execute the following steps in order: This section describes how to convert a string to a number.
+
+ This section describes how to convert a string to a number.
It returns a number. Note: This algorithm does not do any verification to ensure that the string contains only a number.
+
+ Note: This algorithm does not do any verification to ensure that the string contains only a number.
Ensure that the string contains only a valid CSS number
before calling this algorithm. Divide the string into seven components,
+
+ Divide the string into seven components,
in order from left to right: Return the number Return the number This section describes how to consume the remnants of a bad url from a stream of code points,
- "cleaning up" after the tokenizer realizes that it’s in the middle of a <bad-url-token> rather than a <url-token>.
+
+ This section describes how to consume the remnants of a bad url from a stream of code points,
+ "cleaning up" after the tokenizer realizes that it’s in the middle of a <bad-url-token> rather than a <url-token>.
It returns nothing;
its sole use is to consume enough of the input stream to reach a recovery point
where normal tokenizing can resume. Repeatedly consume the next input code point from the stream: Repeatedly consume the next input code point from the stream: The input to the parsing stage is a stream or list of tokens from the tokenization stage.
+ The input to the parsing stage is a stream or list of tokens from the tokenization stage.
The output depends on how the parser is invoked,
as defined by the entry points listed later in this section.
The parser output can consist of at-rules,
qualified rules,
and/or declarations. The parser’s output is constructed according to the fundamental syntax of CSS,
+
+ The parser’s output is constructed according to the fundamental syntax of CSS,
without regards for the validity of any specific item.
Implementations may check the validity of items as they are returned by the various parser algorithms
and treat the algorithm as returning nothing if the item was invalid according to the implementation’s own grammar knowledge,
or may construct a full tree as specified
and "clean up" afterwards by removing any invalid items. The items that can appear in the tree are: The items that can appear in the tree are: Note: This specification places no limits on what an at-rule’s block may contain.
+
+ Note: This specification places no limits on what an at-rule’s block may contain.
Individual at-rules must define whether they accept a block,
and if so,
how to parse it
(preferably using one of the parser algorithms or entry points defined in this specification). Note: Most qualified rules will be style rules,
- where the prelude is a selector [SELECT]
+
+ Note: Most qualified rules will be style rules,
+ where the prelude is a selector [SELECT]
and the block a list of declarations. Declarations are further categorized as "properties" or "descriptors",
- with the former typically appearing in qualified rules
- and the latter appearing in at-rules.
+
+ Declarations are further categorized as "properties" or "descriptors",
+ with the former typically appearing in qualified rules
+ and the latter appearing in at-rules.
(This categorization does not occur at the Syntax level;
instead, it is a product of where the declaration appears,
and is defined by the respective specifications defining the given rule.) Note: The non-preserved tokens listed above are always consumed into higher-level objects,
+
+ Note: The non-preserved tokens listed above are always consumed into higher-level objects,
either functions or simple blocks,
and so never appear in any parser output themselves. Note: The tokens <}-token>s, <)-token>s, <]-token>, <bad-string-token>, and <bad-url-token> are always parse errors,
+ Note: The tokens <}-token>s, <)-token>s, <]-token>, <bad-string-token>, and <bad-url-token> are always parse errors,
but they are preserved in the token stream by this specification to allow other specs,
such as Media Queries,
to define more fine-grainted error-handling
than just dropping an entire declaration or block. This section is non-normative. This section is non-normative. This section presents an informative view of the parser,
+ This section presents an informative view of the parser,
in the form of railroad diagrams. These diagrams are informative and incomplete;
+
+ These diagrams are informative and incomplete;
they describe the grammar of "correct" stylesheets,
but do not describe error-handling at all.
They are provided solely to make it easier to get an intuitive grasp of the syntax. The algorithms defined in this section produce high-level CSS objects
+
+ The algorithms defined in this section produce high-level CSS objects
from lower-level objects.
They assume that they are invoked on a token stream,
but they may also be invoked on a string;
if so,
- first perform input preprocessing
- to produce a code point stream,
- then perform tokenization
+ first perform input preprocessing
+ to produce a code point stream,
+ then perform tokenization
to produce a token stream. "Parse a stylesheet" can also be invoked on a byte stream,
- in which case The input byte stream
+
+ "Parse a stylesheet" can also be invoked on a byte stream,
+ in which case The input byte stream
defines how to decode it into Unicode. Note: This specification does not define how a byte stream is decoded for other entry points. Note: Other specs can define additional entry points for their own purposes. Note: This specification does not define how a byte stream is decoded for other entry points. Note: Other specs can define additional entry points for their own purposes. All of the algorithms defined in this spec may be called with either a list of tokens or of component values.
+ All of the algorithms defined in this spec may be called with either a list of tokens or of component values.
Either way produces an identical result. It is often desirable to parse a string or token list
+ It is often desirable to parse a string or token list
to see if it matches some CSS grammar,
and if it does,
to destructure it according to the grammar.
This section provides a generic hook for this kind of operation.
- It should be invoked like "parse foo as a CSS <color>", or similar. Note: As a reminder, this algorithm, along with all the others in this section,
+ Note: As a reminder, this algorithm, along with all the others in this section,
can be called with a string,
a stream of CSS tokens,
or a stream of CSS component values,
whichever is most convenient. This algorithm must be called with some input to be parsed,
+
+ This algorithm must be called with some input to be parsed,
and some CSS grammar specification or term. This algorithm returns either failure,
+
+ This algorithm returns either failure,
if the input does not match the provided grammar,
or the result of parsing the input according to the grammar,
which is an unspecified structure corresponding to the provided grammar specification.
@@ -3438,876 +5929,1251 @@ To parse something according to a CSS grammar: To parse something according to a CSS grammar: To parse a stylesheet from a stream of tokens: To parse a stylesheet from a stream of tokens: To parse a list of rules from a stream of tokens: To parse a list of rules from a stream of tokens: To parse a rule from a stream of tokens: To parse a rule from a stream of tokens: Otherwise,
- if the next input token is an <at-keyword-token>,
- consume an at-rule,
+
+ Otherwise,
+ if the next input token is an <at-keyword-token>,
+ consume an at-rule,
and let rule be the return value. Otherwise,
- consume a qualified rule
+ Otherwise,
+ consume a qualified rule
and let rule be the return value.
If nothing was returned,
return a syntax error. Note: Unlike "Parse a list of declarations",
+ Note: Unlike "Parse a list of declarations",
this parses only a declaration and not an at-rule. Note: Despite the name,
+ Note: Despite the name,
this actually parses a mixed list of declarations and at-rules,
- as CSS 2.1 does for @page.
+ as CSS 2.1 does for @page.
Unexpected at-rules (which could be all of them, in a given context)
are invalid and should be ignored by the consumer. To parse a list of declarations: To parse a list of component values: To parse a list of component values: To parse a comma-separated list of component values: To parse a comma-separated list of component values: If it was a <comma-token> that was returned,
+
+ If it was a <comma-token> that was returned,
repeat this step. The following algorithms comprise the parser.
+
+ The following algorithms comprise the parser.
They are called by the parser entry points above. These algorithms may be called with a list of either tokens or of component values.
- (The difference being that some tokens are replaced by functions and simple blocks in a list of component values.)
+
+ These algorithms may be called with a list of either tokens or of component values.
+ (The difference being that some tokens are replaced by functions and simple blocks in a list of component values.)
Similar to how the input stream returned EOF code points to represent when it was empty during the tokenization stage,
- the lists in this stage must return an <EOF-token> when the next token is requested but they are empty. An algorithm may be invoked with a specific list,
+ An algorithm may be invoked with a specific list,
in which case it consumes only that list
(and when that list is exhausted,
- it begins returning <EOF-token>s).
+ it begins returning <EOF-token>s).
Otherwise,
it is implicitly invoked with the same list as the invoking algorithm. Create an initially empty list of rules. Repeatedly consume the next input token: Create an initially empty list of rules. Repeatedly consume the next input token: Otherwise,
- reconsume the current input token.
- Consume a qualified rule.
+
+ Otherwise,
+ reconsume the current input token.
+ Consume a qualified rule.
If anything is returned,
append it to the list of rules. Consume the next input token.
+ Consume the next input token.
Create a new at-rule
- with its name set to the value of the current input token,
+ with its name set to the value of the current input token,
its prelude initially set to an empty list,
and its value initially set to nothing. Repeatedly consume the next input token: Repeatedly consume the next input token: Create a new qualified rule
+ Create a new qualified rule
with its prelude initially set to an empty list,
and its value initially set to nothing. Repeatedly consume the next input token: Repeatedly consume the next input token: To consume a list of declarations: Create an initially empty list of declarations. Repeatedly consume the next input token: To consume a list of declarations: Create an initially empty list of declarations. Repeatedly consume the next input token: Note: This algorithm assumes that the next input token has already been checked to be an <ident-token>. Note: This algorithm assumes that the next input token has already been checked to be an <ident-token>. Consume the next input token.
+
+ Consume the next input token.
Create a new declaration
- with its name set to the value of the current input token
+ with its name set to the value of the current input token
and its value initially set to the empty list. Otherwise, consume the next input token. Otherwise, consume the next input token. If the current input token
- is a <{-token>, <[-token>, or <(-token>,
- consume a simple block
+ If the current input token
+ is a <{-token>, <[-token>, or <(-token>,
+ consume a simple block
and return it. Otherwise, if the current input token
- is a <function-token>,
- consume a function
+
+ Otherwise, if the current input token
+ is a <function-token>,
+ consume a function
and return it. Otherwise, return the current input token. Otherwise, return the current input token. Note: This algorithm assumes that the current input token has already been checked to be an <{-token>, <[-token>, or <(-token>. Note: This algorithm assumes that the current input token has already been checked to be an <{-token>, <[-token>, or <(-token>. The ending token is the mirror variant of the current input token.
+ (E.g. if it was called with <[-token>, the ending token is <]-token>.) The ending token is the mirror variant of the current input token.
- (E.g. if it was called with <[-token>, the ending token is <]-token>.) Create a simple block with its associated token set to the current input token
+ Create a simple block with its associated token set to the current input token
and with a value with is initially an empty list. Repeatedly consume the next input token and process it as follows: Repeatedly consume the next input token and process it as follows: Note: This algorithm assumes that the current input token has already been checked to be a <function-token>. Note: This algorithm assumes that the current input token has already been checked to be a <function-token>. Create a function with a name equal to the value of the current input token,
+
+ Create a function with a name equal to the value of the current input token,
and with a value which is initially an empty list. Repeatedly consume the next input token and process it as follows: Repeatedly consume the next input token and process it as follows: Several things in CSS,
- such as the :nth-child() pseudoclass,
+
+ Several things in CSS,
+ such as the :nth-child() pseudoclass,
need to indicate indexes in a list.
The An+B microsyntax is useful for this,
allowing an author to easily indicate single elements
or all elements at regularly-spaced intervals in a list. The An+B notation defines an integer step (A) and offset (B),
+
+ The An+B notation defines an integer step (A) and offset (B),
and represents the An+Bth elements in a list,
for every positive integer or zero value of n,
with the first element in the list having index 1 (not 0). For values of A and B greater than 0,
+
+ For values of A and B greater than 0,
this effectively divides the list into groups of A elements
(the last group taking the remainder),
and selecting the Bth element of each group. The An+B notation also accepts the even and odd keywords,
- which have the same meaning as 2n and 2n+1, respectively. Examples:
- The An+B notation also accepts the even and odd keywords,
+ which have the same meaning as 2n and 2n+1, respectively. Examples:
+ The values of A and B can be negative,
+ The values of A and B can be negative,
but only the positive results of An+B,
for n ≥ 0,
are used. Example:
- Example:
+ If both A and B are 0,
+
+ If both A and B are 0,
the pseudo-class represents no element in the list. This section is non-normative. This section is non-normative. When A is 0, the An part may be omitted
+ When A is 0, the An part may be omitted
(unless the B part is already omitted).
When An is not included
and B is non-negative,
- the + sign before B (when allowed)
+ the + sign before B (when allowed)
may also be omitted.
In this case the syntax simplifies to just B. Examples:
- Examples:
+ When A is 1 or -1,
+ When A is 1 or -1,
the Examples:
- The following notations are therefore equivalent:
- Examples:
+ The following notations are therefore equivalent:
+ If B is 0, then every Ath element is picked.
+
+ If B is 0, then every Ath element is picked.
In such a case,
the +B (or -B) part may be omitted
unless the A part is already omitted. Examples:
- Examples:
+ When B is negative, its minus sign replaces the + sign. Valid example:
- Invalid example:
- When B is negative, its minus sign replaces the + sign. Valid example:
+ Invalid example:
+ Whitespace is permitted on either side of the + or -
+ Whitespace is permitted on either side of the + or -
that separates the An and B parts when both are present. Valid Examples with white space:
- Valid Examples with white space:
+ Invalid Examples with white space:
- Invalid Examples with white space:
+ The An+B notation was originally defined using a slightly different tokenizer than the rest of CSS,
+
+ The An+B notation was originally defined using a slightly different tokenizer than the rest of CSS,
resulting in a somewhat odd definition when expressed in terms of CSS tokens.
This section describes how to recognize the An+B notation in terms of CSS tokens
- (thus defining the <an+b> type for CSS grammar purposes),
+ (thus defining the <an+b> type for CSS grammar purposes),
and how to interpret the CSS tokens to obtain values for A and B. The <an+b> type is defined
- (using the Value Definition Syntax in the Values & Units spec)
+
+ The <an+b> type is defined
+ (using the Value Definition Syntax in the Values & Units spec)
as: where:
+ where:
†: When a plus sign (+) precedes an ident starting with "n", as in the cases marked above,
there must be no whitespace between the two tokens,
or else the tokens do not match the above grammar.
Whitespace is valid (and ignored) between any other two tokens.
- The clauses of the production are interpreted as follows: The clauses of the production are interpreted as follows: Some constructs,
- such as the unicode-range descriptor for the @font-face rule,
+
+ Some constructs,
+ such as the unicode-range descriptor for the @font-face rule,
need a way to describe one or more unicode code points.
- The <urange> production represents a range of one or more unicode code points. Informally, the <urange> production has three forms: Informally, the <urange> production has three forms: In each form, a maximum of 6 digits is allowed for each hexadecimal number
+
+ In each form, a maximum of 6 digits is allowed for each hexadecimal number
(if you treat "?" as a hexadecimal digit). The <urange> notation was originally defined as a primitive token in CSS,
+ The <urange> notation was originally defined as a primitive token in CSS,
but it is used very rarely,
- and collides with legitimate <ident-token>s in confusing ways.
- This section describes how to recognize the <urange> notation
+ and collides with legitimate <ident-token>s in confusing ways.
+ This section describes how to recognize the <urange> notation
in terms of existing CSS tokens,
and how to interpret it as a range of unicode codepoints. Note: The syntax described here is intentionally very low-level,
+
+ Note: The syntax described here is intentionally very low-level,
and geared toward implementors.
Authors should instead read the informal syntax description in the previous section,
- as it contains all information necessary to use <urange>,
+ as it contains all information necessary to use <urange>,
and is actually readable. The <urange> type is defined
- (using the Value Definition Syntax in the Values & Units spec) as: The <urange> type is defined
+ (using the Value Definition Syntax in the Values & Units spec) as: In this production,
+
+ In this production,
no whitespace can occur between any of the tokens. The <urange> production represents a range of one or more contiguous unicode code points
+
+ The <urange> production represents a range of one or more contiguous unicode code points
as a start value and an end value,
which are non-negative integers.
To interpret the production above into a range,
execute the following steps in order: Skipping the first u token,
+
+ Skipping the first u token,
concatenate the representations of all the tokens in the production together
-(or, in the case of <dimension-token>s,
+(or, in the case of <dimension-token>s,
the representation followed by the unit).
Let this be text. If the first character of text is U+002B PLUS SIGN,
+ If the first character of text is U+002B PLUS SIGN,
consume it.
Otherwise,
-this is an invalid <urange>,
+this is an invalid <urange>,
and this algorithm must exit. Consume as many hex digits from text as possible.
-then consume as many U+003F QUESTION MARK (?) code points as possible.
-If zero code points were consumed,
-or more than six code points were consumed,
-this is an invalid <urange>,
+ Consume as many hex digits from text as possible.
+then consume as many U+003F QUESTION MARK (?) code points as possible.
+If zero code points were consumed,
+or more than six code points were consumed,
+this is an invalid <urange>,
and this algorithm must exit. If any U+003F QUESTION MARK (?) code points were consumed, then: If there are any code points left in text,
-this is an invalid <urange>,
+ If any U+003F QUESTION MARK (?) code points were consumed, then: If there are any code points left in text,
+this is an invalid <urange>,
and this algorithm must exit. Interpret the consumed code points as a hexadecimal number,
-with the U+003F QUESTION MARK (?) code points
-replaced by U+0030 DIGIT ZERO (0) code points.
+
+ Interpret the consumed code points as a hexadecimal number,
+with the U+003F QUESTION MARK (?) code points
+replaced by U+0030 DIGIT ZERO (0) code points.
This is the start value. Interpret the consumed code points as a hexadecimal number again,
-with the U+003F QUESTION MARK (?) code points
-replaced by U+0046 LATIN CAPITAL LETTER F (F) code points.
+ Interpret the consumed code points as a hexadecimal number again,
+with the U+003F QUESTION MARK (?) code points
+replaced by U+0046 LATIN CAPITAL LETTER F (F) code points.
This is the end value. Exit this algorithm. Exit this algorithm. Otherwise, interpret the consumed code points as a hexadecimal number.
+ Otherwise, interpret the consumed code points as a hexadecimal number.
This is the start value. If there are no code points left in text,
+
+ If there are no code points left in text,
The end value is the same as the start value.
Exit this algorithm. If the next code point in text is U+002D HYPHEN-MINUS (-),
+ If the next code point in text is U+002D HYPHEN-MINUS (-),
consume it.
Otherwise,
-this is an invalid <urange>,
+this is an invalid <urange>,
and this algorithm must exit. Consume as many hex digits as possible from text. Consume as many hex digits as possible from text. If zero hex digits were consumed,
-or more than 6 hex digits were consumed,
-this is an invalid <urange>,
+ If zero hex digits were consumed,
+or more than 6 hex digits were consumed,
+this is an invalid <urange>,
and this algorithm must exit.
-If there are any code points left in text,
-this is an invalid <urange>,
+If there are any code points left in text,
+this is an invalid <urange>,
and this algorithm must exit. Interpret the consumed code points as a hexadecimal number.
+
+ Interpret the consumed code points as a hexadecimal number.
This is the end value. To determine what codepoints the <urange> represents: To determine what codepoints the <urange> represents: If end value is greater than the maximum allowed code point,
-the <urange> is invalid and a syntax error. If start value is greater than end value,
-the <urange> is invalid and a syntax error. If end value is greater than the maximum allowed code point,
+the <urange> is invalid and a syntax error. Otherwise, the <urange> represents a contiguous range of codepoints from start value to end value, inclusive. Note: The syntax of <urange> is intentionally fairly wide;
+
+ If start value is greater than end value,
+the <urange> is invalid and a syntax error. Otherwise, the <urange> represents a contiguous range of codepoints from start value to end value, inclusive. Note: The syntax of <urange> is intentionally fairly wide;
its patterns capture every possible token sequence
that the informal syntax can generate.
However, it requires no whitespace between its constituent tokens,
which renders it fairly safe to use in practice.
- Even grammars which have a <urange> followed by a <number> or <dimension>
+ Even grammars which have a <urange> followed by a <number> or <dimension>
(which might appear to be ambiguous
- if an author specifies the <urange> with the ''u <number>'' clause)
+ if an author specifies the <urange> with the ''u <number>'' clause)
are actually quite safe,
- as an author would have to intentionally separate the <urange> and the <number>/<dimension>
+ as an author would have to intentionally separate the <urange> and the <number>/<dimension>
with a comment rather than whitespace
for it to be ambiguous.
Thus, while it’s possible for authors to write things that are parsed in confusing ways,
@@ -4316,114 +7182,155 @@ The Values spec defines how to specify a grammar for properties.
+ The Values spec defines how to specify a grammar for properties.
This section does the same, but for rules. Just like in property grammars,
- the notation Just like in property grammars,
+ the notation Several types of tokens are written literally, without quotes: Several types of tokens are written literally, without quotes: Tokens match if their value is an ASCII case-insensitive match
+
+ Tokens match if their value is an ASCII case-insensitive match
for the value defined in the grammar.
- Although it is possible, with escaping,
- to construct an <ident-token> whose value ends with
+ Although it is possible, with escaping,
+ to construct an <ident-token> whose value ends with <delim-token>s are written with their value enclosed in single quotes.
- For example, a <delim-token> containing the "+" code point is written as <delim-token>s are written with their value enclosed in single quotes.
+ For example, a <delim-token> containing the "+" code point is written as When defining a function or a block,
+
+ When defining a function or a block,
the ending token must be specified in the grammar,
but if it’s not present in the eventual token stream,
it still matches. However, the stylesheet may end with the function unclosed, like: However, the stylesheet may end with the function unclosed, like: The CSS parser parses this as a style rule containing one declaration,
+ The CSS parser parses this as a style rule containing one declaration,
whose value is a function named "translate".
This matches the above grammar,
even though the ending token didn’t appear in the token stream,
because by the time the parser is finished,
the presence of the ending token is no longer possible to determine;
all you have is the fact that there’s a block and a function. The CSS parser is agnostic as to the contents of blocks,
+
+ The CSS parser is agnostic as to the contents of blocks,
such as those that come at the end of some at-rules.
Defining the generic grammar of the blocks in terms of tokens is non-trivial,
but there are dedicated and unambiguous algorithms defined for parsing this. The <declaration-list> production represents a list of declarations.
+
+ The <declaration-list> production represents a list of declarations.
It may only be used in grammars as the sole value in a block,
- and represents that the contents of the block must be parsed using the consume a list of declarations algorithm. Similarly, the <rule-list> production represents a list of rules,
+ Similarly, the <rule-list> production represents a list of rules,
and may only be used in grammars as the sole value in a block.
- It represents that the contents of the block must be parsed using the consume a list of rules algorithm. Finally, the <stylesheet> production represents a list of rules.
- It is identical to <rule-list>,
+
+ Finally, the <stylesheet> production represents a list of rules.
+ It is identical to <rule-list>,
except that blocks using it default to accepting all rules
that aren’t otherwise limited to a particular context. This is a complete and sufficient definition of the rule’s grammar. This is a complete and sufficient definition of the rule’s grammar. For another example,
- @keyframes rules are more complex,
+ For another example,
+ @keyframes rules are more complex,
interpreting their prelude as a name and containing keyframes rules in their block
Their grammar is: For rules that use <declaration-list>,
+ For rules that use <declaration-list>,
the spec for the rule must define which properties, descriptors, and/or at-rules are valid inside the rule;
this may be as simple as saying "The @foo rule accepts the properties/descriptors defined in this specification/section.",
and extension specs may simply say "The @foo rule additionally accepts the following properties/descriptors.".
Any declarations or at-rules found inside the block that are not defined as valid
must be removed from the rule’s value. Within a <declaration-list>,
+
+ Within a <declaration-list>,
For rules that use <rule-list>,
+
+ For rules that use <rule-list>,
the spec for the rule must define what types of rules are valid inside the rule,
- same as <declaration-list>,
+ same as <declaration-list>,
and unrecognized rules must similarly be removed from the rule’s value. Keyframe rules, then,
+ Keyframe rules, then,
must further define that they accept as declarations all animatable CSS properties,
- plus the animation-timing-function property,
+ plus the animation-timing-function property,
but that they do not interact with the cascade. For rules that use <stylesheet>,
+ For rules that use <stylesheet>,
all rules are allowed by default,
but the spec for the rule may define what types of rules are invalid inside the rule. It additionally defines a restriction that the <stylesheet> can not contain @media rules,
+ It additionally defines a restriction that the <stylesheet> can not contain @media rules,
which causes them to be dropped from the outer rule’s value if they appear. To parse a CSS stylesheet,
first parse a stylesheet.
Interpret all of the resulting top-level qualified rules as style rules, defined below. If any style rule is invalid,
+
+ If any style rule is invalid,
or any at-rule is not recognized or is invalid according to its grammar or context,
it’s a parse error.
Discard that rule. A style rule is a qualified rule
- that associates a selector list [SELECT]
+ A style rule is a qualified rule
+ that associates a selector list [SELECT]
with a list of property declarations.
They are also called
- rule sets in [CSS21].
- CSS Cascading and Inheritance [CSS3CASCADE] defines how the declarations inside of style rules participate in the cascade. The prelude of the qualified rule is parsed as a
- selector list.
- If this results in an invalid selector list,
+
+ The prelude of the qualified rule is parsed as a
+ selector list.
+ If this results in an invalid selector list,
the entire style rule is invalid. The content of the qualified rule’s block is parsed as a
+
+ The content of the qualified rule’s block is parsed as a
list of declarations.
Unless defined otherwise by another specification or a future level of this specification,
at-rules in that list are invalid
@@ -4512,30 +7441,38 @@ Note: The names of Custom Properties [CSS-VARIABLES] are case-sensitive. Qualified rules at the top-level of a CSS stylesheet are style rules.
+ Note: The names of Custom Properties [CSS-VARIABLES] are case-sensitive. Qualified rules at the top-level of a CSS stylesheet are style rules.
Qualified rules in other contexts may or may not be style rules,
as defined by the context.
- For example, qualified rules inside @media rules [CSS3-CONDITIONAL] are style rules,
- but qualified rules inside @keyframes rules are not [CSS3-ANIMATIONS].
+
+
+ For example, qualified rules inside @media rules [CSS3-CONDITIONAL] are style rules,
+ but qualified rules inside @keyframes rules are not [CSS3-ANIMATIONS].
+
+ The @charset rule is an artifact of the algorithm used to determine the fallback encoding for the stylesheet.
+ The @charset rule is an artifact of the algorithm used to determine the fallback encoding for the stylesheet.
That algorithm looks for a specific byte sequence as the very first few bytes in the file,
which has the syntactic form of an @-rule.
Those bytes are not discarded from the input,
whether or not they influence the encoding actually used to process the stylesheet. Therefore, the stylesheet parser recognizes an @-rule with the general syntax Therefore, the stylesheet parser recognizes an @-rule with the general syntax and, for backward compatibility, includes it in the object model for the stylesheet.
+ and, for backward compatibility, includes it in the object model for the stylesheet.
Modifying, adding, or removing an @charset rule via the object model has no effect
(in particular it does not cause the stylesheet to be rescanned in a different encoding).
The @charset rule is invalid if it is not the very first, top-level rule in the stylesheet,
@@ -4546,384 +7483,716 @@ The tokenizer described in this specification does not produce tokens for comments,
+ The tokenizer described in this specification does not produce tokens for comments,
or otherwise preserve them in any way.
Implementations may preserve the contents of comments and their location in the token stream.
If they do, this preserved information must have no effect on the parsing step. This specification does not define how to serialize CSS in general,
+
+ This specification does not define how to serialize CSS in general,
leaving that task to the CSSOM and individual feature specifications.
In particular, the serialization of comments an whitespace is not defined. The only requirement for serialization is that it must "round-trip" with parsing,
+
+ The only requirement for serialization is that it must "round-trip" with parsing,
that is, parsing the stylesheet must produce the same data structures as
parsing, serializing, and parsing again,
- except for consecutive <whitespace-token>s,
+ except for consecutive <whitespace-token>s,
which may be collapsed into a single token. Note: This exception can exist because
+
+ Note: This exception can exist because
CSS grammars always interpret any amount of whitespace as identical to a single space. If the tokenizer preserves comments,
+
+ If the tokenizer preserves comments,
the preserved comment should be used;
otherwise, an empty comment ( Single characters in the row and column headings represent a <delim-token> with that value,
- except for " To serialize an <an+b> value,
+ Single characters in the row and column headings represent a <delim-token> with that value,
+ except for " To serialize an <an+b> value,
let s initially be the empty string: Return s. Return s. This section is non-normative. This section is non-normative. The following substantive changes were made: The following substantive changes were made: Fixed a bug in the "Consume a URL token" algorithm,
+ Fixed a bug in the "Consume a URL token" algorithm,
where it didn’t consume the quote character starting a string before attempting to consume the string. Fixed a bug in several of the parser algorithms
+
+ Fixed a bug in several of the parser algorithms
related to the current/next input token and things getting consumed early/late. Fix several bugs in the tokenization and parsing algorithms. Fix several bugs in the tokenization and parsing algorithms. Change the definition of ident-like tokens to allow "--" to start an ident. Change the definition of ident-like tokens to allow "--" to start an ident. The following editorial changes were made: The "Consume a string token" algorithm was changed to allow calling it without specifying an explicit ending token,
+ The following editorial changes were made: The "Consume a string token" algorithm was changed to allow calling it without specifying an explicit ending token,
so that it uses the current input token instead.
The three call-sites of the algorithm were changed to use that form. Minor editorial restructuring of algorithms. Minor editorial restructuring of algorithms. Note: The point of this spec is to match reality;
+ Note: The point of this spec is to match reality;
changes from CSS2.1 are nearly always because CSS 2.1 specified something that doesn’t match actual browser behavior,
or left something unspecified.
If some detail doesn’t match browsers,
please let me know
as it’s almost certainly unintentional. Changes in decoding from a byte stream: Changes in decoding from a byte stream: Tokenization changes: Tokenization changes: Instead, a <urange> production was added,
+ Instead, a <urange> production was added,
based on token patterns.
It is technically looser than what 2.1 allowed
(any number of digits and ? characters),
but not in any way that should impact its use in practice. Parsing changes: Parsing changes: An+B changes from Selectors Level 3 [SELECT]: An+B changes from Selectors Level 3 [SELECT]: Thanks for feedback and contributions from
+
+ Thanks for feedback and contributions from
Anne van Kesteren,
David Baron,
Henri Sivonen,
@@ -4932,15 +8201,19 @@ 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",
@@ -4949,53 +8222,74 @@ 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 This is an example of an informative example. This is an example of an informative example. Informative notes begin with the word "Note" and are set apart from the
normative text with Note, this is an informative note. Note, this is an informative note. Advisements are normative sections styled to evoke special attention and are
- set apart from other normative text with Conformance to this specification
is defined for three conformance classes:
+ A style sheet is conformant to this specification
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 this specification
if, in addition to interpreting the style sheet as defined by the
appropriate specifications, it supports all the features defined
@@ -5005,18 +8299,21 @@ An authoring tool is conformant to this specification
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.
- So that authors can exploit the forward-compatible parsing rules to
assign fallback values, CSS renderers must
- treat as invalid (and ignore
+ 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
@@ -5025,13 +8322,16 @@ To avoid clashes with future CSS features, the CSS2.1 specification
- reserves a prefixed
+ 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
@@ -5040,14 +8340,17 @@ 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
@@ -5056,13 +8359,180 @@ Further information on submitting testcases and implementation reports
can be found from on the CSS Working Group’s website at
- http://www.w3.org/Style/CSS/Test/.
+ http://www.w3.org/Style/CSS/Test/.
Questions should be directed to the
- public-css-testsuite@w3.org
+ public-css-testsuite@w3.org
mailing list.
-
+
+
+
+
+
+
+
CSS Syntax Module Level 3
- Editor’s Draft,
- 20 November 2014
- CSS Syntax Module Level 3
+
+ Editor’s Draft,
+
+
+
+
+
+
+
Abstract
-Abstract
+
+ Status of this document
-Status of this document
+
+ Table of Contents
-
-1.
-Introduction
-
-Table of Contents
+
+
+
+ 1.
+Introduction
+
+
+ style
attribute).1.1.
-Module interactions
-1.1.
+Module interactions
+
+
+ 2.
-Description of CSS’s Syntax
-2.
+Description of CSS’s Syntax
+
-
-
p > a {
+
+
p > a {
color: blue;
text-decoration: underline;
}
+
-p > a
" is the selector,
+
+ p > a
" is the selector,
which, if the source document is HTML,
- selects any <a>
elements that are children of a <p>
element.<a>
elements that are children of a <p>
element.
+
+
-color: blue
" is a declaration specifying that,
+ color: blue
" is a declaration specifying that,
for the elements that match the selector,
- their color property should have the value blue.
- Similarly, their text-decoration property should have the value underline.@import "my-styles.css";
+
-@import "my-styles.css";
-@page :left {
+
+
@page :left {
margin-left: 4cm;
margin-right: 3cm;
}
+
-@media print {
+
+
@media print {
body { font-size: 10pt }
}
+
+
-2.1.
+Escaping
-2.1.
-Escaping
-
-
+
-
+
+
+
+ 2.2.
-Error Handling
+ 2.2.
+Error Handling
-2
and it’s useful to be able to add new syntax to the language
without worrying about stylesheets that include it being completely broken in older UAs.
-
-
+
-
+
+
+ 3.
-Tokenizing and Parsing CSS
+ 3.
+Tokenizing and Parsing CSS
-
-
3.1.
-Overview of the Parsing Model
-3.1.
+Overview of the Parsing Model
+
+
+ 3.2.
-The input byte stream
-3.2.
+The input byte stream
+
+
+
-
+
+
+
+
+
+ 40 63 68 61 72 73 65 74 20 22 XX* 22 3B
-XX
byte is a value between 016 and 2116 inclusive
+ 40 63 68 61 72 73 65 74 20 22 XX* 22 3B
+
+
+
+ XX
byte is a value between 016 and 2116 inclusive
or a value between 2316 and 7F16 inclusive,
- then get an encoding
+ then get an encoding
for the sequence of XX
bytes,
interpreted as ASCII
.What does that byte sequence mean?
+
+ What does that byte sequence mean?
+
-@charset "…";
",
where the "…" is the sequence of bytes corresponding to the encoding’s label.utf-16be
or utf-16le
,
+ utf-16be
or utf-16le
,
use utf-8
as the fallback encoding;
if it was anything else except failure,
use the return value as the fallback encoding.Why use utf-8 when the declaration says utf-16?
+
- Why use utf-8 when the declaration says utf-16?
-@charset "…";
” in ASCII,
+ @charset "…";
” in ASCII,
but UTF-16 is not ASCII-compatible.
Either you’ve typed in complete gibberish (like 䁣桡牳整•utf-16be∻
) to get the right bytes in the document,
which we don’t want to encourage,
or your document is actually in an ASCII-compatible encoding
and your encoding declaration is lying.<meta charset>
attribute.<meta charset>
attribute.utf-8
as the fallback encoding.
- <meta charset=utf-8>
element to the head of the document.)<meta charset=utf-8>
element to the head of the document.)
+
+
-@charset "utf-8";
- @charset "utf-8";
+
+
+ <link rel=stylesheet>
.<xml-stylesheet?>
.<link rel=stylesheet>
.@import
.<xml-stylesheet?>
.3.3.
-Preprocessing the input stream
+ @import
.3.3.
+Preprocessing the input stream
+
+
+
-
+
+
+
+
- 4.
+Tokenization
-4.
-Tokenization
-
-
-
+
+
- 4.1.
-Token Railroad Diagrams
-4.1.
+Token Railroad Diagrams
+
-
-
-
-
-
-4.2.
-Definitions
-
-
-
-
+
+
+
+
+
+
+ 4.2.
+Definitions
+
+
+
+
+
+ 4.3.
-Tokenizer Algorithms
-4.3.
+Tokenizer Algorithms
-4.3.1.
-Consume a token
-4.3.1.
+Consume a token
-
-
-
-
+
+
+
+
+
+
+
+
+ 4.3.2.
+Consume comments
-4.3.2.
-Consume comments
-4.3.3.
+Consume a numeric token
+
+ 4.3.3.
-Consume a numeric token
-
-
-
+
+
+ 4.3.4.
-Consume an ident-like token
-4.3.4.
+Consume an ident-like token
+
+
+ 4.3.5.
-Consume a string token
-4.3.5.
+Consume a string token
+
+
+
-
-
+
+
+ 4.3.6.
-Consume a url token
-4.3.6.
+Consume a url token
-
-
+
-
-
+
+
+
-
+
+
+
+
+ 4.3.7.
+Consume an escaped code point
-4.3.7.
-Consume an escaped code point
-
-
-
+
+
+ 4.3.8.
-Check if two code points are a valid escape
-4.3.8.
+Check if two code points are a valid escape
+
+
+ 4.3.9.
-Check if three code points would start an identifier
+ 4.3.9.
+Check if three code points would start an identifier
-
-
+
-
+
+
+ 4.3.10.
-Check if three code points would start a number
+ 4.3.10.
+Check if three code points would start a number
-
-
+
+
+
+
+
+ 4.3.11.
+Consume a name
-4.3.11.
-Consume a name
-
-
-
+
+
+ 4.3.12.
-Consume a number
-4.3.12.
+Consume a number
+
+
+
-
+
-
+
+
+
-
-
-
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+ 4.3.13.
-Convert a string to a number
+ 4.3.13.
+Convert a string to a number
-
-
+
+
+
+
+
+ s·(i + f·10-d)·10te
.s·(i + f·10-d)·10te
.4.3.14.
-Consume the remnants of a bad url
+ 4.3.14.
+Consume the remnants of a bad url
-
-
+
+
+
+
+
+ 5.
+Parsing
-5.
-Parsing
-
-
+
+
+
+
+
+
+ 5.1.
+Parser Railroad Diagrams
-5.1.
-Parser Railroad Diagrams
+
-
-
-
-
-5.2.
-Definitions
-
-
-
+
-
+
+
+
+
+
+
+ 5.2.
+Definitions
+
+
+
+
+
+ and check if they are a case-sensitive match.
+ 5.3.
-Parser Entry Points
+ 5.3.
+Parser Entry Points
-
-
+
+
- CSSStyleSheet#insertRule
method,
+ CSSStyleSheet#insertRule
method,
and similar functions which might exist,
which parse text into a single rule.
- style
attribute,
+ style
attribute,
which parses text into the contents of a single style rule.
- media
HTML attribute.
- 5.3.1.
-Parse something according to a CSS grammar
-5.3.1.
+Parse something according to a CSS grammar
+
+
+
if it is meant to be exposed outside of spec language,
the spec using the result must explicitly translate it into a well-specified representation,
such as, for example, by invoking a CSS serialization algorithm
- (like "serialize as a CSS <string> value").
+ (like "serialize as a CSS <string> value").
-
-
+
-
+
+
+ 5.3.2.
-Parse a stylesheet
+ 5.3.2.
+Parse a stylesheet
-
-
+
+
+
+
+
+ 5.3.3.
+Parse a list of rules
-5.3.3.
-Parse a list of rules
-
-
-
+
+
+ 5.3.4.
-Parse a rule
-5.3.4.
+Parse a rule
-
-
-
+
+
+ 5.3.5.
-Parse a declaration
-5.3.5.
+Parse a declaration
+
+
+
-
-
+
+
+ 5.3.6.
-Parse a list of declarations
-5.3.6.
+Parse a list of declarations
+
+
+
-
+
-
+
+
+ 5.3.7.
-Parse a component value
+ 5.3.7.
+Parse a component value
-
-
-
+
+
+
+
+
+ 5.3.8.
+Parse a list of component values
-5.3.8.
-Parse a list of component values
-
-
-
+
+
+ 5.3.9.
-Parse a comma-separated list of component values
-5.3.9.
+Parse a comma-separated list of component values
-
-
+
-
+
+
+ 5.4.
-Parser Algorithms
+ 5.4.
+Parser Algorithms
-5.4.1.
-Consume a list of rules
-
+ 5.4.1.
+Consume a list of rules
-
-
+
-
+
+
+ 5.4.2.
-Consume an at-rule
+ 5.4.2.
+Consume an at-rule
-
-
-
+
-
+
+
+ 5.4.3.
-Consume a qualified rule
+ 5.4.3.
+Consume a qualified rule
-
-
-
-
+
+
+ 5.4.4.
-Consume a list of declarations
-5.4.4.
+Consume a list of declarations
-
-
+
+
+
+
+
+
+ 5.4.5.
+Consume a declaration
-5.4.5.
-Consume a declaration
+
-
+
+
+
+
+
+
+ 5.4.6.
+Consume a component value
+
+
-5.4.6.
-Consume a component value
-
+
-
-5.4.7.
+Consume a simple block
+
+
+ 5.4.7.
-Consume a simple block
+
-
-
+
+
+
+
+
+
+ 5.4.8.
+Consume a function
-5.4.8.
-Consume a function
+
-
+
-
+
+
+ 6.
-The An+B microsyntax
+ 6.
+The An+B microsyntax
-2n+0 /* represents all of the even elements in the list */
+
2n+0 /* represents all of the even elements in the list */
even /* same */
4n+1 /* represents the 1st, 5th, 9th, 13th, etc. elements in the list */
- -1n+6 /* represents the first 6 elements of the list */
+
+
-1n+6 /* represents the first 6 elements of the list */
-4n+10 /* represents the 2nd, 6th, and 10th elements of the list */
- 6.1.
-Informal Syntax Description
-6.1.
+Informal Syntax Description
+
+
+ 0n+5 /* represents the 5th element in the list */
+
+
0n+5 /* represents the 5th element in the list */
5 /* same */
- 1
may be omitted from the rule.1n+0 /* represents all elements in the list */
+
+
1n+0 /* represents all elements in the list */
n+0 /* same */
n /* same */
- 2n+0 /* represents every even element in the list */
+
+
2n+0 /* represents every even element in the list */
2n /* same */
- 3n-6
- 3n + -6
- 3n-6
+
+
+ 3n + -6
+
+
+ 3n + 1
+
+
3n + 1
+3n - 2
-n+ 6
+6
- 3 n
+
+
+
3 n
+ 2n
+ 2
- 6.2.
-The
+ <an+b>
type6.2.
+The
-<an+b>
type<an+b> =
- odd | even |
- <integer> |
+
+
<an+b> =
+ odd | even |
+ <integer> |
- <n-dimension> |
- '+'?† n |
- -n |
+ <n-dimension> |
+ '+'?† n |
+ -n |
- <ndashdigit-dimension> |
- '+'?† <ndashdigit-ident> |
- <dashndashdigit-ident> |
+ <ndashdigit-dimension> |
+ '+'?† <ndashdigit-ident> |
+ <dashndashdigit-ident> |
- <n-dimension> <signed-integer> |
- '+'?† n <signed-integer> |
- -n <signed-integer> |
+ <n-dimension> <signed-integer> |
+ '+'?† n <signed-integer> |
+ -n <signed-integer> |
- <ndash-dimension> <signless-integer> |
- '+'?† n- <signless-integer> |
- -n- <signless-integer> |
+ <ndash-dimension> <signless-integer> |
+ '+'?† n- <signless-integer> |
+ -n- <signless-integer> |
- <n-dimension> ['+' | '-'] <signless-integer>
- '+'?† n ['+' | '-'] <signless-integer> |
- -n ['+' | '-'] <signless-integer>
+ <n-dimension> ['+' | '-'] <signless-integer>
+ '+'?† n ['+' | '-'] <signless-integer> |
+ -n ['+' | '-'] <signless-integer>
-
-
-
- <n-dimension>
is a <dimension-token> with its type flag set to "integer", and a unit that is an ASCII case-insensitive match for "n"
- <ndash-dimension>
is a <dimension-token> with its type flag set to "integer", and a unit that is an ASCII case-insensitive match for "n-"
- <ndashdigit-dimension>
is a <dimension-token> with its type flag set to "integer", and a unit that is an ASCII case-insensitive match for "n-*", where "*" is a series of one or more digits
- <ndashdigit-ident>
is an <ident-token> whose value is an ASCII case-insensitive match for "n-*", where "*" is a series of one or more digits
- <dashndashdigit-ident>
is an <ident-token> whose value is an ASCII case-insensitive match for "-n-*", where "*" is a series of one or more digits
- <integer>
is a <number-token> with its type flag set to "integer"
- <signed-integer>
is a <number-token> with its type flag set to "integer", and whose representation starts with "+" or "-"
- <signless-integer>
is a <number-token> with its type flag set to "integer", and whose representation start with a digit
-
+
+
+
+
+ <n-dimension>
is a <dimension-token> with its type flag set to "integer", and a unit that is an ASCII case-insensitive match for "n"
+ <ndash-dimension>
is a <dimension-token> with its type flag set to "integer", and a unit that is an ASCII case-insensitive match for "n-"
+ <ndashdigit-dimension>
is a <dimension-token> with its type flag set to "integer", and a unit that is an ASCII case-insensitive match for "n-*", where "*" is a series of one or more digits
+ <ndashdigit-ident>
is an <ident-token> whose value is an ASCII case-insensitive match for "n-*", where "*" is a series of one or more digits
+ <dashndashdigit-ident>
is an <ident-token> whose value is an ASCII case-insensitive match for "-n-*", where "*" is a series of one or more digits
+ <integer>
is a <number-token> with its type flag set to "integer"
+ <signed-integer>
is a <number-token> with its type flag set to "integer", and whose representation starts with "+" or "-"
+ <signless-integer>
is a <number-token> with its type flag set to "integer", and whose representation start with a digit
+
-
+
-
+
+
+ <integer>
- <integer>
+ <n-dimension>
- '+'? n
- -n
- <n-dimension>
+ '+'? n
+ -n
+ <ndashdigit-dimension>
- '+'? <ndashdigit-ident>
- <ndashdigit-dimension>
+ '+'? <ndashdigit-ident>
+ <dashndashdigit-ident>
- <dashndashdigit-ident>
+ <n-dimension> <signed-integer>
- '+'? n <signed-integer>
- -n <signed-integer>
- <n-dimension> <signed-integer>
+ '+'? n <signed-integer>
+ -n <signed-integer>
+ <ndash-dimension> <signless-integer>
- '+'? n- <signless-integer>
- -n- <signless-integer>
- <ndash-dimension> <signless-integer>
+ '+'? n- <signless-integer>
+ -n- <signless-integer>
+ <n-dimension> ['+' | '-'] <signless-integer>
- '+'? n ['+' | '-'] <signless-integer>
- -n ['+' | '-'] <signless-integer>
- <n-dimension> ['+' | '-'] <signless-integer>
+ '+'? n ['+' | '-'] <signless-integer>
+ -n ['+' | '-'] <signless-integer>
+ '-'
was provided between the two, B is instead the negation of the integer’s value.
- 7.
-The Unicode-Range microsyntax
+ 7.
+The Unicode-Range microsyntax
-
-
-
+
+
+ 7.1.
-The <urange> type
-7.1.
+The <urange> type
+
+
+ <urange> =
- u '+' <ident-token> '?'* |
- u <dimension-token> '?'* |
- u <number-token> '?'* |
- u <number-token> <dimension-token> |
- u <number-token> <number-token> |
- u '+' '?'+
+
<urange> =
+ u '+' <ident-token> '?'* |
+ u <dimension-token> '?'* |
+ u <number-token> '?'* |
+ u <number-token> <dimension-token> |
+ u <number-token> <number-token> |
+ u '+' '?'+
-
+
+
+
-
-
+
+
-
+
+
+
-7.
-
8.
-Defining Grammars for Rules and Other Values
-8.
+Defining Grammars for Rules and Other Values
+
+
+ <foo>
refers to the "foo" grammar term,
+
+ <foo>
refers to the "foo" grammar term,
assumed to be defined elsewhere.
- Substituting the <foo>
for its definition results in a semantically identical grammar.<foo>
for its definition results in a semantically identical grammar.
+
-
-
+
+ :
), <comma-token> (written as ,
), <semicolon-token> (written as ;
), <(-token>, <)-token>, <{-token>, and <}-token>s.
-
+
+
-:
), <comma-token> (written as ,
), <semicolon-token> (written as ;
), <(-token>, <)-token>, <{-token>, and <}-token>s.
+ (
or starts with @
,
- such a tokens is not a <function-token> or an <at-keyword-token>
+
+ (
or starts with @
,
+ such a tokens is not a <function-token> or an <at-keyword-token>
and does not match corresponding grammar definitions.
-'+'
.
- Similarly, the <[-token> and <]-token>s must be written in single quotes,
+'+'
.
+ Similarly, the <[-token> and <]-token>s must be written in single quotes,
as they’re used by the syntax of the grammar itself to group clauses.
- <whitespace-token> is never indicated in the grammar;
- <whitespace-token>s are allowed before, after, and between any two tokens,
+ <whitespace-token> is never indicated in the grammar;
+ <whitespace-token>s are allowed before, after, and between any two tokens,
unless explicitly specified otherwise in prose definitions.
(For example, if the prelude of a rule is a selector,
whitespace is significant.)translateX( <translation-value> )
+
-translateX( <translation-value> )
-.foo { transform: translate(50px
-.foo { transform: translate(50px
+
+
+
+ 8.1.
-Defining Block Contents: the <declaration-list>, <rule-list>, and <stylesheet> productions
+ 8.1.
+Defining Block Contents: the <declaration-list>, <rule-list>, and <stylesheet> productions
-@font-face { <declaration-list> }
-@font-face { <declaration-list> }
+
+
+
+ @keyframes <keyframes-name> { <rule-list> }
+
+
+ @keyframes <keyframes-name> { <rule-list> }
- !important
is automatically invalid on any descriptors.
If the rule accepts properties,
the spec for the rule must define whether the properties interact with the cascade,
@@ -4432,76 +7339,98 @@ !important
are automatically invalid;
otherwise using !important
is valid and has its usual effect on the cascade origin of the property.
- <keyframe-rule> = <keyframe-selector> { <declaration-list> }
-<keyframe-rule> = <keyframe-selector> { <declaration-list> }
+
+
+
+ @media <media-query-list> { <stylesheet> }
-@media <media-query-list> { <stylesheet> }
+
+
+
+ 9.
+CSS stylesheets
-9.
-CSS stylesheets
-9.1.
-Style rules
-9.1.
+Style rules
+
+
+ 9.1.
The validity of the style rule’s contents have no effect on the validity of the style rule itself.
Unless otherwise specified, property names are ASCII case-insensitive.
-
9.2.
+The @charset Rule
-9.2.
-The @charset Rule
-@charset = @charset <string> ;
+ @charset = @charset <string> ;
+
+
+ 9.2
-
10.
-Serialization
-10.
+Serialization
+
+
+
-
+
+
-
- /**/
) must be inserted.
(Preserved comments may be reinserted even if the following tables don’t require a comment between two tokens.)(
",
- which represents a (-token.
-
-
-
-
- ident
- function
- url
- bad url
- -
- number
- percentage
- dimension
- CDC
- (
- ?
-
- ident
- ✗ ✗ ✗ ✗ ✗ ✗ ✗ ✗ ✗ ✗
-
- at-keyword
- ✗ ✗ ✗ ✗ ✗ ✗ ✗ ✗ ✗
-
- hash
- ✗ ✗ ✗ ✗ ✗ ✗ ✗ ✗ ✗
-
- dimension
- ✗ ✗ ✗ ✗ ✗ ✗ ✗ ✗ ✗
-
- #
- ✗ ✗ ✗ ✗ ✗ ✗ ✗ ✗
-
- -
- ✗ ✗ ✗ ✗ ✗ ✗ ✗
-
- number
- ✗ ✗ ✗ ✗ ✗ ✗ ✗
-
- @
- ✗ ✗ ✗ ✗ ✗
-
- .
- ✗ ✗ ✗
-
- +
- ✗ ✗ ✗
-
-
-
-
- = | *
-
- $
- ✗
-
- *
- ✗
-
- ^
- ✗
-
- ~
- ✗
-
- |
- ✗ ✗
-
- /
- ✗
- 10.1.
-Serializing <an+b>
-
-(
",
+ which represents a (-token.
+
+
+
+
+
+
+
+
+
+
+
+ ident
+
+ function
+
+ url
+
+ bad url
+
+ -
+
+ number
+
+ percentage
+
+ dimension
+
+ CDC
+
+ (
+
+ ?
+
+
+
+
+ ident
+
+ ✗
+ ✗
+ ✗
+ ✗
+ ✗
+ ✗
+ ✗
+ ✗
+ ✗
+ ✗
+
+
+
+
+
+ at-keyword
+
+ ✗
+ ✗
+ ✗
+ ✗
+ ✗
+ ✗
+ ✗
+ ✗
+ ✗
+
+
+
+
+
+
+ hash
+
+ ✗
+ ✗
+ ✗
+ ✗
+ ✗
+ ✗
+ ✗
+ ✗
+ ✗
+
+
+
+
+
+
+ dimension
+
+ ✗
+ ✗
+ ✗
+ ✗
+ ✗
+ ✗
+ ✗
+ ✗
+ ✗
+
+
+
+
+
+
+ #
+
+ ✗
+ ✗
+ ✗
+ ✗
+ ✗
+ ✗
+ ✗
+ ✗
+
+
+
+
+
+
+
+ -
+
+ ✗
+ ✗
+ ✗
+ ✗
+
+ ✗
+ ✗
+ ✗
+
+
+
+
+
+
+
+ number
+
+ ✗
+ ✗
+ ✗
+ ✗
+
+ ✗
+ ✗
+ ✗
+
+
+
+
+
+
+
+ @
+
+ ✗
+ ✗
+ ✗
+ ✗
+ ✗
+
+
+
+
+
+
+
+
+
+
+ .
+
+
+
+
+
+
+ ✗
+ ✗
+ ✗
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ ✗
+ ✗
+ ✗
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ =
+ |
+ *
+
+
+
+
+ $
+
+ ✗
+
+
+
+
+
+
+ *
+
+ ✗
+
+
+
+
+
+
+ ^
+
+ ✗
+
+
+
+
+
+
+ ~
+
+ ✗
+
+
+
+
+
+
+ |
+
+ ✗
+ ✗
+
+
+
+
+
+
+ /
+
+
+
+ ✗
+
+ 10.1.
+Serializing <an+b>
+
+
+
-
+
+
+
+
+
+ 11.
+Changes
-11.
-Changes
+ 11.1.
+Changes from the 20 February 2014 Candidate Recommendation
-11.1.
-Changes from the 20 February 2014 Candidate Recommendation
+
-
+
-
+
+
+
+
-11.2.
-Changes from the 5 November 2013 Last Call Working Draft
+
-
+
+ 11.2.
+Changes from the 5 November 2013 Last Call Working Draft
+
+
+
+
+
-@charset
byte sequence to 1024 bytes.
- This aligns with what HTML does for <meta charset>
+ This aligns with what HTML does for <meta charset>
and makes sure the size of the sequence is bounded.
This only makes a difference with leading or trailing whitespace
in the encoding label:
-@charset " (lots of whitespace) utf-8";
- 11.3.
-Changes from the 19 September 2013 Working Draft
+ @charset " (lots of whitespace) utf-8";
+
+
+ 11.3.
+Changes from the 19 September 2013 Working Draft
-
-
-
+
+
+ 11.4.
-Changes from CSS 2.1 and Selectors Level 3
-11.4.
+Changes from CSS 2.1 and Selectors Level 3
+
+
+
-
-
+
+
+
-
-
+
+
+
-
-
+
+
+
+
-
+
-
+
+
+
-
+
-
+
+
+
+
+
-
+ (when they appear as part of the unit of a <dimension-token> or <ident-token>).
+
+
+
-
-Acknowledgments
+
+Acknowledgments
-
Marc O’Morain,
Raffaello Giulietti,
Simon Pieter,
+ Tyler Karaszewski,
and Zack Weinberg.
-
-Conformance
-
-Document conventions
+
+Conformance
+
+
+Document conventions
+
+
However, for readability, these words do not appear in all uppercase
letters in this specification.
+
class="example"
,
like this:
- class="note"
, like this:
- <strong class="advisement">
, like
+ set apart from other normative text with <strong class="advisement">
, like
this:
-
+
UAs MUST provide an accessible alternative.
-
-Conformance classes
+
+Conformance classes
+
-
+
does not make the UA non-conformant. (For example, a UA is not
required to render color on a monochrome monitor.)
+
-Partial implementations
+
+
+Partial implementations
+
(as unsupported values must be), CSS requires that the entire declaration
be ignored.
-
-Experimental implementations
+
+Experimental implementations
+
+
in the draft.
-
-Non-experimental implementations
+
+Non-experimental implementations
+
+
submitted to W3C are subject to review and correction by the CSS
Working Group.
+
References
Normative References
Informative References
Index
\ No newline at end of file
+
+ References
+ Normative References
+
+
+ Informative References
+
+
+ Index
+
+
+
\ No newline at end of file