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.

5.2 Selector syntax<br />

A simple selector is either a type selector [p. 56] or universal selector [p. 55]<br />

followed im<strong>media</strong>tely by zero or more attribute selectors [p. 57] , ID selectors<br />

[p. 60] , or pseudo-classes [p. 61] , in any order. The simple selector matches if<br />

all of its components match.<br />

A selector is a chain of one or more simple selectors separated by combinators.<br />

Combinators are: whitespace, ">", and "+". Whitespace may appear<br />

between a combinator and the simple selectors around it.<br />

The elements of the document tree that match a selector are called subjects of<br />

the selector. A selector consisting of a single simple selector matches any<br />

element satisfying its requirements. Prepending a simple selector and combinator<br />

to a chain imposes additional matching constraints, so the subjects of a selector<br />

are always a subset of the elements matching the rightmost simple selector.<br />

One pseudo-element [p. 61] may be appended to the last simple selector in a<br />

chain, in which case the style information applies to a subpart of each subject.<br />

5.2.1 Grouping<br />

When several selectors share the same declarations, they may be grouped into a<br />

comma-separated list.<br />

Example(s):<br />

In this example, we condense three rules with identical declarations into one.<br />

Thus,<br />

H1 { font-family: sans-serif }<br />

H2 { font-family: sans-serif }<br />

H3 { font-family: sans-serif }<br />

is equivalent to:<br />

H1, H2, H3 { font-family: sans-serif }<br />

CSS offers other "shorthand" mechanisms as well, including multiple declarations<br />

[p. 41] and shorthand properties [p. 16] .<br />

5.3 Universal selector<br />

The universal selector, written "*", matches the name of any element type. It<br />

matches any single element in the document tree. [p. 30]<br />

If the universal selector is not the only component of a simple selector [p. 55] ,<br />

the "*" may be omitted. For example:<br />

*[LANG=fr] and [LANG=fr] are equivalent.<br />

*.warning and .warning are equivalent.<br />

*#myid and #myid are equivalent.<br />

55

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

Saved successfully!

Ooh no, something went wrong!