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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

P[example="public class foo\<br />

{\<br />

private int x;\<br />

\<br />

foo(int x) {\<br />

this.x = x;\<br />

}\<br />

\<br />

}"] { color: red }<br />

4.1.8 Declarations and properties<br />

A declaration is either empty or consists of a property, followed by a colon (:),<br />

followed by a value. Around each of these there may be whitespace [p. 37] .<br />

Because of the way selectors work, multiple declarations for the same selector<br />

may be organized into semicolon (;) separated groups.<br />

Example(s):<br />

Thus, the following rules:<br />

H1 { font-weight: bold }<br />

H1 { font-size: 12pt }<br />

H1 { line-height: 14pt }<br />

H1 { font-family: Helvetica }<br />

H1 { font-variant: normal }<br />

H1 { font-style: normal }<br />

are equivalent to:<br />

H1 {<br />

font-weight: bold;<br />

font-size: 12pt;<br />

line-height: 14pt;<br />

font-family: Helvetica;<br />

font-variant: normal;<br />

font-style: normal<br />

}<br />

A property is an identifier [p. 38] . Any character may occur in the value, but<br />

parentheses ("( )"), brackets ("[ ]"), braces ("{ }"), single quotes (’) and double<br />

quotes (") must come in matching pairs, and semicolons not in strings must be<br />

escaped [p. 38] . Parentheses, brackets, and braces may be nested. Inside the<br />

quotes, characters are parsed as a string.<br />

The syntax of values is specified separately for each property, but in any case,<br />

values are built from identifiers, strings, numbers, lengths, percentages, URIs,<br />

colors, angles, times, and frequencies.<br />

A user agent must ignore [p. 42] a declaration with an invalid property name or<br />

an invalid value. Every <strong>CSS2</strong> property has its own syntactic and semantic restrictions<br />

on the values it accepts.<br />

Illegal example(s):<br />

For example, assume a <strong>CSS2</strong> parser encounters this style sheet:<br />

H1 { color: red; font-style: 12pt } /* Invalid value: 12pt */<br />

P { color: blue; font-vendor: any; /* Invalid prop.: font-vendor */<br />

font-variant: small-caps }<br />

EM EM { font-style: normal }<br />

41

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

Saved successfully!

Ooh no, something went wrong!