22.12.2013 Views

W3C CSS2 Cascading Style Sheets, level 2 - instructional media + ...

W3C CSS2 Cascading Style Sheets, level 2 - instructional media + ...

W3C CSS2 Cascading Style Sheets, level 2 - instructional media + ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

4.1.6 Blocks<br />

A block starts with a left curly brace ({) and ends with the matching right curly<br />

brace (}). In between there may be any characters, except that parentheses (( )),<br />

brackets ([ ]) and braces ({ }) must always occur in matching pairs and may be<br />

nested. Single (’) and double quotes (") must also occur in matching pairs, and<br />

characters between them are parsed as a string. See Tokenization [p. 35] above<br />

for the definition of a string.<br />

Illegal example(s):<br />

Here is an example of a block. Note that the right brace between the double<br />

quotes does not match the opening brace of the block, and that the second<br />

single quote is an escaped character [p. 38] , and thus doesn’t match the first<br />

single quote:<br />

{ causta: "}" + ({7} * ’\’’) }<br />

Note that the above rule is not valid <strong>CSS2</strong>, but it is still a block as defined<br />

above.<br />

4.1.7 Rule sets, declaration blocks, and selectors<br />

A rule set (also called "rule") consists of a selector followed by a declaration<br />

block.<br />

A declaration-block (also called a {}-block in the following text) starts with a left<br />

curly brace ({) and ends with the matching right curly brace (}). In between there<br />

must be a list of zero or more semicolon-separated (;) declarations.<br />

The selector (see also the section on selectors [p. 53] ) consists of everything<br />

up to (but not including) the first left curly brace ({). A selector always goes<br />

together with a {}-block. When a user agent can’t parse the selector (i.e., it is not<br />

valid <strong>CSS2</strong>), it must ignore [p. 42] the {}-block as well.<br />

<strong>CSS2</strong> gives a special meaning to the comma (,) in selectors. However, since it<br />

is not known if the comma may acquire other meanings in future versions of<br />

CSS, the whole statement should be ignored [p. 42] if there is an error anywhere<br />

in the selector, even though the rest of the selector may look reasonable in<br />

<strong>CSS2</strong>.<br />

Illegal example(s):<br />

For example, since the "&" is not a valid token in a <strong>CSS2</strong> selector, a <strong>CSS2</strong><br />

user agent must ignore [p. 42] the whole second line, and not set the color of H3<br />

to red:<br />

H1, H2 {color: green }<br />

H3, H4 & H5 {color: red }<br />

H6 {color: black }<br />

Example(s):<br />

Here is a more complex example. The first two pairs of curly braces are inside<br />

a string, and do not mark the end of the selector. This is a valid <strong>CSS2</strong> statement.<br />

40

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!