Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(278)

Side by Side Diff: chrome/test/data/dromaeo/tests/jslib-style-prototype.html

Issue 269054: Importing dromaeo performance tests to src/chrome/test/data.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <html>
2 <head>
3 <script src="../htmlrunner.js"></script>
4 <script src="../lib/prototype.js"></script>
5 <script>
6 window.onload = function(){
7 startTest("jslib-style-prototype", '');
8
9 // Try to force real results
10 var ret, tmp, div;
11
12 var html = document.body.innerHTML;
13
14 prep(function(){
15 div = $$("div");
16 var tmp = document.createElement("div");
17 tmp.innerHTML = html;
18 document.body.appendChild( tmp );
19 });
20
21 test("Prototype - getStyle()", function(){
22 for ( var i = 0; i < 10; i++ )
23 ret = div.invoke("getStyle","color");
24 });
25
26 test("Prototype - setStyle()", function(){
27 for ( var i = 0; i < 10; i++ )
28 div.invoke("setStyle","color","red");
29 });
30
31 test("Prototype - getHeight()", function(){
32 for ( var i = 0; i < 10; i++ )
33 ret = div.invoke("getHeight");
34 });
35
36 test("Prototype - getWidth()", function(){
37 for ( var i = 0; i < 10; i++ )
38 ret = div.invoke("getWidth");
39 });
40
41 test("Prototype - visible()", function(){
42 for ( var i = 0; i < 10; i++ )
43 ret = div.invoke("visible");
44 });
45
46 test("Prototype - .show()", function(){
47 for ( var i = 0; i < 10; i++ )
48 div.invoke("show");
49 });
50
51 test("Prototype - .hide()", function(){
52 for ( var i = 0; i < 10; i++ )
53 div.invoke("hide");
54 });
55
56 test("Prototype - .toggle() x10", function(){
57 for ( var i = 0; i < 10; i++ )
58 div.invoke("toggle");
59 });
60
61 endTest();
62 };
63 </script>
64 </head>
65 <body>
66 <div class="head">
67 <p><a href="http://www.w3.org/"><img height=48 alt=W3C src="http://www.w3.org /Icons/w3c_home" width=72></a>
68
69 <h1 id="title">Selectors</h1>
70
71 <h2>W3C Working Draft 15 December 2005</h2>
72
73 <dl>
74
75 <dt>This version:
76
77 <dd><a href="http://www.w3.org/TR/2005/WD-css3-selectors-20051215">
78 http://www.w3.org/TR/2005/WD-css3-selectors-20051215</a>
79
80 <dt>Latest version:
81
82 <dd><a href="http://www.w3.org/TR/css3-selectors">
83 http://www.w3.org/TR/css3-selectors</a>
84
85 <dt>Previous version:
86
87 <dd><a href="http://www.w3.org/TR/2001/CR-css3-selectors-20011113">
88 http://www.w3.org/TR/2001/CR-css3-selectors-20011113</a>
89
90 <dt><a name=editors-list></a>Editors:
91
92 <dd class="vcard"><span class="fn">Daniel Glazman</span> (Invited Expert)</d d>
93
94 <dd class="vcard"><a lang="tr" class="url fn" href="http://www.tantek.com/"> Tantek &Ccedil;elik</a> (Invited Expert)
95
96 <dd class="vcard"><a href="mailto:ian@hixie.ch" class="url fn">Ian Hickson</ a> (<span
97 class="company"><a href="http://www.google.com/">Google</a></span>)
98
99 <dd class="vcard"><span class="fn">Peter Linss</span> (former editor, <span class="company"><a
100 href="http://www.netscape.com/">Netscape/AOL</a></span>)
101
102 <dd class="vcard"><span class="fn">John Williams</span> (former editor, <spa n class="company"><a
103 href="http://www.quark.com/">Quark, Inc.</a></span>)
104
105 </dl>
106
107 <p class="copyright"><a
108 href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">
109 Copyright</a> &copy; 2005 <a href="http://www.w3.org/"><abbr
110 title="World Wide Web Consortium">W3C</abbr></a><sup>&reg;</sup>
111 (<a href="http://www.csail.mit.edu/"><abbr title="Massachusetts
112 Institute of Technology">MIT</abbr></a>, <a
113 href="http://www.ercim.org/"><acronym title="European Research
114 Consortium for Informatics and Mathematics">ERCIM</acronym></a>, <a
115 href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C
116 <a
117 href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liabili ty</a>,
118 <a
119 href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark </a>,
120 <a
121 href="http://www.w3.org/Consortium/Legal/copyright-documents">document
122 use</a> rules apply.
123
124 <hr title="Separator for header">
125
126 </div>
127
128 <h2><a name=abstract></a>Abstract</h2>
129
130 <p><em>Selectors</em> are patterns that match against elements in a
131 tree. Selectors have been optimized for use with HTML and XML, and
132 are designed to be usable in performance-critical code.</p>
133
134 <p><acronym title="Cascading Style Sheets">CSS</acronym> (Cascading
135 Style Sheets) is a language for describing the rendering of <acronym
136 title="Hypertext Markup Language">HTML</acronym> and <acronym
137 title="Extensible Markup Language">XML</acronym> documents on
138 screen, on paper, in speech, etc. CSS uses Selectors for binding
139 style properties to elements in the document. This document
140 describes extensions to the selectors defined in CSS level 2. These
141 extended selectors will be used by CSS level 3.
142
143 <p>Selectors define the following function:</p>
144
145 <pre>expression &#x2217; element &rarr; boolean</pre>
146
147 <p>That is, given an element and a selector, this specification
148 defines whether that element matches the selector.</p>
149
150 <p>These expressions can also be used, for instance, to select a set
151 of elements, or a single element from a set of elements, by
152 evaluating the expression across all the elements in a
153 subtree. <acronym title="Simple Tree Transformation
154 Sheets">STTS</acronym> (Simple Tree Transformation Sheets), a
155 language for transforming XML trees, uses this mechanism. <a href="#refsSTTS"> [STTS]</a></p>
156
157 <h2><a name=status></a>Status of this document</h2>
158
159 <p><em>This section describes the status of this document at the
160 time of its publication. Other documents may supersede this
161 document. A list of current W3C publications and the latest revision
162 of this technical report can be found in the <a
163 href="http://www.w3.org/TR/">W3C technical reports index at
164 http://www.w3.org/TR/.</a></em></p>
165
166 <p>This document describes the selectors that already exist in <a
167 href="#refsCSS1"><abbr title="CSS level 1">CSS1</abbr></a> and <a
168 href="#refsCSS21"><abbr title="CSS level 2">CSS2</abbr></a>, and
169 also proposes new selectors for <abbr title="CSS level
170 3">CSS3</abbr> and other languages that may need them.</p>
171
172 <p>The CSS Working Group doesn't expect that all implementations of
173 CSS3 will have to implement all selectors. Instead, there will
174 probably be a small number of variants of CSS3, called profiles. For
175 example, it may be that only a profile for interactive user agents
176 will include all of the selectors.</p>
177
178 <p>This specification is a last call working draft for the the <a
179 href="http://www.w3.org/Style/CSS/members">CSS Working Group</a>
180 (<a href="/Style/">Style Activity</a>). This
181 document is a revision of the <a
182 href="http://www.w3.org/TR/2001/CR-css3-selectors-20011113/">Candidate
183 Recommendation dated 2001 November 13</a>, and has incorporated
184 implementation feedback received in the past few years. It is
185 expected that this last call will proceed straight to Proposed
186 Recommendation stage since it is believed that interoperability will
187 be demonstrable.</p>
188
189 <p>All persons are encouraged to review and implement this
190 specification and return comments to the (<a
191 href="http://lists.w3.org/Archives/Public/www-style/">archived</a>)
192 public mailing list <a
193 href="http://www.w3.org/Mail/Lists.html#www-style">www-style</a>
194 (see <a href="http://www.w3.org/Mail/Request">instructions</a>). W3C
195 Members can also send comments directly to the CSS Working
196 Group.
197 The deadline for comments is 14 January 2006.</p>
198
199 <p>This is still a draft document and may be updated, replaced, or
200 obsoleted by other documents at any time. It is inappropriate to
201 cite a W3C Working Draft as other than &quot;work in progress&quot;.
202
203 <p>This document may be available in <a
204 href="http://www.w3.org/Style/css3-selectors-updates/translations">translation </a>.
205 The English version of this specification is the only normative
206 version.
207
208 <div class="subtoc">
209
210 <h2 id="test10"><a name=contents>Table of contents</a></h2>
211
212 <ul class="toc">
213 <li class="tocline2"><a href="#context">1. Introduction</a>
214 <ul>
215 <li><a href="#dependencies">1.1. Dependencies</a> </li>
216 <li><a href="#terminology">1.2. Terminology</a> </li>
217 <li><a href="#changesFromCSS2">1.3. Changes from CSS2</a> </li>
218 </ul>
219 <li class="tocline2"><a href="#selectors">2. Selectors</a>
220 <li class="tocline2"><a href="#casesens">3. Case sensitivity</a>
221 <li class="tocline2"><a href="#selector-syntax">4. Selector syntax</a>
222 <li class="tocline2"><a href="#grouping">5. Groups of selectors</a>
223 <li class="tocline2"><a href="#simple-selectors">6. Simple selectors</a>
224 <ul class="toc">
225 <li class="tocline3"><a href="#type-selectors">6.1. Type selectors</a>
226 <ul class="toc">
227 <li class="tocline4"><a href="#typenmsp">6.1.1. Type selectors and names paces</a></li>
228 </ul>
229 <li class="tocline3"><a href="#universal-selector">6.2. Universal selector </a>
230 <ul>
231 <li><a href="#univnmsp">6.2.1. Universal selector and namespaces</a></li >
232 </ul>
233 <li class="tocline3"><a href="#attribute-selectors">6.3. Attribute selecto rs</a>
234 <ul class="toc">
235 <li class="tocline4"><a href="#attribute-representation">6.3.1. Represen tation of attributes and attributes values</a>
236 <li><a href="#attribute-substrings">6.3.2. Substring matching attribute selectors</a>
237 <li class="tocline4"><a href="#attrnmsp">6.3.3. Attribute selectors and namespaces</a>
238 <li class="tocline4"><a href="#def-values">6.3.4. Default attribute valu es in DTDs</a></li>
239 </ul>
240 <li class="tocline3"><a href="#class-html">6.4. Class selectors</a>
241 <li class="tocline3"><a href="#id-selectors">6.5. ID selectors</a>
242 <li class="tocline3"><a href="#pseudo-classes">6.6. Pseudo-classes</a>
243 <ul class="toc">
244 <li class="tocline4"><a href="#dynamic-pseudos">6.6.1. Dynamic pseudo-cl asses</a>
245 <li class="tocline4"><a href="#target-pseudo">6.6.2. The :target pseudo- class</a>
246 <li class="tocline4"><a href="#lang-pseudo">6.6.3. The :lang() pseudo-cl ass</a>
247 <li class="tocline4"><a href="#UIstates">6.6.4. UI element states pseudo -classes</a>
248 <li class="tocline4"><a href="#structural-pseudos">6.6.5. Structural pse udo-classes</a>
249 <ul>
250 <li><a href="#root-pseudo">:root pseudo-class</a>
251 <li><a href="#nth-child-pseudo">:nth-child() pseudo-class</a>
252 <li><a href="#nth-last-child-pseudo">:nth-last-child()</a>
253 <li><a href="#nth-of-type-pseudo">:nth-of-type() pseudo-class</a>
254 <li><a href="#nth-last-of-type-pseudo">:nth-last-of-type()</a>
255 <li><a href="#first-child-pseudo">:first-child pseudo-class</a>
256 <li><a href="#last-child-pseudo">:last-child pseudo-class</a>
257 <li><a href="#first-of-type-pseudo">:first-of-type pseudo-class</a>
258 <li><a href="#last-of-type-pseudo">:last-of-type pseudo-class</a>
259 <li><a href="#only-child-pseudo">:only-child pseudo-class</a>
260 <li><a href="#only-of-type-pseudo">:only-of-type pseudo-class</a>
261 <li><a href="#empty-pseudo">:empty pseudo-class</a></li>
262 </ul>
263 <li class="tocline4"><a href="#negation">6.6.7. The negation pseudo-clas s</a></li>
264 </ul>
265 </li>
266 </ul>
267 <li><a href="#pseudo-elements">7. Pseudo-elements</a>
268 <ul>
269 <li><a href="#first-line">7.1. The ::first-line pseudo-element</a>
270 <li><a href="#first-letter">7.2. The ::first-letter pseudo-element</a>
271 <li><a href="#UIfragments">7.3. The ::selection pseudo-element</a>
272 <li><a href="#gen-content">7.4. The ::before and ::after pseudo-elements</ a></li>
273 </ul>
274 <li class="tocline2"><a href="#combinators">8. Combinators</a>
275 <ul class="toc">
276 <li class="tocline3"><a href="#descendant-combinators">8.1. Descendant com binators</a>
277 <li class="tocline3"><a href="#child-combinators">8.2. Child combinators</ a>
278 <li class="tocline3"><a href="#sibling-combinators">8.3. Sibling combinato rs</a>
279 <ul class="toc">
280 <li class="tocline4"><a href="#adjacent-sibling-combinators">8.3.1. Adja cent sibling combinator</a>
281 <li class="tocline4"><a href="#general-sibling-combinators">8.3.2. Gener al sibling combinator</a></li>
282 </ul>
283 </li>
284 </ul>
285 <li class="tocline2"><a href="#specificity">9. Calculating a selector's spec ificity</a>
286 <li class="tocline2"><a href="#w3cselgrammar">10. The grammar of Selectors</ a>
287 <ul class="toc">
288 <li class="tocline3"><a href="#grammar">10.1. Grammar</a>
289 <li class="tocline3"><a href="#lex">10.2. Lexical scanner</a></li>
290 </ul>
291 <li class="tocline2"><a href="#downlevel">11. Namespaces and down-level clie nts</a>
292 <li class="tocline2"><a href="#profiling">12. Profiles</a>
293 <li><a href="#Conformance">13. Conformance and requirements</a>
294 <li><a href="#Tests">14. Tests</a>
295 <li><a href="#ACKS">15. Acknowledgements</a>
296 <li class="tocline2"><a href="#references">16. References</a>
297 </ul>
298
299 </div>
300
301 <h2><a name=context>1. Introduction</a></h2>
302
303 <h3><a name=dependencies></a>1.1. Dependencies</h3>
304
305 <p>Some features of this specification are specific to CSS, or have
306 particular limitations or rules specific to CSS. In this
307 specification, these have been described in terms of CSS2.1. <a
308 href="#refsCSS21">[CSS21]</a></p>
309
310 <h3><a name=terminology></a>1.2. Terminology</h3>
311
312 <p>All of the text of this specification is normative except
313 examples, notes, and sections explicitly marked as
314 non-normative.</p>
315
316 <h3><a name=changesFromCSS2></a>1.3. Changes from CSS2</h3>
317
318 <p><em>This section is non-normative.</em></p>
319
320 <p>The main differences between the selectors in CSS2 and those in
321 Selectors are:
322
323 <ul>
324
325 <li>the list of basic definitions (selector, group of selectors,
326 simple selector, etc.) has been changed; in particular, what was
327 referred to in CSS2 as a simple selector is now called a sequence
328 of simple selectors, and the term "simple selector" is now used for
329 the components of this sequence</li>
330
331 <li>an optional namespace component is now allowed in type element
332 selectors, the universal selector and attribute selectors</li>
333
334 <li>a <a href="#general-sibling-combinators">new combinator</a> has been intr oduced</li>
335
336 <li>new simple selectors including substring matching attribute
337 selectors, and new pseudo-classes</li>
338
339 <li>new pseudo-elements, and introduction of the "::" convention
340 for pseudo-elements</li>
341
342 <li>the grammar has been rewritten</li>
343
344 <li>profiles to be added to specifications integrating Selectors
345 and defining the set of selectors which is actually supported by
346 each specification</li>
347
348 <li>Selectors are now a CSS3 Module and an independent
349 specification; other specifications can now refer to this document
350 independently of CSS</li>
351
352 <li>the specification now has its own test suite</li>
353
354 </ul>
355
356 <h2><a name=selectors></a>2. Selectors</h2>
357
358 <p><em>This section is non-normative, as it merely summarizes the
359 following sections.</em></p>
360
361 <p>A Selector represents a structure. This structure can be used as a
362 condition (e.g. in a CSS rule) that determines which elements a
363 selector matches in the document tree, or as a flat description of the
364 HTML or XML fragment corresponding to that structure.</p>
365
366 <p>Selectors may range from simple element names to rich contextual
367 representations.</p>
368
369 <p>The following table summarizes the Selector syntax:</p>
370
371 <table class="selectorsReview">
372 <thead>
373 <tr>
374 <th class="pattern">Pattern</th>
375 <th class="meaning">Meaning</th>
376 <th class="described">Described in section</th>
377 <th class="origin">First defined in CSS level</th></tr>
378 <tbody>
379 <tr>
380 <td class="pattern">*</td>
381 <td class="meaning">any element</td>
382 <td class="described"><a
383 href="#universal-selector">Universal
384 selector</a></td>
385 <td class="origin">2</td></tr>
386 <tr>
387 <td class="pattern">E</td>
388 <td class="meaning">an element of type E</td>
389 <td class="described"><a
390 href="#type-selectors">Type selector</a></td>
391 <td class="origin">1</td></tr>
392 <tr>
393 <td class="pattern">E[foo]</td>
394 <td class="meaning">an E element with a "foo" attribute</td>
395 <td class="described"><a
396 href="#attribute-selectors">Attribute
397 selectors</a></td>
398 <td class="origin">2</td></tr>
399 <tr>
400 <td class="pattern">E[foo="bar"]</td>
401 <td class="meaning">an E element whose "foo" attribute value is exactly
402 equal to "bar"</td>
403 <td class="described"><a
404 href="#attribute-selectors">Attribute
405 selectors</a></td>
406 <td class="origin">2</td></tr>
407 <tr>
408 <td class="pattern">E[foo~="bar"]</td>
409 <td class="meaning">an E element whose "foo" attribute value is a list of
410 space-separated values, one of which is exactly equal to "bar"</td>
411 <td class="described"><a
412 href="#attribute-selectors">Attribute
413 selectors</a></td>
414 <td class="origin">2</td></tr>
415 <tr>
416 <td class="pattern">E[foo^="bar"]</td>
417 <td class="meaning">an E element whose "foo" attribute value begins exactly
418 with the string "bar"</td>
419 <td class="described"><a
420 href="#attribute-selectors">Attribute
421 selectors</a></td>
422 <td class="origin">3</td></tr>
423 <tr>
424 <td class="pattern">E[foo$="bar"]</td>
425 <td class="meaning">an E element whose "foo" attribute value ends exactly
426 with the string "bar"</td>
427 <td class="described"><a
428 href="#attribute-selectors">Attribute
429 selectors</a></td>
430 <td class="origin">3</td></tr>
431 <tr>
432 <td class="pattern">E[foo*="bar"]</td>
433 <td class="meaning">an E element whose "foo" attribute value contains the
434 substring "bar"</td>
435 <td class="described"><a
436 href="#attribute-selectors">Attribute
437 selectors</a></td>
438 <td class="origin">3</td></tr>
439 <tr>
440 <td class="pattern">E[hreflang|="en"]</td>
441 <td class="meaning">an E element whose "hreflang" attribute has a hyphen-sep arated
442 list of values beginning (from the left) with "en"</td>
443 <td class="described"><a
444 href="#attribute-selectors">Attribute
445 selectors</a></td>
446 <td class="origin">2</td></tr>
447 <tr>
448 <td class="pattern">E:root</td>
449 <td class="meaning">an E element, root of the document</td>
450 <td class="described"><a
451 href="#structural-pseudos">Structural
452 pseudo-classes</a></td>
453 <td class="origin">3</td></tr>
454 <tr>
455 <td class="pattern">E:nth-child(n)</td>
456 <td class="meaning">an E element, the n-th child of its parent</td>
457 <td class="described"><a
458 href="#structural-pseudos">Structural
459 pseudo-classes</a></td>
460 <td class="origin">3</td></tr>
461 <tr>
462 <td class="pattern">E:nth-last-child(n)</td>
463 <td class="meaning">an E element, the n-th child of its parent, counting
464 from the last one</td>
465 <td class="described"><a
466 href="#structural-pseudos">Structural
467 pseudo-classes</a></td>
468 <td class="origin">3</td></tr>
469 <tr>
470 <td class="pattern">E:nth-of-type(n)</td>
471 <td class="meaning">an E element, the n-th sibling of its type</td>
472 <td class="described"><a
473 href="#structural-pseudos">Structural
474 pseudo-classes</a></td>
475 <td class="origin">3</td></tr>
476 <tr>
477 <td class="pattern">E:nth-last-of-type(n)</td>
478 <td class="meaning">an E element, the n-th sibling of its type, counting
479 from the last one</td>
480 <td class="described"><a
481 href="#structural-pseudos">Structural
482 pseudo-classes</a></td>
483 <td class="origin">3</td></tr>
484 <tr>
485 <td class="pattern">E:first-child</td>
486 <td class="meaning">an E element, first child of its parent</td>
487 <td class="described"><a
488 href="#structural-pseudos">Structural
489 pseudo-classes</a></td>
490 <td class="origin">2</td></tr>
491 <tr>
492 <td class="pattern">E:last-child</td>
493 <td class="meaning">an E element, last child of its parent</td>
494 <td class="described"><a
495 href="#structural-pseudos">Structural
496 pseudo-classes</a></td>
497 <td class="origin">3</td></tr>
498 <tr>
499 <td class="pattern">E:first-of-type</td>
500 <td class="meaning">an E element, first sibling of its type</td>
501 <td class="described"><a
502 href="#structural-pseudos">Structural
503 pseudo-classes</a></td>
504 <td class="origin">3</td></tr>
505 <tr>
506 <td class="pattern">E:last-of-type</td>
507 <td class="meaning">an E element, last sibling of its type</td>
508 <td class="described"><a
509 href="#structural-pseudos">Structural
510 pseudo-classes</a></td>
511 <td class="origin">3</td></tr>
512 <tr>
513 <td class="pattern">E:only-child</td>
514 <td class="meaning">an E element, only child of its parent</td>
515 <td class="described"><a
516 href="#structural-pseudos">Structural
517 pseudo-classes</a></td>
518 <td class="origin">3</td></tr>
519 <tr>
520 <td class="pattern">E:only-of-type</td>
521 <td class="meaning">an E element, only sibling of its type</td>
522 <td class="described"><a
523 href="#structural-pseudos">Structural
524 pseudo-classes</a></td>
525 <td class="origin">3</td></tr>
526 <tr>
527 <td class="pattern">E:empty</td>
528 <td class="meaning">an E element that has no children (including text
529 nodes)</td>
530 <td class="described"><a
531 href="#structural-pseudos">Structural
532 pseudo-classes</a></td>
533 <td class="origin">3</td></tr>
534 <tr>
535 <td class="pattern">E:link<br>E:visited</td>
536 <td class="meaning">an E element being the source anchor of a hyperlink of
537 which the target is not yet visited (:link) or already visited
538 (:visited)</td>
539 <td class="described"><a
540 href="#link">The link
541 pseudo-classes</a></td>
542 <td class="origin">1</td></tr>
543 <tr>
544 <td class="pattern">E:active<br>E:hover<br>E:focus</td>
545 <td class="meaning">an E element during certain user actions</td>
546 <td class="described"><a
547 href="#useraction-pseudos">The user
548 action pseudo-classes</a></td>
549 <td class="origin">1 and 2</td></tr>
550 <tr>
551 <td class="pattern">E:target</td>
552 <td class="meaning">an E element being the target of the referring URI</td>
553 <td class="described"><a
554 href="#target-pseudo">The target
555 pseudo-class</a></td>
556 <td class="origin">3</td></tr>
557 <tr>
558 <td class="pattern">E:lang(fr)</td>
559 <td class="meaning">an element of type E in language "fr" (the document
560 language specifies how language is determined)</td>
561 <td class="described"><a
562 href="#lang-pseudo">The :lang()
563 pseudo-class</a></td>
564 <td class="origin">2</td></tr>
565 <tr>
566 <td class="pattern">E:enabled<br>E:disabled</td>
567 <td class="meaning">a user interface element E which is enabled or
568 disabled</td>
569 <td class="described"><a
570 href="#UIstates">The UI element states
571 pseudo-classes</a></td>
572 <td class="origin">3</td></tr>
573 <tr>
574 <td class="pattern">E:checked<!--<br>E:indeterminate--></td>
575 <td class="meaning">a user interface element E which is checked<!-- or in an
576 indeterminate state--> (for instance a radio-button or checkbox)</td>
577 <td class="described"><a
578 href="#UIstates">The UI element states
579 pseudo-classes</a></td>
580 <td class="origin">3</td></tr>
581 <tr>
582 <td class="pattern">E::first-line</td>
583 <td class="meaning">the first formatted line of an E element</td>
584 <td class="described"><a
585 href="#first-line">The ::first-line
586 pseudo-element</a></td>
587 <td class="origin">1</td></tr>
588 <tr>
589 <td class="pattern">E::first-letter</td>
590 <td class="meaning">the first formatted letter of an E element</td>
591 <td class="described"><a
592 href="#first-letter">The ::first-letter
593 pseudo-element</a></td>
594 <td class="origin">1</td></tr>
595 <tr>
596 <td class="pattern">E::selection</td>
597 <td class="meaning">the portion of an E element that is currently
598 selected/highlighted by the user</td>
599 <td class="described"><a
600 href="#UIfragments">The UI element
601 fragments pseudo-elements</a></td>
602 <td class="origin">3</td></tr>
603 <tr>
604 <td class="pattern">E::before</td>
605 <td class="meaning">generated content before an E element</td>
606 <td class="described"><a
607 href="#gen-content">The ::before
608 pseudo-element</a></td>
609 <td class="origin">2</td></tr>
610 <tr>
611 <td class="pattern">E::after</td>
612 <td class="meaning">generated content after an E element</td>
613 <td class="described"><a
614 href="#gen-content">The ::after
615 pseudo-element</a></td>
616 <td class="origin">2</td></tr>
617 <tr>
618 <td class="pattern">E.warning</td>
619 <td class="meaning">an E element whose class is
620 "warning" (the document language specifies how class is determined).</td>
621 <td class="described"><a
622 href="#class-html">Class
623 selectors</a></td>
624 <td class="origin">1</td></tr>
625 <tr>
626 <td class="pattern">E#myid</td>
627 <td class="meaning">an E element with ID equal to "myid".</td>
628 <td class="described"><a
629 href="#id-selectors">ID
630 selectors</a></td>
631 <td class="origin">1</td></tr>
632 <tr>
633 <td class="pattern">E:not(s)</td>
634 <td class="meaning">an E element that does not match simple selector s</td>
635 <td class="described"><a
636 href="#negation">Negation
637 pseudo-class</a></td>
638 <td class="origin">3</td></tr>
639 <tr>
640 <td class="pattern">E F</td>
641 <td class="meaning">an F element descendant of an E element</td>
642 <td class="described"><a
643 href="#descendant-combinators">Descendant
644 combinator</a></td>
645 <td class="origin">1</td></tr>
646 <tr>
647 <td class="pattern">E &gt; F</td>
648 <td class="meaning">an F element child of an E element</td>
649 <td class="described"><a
650 href="#child-combinators">Child
651 combinator</a></td>
652 <td class="origin">2</td></tr>
653 <tr>
654 <td class="pattern">E + F</td>
655 <td class="meaning">an F element immediately preceded by an E element</td>
656 <td class="described"><a
657 href="#adjacent-sibling-combinators">Adjacent sibling combinator</a></td>
658 <td class="origin">2</td></tr>
659 <tr>
660 <td class="pattern">E ~ F</td>
661 <td class="meaning">an F element preceded by an E element</td>
662 <td class="described"><a
663 href="#general-sibling-combinators">General sibling combinator</a></td>
664 <td class="origin">3</td></tr></tbody></table>
665
666 <p>The meaning of each selector is derived from the table above by
667 prepending "matches" to the contents of each cell in the "Meaning"
668 column.</p>
669
670 <h2><a name=casesens>3. Case sensitivity</a></h2>
671
672 <p>The case sensitivity of document language element names, attribute
673 names, and attribute values in selectors depends on the document
674 language. For example, in HTML, element names are case-insensitive,
675 but in XML, they are case-sensitive.</p>
676
677 <h2><a name=selector-syntax>4. Selector syntax</a></h2>
678
679 <p>A <dfn><a name=selector>selector</a></dfn> is a chain of one
680 or more <a href="#sequence">sequences of simple selectors</a>
681 separated by <a href="#combinators">combinators</a>.</p>
682
683 <p>A <dfn><a name=sequence>sequence of simple selectors</a></dfn>
684 is a chain of <a href="#simple-selectors-dfn">simple selectors</a>
685 that are not separated by a <a href="#combinators">combinator</a>. It
686 always begins with a <a href="#type-selectors">type selector</a> or a
687 <a href="#universal-selector">universal selector</a>. No other type
688 selector or universal selector is allowed in the sequence.</p>
689
690 <p>A <dfn><a name=simple-selectors-dfn></a><a
691 href="#simple-selectors">simple selector</a></dfn> is either a <a
692 href="#type-selectors">type selector</a>, <a
693 href="#universal-selector">universal selector</a>, <a
694 href="#attribute-selectors">attribute selector</a>, <a
695 href="#class-html">class selector</a>, <a
696 href="#id-selectors">ID selector</a>, <a
697 href="#content-selectors">content selector</a>, or <a
698 href="#pseudo-classes">pseudo-class</a>. One <a
699 href="#pseudo-elements">pseudo-element</a> may be appended to the last
700 sequence of simple selectors.</p>
701
702 <p><dfn>Combinators</dfn> are: white space, &quot;greater-than
703 sign&quot; (U+003E, <code>&gt;</code>), &quot;plus sign&quot; (U+002B,
704 <code>+</code>) and &quot;tilde&quot; (U+007E, <code>~</code>). White
705 space may appear between a combinator and the simple selectors around
706 it. <a name=whitespace></a>Only the characters "space" (U+0020), "tab"
707 (U+0009), "line feed" (U+000A), "carriage return" (U+000D), and "form
708 feed" (U+000C) can occur in white space. Other space-like characters,
709 such as "em-space" (U+2003) and "ideographic space" (U+3000), are
710 never part of white space.</p>
711
712 <p>The elements of a document tree that are represented by a selector
713 are the <dfn><a name=subject></a>subjects of the selector</dfn>. A
714 selector consisting of a single sequence of simple selectors
715 represents any element satisfying its requirements. Prepending another
716 sequence of simple selectors and a combinator to a sequence imposes
717 additional matching constraints, so the subjects of a selector are
718 always a subset of the elements represented by the last sequence of
719 simple selectors.</p>
720
721 <p>An empty selector, containing no sequence of simple selectors and
722 no pseudo-element, is an <a href="#Conformance">invalid
723 selector</a>.</p>
724
725 <h2><a name=grouping>5. Groups of selectors</a></h2>
726
727 <p>When several selectors share the same declarations, they may be
728 grouped into a comma-separated list. (A comma is U+002C.)</p>
729
730 <div class="example">
731 <p>CSS examples:</p>
732 <p>In this example, we condense three rules with identical
733 declarations into one. Thus,</p>
734 <pre>h1 { font-family: sans-serif }
735 h2 { font-family: sans-serif }
736 h3 { font-family: sans-serif }</pre>
737 <p>is equivalent to:</p>
738 <pre>h1, h2, h3 { font-family: sans-serif }</pre>
739 </div>
740
741 <p><strong>Warning</strong>: the equivalence is true in this example
742 because all the selectors are valid selectors. If just one of these
743 selectors were invalid, the entire group of selectors would be
744 invalid. This would invalidate the rule for all three heading
745 elements, whereas in the former case only one of the three individual
746 heading rules would be invalidated.</p>
747
748
749 <h2><a name=simple-selectors>6. Simple selectors</a></h2>
750
751 <h3><a name=type-selectors>6.1. Type selector</a></h3>
752
753 <p>A <dfn>type selector</dfn> is the name of a document language
754 element type. A type selector represents an instance of the element
755 type in the document tree.</p>
756
757 <div class="example">
758 <p>Example:</p>
759 <p>The following selector represents an <code>h1</code> element in the document tree:</p>
760 <pre>h1</pre>
761 </div>
762
763
764 <h4><a name=typenmsp>6.1.1. Type selectors and namespaces</a></h4>
765
766 <p>Type selectors allow an optional namespace (<a
767 href="#refsXMLNAMES">[XMLNAMES]</a>) component. A namespace prefix
768 that has been previously declared may be prepended to the element name
769 separated by the namespace separator &quot;vertical bar&quot;
770 (U+007C, <code>|</code>).</p>
771
772 <p>The namespace component may be left empty to indicate that the
773 selector is only to represent elements with no declared namespace.</p>
774
775 <p>An asterisk may be used for the namespace prefix, indicating that
776 the selector represents elements in any namespace (including elements
777 with no namespace).</p>
778
779 <p>Element type selectors that have no namespace component (no
780 namespace separator), represent elements without regard to the
781 element's namespace (equivalent to "<code>*|</code>") unless a default
782 namespace has been declared. If a default namespace has been declared,
783 the selector will represent only elements in the default
784 namespace.</p>
785
786 <p>A type selector containing a namespace prefix that has not been
787 previously declared is an <a href="#Conformance">invalid</a> selector.
788 The mechanism for declaring a namespace prefix is left up to the
789 language implementing Selectors. In CSS, such a mechanism is defined
790 in the General Syntax module.</p>
791
792 <p>In a namespace-aware client, element type selectors will only match
793 against the <a
794 href="http://www.w3.org/TR/REC-xml-names/#NT-LocalPart">local part</a>
795 of the element's <a
796 href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">qualified
797 name</a>. See <a href="#downlevel">below</a> for notes about matching
798 behaviors in down-level clients.</p>
799
800 <p>In summary:</p>
801
802 <dl>
803 <dt><code>ns|E</code></dt>
804 <dd>elements with name E in namespace ns</dd>
805 <dt><code>*|E</code></dt>
806 <dd>elements with name E in any namespace, including those without any
807 declared namespace</dd>
808 <dt><code>|E</code></dt>
809 <dd>elements with name E without any declared namespace</dd>
810 <dt><code>E</code></dt>
811 <dd>if no default namespace has been specified, this is equivalent to *|E.
812 Otherwise it is equivalent to ns|E where ns is the default namespace.</dd>
813 </dl>
814
815 <div class="example">
816 <p>CSS examples:</p>
817
818 <pre>@namespace foo url(http://www.example.com);
819 foo|h1 { color: blue }
820 foo|* { color: yellow }
821 |h1 { color: red }
822 *|h1 { color: green }
823 h1 { color: green }</pre>
824
825 <p>The first rule will match only <code>h1</code> elements in the
826 "http://www.example.com" namespace.</p>
827
828 <p>The second rule will match all elements in the
829 "http://www.example.com" namespace.</p>
830
831 <p>The third rule will match only <code>h1</code> elements without
832 any declared namespace.</p>
833
834 <p>The fourth rule will match <code>h1</code> elements in any
835 namespace (including those without any declared namespace).</p>
836
837 <p>The last rule is equivalent to the fourth rule because no default
838 namespace has been defined.</p>
839
840 </div>
841
842 <h3><a name=universal-selector>6.2. Universal selector</a> </h3>
843
844 <p>The <dfn>universal selector</dfn>, written &quot;asterisk&quot;
845 (<code>*</code>), represents the qualified name of any element
846 type. It represents any single element in the document tree in any
847 namespace (including those without any declared namespace) if no
848 default namespace has been specified. If a default namespace has been
849 specified, see <a href="#univnmsp">Universal selector and
850 Namespaces</a> below.</p>
851
852 <p>If the universal selector is not the only component of a sequence
853 of simple selectors, the <code>*</code> may be omitted.</p>
854
855 <div class="example">
856 <p>Examples:</p>
857 <ul>
858 <li><code>*[hreflang|=en]</code> and <code>[hreflang|=en]</code> are equivalen t,</li>
859 <li><code>*.warning</code> and <code>.warning</code> are equivalent,</li>
860 <li><code>*#myid</code> and <code>#myid</code> are equivalent.</li>
861 </ul>
862 </div>
863
864 <p class="note"><strong>Note:</strong> it is recommended that the
865 <code>*</code>, representing the universal selector, not be
866 omitted.</p>
867
868 <h4><a name=univnmsp>6.2.1. Universal selector and namespaces</a></h4>
869
870 <p>The universal selector allows an optional namespace component. It
871 is used as follows:</p>
872
873 <dl>
874 <dt><code>ns|*</code></dt>
875 <dd>all elements in namespace ns</dd>
876 <dt><code>*|*</code></dt>
877 <dd>all elements</dd>
878 <dt><code>|*</code></dt>
879 <dd>all elements without any declared namespace</dd>
880 <dt><code>*</code></dt>
881 <dd>if no default namespace has been specified, this is equivalent to *|*.
882 Otherwise it is equivalent to ns|* where ns is the default namespace.</dd>
883 </dl>
884
885 <p>A universal selector containing a namespace prefix that has not
886 been previously declared is an <a href="#Conformance">invalid</a>
887 selector. The mechanism for declaring a namespace prefix is left up
888 to the language implementing Selectors. In CSS, such a mechanism is
889 defined in the General Syntax module.</p>
890
891
892 <h3><a name=attribute-selectors>6.3. Attribute selectors</a></h3>
893
894 <p>Selectors allow the representation of an element's attributes. When
895 a selector is used as an expression to match against an element,
896 attribute selectors must be considered to match an element if that
897 element has an attribute that matches the attribute represented by the
898 attribute selector.</p>
899
900 <h4><a name=attribute-representation>6.3.1. Attribute presence and values
901 selectors</a></h4>
902
903 <p>CSS2 introduced four attribute selectors:</p>
904
905 <dl>
906 <dt><code>[att]</code>
907 <dd>Represents an element with the <code>att</code> attribute, whatever the va lue of
908 the attribute.</dd>
909 <dt><code>[att=val]</code></dt>
910 <dd>Represents an element with the <code>att</code> attribute whose value is e xactly
911 "val".</dd>
912 <dt><code>[att~=val]</code></dt>
913 <dd>Represents an element with the <code>att</code> attribute whose value is a <a
914 href="#whitespace">whitespace</a>-separated list of words, one of
915 which is exactly "val". If "val" contains whitespace, it will never
916 represent anything (since the words are <em>separated</em> by
917 spaces).</dd>
918 <dt><code>[att|=val]</code>
919 <dd>Represents an element with the <code>att</code> attribute, its value eithe r
920 being exactly "val" or beginning with "val" immediately followed by
921 "-" (U+002D). This is primarily intended to allow language subcode
922 matches (e.g., the <code>hreflang</code> attribute on the
923 <code>link</code> element in HTML) as described in RFC 3066 (<a
924 href="#refsRFC3066">[RFC3066]</a>). For <code>lang</code> (or
925 <code>xml:lang</code>) language subcode matching, please see <a
926 href="#lang-pseudo">the <code>:lang</code> pseudo-class</a>.</dd>
927 </dl>
928
929 <p>Attribute values must be identifiers or strings. The
930 case-sensitivity of attribute names and values in selectors depends on
931 the document language.</p>
932
933 <div class="example">
934
935 <p>Examples:</p>
936
937 <p>The following attribute selector represents an <code>h1</code>
938 element that carries the <code>title</code> attribute, whatever its
939 value:</p>
940
941 <pre>h1[title]</pre>
942
943 <p>In the following example, the selector represents a
944 <code>span</code> element whose <code>class</code> attribute has
945 exactly the value "example":</p>
946
947 <pre>span[class="example"]</pre>
948
949 <p>Multiple attribute selectors can be used to represent several
950 attributes of an element, or several conditions on the same
951 attribute. Here, the selector represents a <code>span</code> element
952 whose <code>hello</code> attribute has exactly the value "Cleveland"
953 and whose <code>goodbye</code> attribute has exactly the value
954 "Columbus":</p>
955
956 <pre>span[hello="Cleveland"][goodbye="Columbus"]</pre>
957
958 <p>The following selectors illustrate the differences between "="
959 and "~=". The first selector will represent, for example, the value
960 "copyright copyleft copyeditor" on a <code>rel</code> attribute. The
961 second selector will only represent an <code>a</code> element with
962 an <code>href</code> attribute having the exact value
963 "http://www.w3.org/".</p>
964
965 <pre>a[rel~="copyright"]
966 a[href="http://www.w3.org/"]</pre>
967
968 <p>The following selector represents a <code>link</code> element
969 whose <code>hreflang</code> attribute is exactly "fr".</p>
970
971 <pre>link[hreflang=fr]</pre>
972
973 <p>The following selector represents a <code>link</code> element for
974 which the values of the <code>hreflang</code> attribute begins with
975 "en", including "en", "en-US", and "en-cockney":</p>
976
977 <pre>link[hreflang|="en"]</pre>
978
979 <p>Similarly, the following selectors represents a
980 <code>DIALOGUE</code> element whenever it has one of two different
981 values for an attribute <code>character</code>:</p>
982
983 <pre>DIALOGUE[character=romeo]
984 DIALOGUE[character=juliet]</pre>
985
986 </div>
987
988 <h4><a name=attribute-substrings></a>6.3.2. Substring matching attribute
989 selectors</h4>
990
991 <p>Three additional attribute selectors are provided for matching
992 substrings in the value of an attribute:</p>
993
994 <dl>
995 <dt><code>[att^=val]</code></dt>
996 <dd>Represents an element with the <code>att</code> attribute whose value begi ns
997 with the prefix "val".</dd>
998 <dt><code>[att$=val]</code>
999 <dd>Represents an element with the <code>att</code> attribute whose value ends with
1000 the suffix "val".</dd>
1001 <dt><code>[att*=val]</code>
1002 <dd>Represents an element with the <code>att</code> attribute whose value cont ains
1003 at least one instance of the substring "val".</dd>
1004 </dl>
1005
1006 <p>Attribute values must be identifiers or strings. The
1007 case-sensitivity of attribute names in selectors depends on the
1008 document language.</p>
1009
1010 <div class="example">
1011 <p>Examples:</p>
1012 <p>The following selector represents an HTML <code>object</code>, referencing a n
1013 image:</p>
1014 <pre>object[type^="image/"]</pre>
1015 <p>The following selector represents an HTML anchor <code>a</code> with an
1016 <code>href</code> attribute whose value ends with ".html".</p>
1017 <pre>a[href$=".html"]</pre>
1018 <p>The following selector represents an HTML paragraph with a <code>title</code >
1019 attribute whose value contains the substring "hello"</p>
1020 <pre>p[title*="hello"]</pre>
1021 </div>
1022
1023 <h4><a name=attrnmsp>6.3.3. Attribute selectors and namespaces</a></h4>
1024
1025 <p>Attribute selectors allow an optional namespace component to the
1026 attribute name. A namespace prefix that has been previously declared
1027 may be prepended to the attribute name separated by the namespace
1028 separator &quot;vertical bar&quot; (<code>|</code>). In keeping with
1029 the Namespaces in the XML recommendation, default namespaces do not
1030 apply to attributes, therefore attribute selectors without a namespace
1031 component apply only to attributes that have no declared namespace
1032 (equivalent to "<code>|attr</code>"). An asterisk may be used for the
1033 namespace prefix indicating that the selector is to match all
1034 attribute names without regard to the attribute's namespace.
1035
1036 <p>An attribute selector with an attribute name containing a namespace
1037 prefix that has not been previously declared is an <a
1038 href="#Conformance">invalid</a> selector. The mechanism for declaring
1039 a namespace prefix is left up to the language implementing Selectors.
1040 In CSS, such a mechanism is defined in the General Syntax module.
1041
1042 <div class="example">
1043 <p>CSS examples:</p>
1044 <pre>@namespace foo "http://www.example.com";
1045 [foo|att=val] { color: blue }
1046 [*|att] { color: yellow }
1047 [|att] { color: green }
1048 [att] { color: green }</pre>
1049
1050 <p>The first rule will match only elements with the attribute
1051 <code>att</code> in the "http://www.example.com" namespace with the
1052 value "val".</p>
1053
1054 <p>The second rule will match only elements with the attribute
1055 <code>att</code> regardless of the namespace of the attribute
1056 (including no declared namespace).</p>
1057
1058 <p>The last two rules are equivalent and will match only elements
1059 with the attribute <code>att</code> where the attribute is not
1060 declared to be in a namespace.</p>
1061
1062 </div>
1063
1064 <h4><a name=def-values>6.3.4. Default attribute values in DTDs</a></h4>
1065
1066 <p>Attribute selectors represent explicitly set attribute values in
1067 the document tree. Default attribute values may be defined in a DTD or
1068 elsewhere, but cannot always be selected by attribute
1069 selectors. Selectors should be designed so that they work even if the
1070 default values are not included in the document tree.</p>
1071
1072 <p>More precisely, a UA is <em>not</em> required to read an "external
1073 subset" of the DTD but <em>is</em> required to look for default
1074 attribute values in the document's "internal subset." (See <a
1075 href="#refsXML10">[XML10]</a> for definitions of these subsets.)</p>
1076
1077 <p>A UA that recognizes an XML namespace <a
1078 href="#refsXMLNAMES">[XMLNAMES]</a> is not required to use its
1079 knowledge of that namespace to treat default attribute values as if
1080 they were present in the document. (For example, an XHTML UA is not
1081 required to use its built-in knowledge of the XHTML DTD.)</p>
1082
1083 <p class="note"><strong>Note:</strong> Typically, implementations
1084 choose to ignore external subsets.</p>
1085
1086 <div class="example">
1087 <p>Example:</p>
1088
1089 <p>Consider an element EXAMPLE with an attribute "notation" that has a
1090 default value of "decimal". The DTD fragment might be</p>
1091
1092 <pre class="dtd-example">&lt;!ATTLIST EXAMPLE notation (decimal,octal) "decimal" ></pre>
1093
1094 <p>If the style sheet contains the rules</p>
1095
1096 <pre>EXAMPLE[notation=decimal] { /*... default property settings ...*/ }
1097 EXAMPLE[notation=octal] { /*... other settings...*/ }</pre>
1098
1099 <p>the first rule will not match elements whose "notation" attribute
1100 is set by default, i.e. not set explicitly. To catch all cases, the
1101 attribute selector for the default value must be dropped:</p>
1102
1103 <pre>EXAMPLE { /*... default property settings ...*/ }
1104 EXAMPLE[notation=octal] { /*... other settings...*/ }</pre>
1105
1106 <p>Here, because the selector <code>EXAMPLE[notation=octal]</code> is
1107 more specific than the tag
1108 selector alone, the style declarations in the second rule will override
1109 those in the first for elements that have a "notation" attribute value
1110 of "octal". Care has to be taken that all property declarations that
1111 are to apply only to the default case are overridden in the non-default
1112 cases' style rules.</p>
1113
1114 </div>
1115
1116 <h3><a name=class-html>6.4. Class selectors</a></h3>
1117
1118 <p>Working with HTML, authors may use the period (U+002E,
1119 <code>.</code>) notation as an alternative to the <code>~=</code>
1120 notation when representing the <code>class</code> attribute. Thus, for
1121 HTML, <code>div.value</code> and <code>div[class~=value]</code> have
1122 the same meaning. The attribute value must immediately follow the
1123 &quot;period&quot; (<code>.</code>).</p>
1124
1125 <p>UAs may apply selectors using the period (.) notation in XML
1126 documents if the UA has namespace-specific knowledge that allows it to
1127 determine which attribute is the &quot;class&quot; attribute for the
1128 respective namespace. One such example of namespace-specific knowledge
1129 is the prose in the specification for a particular namespace (e.g. SVG
1130 1.0 <a href="#refsSVG">[SVG]</a> describes the <a
1131 href="http://www.w3.org/TR/2001/PR-SVG-20010719/styling.html#ClassAttribute">SVG
1132 &quot;class&quot; attribute</a> and how a UA should interpret it, and
1133 similarly MathML 1.01 <a href="#refsMATH">[MATH]</a> describes the <a
1134 href="http://www.w3.org/1999/07/REC-MathML-19990707/chapter2.html#sec2.3.4">Math ML
1135 &quot;class&quot; attribute</a>.)</p>
1136
1137 <div class="example">
1138 <p>CSS examples:</p>
1139
1140 <p>We can assign style information to all elements with
1141 <code>class~="pastoral"</code> as follows:</p>
1142
1143 <pre>*.pastoral { color: green } /* all elements with class~=pastoral */</pre >
1144
1145 <p>or just</p>
1146
1147 <pre>.pastoral { color: green } /* all elements with class~=pastoral */</pre>
1148
1149 <p>The following assigns style only to H1 elements with
1150 <code>class~="pastoral"</code>:</p>
1151
1152 <pre>H1.pastoral { color: green } /* H1 elements with class~=pastoral */</pre >
1153
1154 <p>Given these rules, the first H1 instance below would not have
1155 green text, while the second would:</p>
1156
1157 <pre>&lt;H1&gt;Not green&lt;/H1&gt;
1158 &lt;H1 class="pastoral"&gt;Very green&lt;/H1&gt;</pre>
1159
1160 </div>
1161
1162 <p>To represent a subset of "class" values, each value must be preceded
1163 by a ".", in any order.</P>
1164
1165 <div class="example">
1166
1167 <p>CSS example:</p>
1168
1169 <p>The following rule matches any P element whose "class" attribute
1170 has been assigned a list of <a
1171 href="#whitespace">whitespace</a>-separated values that includes
1172 "pastoral" and "marine":</p>
1173
1174 <pre>p.pastoral.marine { color: green }</pre>
1175
1176 <p>This rule matches when <code>class="pastoral blue aqua
1177 marine"</code> but does not match for <code>class="pastoral
1178 blue"</code>.</p>
1179
1180 </div>
1181
1182 <p class="note"><strong>Note:</strong> Because CSS gives considerable
1183 power to the "class" attribute, authors could conceivably design their
1184 own "document language" based on elements with almost no associated
1185 presentation (such as DIV and SPAN in HTML) and assigning style
1186 information through the "class" attribute. Authors should avoid this
1187 practice since the structural elements of a document language often
1188 have recognized and accepted meanings and author-defined classes may
1189 not.</p>
1190
1191 <p class="note"><strong>Note:</strong> If an element has multiple
1192 class attributes, their values must be concatenated with spaces
1193 between the values before searching for the class. As of this time the
1194 working group is not aware of any manner in which this situation can
1195 be reached, however, so this behavior is explicitly non-normative in
1196 this specification.</p>
1197
1198 <h3><a name=id-selectors>6.5. ID selectors</a></h3>
1199
1200 <p>Document languages may contain attributes that are declared to be
1201 of type ID. What makes attributes of type ID special is that no two
1202 such attributes can have the same value in a document, regardless of
1203 the type of the elements that carry them; whatever the document
1204 language, an ID typed attribute can be used to uniquely identify its
1205 element. In HTML all ID attributes are named "id"; XML applications
1206 may name ID attributes differently, but the same restriction
1207 applies.</p>
1208
1209 <p>An ID-typed attribute of a document language allows authors to
1210 assign an identifier to one element instance in the document tree. W3C
1211 ID selectors represent an element instance based on its identifier. An
1212 ID selector contains a &quot;number sign&quot; (U+0023,
1213 <code>#</code>) immediately followed by the ID value, which must be an
1214 identifier.</p>
1215
1216 <p>Selectors does not specify how a UA knows the ID-typed attribute of
1217 an element. The UA may, e.g., read a document's DTD, have the
1218 information hard-coded or ask the user.
1219
1220 <div class="example">
1221 <p>Examples:</p>
1222 <p>The following ID selector represents an <code>h1</code> element
1223 whose ID-typed attribute has the value "chapter1":</p>
1224 <pre>h1#chapter1</pre>
1225 <p>The following ID selector represents any element whose ID-typed
1226 attribute has the value "chapter1":</p>
1227 <pre>#chapter1</pre>
1228 <p>The following selector represents any element whose ID-typed
1229 attribute has the value "z98y".</p>
1230 <pre>*#z98y</pre>
1231 </div>
1232
1233 <p class="note"><strong>Note.</strong> In XML 1.0 <a
1234 href="#refsXML10">[XML10]</a>, the information about which attribute
1235 contains an element's IDs is contained in a DTD or a schema. When
1236 parsing XML, UAs do not always read the DTD, and thus may not know
1237 what the ID of an element is (though a UA may have namespace-specific
1238 knowledge that allows it to determine which attribute is the ID
1239 attribute for that namespace). If a style sheet designer knows or
1240 suspects that a UA may not know what the ID of an element is, he
1241 should use normal attribute selectors instead:
1242 <code>[name=p371]</code> instead of <code>#p371</code>. Elements in
1243 XML 1.0 documents without a DTD do not have IDs at all.</p>
1244
1245 <p>If an element has multiple ID attributes, all of them must be
1246 treated as IDs for that element for the purposes of the ID
1247 selector. Such a situation could be reached using mixtures of xml:id,
1248 DOM3 Core, XML DTDs, and namespace-specific knowledge.</p>
1249
1250 <h3><a name=pseudo-classes>6.6. Pseudo-classes</a></h3>
1251
1252 <p>The pseudo-class concept is introduced to permit selection based on
1253 information that lies outside of the document tree or that cannot be
1254 expressed using the other simple selectors.</p>
1255
1256 <p>A pseudo-class always consists of a &quot;colon&quot;
1257 (<code>:</code>) followed by the name of the pseudo-class and
1258 optionally by a value between parentheses.</p>
1259
1260 <p>Pseudo-classes are allowed in all sequences of simple selectors
1261 contained in a selector. Pseudo-classes are allowed anywhere in
1262 sequences of simple selectors, after the leading type selector or
1263 universal selector (possibly omitted). Pseudo-class names are
1264 case-insensitive. Some pseudo-classes are mutually exclusive, while
1265 others can be applied simultaneously to the same
1266 element. Pseudo-classes may be dynamic, in the sense that an element
1267 may acquire or lose a pseudo-class while a user interacts with the
1268 document.</p>
1269
1270
1271 <h4><a name=dynamic-pseudos>6.6.1. Dynamic pseudo-classes</a></h4>
1272
1273 <p>Dynamic pseudo-classes classify elements on characteristics other
1274 than their name, attributes, or content, in principle characteristics
1275 that cannot be deduced from the document tree.</p>
1276
1277 <p>Dynamic pseudo-classes do not appear in the document source or
1278 document tree.</p>
1279
1280
1281 <h5>The <a name=link>link pseudo-classes: :link and :visited</a></h5>
1282
1283 <p>User agents commonly display unvisited links differently from
1284 previously visited ones. Selectors
1285 provides the pseudo-classes <code>:link</code> and
1286 <code>:visited</code> to distinguish them:</p>
1287
1288 <ul>
1289 <li>The <code>:link</code> pseudo-class applies to links that have
1290 not yet been visited.</li>
1291 <li>The <code>:visited</code> pseudo-class applies once the link has
1292 been visited by the user. </li>
1293 </ul>
1294
1295 <p>After some amount of time, user agents may choose to return a
1296 visited link to the (unvisited) ':link' state.</p>
1297
1298 <p>The two states are mutually exclusive.</p>
1299
1300 <div class="example">
1301
1302 <p>Example:</p>
1303
1304 <p>The following selector represents links carrying class
1305 <code>external</code> and already visited:</p>
1306
1307 <pre>a.external:visited</pre>
1308
1309 </div>
1310
1311 <p class="note"><strong>Note:</strong> It is possible for style sheet
1312 authors to abuse the :link and :visited pseudo-classes to determine
1313 which sites a user has visited without the user's consent.
1314
1315 <p>UAs may therefore treat all links as unvisited links, or implement
1316 other measures to preserve the user's privacy while rendering visited
1317 and unvisited links differently.</p>
1318
1319 <h5>The <a name=useraction-pseudos>user action pseudo-classes
1320 :hover, :active, and :focus</a></h5>
1321
1322 <p>Interactive user agents sometimes change the rendering in response
1323 to user actions. Selectors provides
1324 three pseudo-classes for the selection of an element the user is
1325 acting on.</p>
1326
1327 <ul>
1328
1329 <li>The <code>:hover</code> pseudo-class applies while the user
1330 designates an element with a pointing device, but does not activate
1331 it. For example, a visual user agent could apply this pseudo-class
1332 when the cursor (mouse pointer) hovers over a box generated by the
1333 element. User agents not that do not support <a
1334 href="http://www.w3.org/TR/REC-CSS2/media.html#interactive-media-group">intera ctive
1335 media</a> do not have to support this pseudo-class. Some conforming
1336 user agents that support <a
1337 href="http://www.w3.org/TR/REC-CSS2/media.html#interactive-media-group">intera ctive
1338 media</a> may not be able to support this pseudo-class (e.g., a pen
1339 device that does not detect hovering).</li>
1340
1341 <li>The <code>:active</code> pseudo-class applies while an element
1342 is being activated by the user. For example, between the times the
1343 user presses the mouse button and releases it.</li>
1344
1345 <li>The <code>:focus</code> pseudo-class applies while an element
1346 has the focus (accepts keyboard or mouse events, or other forms of
1347 input). </li>
1348
1349 </ul>
1350
1351 <p>There may be document language or implementation specific limits on
1352 which elements can become <code>:active</code> or acquire
1353 <code>:focus</code>.</p>
1354
1355 <p>These pseudo-classes are not mutually exclusive. An element may
1356 match several pseudo-classes at the same time.</p>
1357
1358 <p>Selectors doesn't define if the parent of an element that is
1359 ':active' or ':hover' is also in that state.</p>
1360
1361 <div class="example">
1362 <p>Examples:</p>
1363 <pre>a:link /* unvisited links */
1364 a:visited /* visited links */
1365 a:hover /* user hovers */
1366 a:active /* active links */</pre>
1367 <p>An example of combining dynamic pseudo-classes:</p>
1368 <pre>a:focus
1369 a:focus:hover</pre>
1370 <p>The last selector matches <code>a</code> elements that are in
1371 the pseudo-class :focus and in the pseudo-class :hover.</p>
1372 </div>
1373
1374 <p class="note"><strong>Note:</strong> An element can be both ':visited'
1375 and ':active' (or ':link' and ':active').</p>
1376
1377 <h4><a name=target-pseudo>6.6.2. The target pseudo-class :target</a></h4>
1378
1379 <p>Some URIs refer to a location within a resource. This kind of URI
1380 ends with a &quot;number sign&quot; (#) followed by an anchor
1381 identifier (called the fragment identifier).</p>
1382
1383 <p>URIs with fragment identifiers link to a certain element within the
1384 document, known as the target element. For instance, here is a URI
1385 pointing to an anchor named <code>section_2</code> in an HTML
1386 document:</p>
1387
1388 <pre>http://example.com/html/top.html#section_2</pre>
1389
1390 <p>A target element can be represented by the <code>:target</code>
1391 pseudo-class. If the document's URI has no fragment identifier, then
1392 the document has no target element.</p>
1393
1394 <div class="example">
1395 <p>Example:</p>
1396 <pre>p.note:target</pre>
1397 <p>This selector represents a <code>p</code> element of class
1398 <code>note</code> that is the target element of the referring
1399 URI.</p>
1400 </div>
1401
1402 <div class="example">
1403 <p>CSS example:</p>
1404 <p>Here, the <code>:target</code> pseudo-class is used to make the
1405 target element red and place an image before it, if there is one:</p>
1406 <pre>*:target { color : red }
1407 *:target::before { content : url(target.png) }</pre>
1408 </div>
1409
1410 <h4><a name=lang-pseudo>6.6.3. The language pseudo-class :lang</a></h4>
1411
1412 <p>If the document language specifies how the human language of an
1413 element is determined, it is possible to write selectors that
1414 represent an element based on its language. For example, in HTML <a
1415 href="#refsHTML4">[HTML4]</a>, the language is determined by a
1416 combination of the <code>lang</code> attribute, the <code>meta</code>
1417 element, and possibly by information from the protocol (such as HTTP
1418 headers). XML uses an attribute called <code>xml:lang</code>, and
1419 there may be other document language-specific methods for determining
1420 the language.</p>
1421
1422 <p>The pseudo-class <code>:lang(C)</code> represents an element that
1423 is in language C. Whether an element is represented by a
1424 <code>:lang()</code> selector is based solely on the identifier C
1425 being either equal to, or a hyphen-separated substring of, the
1426 element's language value, in the same way as if performed by the <a
1427 href="#attribute-representation">'|='</a> operator in attribute
1428 selectors. The identifier C does not have to be a valid language
1429 name.</p>
1430
1431 <p>C must not be empty. (If it is, the selector is invalid.)</p>
1432
1433 <p class="note"><strong>Note:</strong> It is recommended that
1434 documents and protocols indicate language using codes from RFC 3066 <a
1435 href="#refsRFC3066">[RFC3066]</a> or its successor, and by means of
1436 "xml:lang" attributes in the case of XML-based documents <a
1437 href="#refsXML10">[XML10]</a>. See <a
1438 href="http://www.w3.org/International/questions/qa-lang-2or3.html">
1439 "FAQ: Two-letter or three-letter language codes."</a></p>
1440
1441 <div class="example">
1442 <p>Examples:</p>
1443 <p>The two following selectors represent an HTML document that is in
1444 Belgian, French, or German. The two next selectors represent
1445 <code>q</code> quotations in an arbitrary element in Belgian, French,
1446 or German.</p>
1447 <pre>html:lang(fr-be)
1448 html:lang(de)
1449 :lang(fr-be) &gt; q
1450 :lang(de) &gt; q</pre>
1451 </div>
1452
1453 <h4><a name=UIstates>6.6.4. The UI element states pseudo-classes</a></h4>
1454
1455 <h5><a name=enableddisabled>The :enabled and :disabled pseudo-classes</a></h5>
1456
1457 <p>The <code>:enabled</code> pseudo-class allows authors to customize
1458 the look of user interface elements that are enabled &mdash; which the
1459 user can select or activate in some fashion (e.g. clicking on a button
1460 with a mouse). There is a need for such a pseudo-class because there
1461 is no way to programmatically specify the default appearance of say,
1462 an enabled <code>input</code> element without also specifying what it
1463 would look like when it was disabled.</p>
1464
1465 <p>Similar to <code>:enabled</code>, <code>:disabled</code> allows the
1466 author to specify precisely how a disabled or inactive user interface
1467 element should look.</p>
1468
1469 <p>Most elements will be neither enabled nor disabled. An element is
1470 enabled if the user can either activate it or transfer the focus to
1471 it. An element is disabled if it could be enabled, but the user cannot
1472 presently activate it or transfer focus to it.</p>
1473
1474
1475 <h5><a name=checked>The :checked pseudo-class</a></h5>
1476
1477 <p>Radio and checkbox elements can be toggled by the user. Some menu
1478 items are "checked" when the user selects them. When such elements are
1479 toggled "on" the <code>:checked</code> pseudo-class applies. The
1480 <code>:checked</code> pseudo-class initially applies to such elements
1481 that have the HTML4 <code>selected</code> and <code>checked</code>
1482 attributes as described in <a
1483 href="http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.2.1">Section
1484 17.2.1 of HTML4</a>, but of course the user can toggle "off" such
1485 elements in which case the <code>:checked</code> pseudo-class would no
1486 longer apply. While the <code>:checked</code> pseudo-class is dynamic
1487 in nature, and is altered by user action, since it can also be based
1488 on the presence of the semantic HTML4 <code>selected</code> and
1489 <code>checked</code> attributes, it applies to all media.
1490
1491
1492 <h5><a name=indeterminate>The :indeterminate pseudo-class</a></h5>
1493
1494 <div class="note">
1495
1496 <p>Radio and checkbox elements can be toggled by the user, but are
1497 sometimes in an indeterminate state, neither checked nor unchecked.
1498 This can be due to an element attribute, or DOM manipulation.</p>
1499
1500 <p>A future version of this specification may introduce an
1501 <code>:indeterminate</code> pseudo-class that applies to such elements.
1502 <!--While the <code>:indeterminate</code> pseudo-class is dynamic in
1503 nature, and is altered by user action, since it can also be based on
1504 the presence of an element attribute, it applies to all media.</p>
1505
1506 <p>Components of a radio-group initialized with no pre-selected choice
1507 are an example of :indeterminate state.--></p>
1508
1509 </div>
1510
1511
1512 <h4><a name=structural-pseudos>6.6.5. Structural pseudo-classes</a></h4>
1513
1514 <p>Selectors introduces the concept of <dfn>structural
1515 pseudo-classes</dfn> to permit selection based on extra information that lies in
1516 the document tree but cannot be represented by other simple selectors or
1517 combinators.
1518
1519 <p>Note that standalone pieces of PCDATA (text nodes in the DOM) are
1520 not counted when calculating the position of an element in the list of
1521 children of its parent. When calculating the position of an element in
1522 the list of children of its parent, the index numbering starts at 1.
1523
1524
1525 <h5><a name=root-pseudo>:root pseudo-class</a></h5>
1526
1527 <p>The <code>:root</code> pseudo-class represents an element that is
1528 the root of the document. In HTML 4, this is always the
1529 <code>HTML</code> element.
1530
1531
1532 <h5><a name=nth-child-pseudo>:nth-child() pseudo-class</a></h5>
1533
1534 <p>The
1535 <code>:nth-child(<var>a</var><code>n</code>+<var>b</var>)</code>
1536 pseudo-class notation represents an element that has
1537 <var>a</var><code>n</code>+<var>b</var>-1 siblings
1538 <strong>before</strong> it in the document tree, for a given positive
1539 integer or zero value of <code>n</code>, and has a parent element. In
1540 other words, this matches the <var>b</var>th child of an element after
1541 all the children have been split into groups of <var>a</var> elements
1542 each. For example, this allows the selectors to address every other
1543 row in a table, and could be used to alternate the color
1544 of paragraph text in a cycle of four. The <var>a</var> and
1545 <var>b</var> values must be zero, negative integers or positive
1546 integers. The index of the first child of an element is 1.
1547
1548 <p>In addition to this, <code>:nth-child()</code> can take
1549 '<code>odd</code>' and '<code>even</code>' as arguments instead.
1550 '<code>odd</code>' has the same signification as <code>2n+1</code>,
1551 and '<code>even</code>' has the same signification as <code>2n</code>.
1552
1553
1554 <div class="example">
1555 <p>Examples:</p>
1556 <pre>tr:nth-child(2n+1) /* represents every odd row of an HTML table */
1557 tr:nth-child(odd) /* same */
1558 tr:nth-child(2n) /* represents every even row of an HTML table */
1559 tr:nth-child(even) /* same */
1560
1561 /* Alternate paragraph colours in CSS */
1562 p:nth-child(4n+1) { color: navy; }
1563 p:nth-child(4n+2) { color: green; }
1564 p:nth-child(4n+3) { color: maroon; }
1565 p:nth-child(4n+4) { color: purple; }</pre>
1566 </div>
1567
1568 <p>When <var>a</var>=0, no repeating is used, so for example
1569 <code>:nth-child(0n+5)</code> matches only the fifth child. When
1570 <var>a</var>=0, the <var>a</var><code>n</code> part need not be
1571 included, so the syntax simplifies to
1572 <code>:nth-child(<var>b</var>)</code> and the last example simplifies
1573 to <code>:nth-child(5)</code>.
1574
1575 <div class="example">
1576 <p>Examples:</p>
1577 <pre>foo:nth-child(0n+1) /* represents an element foo, first child of its pare nt element */
1578 foo:nth-child(1) /* same */</pre>
1579 </div>
1580
1581 <p>When <var>a</var>=1, the number may be omitted from the rule.
1582
1583 <div class="example">
1584 <p>Examples:</p>
1585 <p>The following selectors are therefore equivalent:</p>
1586 <pre>bar:nth-child(1n+0) /* represents all bar elements, specificity (0,1,1) * /
1587 bar:nth-child(n+0) /* same */
1588 bar:nth-child(n) /* same */
1589 bar /* same but lower specificity (0,0,1) */</pre>
1590 </div>
1591
1592 <p>If <var>b</var>=0, then every <var>a</var>th element is picked. In
1593 such a case, the <var>b</var> part may be omitted.
1594
1595 <div class="example">
1596 <p>Examples:</p>
1597 <pre>tr:nth-child(2n+0) /* represents every even row of an HTML table */
1598 tr:nth-child(2n) /* same */</pre>
1599 </div>
1600
1601 <p>If both <var>a</var> and <var>b</var> are equal to zero, the
1602 pseudo-class represents no element in the document tree.</p>
1603
1604 <p>The value <var>a</var> can be negative, but only the positive
1605 values of <var>a</var><code>n</code>+<var>b</var>, for
1606 <code>n</code>&ge;0, may represent an element in the document
1607 tree.</p>
1608
1609 <div class="example">
1610 <p>Example:</p>
1611 <pre>html|tr:nth-child(-n+6) /* represents the 6 first rows of XHTML tables */< /pre>
1612 </div>
1613
1614 <p>When the value <var>b</var> is negative, the "+" character in the
1615 expression must be removed (it is effectively replaced by the "-"
1616 character indicating the negative value of <var>b</var>).</p>
1617
1618 <div class="example">
1619 <p>Examples:</p>
1620 <pre>:nth-child(10n-1) /* represents the 9th, 19th, 29th, etc, element */
1621 :nth-child(10n+9) /* Same */
1622 :nth-child(10n+-1) /* Syntactically invalid, and would be ignored */</pre>
1623 </div>
1624
1625
1626 <h5><a name=nth-last-child-pseudo>:nth-last-child() pseudo-class</a></h5>
1627
1628 <p>The <code>:nth-last-child(<var>a</var>n+<var>b</var>)</code>
1629 pseudo-class notation represents an element that has
1630 <var>a</var><code>n</code>+<var>b</var>-1 siblings
1631 <strong>after</strong> it in the document tree, for a given positive
1632 integer or zero value of <code>n</code>, and has a parent element. See
1633 <code>:nth-child()</code> pseudo-class for the syntax of its argument.
1634 It also accepts the '<code>even</code>' and '<code>odd</code>' values
1635 as arguments.
1636
1637
1638 <div class="example">
1639 <p>Examples:</p>
1640 <pre>tr:nth-last-child(-n+2) /* represents the two last rows of an HTML table */
1641
1642 foo:nth-last-child(odd) /* represents all odd foo elements in their parent el ement,
1643 counting from the last one */</pre>
1644 </div>
1645
1646
1647 <h5><a name=nth-of-type-pseudo>:nth-of-type() pseudo-class</a></h5>
1648
1649 <p>The <code>:nth-of-type(<var>a</var>n+<var>b</var>)</code>
1650 pseudo-class notation represents an element that has
1651 <var>a</var><code>n</code>+<var>b</var>-1 siblings with the same
1652 element name <strong>before</strong> it in the document tree, for a
1653 given zero or positive integer value of <code>n</code>, and has a
1654 parent element. In other words, this matches the <var>b</var>th child
1655 of that type after all the children of that type have been split into
1656 groups of a elements each. See <code>:nth-child()</code> pseudo-class
1657 for the syntax of its argument. It also accepts the
1658 '<code>even</code>' and '<code>odd</code>' values.
1659
1660
1661 <div class="example">
1662 <p>CSS example:</p>
1663 <p>This allows an author to alternate the position of floated images:</p>
1664 <pre>img:nth-of-type(2n+1) { float: right; }
1665 img:nth-of-type(2n) { float: left; }</pre>
1666 </div>
1667
1668
1669 <h5><a name=nth-last-of-type-pseudo>:nth-last-of-type() pseudo-class</a></h5>
1670
1671 <p>The <code>:nth-last-of-type(<var>a</var>n+<var>b</var>)</code>
1672 pseudo-class notation represents an element that has
1673 <var>a</var><code>n</code>+<var>b</var>-1 siblings with the same
1674 element name <strong>after</strong> it in the document tree, for a
1675 given zero or positive integer value of <code>n</code>, and has a
1676 parent element. See <code>:nth-child()</code> pseudo-class for the
1677 syntax of its argument. It also accepts the '<code>even</code>' and '<code>odd</ code>' values.
1678
1679
1680 <div class="example">
1681 <p>Example:</p>
1682 <p>To represent all <code>h2</code> children of an XHTML
1683 <code>body</code> except the first and last, one could use the
1684 following selector:</p>
1685 <pre>body &gt; h2:nth-of-type(n+2):nth-last-of-type(n+2)</pre>
1686 <p>In this case, one could also use <code>:not()</code>, although the
1687 selector ends up being just as long:</p>
1688 <pre>body &gt; h2:not(:first-of-type):not(:last-of-type)</pre>
1689 </div>
1690
1691
1692 <h5><a name=first-child-pseudo>:first-child pseudo-class</a></h5>
1693
1694 <p>Same as <code>:nth-child(1)</code>. The <code>:first-child</code> pseudo-clas s
1695 represents an element that is the first child of some other element.
1696
1697
1698 <div class="example">
1699 <p>Examples:</p>
1700 <p>The following selector represents a <code>p</code> element that is
1701 the first child of a <code>div</code> element:</p>
1702 <pre>div &gt; p:first-child</pre>
1703 <p>This selector can represent the <code>p</code> inside the
1704 <code>div</code> of the following fragment:</p>
1705 <pre>&lt;p&gt; The last P before the note.&lt;/p&gt;
1706 &lt;div class="note"&gt;
1707 &lt;p&gt; The first P inside the note.&lt;/p&gt;
1708 &lt;/div&gt;</pre>but cannot represent the second <code>p</code> in the followin g
1709 fragment:
1710 <pre>&lt;p&gt; The last P before the note.&lt;/p&gt;
1711 &lt;div class="note"&gt;
1712 &lt;h2&gt; Note &lt;/h2&gt;
1713 &lt;p&gt; The first P inside the note.&lt;/p&gt;
1714 &lt;/div&gt;</pre>
1715 <p>The following two selectors are usually equivalent:</p>
1716 <pre>* &gt; a:first-child /* a is first child of any element */
1717 a:first-child /* Same (assuming a is not the root element) */</pre>
1718 </div>
1719
1720 <h5><a name=last-child-pseudo>:last-child pseudo-class</a></h5>
1721
1722 <p>Same as <code>:nth-last-child(1)</code>. The <code>:last-child</code> pseudo- class
1723 represents an element that is the last child of some other element.
1724
1725 <div class="example">
1726 <p>Example:</p>
1727 <p>The following selector represents a list item <code>li</code> that
1728 is the last child of an ordered list <code>ol</code>.
1729 <pre>ol &gt; li:last-child</pre>
1730 </div>
1731
1732 <h5><a name=first-of-type-pseudo>:first-of-type pseudo-class</a></h5>
1733
1734 <p>Same as <code>:nth-of-type(1)</code>. The <code>:first-of-type</code> pseudo- class
1735 represents an element that is the first sibling of its type in the list of
1736 children of its parent element.
1737
1738 <div class="example">
1739 <p>Example:</p>
1740 <p>The following selector represents a definition title
1741 <code>dt</code> inside a definition list <code>dl</code>, this
1742 <code>dt</code> being the first of its type in the list of children of
1743 its parent element.</p>
1744 <pre>dl dt:first-of-type</pre>
1745 <p>It is a valid description for the first two <code>dt</code>
1746 elements in the following example but not for the third one:</p>
1747 <pre>&lt;dl&gt;
1748 &lt;dt&gt;gigogne&lt;/dt&gt;
1749 &lt;dd&gt;
1750 &lt;dl&gt;
1751 &lt;dt&gt;fus&eacute;e&lt;/dt&gt;
1752 &lt;dd&gt;multistage rocket&lt;/dd&gt;
1753 &lt;dt&gt;table&lt;/dt&gt;
1754 &lt;dd&gt;nest of tables&lt;/dd&gt;
1755 &lt;/dl&gt;
1756 &lt;/dd&gt;
1757 &lt;/dl&gt;</pre>
1758 </div>
1759
1760 <h5><a name=last-of-type-pseudo>:last-of-type pseudo-class</a></h5>
1761
1762 <p>Same as <code>:nth-last-of-type(1)</code>. The
1763 <code>:last-of-type</code> pseudo-class represents an element that is
1764 the last sibling of its type in the list of children of its parent
1765 element.</p>
1766
1767 <div class="example">
1768 <p>Example:</p>
1769 <p>The following selector represents the last data cell
1770 <code>td</code> of a table row.</p>
1771 <pre>tr &gt; td:last-of-type</pre>
1772 </div>
1773
1774 <h5><a name=only-child-pseudo>:only-child pseudo-class</a></h5>
1775
1776 <p>Represents an element that has a parent element and whose parent
1777 element has no other element children. Same as
1778 <code>:first-child:last-child</code> or
1779 <code>:nth-child(1):nth-last-child(1)</code>, but with a lower
1780 specificity.</p>
1781
1782 <h5><a name=only-of-type-pseudo>:only-of-type pseudo-class</a></h5>
1783
1784 <p>Represents an element that has a parent element and whose parent
1785 element has no other element children with the same element name. Same
1786 as <code>:first-of-type:last-of-type</code> or
1787 <code>:nth-of-type(1):nth-last-of-type(1)</code>, but with a lower
1788 specificity.</p>
1789
1790
1791 <h5><a name=empty-pseudo></a>:empty pseudo-class</h5>
1792
1793 <p>The <code>:empty</code> pseudo-class represents an element that has
1794 no children at all. In terms of the DOM, only element nodes and text
1795 nodes (including CDATA nodes and entity references) whose data has a
1796 non-zero length must be considered as affecting emptiness; comments,
1797 PIs, and other nodes must not affect whether an element is considered
1798 empty or not.</p>
1799
1800 <div class="example">
1801 <p>Examples:</p>
1802 <p><code>p:empty</code> is a valid representation of the following fragment:</p >
1803 <pre>&lt;p&gt;&lt;/p&gt;</pre>
1804 <p><code>foo:empty</code> is not a valid representation for the
1805 following fragments:</p>
1806 <pre>&lt;foo&gt;bar&lt;/foo&gt;</pre>
1807 <pre>&lt;foo&gt;&lt;bar&gt;bla&lt;/bar&gt;&lt;/foo&gt;</pre>
1808 <pre>&lt;foo&gt;this is not &lt;bar&gt;:empty&lt;/bar&gt;&lt;/foo&gt;</pre>
1809 </div>
1810
1811 <h4><a name=content-selectors>6.6.6. Blank</a></h4> <!-- It's the Return of Appe ndix H!!! Run away! -->
1812
1813 <p>This section intentionally left blank.</p>
1814 <!-- (used to be :contains()) -->
1815
1816 <h4><a name=negation></a>6.6.7. The negation pseudo-class</h4>
1817
1818 <p>The negation pseudo-class, <code>:not(<var>X</var>)</code>, is a
1819 functional notation taking a <a href="#simple-selectors-dfn">simple
1820 selector</a> (excluding the negation pseudo-class itself and
1821 pseudo-elements) as an argument. It represents an element that is not
1822 represented by the argument.
1823
1824 <!-- pseudo-elements are not simple selectors, so the above paragraph
1825 may be a bit confusing -->
1826
1827 <div class="example">
1828 <p>Examples:</p>
1829 <p>The following CSS selector matches all <code>button</code>
1830 elements in an HTML document that are not disabled.</p>
1831 <pre>button:not([DISABLED])</pre>
1832 <p>The following selector represents all but <code>FOO</code>
1833 elements.</p>
1834 <pre>*:not(FOO)</pre>
1835 <p>The following group of selectors represents all HTML elements
1836 except links.</p>
1837 <pre>html|*:not(:link):not(:visited)</pre>
1838 </div>
1839
1840 <p>Default namespace declarations do not affect the argument of the
1841 negation pseudo-class unless the argument is a universal selector or a
1842 type selector.</p>
1843
1844 <div class="example">
1845 <p>Examples:</p>
1846 <p>Assuming that the default namespace is bound to
1847 "http://example.com/", the following selector represents all
1848 elements that are not in that namespace:</p>
1849 <pre>*|*:not(*)</pre>
1850 <p>The following CSS selector matches any element being hovered,
1851 regardless of its namespace. In particular, it is not limited to
1852 only matching elements in the default namespace that are not being
1853 hovered, and elements not in the default namespace don't match the
1854 rule when they <em>are</em> being hovered.</p>
1855 <pre>*|*:not(:hover)</pre>
1856 </div>
1857
1858 <p class="note"><strong>Note</strong>: the :not() pseudo allows
1859 useless selectors to be written. For instance <code>:not(*|*)</code>,
1860 which represents no element at all, or <code>foo:not(bar)</code>,
1861 which is equivalent to <code>foo</code> but with a higher
1862 specificity.</p>
1863
1864 <h3><a name=pseudo-elements>7. Pseudo-elements</a></h3>
1865
1866 <p>Pseudo-elements create abstractions about the document tree beyond
1867 those specified by the document language. For instance, document
1868 languages do not offer mechanisms to access the first letter or first
1869 line of an element's content. Pseudo-elements allow designers to refer
1870 to this otherwise inaccessible information. Pseudo-elements may also
1871 provide designers a way to refer to content that does not exist in the
1872 source document (e.g., the <code>::before</code> and
1873 <code>::after</code> pseudo-elements give access to generated
1874 content).</p>
1875
1876 <p>A pseudo-element is made of two colons (<code>::</code>) followed
1877 by the name of the pseudo-element.</p>
1878
1879 <p>This <code>::</code> notation is introduced by the current document
1880 in order to establish a discrimination between pseudo-classes and
1881 pseudo-elements. For compatibility with existing style sheets, user
1882 agents must also accept the previous one-colon notation for
1883 pseudo-elements introduced in CSS levels 1 and 2 (namely,
1884 <code>:first-line</code>, <code>:first-letter</code>,
1885 <code>:before</code> and <code>:after</code>). This compatibility is
1886 not allowed for the new pseudo-elements introduced in CSS level 3.</p>
1887
1888 <p>Only one pseudo-element may appear per selector, and if present it
1889 must appear after the sequence of simple selectors that represents the
1890 <a href="#subject">subjects</a> of the selector. <span class="note">A
1891 future version of this specification may allow multiple
1892 pesudo-elements per selector.</span></p>
1893
1894 <h4><a name=first-line>7.1. The ::first-line pseudo-element</a></h4>
1895
1896 <p>The <code>::first-line</code> pseudo-element describes the contents
1897 of the first formatted line of an element.
1898
1899 <div class="example">
1900 <p>CSS example:</p>
1901 <pre>p::first-line { text-transform: uppercase }</pre>
1902 <p>The above rule means "change the letters of the first line of every
1903 paragraph to uppercase".</p>
1904 </div>
1905
1906 <p>The selector <code>p::first-line</code> does not match any real
1907 HTML element. It does match a pseudo-element that conforming user
1908 agents will insert at the beginning of every paragraph.</p>
1909
1910 <p>Note that the length of the first line depends on a number of
1911 factors, including the width of the page, the font size, etc. Thus,
1912 an ordinary HTML paragraph such as:</p>
1913
1914 <pre>
1915 &lt;P&gt;This is a somewhat long HTML
1916 paragraph that will be broken into several
1917 lines. The first line will be identified
1918 by a fictional tag sequence. The other lines
1919 will be treated as ordinary lines in the
1920 paragraph.&lt;/P&gt;
1921 </pre>
1922
1923 <p>the lines of which happen to be broken as follows:
1924
1925 <pre>
1926 THIS IS A SOMEWHAT LONG HTML PARAGRAPH THAT
1927 will be broken into several lines. The first
1928 line will be identified by a fictional tag
1929 sequence. The other lines will be treated as
1930 ordinary lines in the paragraph.
1931 </pre>
1932
1933 <p>This paragraph might be "rewritten" by user agents to include the
1934 <em>fictional tag sequence</em> for <code>::first-line</code>. This
1935 fictional tag sequence helps to show how properties are inherited.</p>
1936
1937 <pre>
1938 &lt;P&gt;<b>&lt;P::first-line&gt;</b> This is a somewhat long HTML
1939 paragraph that <b>&lt;/P::first-line&gt;</b> will be broken into several
1940 lines. The first line will be identified
1941 by a fictional tag sequence. The other lines
1942 will be treated as ordinary lines in the
1943 paragraph.&lt;/P&gt;
1944 </pre>
1945
1946 <p>If a pseudo-element breaks up a real element, the desired effect
1947 can often be described by a fictional tag sequence that closes and
1948 then re-opens the element. Thus, if we mark up the previous paragraph
1949 with a <code>span</code> element:</p>
1950
1951 <pre>
1952 &lt;P&gt;<b>&lt;SPAN class="test"&gt;</b> This is a somewhat long HTML
1953 paragraph that will be broken into several
1954 lines.<b>&lt;/SPAN&gt;</b> The first line will be identified
1955 by a fictional tag sequence. The other lines
1956 will be treated as ordinary lines in the
1957 paragraph.&lt;/P&gt;
1958 </pre>
1959
1960 <p>the user agent could simulate start and end tags for
1961 <code>span</code> when inserting the fictional tag sequence for
1962 <code>::first-line</code>.
1963
1964 <pre>
1965 &lt;P&gt;&lt;P::first-line&gt;<b>&lt;SPAN class="test"&gt;</b> This is a
1966 somewhat long HTML
1967 paragraph that will <b>&lt;/SPAN&gt;</b>&lt;/P::first-line&gt;<b>&lt;SPAN class= "test"&gt;</b> be
1968 broken into several
1969 lines.<b>&lt;/SPAN&gt;</b> The first line will be identified
1970 by a fictional tag sequence. The other lines
1971 will be treated as ordinary lines in the
1972 paragraph.&lt;/P&gt;
1973 </pre>
1974
1975 <p>In CSS, the <code>::first-line</code> pseudo-element can only be
1976 attached to a block-level element, an inline-block, a table-caption,
1977 or a table-cell.</p>
1978
1979 <p><a name="first-formatted-line"></a>The "first formatted line" of an
1980 element may occur inside a
1981 block-level descendant in the same flow (i.e., a block-level
1982 descendant that is not positioned and not a float). E.g., the first
1983 line of the <code>div</code> in <code>&lt;DIV>&lt;P>This
1984 line...&lt;/P>&lt/DIV></code> is the first line of the <code>p</code> (assuming
1985 that both <code>p</code> and <code>div</code> are block-level).
1986
1987 <p>The first line of a table-cell or inline-block cannot be the first
1988 formatted line of an ancestor element. Thus, in <code>&lt;DIV&gt;&lt;P
1989 STYLE="display: inline-block">Hello&lt;BR&gt;Goodbye&lt;/P&gt;
1990 etcetera&lt;/DIV&gt;</code> the first formatted line of the
1991 <code>div</code> is not the line "Hello".
1992
1993 <p class="note">Note that the first line of the <code>p</code> in this
1994 fragment: <code>&lt;p&gt&lt;br&gt;First...</code> doesn't contain any
1995 letters (assuming the default style for <code>br</code> in HTML
1996 4). The word "First" is not on the first formatted line.
1997
1998 <p>A UA should act as if the fictional start tags of the
1999 <code>::first-line</code> pseudo-elements were nested just inside the
2000 innermost enclosing block-level element. (Since CSS1 and CSS2 were
2001 silent on this case, authors should not rely on this behavior.) Here
2002 is an example. The fictional tag sequence for</p>
2003
2004 <pre>
2005 &lt;DIV>
2006 &lt;P>First paragraph&lt;/P>
2007 &lt;P>Second paragraph&lt;/P>
2008 &lt;/DIV>
2009 </pre>
2010
2011 <p>is</p>
2012
2013 <pre>
2014 &lt;DIV>
2015 &lt;P>&lt;DIV::first-line>&lt;P::first-line>First paragraph&lt;/P::first-line> &lt;/DIV::first-line>&lt;/P>
2016 &lt;P>&lt;P::first-line>Second paragraph&lt;/P::first-line>&lt;/P>
2017 &lt;/DIV>
2018 </pre>
2019
2020 <p>The <code>::first-line</code> pseudo-element is similar to an
2021 inline-level element, but with certain restrictions. In CSS, the
2022 following properties apply to a <code>::first-line</code>
2023 pseudo-element: font properties, color property, background
2024 properties, 'word-spacing', 'letter-spacing', 'text-decoration',
2025 'vertical-align', 'text-transform', 'line-height'. UAs may apply other
2026 properties as well.</p>
2027
2028
2029 <h4><a name=first-letter>7.2. The ::first-letter pseudo-element</a></h4>
2030
2031 <p>The <code>::first-letter</code> pseudo-element represents the first
2032 letter of the first line of a block, if it is not preceded by any
2033 other content (such as images or inline tables) on its line. The
2034 ::first-letter pseudo-element may be used for "initial caps" and "drop
2035 caps", which are common typographical effects. This type of initial
2036 letter is similar to an inline-level element if its 'float' property
2037 is 'none'; otherwise, it is similar to a floated element.</p>
2038
2039 <p>In CSS, these are the properties that apply to <code>::first-letter</code>
2040 pseudo-elements: font properties, 'text-decoration', 'text-transform',
2041 'letter-spacing', 'word-spacing' (when appropriate), 'line-height',
2042 'float', 'vertical-align' (only if 'float' is 'none'), margin
2043 properties, padding properties, border properties, color property,
2044 background properties. UAs may apply other properties as well. To
2045 allow UAs to render a typographically correct drop cap or initial cap,
2046 the UA may choose a line-height, width and height based on the shape
2047 of the letter, unlike for normal elements.</p>
2048
2049 <div class="example">
2050 <p>Example:</p>
2051 <p>This example shows a possible rendering of an initial cap. Note
2052 that the 'line-height' that is inherited by the <code>::first-letter</code>
2053 pseudo-element is 1.1, but the UA in this example has computed the
2054 height of the first letter differently, so that it doesn't cause any
2055 unnecessary space between the first two lines. Also note that the
2056 fictional start tag of the first letter is inside the <span>span</span>, and thu s
2057 the font weight of the first letter is normal, not bold as the <span>span</span> :
2058 <pre>
2059 p { line-height: 1.1 }
2060 p::first-letter { font-size: 3em; font-weight: normal }
2061 span { font-weight: bold }
2062 ...
2063 &lt;p>&lt;span>Het hemelsche&lt;/span> gerecht heeft zich ten lange lesten&lt;br >
2064 Erbarremt over my en mijn benaeuwde vesten&lt;br>
2065 En arme burgery, en op mijn volcx gebed&lt;br>
2066 En dagelix geschrey de bange stad ontzet.
2067 </pre>
2068 <div class="figure">
2069 <p><img src="initial-cap.png" alt="Image illustrating the ::first-letter pseudo- element">
2070 </div>
2071 </div>
2072
2073 <div class="example">
2074 <p>The following CSS will make a drop cap initial letter span about two lines:</ p>
2075
2076 <pre>
2077 &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"&gt;
2078 &lt;HTML&gt;
2079 &lt;HEAD&gt;
2080 &lt;TITLE&gt;Drop cap initial letter&lt;/TITLE&gt;
2081 &lt;STYLE type="text/css"&gt;
2082 P { font-size: 12pt; line-height: 1.2 }
2083 P::first-letter { font-size: 200%; font-weight: bold; float: left }
2084 SPAN { text-transform: uppercase }
2085 &lt;/STYLE&gt;
2086 &lt;/HEAD&gt;
2087 &lt;BODY&gt;
2088 &lt;P&gt;&lt;SPAN&gt;The first&lt;/SPAN&gt; few words of an article
2089 in The Economist.&lt;/P&gt;
2090 &lt;/BODY&gt;
2091 &lt;/HTML&gt;
2092 </pre>
2093
2094 <p>This example might be formatted as follows:</p>
2095
2096 <div class="figure">
2097 <P><img src="first-letter.gif" alt="Image illustrating the combined effect of th e ::first-letter and ::first-line pseudo-elements"></p>
2098 </div>
2099
2100 <p>The <span class="index-inst" title="fictional tag
2101 sequence">fictional tag sequence</span> is:</p>
2102
2103 <pre>
2104 &lt;P&gt;
2105 &lt;SPAN&gt;
2106 &lt;P::first-letter&gt;
2107 T
2108 &lt;/P::first-letter&gt;he first
2109 &lt;/SPAN&gt;
2110 few words of an article in the Economist.
2111 &lt;/P&gt;
2112 </pre>
2113
2114 <p>Note that the <code>::first-letter</code> pseudo-element tags abut
2115 the content (i.e., the initial character), while the ::first-line
2116 pseudo-element start tag is inserted right after the start tag of the
2117 block element.</p> </div>
2118
2119 <p>In order to achieve traditional drop caps formatting, user agents
2120 may approximate font sizes, for example to align baselines. Also, the
2121 glyph outline may be taken into account when formatting.</p>
2122
2123 <p>Punctuation (i.e, characters defined in Unicode in the "open" (Ps),
2124 "close" (Pe), "initial" (Pi). "final" (Pf) and "other" (Po)
2125 punctuation classes), that precedes or follows the first letter should
2126 be included. <a href="#refsUNICODE">[UNICODE]</a></p>
2127
2128 <div class="figure">
2129 <P><img src="first-letter2.gif" alt="Quotes that precede the
2130 first letter should be included."></p>
2131 </div>
2132
2133 <p>The <code>::first-letter</code> also applies if the first letter is
2134 in fact a digit, e.g., the "6" in "67 million dollars is a lot of
2135 money."</p>
2136
2137 <p>In CSS, the <code>::first-letter</code> pseudo-element applies to
2138 block, list-item, table-cell, table-caption, and inline-block
2139 elements. <span class="note">A future version of this specification
2140 may allow this pesudo-element to apply to more element
2141 types.</span></p>
2142
2143 <p>The <code>::first-letter</code> pseudo-element can be used with all
2144 such elements that contain text, or that have a descendant in the same
2145 flow that contains text. A UA should act as if the fictional start tag
2146 of the ::first-letter pseudo-element is just before the first text of
2147 the element, even if that first text is in a descendant.</p>
2148
2149 <div class="example">
2150 <p>Example:</p>
2151 <p>The fictional tag sequence for this HTMLfragment:
2152 <pre>&lt;div>
2153 &lt;p>The first text.</pre>
2154 <p>is:
2155 <pre>&lt;div>
2156 &lt;p>&lt;div::first-letter>&lt;p::first-letter>T&lt;/...>&lt;/...>he first text .</pre>
2157 </div>
2158
2159 <p>The first letter of a table-cell or inline-block cannot be the
2160 first letter of an ancestor element. Thus, in <code>&lt;DIV&gt;&lt;P
2161 STYLE="display: inline-block">Hello&lt;BR&gt;Goodbye&lt;/P&gt;
2162 etcetera&lt;/DIV&gt;</code> the first letter of the <code>div</code> is not the
2163 letter "H". In fact, the <code>div</code> doesn't have a first letter.
2164
2165 <p>The first letter must occur on the <a
2166 href="#first-formatted-line">first formatted line.</a> For example, in
2167 this fragment: <code>&lt;p&gt&lt;br&gt;First...</code> the first line
2168 doesn't contain any letters and <code>::first-letter</code> doesn't
2169 match anything (assuming the default style for <code>br</code> in HTML
2170 4). In particular, it does not match the "F" of "First."
2171
2172 <p>In CSS, if an element is a list item ('display: list-item'), the
2173 <code>::first-letter</code> applies to the first letter in the
2174 principal box after the marker. UAs may ignore
2175 <code>::first-letter</code> on list items with 'list-style-position:
2176 inside'. If an element has <code>::before</code> or
2177 <code>::after</code> content, the <code>::first-letter</code> applies
2178 to the first letter of the element <em>including</em> that content.
2179
2180 <div class="example">
2181 <p>Example:</p>
2182 <p>After the rule 'p::before {content: "Note: "}', the selector
2183 'p::first-letter' matches the "N" of "Note".</p>
2184 </div>
2185
2186 <p>Some languages may have specific rules about how to treat certain
2187 letter combinations. In Dutch, for example, if the letter combination
2188 "ij" appears at the beginning of a word, both letters should be
2189 considered within the <code>::first-letter</code> pseudo-element.
2190
2191 <p>If the letters that would form the ::first-letter are not in the
2192 same element, such as "'T" in <code>&lt;p>'&lt;em>T...</code>, the UA
2193 may create a ::first-letter pseudo-element from one of the elements,
2194 both elements, or simply not create a pseudo-element.</p>
2195
2196 <p>Similarly, if the first letter(s) of the block are not at the start
2197 of the line (for example due to bidirectional reordering), then the UA
2198 need not create the pseudo-element(s).
2199
2200 <div class="example">
2201 <p>Example:</p>
2202 <p><a name="overlapping-example">The following example</a> illustrates
2203 how overlapping pseudo-elements may interact. The first letter of
2204 each P element will be green with a font size of '24pt'. The rest of
2205 the first formatted line will be 'blue' while the rest of the
2206 paragraph will be 'red'.</p>
2207
2208 <pre>p { color: red; font-size: 12pt }
2209 p::first-letter { color: green; font-size: 200% }
2210 p::first-line { color: blue }
2211
2212 &lt;P&gt;Some text that ends up on two lines&lt;/P&gt;</pre>
2213
2214 <p>Assuming that a line break will occur before the word "ends", the
2215 <span class="index-inst" title="fictional tag sequence">fictional tag
2216 sequence</span> for this fragment might be:</p>
2217
2218 <pre>&lt;P&gt;
2219 &lt;P::first-line&gt;
2220 &lt;P::first-letter&gt;
2221 S
2222 &lt;/P::first-letter&gt;ome text that
2223 &lt;/P::first-line&gt;
2224 ends up on two lines
2225 &lt;/P&gt;</pre>
2226
2227 <p>Note that the <code>::first-letter</code> element is inside the <code>::first -line</code>
2228 element. Properties set on <code>::first-line</code> are inherited by
2229 <code>::first-letter</code>, but are overridden if the same property is set on
2230 <code>::first-letter</code>.</p>
2231 </div>
2232
2233
2234 <h4><a name=UIfragments>7.3.</a> <a name=selection>The ::selection pseudo-elemen t</a></h4>
2235
2236 <p>The <code>::selection</code> pseudo-element applies to the portion
2237 of a document that has been highlighted by the user. This also
2238 applies, for example, to selected text within an editable text
2239 field. This pseudo-element should not be confused with the <code><a
2240 href="#checked">:checked</a></code> pseudo-class (which used to be
2241 named <code>:selected</code>)
2242
2243 <p>Although the <code>::selection</code> pseudo-element is dynamic in
2244 nature, and is altered by user action, it is reasonable to expect that
2245 when a UA re-renders to a static medium (such as a printed page, see
2246 <a href="#refsCSS21">[CSS21]</a>) which was originally rendered to a
2247 dynamic medium (like screen), the UA may wish to transfer the current
2248 <code>::selection</code> state to that other medium, and have all the
2249 appropriate formatting and rendering take effect as well. This is not
2250 required &mdash; UAs may omit the <code>::selection</code>
2251 pseudo-element for static media.
2252
2253 <p>These are the CSS properties that apply to <code>::selection</code>
2254 pseudo-elements: color, background, cursor (optional), outline
2255 (optional). The computed value of the 'background-image' property on
2256 <code>::selection</code> may be ignored.
2257
2258
2259 <h4><a name=gen-content>7.4. The ::before and ::after pseudo-elements</a></h4>
2260
2261 <p>The <code>::before</code> and <code>::after</code> pseudo-elements
2262 can be used to describe generated content before or after an element's
2263 content. They are explained in CSS 2.1 <a
2264 href="#refsCSS21">[CSS21]</a>.</p>
2265
2266 <p>When the <code>::first-letter</code> and <code>::first-line</code>
2267 pseudo-elements are combined with <code>::before</code> and
2268 <code>::after</code>, they apply to the first letter or line of the
2269 element including the inserted text.</p>
2270
2271 <h2><a name=combinators>8. Combinators</a></h2>
2272
2273 <h3><a name=descendant-combinators>8.1. Descendant combinator</a></h3>
2274
2275 <p>At times, authors may want selectors to describe an element that is
2276 the descendant of another element in the document tree (e.g., "an
2277 <code>EM</code> element that is contained within an <code>H1</code>
2278 element"). Descendant combinators express such a relationship. A
2279 descendant combinator is <a href="#whitespace">white space</a> that
2280 separates two sequences of simple selectors. A selector of the form
2281 "<code>A B</code>" represents an element <code>B</code> that is an
2282 arbitrary descendant of some ancestor element <code>A</code>.
2283
2284 <div class="example">
2285 <p>Examples:</p>
2286 <p>For example, consider the following selector:</p>
2287 <pre>h1 em</pre>
2288 <p>It represents an <code>em</code> element being the descendant of
2289 an <code>h1</code> element. It is a correct and valid, but partial,
2290 description of the following fragment:</p>
2291 <pre>&lt;h1&gt;This &lt;span class="myclass"&gt;headline
2292 is &lt;em&gt;very&lt;/em&gt; important&lt;/span&gt;&lt;/h1&gt;</pre>
2293 <p>The following selector:</p>
2294 <pre>div * p</pre>
2295 <p>represents a <code>p</code> element that is a grandchild or later
2296 descendant of a <code>div</code> element. Note the whitespace on
2297 either side of the "*" is not part of the universal selector; the
2298 whitespace is a combinator indicating that the DIV must be the
2299 ancestor of some element, and that that element must be an ancestor
2300 of the P.</p>
2301 <p>The following selector, which combines descendant combinators and
2302 <a href="#attribute-selectors">attribute selectors</a>, represents an
2303 element that (1) has the <code>href</code> attribute set and (2) is
2304 inside a <code>p</code> that is itself inside a <code>div</code>:</p>
2305 <pre>div p *[href]</pre>
2306 </div>
2307
2308 <h3><a name=child-combinators>8.2. Child combinators</a></h3>
2309
2310 <p>A <dfn>child combinator</dfn> describes a childhood relationship
2311 between two elements. A child combinator is made of the
2312 &quot;greater-than sign&quot; (<code>&gt;</code>) character and
2313 separates two sequences of simple selectors.
2314
2315
2316 <div class="example">
2317 <p>Examples:</p>
2318 <p>The following selector represents a <code>p</code> element that is
2319 child of <code>body</code>:</p>
2320 <pre>body &gt; p</pre>
2321 <p>The following example combines descendant combinators and child
2322 combinators.</p>
2323 <pre>div ol&gt;li p</pre><!-- LEAVE THOSE SPACES OUT! see below -->
2324 <p>It represents a <code>p</code> element that is a descendant of an
2325 <code>li</code> element; the <code>li</code> element must be the
2326 child of an <code>ol</code> element; the <code>ol</code> element must
2327 be a descendant of a <code>div</code>. Notice that the optional white
2328 space around the "&gt;" combinator has been left out.</p>
2329 </div>
2330
2331 <p>For information on selecting the first child of an element, please
2332 see the section on the <code><a
2333 href="#structural-pseudos">:first-child</a></code> pseudo-class
2334 above.</p>
2335
2336 <h3><a name=sibling-combinators>8.3. Sibling combinators</a></h3>
2337
2338 <p>There are two different sibling combinators: the adjacent sibling
2339 combinator and the general sibling combinator. In both cases,
2340 non-element nodes (e.g. text between elements) are ignored when
2341 considering adjacency of elements.</p>
2342
2343 <h4><a name=adjacent-sibling-combinators>8.3.1. Adjacent sibling combinator</a>< /h4>
2344
2345 <p>The adjacent sibling combinator is made of the &quot;plus
2346 sign&quot; (U+002B, <code>+</code>) character that separates two
2347 sequences of simple selectors. The elements represented by the two
2348 sequences share the same parent in the document tree and the element
2349 represented by the first sequence immediately precedes the element
2350 represented by the second one.</p>
2351
2352 <div class="example">
2353 <p>Examples:</p>
2354 <p>The following selector represents a <code>p</code> element
2355 immediately following a <code>math</code> element:</p>
2356 <pre>math + p</pre>
2357 <p>The following selector is conceptually similar to the one in the
2358 previous example, except that it adds an attribute selector &mdash; it
2359 adds a constraint to the <code>h1</code> element, that it must have
2360 <code>class="opener"</code>:</p>
2361 <pre>h1.opener + h2</pre>
2362 </div>
2363
2364
2365 <h4><a name=general-sibling-combinators>8.3.2. General sibling combinator</a></h 4>
2366
2367 <p>The general sibling combinator is made of the &quot;tilde&quot;
2368 (U+007E, <code>~</code>) character that separates two sequences of
2369 simple selectors. The elements represented by the two sequences share
2370 the same parent in the document tree and the element represented by
2371 the first sequence precedes (not necessarily immediately) the element
2372 represented by the second one.</p>
2373
2374 <div class="example">
2375 <p>Example:</p>
2376 <pre>h1 ~ pre</pre>
2377 <p>represents a <code>pre</code> element following an <code>h1</code>. It
2378 is a correct and valid, but partial, description of:</p>
2379 <pre>&lt;h1&gt;Definition of the function a&lt;/h1&gt;
2380 &lt;p&gt;Function a(x) has to be applied to all figures in the table.&lt;/p&gt;
2381 &lt;pre&gt;function a(x) = 12x/13.5&lt;/pre&gt;</pre>
2382 </div>
2383
2384 <h2><a name=specificity>9. Calculating a selector's specificity</a></h2>
2385
2386 <p>A selector's specificity is calculated as follows:</p>
2387
2388 <ul>
2389 <li>count the number of ID selectors in the selector (= a)</li>
2390 <li>count the number of class selectors, attributes selectors, and pseudo-clas ses in the selector (= b)</li>
2391 <li>count the number of element names in the selector (= c)</li>
2392 <li>ignore pseudo-elements</li>
2393 </ul>
2394
2395 <p>Selectors inside <a href="#negation">the negation pseudo-class</a>
2396 are counted like any other, but the negation itself does not count as
2397 a pseudo-class.</p>
2398
2399 <p>Concatenating the three numbers a-b-c (in a number system with a
2400 large base) gives the specificity.</p>
2401
2402 <div class="example">
2403 <p>Examples:</p>
2404 <pre>* /* a=0 b=0 c=0 -&gt; specificity = 0 */
2405 LI /* a=0 b=0 c=1 -&gt; specificity = 1 */
2406 UL LI /* a=0 b=0 c=2 -&gt; specificity = 2 */
2407 UL OL+LI /* a=0 b=0 c=3 -&gt; specificity = 3 */
2408 H1 + *[REL=up] /* a=0 b=1 c=1 -&gt; specificity = 11 */
2409 UL OL LI.red /* a=0 b=1 c=3 -&gt; specificity = 13 */
2410 LI.red.level /* a=0 b=2 c=1 -&gt; specificity = 21 */
2411 #x34y /* a=1 b=0 c=0 -&gt; specificity = 100 */
2412 #s12:not(FOO) /* a=1 b=0 c=1 -&gt; specificity = 101 */
2413 </pre>
2414 </div>
2415
2416 <p class="note"><strong>Note:</strong> the specificity of the styles
2417 specified in an HTML <code>style</code> attribute is described in CSS
2418 2.1. <a href="#refsCSS21">[CSS21]</a>.</p>
2419
2420 <h2><a name=w3cselgrammar>10. The grammar of Selectors</a></h2>
2421
2422 <h3><a name=grammar>10.1. Grammar</a></h3>
2423
2424 <p>The grammar below defines the syntax of Selectors. It is globally
2425 LL(1) and can be locally LL(2) (but note that most UA's should not use
2426 it directly, since it doesn't express the parsing conventions). The
2427 format of the productions is optimized for human consumption and some
2428 shorthand notations beyond Yacc (see <a href="#refsYACC">[YACC]</a>)
2429 are used:</p>
2430
2431 <ul>
2432 <li><b>*</b>: 0 or more
2433 <li><b>+</b>: 1 or more
2434 <li><b>?</b>: 0 or 1
2435 <li><b>|</b>: separates alternatives
2436 <li><b>[ ]</b>: grouping </li>
2437 </ul>
2438
2439 <p>The productions are:</p>
2440
2441 <pre>selectors_group
2442 : selector [ COMMA S* selector ]*
2443 ;
2444
2445 selector
2446 : simple_selector_sequence [ combinator simple_selector_sequence ]*
2447 ;
2448
2449 combinator
2450 /* combinators can be surrounded by white space */
2451 : PLUS S* | GREATER S* | TILDE S* | S+
2452 ;
2453
2454 simple_selector_sequence
2455 : [ type_selector | universal ]
2456 [ HASH | class | attrib | pseudo | negation ]*
2457 | [ HASH | class | attrib | pseudo | negation ]+
2458 ;
2459
2460 type_selector
2461 : [ namespace_prefix ]? element_name
2462 ;
2463
2464 namespace_prefix
2465 : [ IDENT | '*' ]? '|'
2466 ;
2467
2468 element_name
2469 : IDENT
2470 ;
2471
2472 universal
2473 : [ namespace_prefix ]? '*'
2474 ;
2475
2476 class
2477 : '.' IDENT
2478 ;
2479
2480 attrib
2481 : '[' S* [ namespace_prefix ]? IDENT S*
2482 [ [ PREFIXMATCH |
2483 SUFFIXMATCH |
2484 SUBSTRINGMATCH |
2485 '=' |
2486 INCLUDES |
2487 DASHMATCH ] S* [ IDENT | STRING ] S*
2488 ]? ']'
2489 ;
2490
2491 pseudo
2492 /* '::' starts a pseudo-element, ':' a pseudo-class */
2493 /* Exceptions: :first-line, :first-letter, :before and :after. */
2494 /* Note that pseudo-elements are restricted to one per selector and */
2495 /* occur only in the last simple_selector_sequence. */
2496 : ':' ':'? [ IDENT | functional_pseudo ]
2497 ;
2498
2499 functional_pseudo
2500 : FUNCTION S* expression ')'
2501 ;
2502
2503 expression
2504 /* In CSS3, the expressions are identifiers, strings, */
2505 /* or of the form "an+b" */
2506 : [ [ PLUS | '-' | DIMENSION | NUMBER | STRING | IDENT ] S* ]+
2507 ;
2508
2509 negation
2510 : NOT S* negation_arg S* ')'
2511 ;
2512
2513 negation_arg
2514 : type_selector | universal | HASH | class | attrib | pseudo
2515 ;</pre>
2516
2517
2518 <h3><a name=lex>10.2. Lexical scanner</a></h3>
2519
2520 <p>The following is the <a name=x3>tokenizer</a>, written in Flex (see
2521 <a href="#refsFLEX">[FLEX]</a>) notation. The tokenizer is
2522 case-insensitive.</p>
2523
2524 <p>The two occurrences of "\377" represent the highest character
2525 number that current versions of Flex can deal with (decimal 255). They
2526 should be read as "\4177777" (decimal 1114111), which is the highest
2527 possible code point in Unicode/ISO-10646. <a
2528 href="#refsUNICODE">[UNICODE]</a></p>
2529
2530 <pre>%option case-insensitive
2531
2532 ident [-]?{nmstart}{nmchar}*
2533 name {nmchar}+
2534 nmstart [_a-z]|{nonascii}|{escape}
2535 nonascii [^\0-\177]
2536 unicode \\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?
2537 escape {unicode}|\\[^\n\r\f0-9a-f]
2538 nmchar [_a-z0-9-]|{nonascii}|{escape}
2539 num [0-9]+|[0-9]*\.[0-9]+
2540 string {string1}|{string2}
2541 string1 \"([^\n\r\f\\"]|\\{nl}|{nonascii}|{escape})*\"
2542 string2 \'([^\n\r\f\\']|\\{nl}|{nonascii}|{escape})*\'
2543 invalid {invalid1}|{invalid2}
2544 invalid1 \"([^\n\r\f\\"]|\\{nl}|{nonascii}|{escape})*
2545 invalid2 \'([^\n\r\f\\']|\\{nl}|{nonascii}|{escape})*
2546 nl \n|\r\n|\r|\f
2547 w [ \t\r\n\f]*
2548
2549 %%
2550
2551 [ \t\r\n\f]+ return S;
2552
2553 "~=" return INCLUDES;
2554 "|=" return DASHMATCH;
2555 "^=" return PREFIXMATCH;
2556 "$=" return SUFFIXMATCH;
2557 "*=" return SUBSTRINGMATCH;
2558 {ident} return IDENT;
2559 {string} return STRING;
2560 {ident}"(" return FUNCTION;
2561 {num} return NUMBER;
2562 "#"{name} return HASH;
2563 {w}"+" return PLUS;
2564 {w}"&gt;" return GREATER;
2565 {w}"," return COMMA;
2566 {w}"~" return TILDE;
2567 ":not(" return NOT;
2568 @{ident} return ATKEYWORD;
2569 {invalid} return INVALID;
2570 {num}% return PERCENTAGE;
2571 {num}{ident} return DIMENSION;
2572 "&lt;!--" return CDO;
2573 "--&gt;" return CDC;
2574
2575 "url("{w}{string}{w}")" return URI;
2576 "url("{w}([!#$%&*-~]|{nonascii}|{escape})*{w}")" return URI;
2577 U\+[0-9a-f?]{1,6}(-[0-9a-f]{1,6})? return UNICODE_RANGE;
2578
2579 \/\*[^*]*\*+([^/*][^*]*\*+)*\/ /* ignore comments */
2580
2581 . return *yytext;</pre>
2582
2583
2584
2585 <h2><a name=downlevel>11. Namespaces and down-level clients</a></h2>
2586
2587 <p>An important issue is the interaction of CSS selectors with XML
2588 documents in web clients that were produced prior to this
2589 document. Unfortunately, due to the fact that namespaces must be
2590 matched based on the URI which identifies the namespace, not the
2591 namespace prefix, some mechanism is required to identify namespaces in
2592 CSS by their URI as well. Without such a mechanism, it is impossible
2593 to construct a CSS style sheet which will properly match selectors in
2594 all cases against a random set of XML documents. However, given
2595 complete knowledge of the XML document to which a style sheet is to be
2596 applied, and a limited use of namespaces within the XML document, it
2597 is possible to construct a style sheet in which selectors would match
2598 elements and attributes correctly.</p>
2599
2600 <p>It should be noted that a down-level CSS client will (if it
2601 properly conforms to CSS forward compatible parsing rules) ignore all
2602 <code>@namespace</code> at-rules, as well as all style rules that make
2603 use of namespace qualified element type or attribute selectors. The
2604 syntax of delimiting namespace prefixes in CSS was deliberately chosen
2605 so that down-level CSS clients would ignore the style rules rather
2606 than possibly match them incorrectly.</p>
2607
2608 <p>The use of default namespaces in CSS makes it possible to write
2609 element type selectors that will function in both namespace aware CSS
2610 clients as well as down-level clients. It should be noted that
2611 down-level clients may incorrectly match selectors against XML
2612 elements in other namespaces.</p>
2613
2614 <p>The following are scenarios and examples in which it is possible to
2615 construct style sheets which would function properly in web clients
2616 that do not implement this proposal.</p>
2617
2618 <ol>
2619 <li>
2620
2621 <p>The XML document does not use namespaces.</p>
2622
2623 <ul>
2624
2625 <li>In this case, it is obviously not necessary to declare or use
2626 namespaces in the style sheet. Standard CSS element type and
2627 attribute selectors will function adequately in a down-level
2628 client.</li>
2629
2630 <li>In a CSS namespace aware client, the default behavior of
2631 element selectors matching without regard to namespace will
2632 function properly against all elements, since no namespaces are
2633 present. However, the use of specific element type selectors that
2634 match only elements that have no namespace ("<code>|name</code>")
2635 will guarantee that selectors will match only XML elements that do
2636 not have a declared namespace. </li>
2637
2638 </ul>
2639
2640 </li>
2641
2642 <li>
2643
2644 <p>The XML document defines a single, default namespace used
2645 throughout the document. No namespace prefixes are used in element
2646 names.</p>
2647
2648 <ul>
2649
2650 <li>In this case, a down-level client will function as if
2651 namespaces were not used in the XML document at all. Standard CSS
2652 element type and attribute selectors will match against all
2653 elements. </li>
2654
2655 </ul>
2656
2657 </li>
2658
2659 <li>
2660
2661 <p>The XML document does <b>not</b> use a default namespace, all
2662 namespace prefixes used are known to the style sheet author, and
2663 there is a direct mapping between namespace prefixes and namespace
2664 URIs. (A given prefix may only be mapped to one namespace URI
2665 throughout the XML document; there may be multiple prefixes mapped
2666 to the same URI).</p>
2667
2668 <ul>
2669
2670 <li>In this case, the down-level client will view and match
2671 element type and attribute selectors based on their fully
2672 qualified name, not the local part as outlined in the <a
2673 href="#typenmsp">Type selectors and Namespaces</a> section. CSS
2674 selectors may be declared using an escaped colon "<code>\:</code>"
2675 to describe the fully qualified names, e.g.
2676 "<code>html\:h1</code>" will match
2677 <code>&lt;html:h1&gt;</code>. Selectors using the qualified name
2678 will only match XML elements that use the same prefix. Other
2679 namespace prefixes used in the XML that are mapped to the same URI
2680 will not match as expected unless additional CSS style rules are
2681 declared for them.</li>
2682
2683 <li>Note that selectors declared in this fashion will
2684 <em>only</em> match in down-level clients. A CSS namespace aware
2685 client will match element type and attribute selectors based on
2686 the name's local part. Selectors declared with the fully
2687 qualified name will not match (unless there is no namespace prefix
2688 in the fully qualified name).</li>
2689
2690 </ul>
2691
2692 </li>
2693
2694 </ol>
2695
2696 <p>In other scenarios: when the namespace prefixes used in the XML are
2697 not known in advance by the style sheet author; or a combination of
2698 elements with no namespace are used in conjunction with elements using
2699 a default namespace; or the same namespace prefix is mapped to
2700 <em>different</em> namespace URIs within the same document, or in
2701 different documents; it is impossible to construct a CSS style sheet
2702 that will function properly against all elements in those documents,
2703 unless, the style sheet is written using a namespace URI syntax (as
2704 outlined in this document or similar) and the document is processed by
2705 a CSS and XML namespace aware client.</p>
2706
2707 <h2><a name=profiling>12. Profiles</a></h2>
2708
2709 <p>Each specification using Selectors must define the subset of W3C
2710 Selectors it allows and excludes, and describe the local meaning of
2711 all the components of that subset.</p>
2712
2713 <p>Non normative examples:
2714
2715 <div class="profile">
2716 <table class="tprofile">
2717 <tbody>
2718 <tr>
2719 <th class="title" colspan=2>Selectors profile</th></tr>
2720 <tr>
2721 <th>Specification</th>
2722 <td>CSS level 1</td></tr>
2723 <tr>
2724 <th>Accepts</th>
2725 <td>type selectors<br>class selectors<br>ID selectors<br>:link,
2726 :visited and :active pseudo-classes<br>descendant combinator
2727 <br>::first-line and ::first-letter pseudo-elements</td></tr>
2728 <tr>
2729 <th>Excludes</th>
2730 <td>
2731
2732 <p>universal selector<br>attribute selectors<br>:hover and :focus
2733 pseudo-classes<br>:target pseudo-class<br>:lang() pseudo-class<br>all UI
2734 element states pseudo-classes<br>all structural
2735 pseudo-classes<br>negation pseudo-class<br>all
2736 UI element fragments pseudo-elements<br>::before and ::after
2737 pseudo-elements<br>child combinators<br>sibling combinators
2738
2739 <p>namespaces</td></tr>
2740 <tr>
2741 <th>Extra constraints</th>
2742 <td>only one class selector allowed per sequence of simple
2743 selectors</td></tr></tbody></table><br><br>
2744 <table class="tprofile">
2745 <tbody>
2746 <tr>
2747 <th class="title" colspan=2>Selectors profile</th></tr>
2748 <tr>
2749 <th>Specification</th>
2750 <td>CSS level 2</td></tr>
2751 <tr>
2752 <th>Accepts</th>
2753 <td>type selectors<br>universal selector<br>attribute presence and
2754 values selectors<br>class selectors<br>ID selectors<br>:link, :visited,
2755 :active, :hover, :focus, :lang() and :first-child pseudo-classes
2756 <br>descendant combinator<br>child combinator<br>adjacent sibling
2757 combinator<br>::first-line and ::first-letter pseudo-elements<br>::before
2758 and ::after pseudo-elements</td></tr>
2759 <tr>
2760 <th>Excludes</th>
2761 <td>
2762
2763 <p>content selectors<br>substring matching attribute
2764 selectors<br>:target pseudo-classes<br>all UI element
2765 states pseudo-classes<br>all structural pseudo-classes other
2766 than :first-child<br>negation pseudo-class<br>all UI element
2767 fragments pseudo-elements<br>general sibling combinators
2768
2769 <p>namespaces</td></tr>
2770 <tr>
2771 <th>Extra constraints</th>
2772 <td>more than one class selector per sequence of simple selectors (CSS1
2773 constraint) allowed</td></tr></tbody></table>
2774
2775 <p>In CSS, selectors express pattern matching rules that determine which style
2776 rules apply to elements in the document tree.
2777
2778 <p>The following selector (CSS level 2) will <b>match</b> all anchors <code>a</c ode>
2779 with attribute <code>name</code> set inside a section 1 header <code>h1</code>:
2780 <pre>h1 a[name]</pre>
2781
2782 <p>All CSS declarations attached to such a selector are applied to elements
2783 matching it. </div>
2784
2785 <div class="profile">
2786 <table class="tprofile">
2787 <tbody>
2788 <tr>
2789 <th class="title" colspan=2>Selectors profile</th></tr>
2790 <tr>
2791 <th>Specification</th>
2792 <td>STTS 3</td>
2793 </tr>
2794 <tr>
2795 <th>Accepts</th>
2796 <td>
2797
2798 <p>type selectors<br>universal selectors<br>attribute selectors<br>class
2799 selectors<br>ID selectors<br>all structural pseudo-classes<br>
2800 all combinators
2801
2802 <p>namespaces</td></tr>
2803 <tr>
2804 <th>Excludes</th>
2805 <td>non-accepted pseudo-classes<br>pseudo-elements<br></td></tr>
2806 <tr>
2807 <th>Extra constraints</th>
2808 <td>some selectors and combinators are not allowed in fragment
2809 descriptions on the right side of STTS declarations.</td></tr></tbody></ta ble>
2810 <form>
2811 <input type="text" name="test10"/>
2812 <input type="text" name="foo"/>
2813 <input type="text" name="foo"/>
2814 <input type="text" name="foo"/>
2815 <input type="text" name="foo"/>
2816 <input type="text" name="foo"/>
2817 <input type="text" name="foo"/>
2818 <input type="text" name="foo"/>
2819 <input type="text" name="foo"/>
2820 <input type="text" name="foo"/>
2821 <input type="text" name="foo"/>
2822 <input type="text" name="foo"/>
2823 <input type="text" name="foo"/>
2824 <input type="text" name="foo"/>
2825 <input type="text" name="foo"/>
2826 <input type="text" name="foo"/>
2827 <input type="text" name="foo"/>
2828 <input type="text" name="foo"/>
2829 <input type="text" name="foo"/>
2830 <input type="text" name="foo"/>
2831 <input type="text" name="foo"/>
2832 <input type="text" name="foo"/>
2833 <input type="text" name="foo"/>
2834 <input type="text" name="foo"/>
2835 <input type="text" name="foo"/>
2836 </form>
2837
2838 <p>Selectors can be used in STTS 3 in two different
2839 manners:
2840 <ol>
2841 <li>a selection mechanism equivalent to CSS selection mechanism: declarations
2842 attached to a given selector are applied to elements matching that selector,
2843 <li>fragment descriptions that appear on the right side of declarations.
2844 </li></ol></div>
2845
2846 <h2><a name=Conformance></a>13. Conformance and requirements</h2>
2847
2848 <p>This section defines conformance with the present specification only.
2849
2850 <p>The inability of a user agent to implement part of this specification due to
2851 the limitations of a particular device (e.g., non interactive user agents will
2852 probably not implement dynamic pseudo-classes because they make no sense without
2853 interactivity) does not imply non-conformance.
2854
2855 <p>All specifications reusing Selectors must contain a <a
2856 href="#profiling">Profile</a> listing the
2857 subset of Selectors it accepts or excludes, and describing the constraints
2858 it adds to the current specification.
2859
2860 <p>Invalidity is caused by a parsing error, e.g. an unrecognized token or a toke n
2861 which is not allowed at the current parsing point.
2862
2863 <p>User agents must observe the rules for handling parsing errors:
2864 <ul>
2865 <li>a simple selector containing an undeclared namespace prefix is invalid</li >
2866 <li>a selector containing an invalid simple selector, an invalid combinator
2867 or an invalid token is invalid. </li>
2868 <li>a group of selectors containing an invalid selector is invalid.</li>
2869 </ul>
2870
2871 <p class="foo test10 bar">Specifications reusing Selectors must define how to ha ndle parsing
2872 errors. (In the case of CSS, the entire rule in which the selector is
2873 used is dropped.)</p>
2874
2875 <!-- Apparently all these references are out of date:
2876 <p>Implementations of this specification must behave as
2877 "recipients of text data" as defined by <a href="#refsCWWW">[CWWW]</a>
2878 when parsing selectors and attempting matches. (In particular,
2879 implementations must assume the data is normalized and must not
2880 normalize it.) Normative rules for matching strings are defined in
2881 <a href="#refsCWWW">[CWWW]</a> and <a
2882 href="#refsUNICODE">[UNICODE]</a> and apply to implementations of this
2883 specification.</p>-->
2884
2885 <h2><a name=Tests></a>14. Tests</h2>
2886
2887 <p>This specification has <a
2888 href="http://www.w3.org/Style/CSS/Test/CSS3/Selectors/current/">a test
2889 suite</a> allowing user agents to verify their basic conformance to
2890 the specification. This test suite does not pretend to be exhaustive
2891 and does not cover all possible combined cases of Selectors.</p>
2892
2893 <h2><a name=ACKS></a>15. Acknowledgements</h2>
2894
2895 <p>The CSS working group would like to thank everyone who has sent
2896 comments on this specification over the years.</p>
2897
2898 <p>The working group would like to extend special thanks to Donna
2899 McManus, Justin Baker, Joel Sklar, and Molly Ives Brower who perfermed
2900 the final editorial review.</p>
2901
2902 <h2><a name=references>16. References</a></h2>
2903
2904 <dl class="refs">
2905
2906 <dt>[CSS1]
2907 <dd><a name=refsCSS1></a> Bert Bos, H&aring;kon Wium Lie; "<cite>Cascading Sty le Sheets, level 1</cite>", W3C Recommendation, 17 Dec 1996, revised 11 Jan 1999
2908 <dd>(<code><a href="http://www.w3.org/TR/REC-CSS1">http://www.w3.org/TR/REC-CS S1</a></code>)
2909
2910 <dt>[CSS21]
2911 <dd><a name=refsCSS21></a> Bert Bos, Tantek &Ccedil;elik, Ian Hickson, H&aring ;kon Wium Lie, editors; "<cite>Cascading Style Sheets, level 2 revision 1</cite> ", W3C Working Draft, 13 June 2005
2912 <dd>(<code><a href="http://www.w3.org/TR/CSS21">http://www.w3.org/TR/CSS21</a> </code>)
2913
2914 <dt>[CWWW]
2915 <dd><a name=refsCWWW></a> Martin J. D&uuml;rst, Fran&ccedil;ois Yergeau, Misha Wolf, Asmus Freytag, Tex Texin, editors; "<cite>Character Model for the World W ide Web</cite>", W3C Recommendation, 15 February 2005
2916 <dd>(<code><a href="http://www.w3.org/TR/charmod/">http://www.w3.org/TR/charmo d/</a></code>)
2917
2918 <dt>[FLEX]
2919 <dd><a name="refsFLEX"></a> "<cite>Flex: The Lexical Scanner Generator</cite>" , Version 2.3.7, ISBN 1882114213
2920
2921 <dt>[HTML4]
2922 <dd><a name="refsHTML4"></a> Dave Ragget, Arnaud Le Hors, Ian Jacobs, editors; "<cite>HTML 4.01 Specification</cite>", W3C Recommendation, 24 December 1999
2923 <dd>(<a href="http://www.w3.org/TR/html4/"><code>http://www.w3.org/TR/html4/</ code></a>)
2924
2925 <dt>[MATH]
2926 <dd><a name="refsMATH"></a> Patrick Ion, Robert Miner, editors; "<cite>Mathema tical Markup Language (MathML) 1.01</cite>", W3C Recommendation, revision of 7 J uly 1999
2927 <dd>(<code><a href="http://www.w3.org/TR/REC-MathML/">http://www.w3.org/TR/REC -MathML/</a></code>)
2928
2929 <dt>[RFC3066]
2930 <dd><a name="refsRFC3066"></a> H. Alvestrand; "<cite>Tags for the Identificati on of Languages</cite>", Request for Comments 3066, January 2001
2931 <dd>(<a href="http://www.ietf.org/rfc/rfc3066.txt"><code>http://www.ietf.org/r fc/rfc3066.txt</code></a>)
2932
2933 <dt>[STTS]
2934 <dd><a name=refsSTTS></a> Daniel Glazman; "<cite>Simple Tree Transformation Sh eets 3</cite>", Electricit&eacute; de France, submission to the W3C, 11 November 1998
2935 <dd>(<code><a href="http://www.w3.org/TR/NOTE-STTS3">http://www.w3.org/TR/NOTE -STTS3</a></code>)
2936
2937 <dt>[SVG]
2938 <dd><a name="refsSVG"></a> Jon Ferraiolo, &#34276;&#27810; &#28147;, Dean Jack son, editors; "<cite>Scalable Vector Graphics (SVG) 1.1 Specification</cite>", W 3C Recommendation, 14 January 2003
2939 <dd>(<code><a href="http://www.w3.org/TR/SVG/">http://www.w3.org/TR/SVG/</a></ code>)
2940
2941 <dt>[UNICODE]</dt>
2942 <dd><a name="refsUNICODE"></a> <cite><a
2943 href="http://www.unicode.org/versions/Unicode4.1.0/">The Unicode Standard, Ve rsion 4.1</a></cite>, The Unicode Consortium. Boston, MA, Addison-Wesley, March 2005. ISBN 0-321-18578-1, as amended by <a href="http://www.unicode.org/versions /Unicode4.0.1/">Unicode 4.0.1</a> and <a href="http://www.unicode.org/versions/U nicode4.1.0/">Unicode 4.1.0</a>.
2944 <dd>(<code><a href="http://www.unicode.org/versions/">http://www.unicode.org/v ersions/</a></code>)</dd>
2945
2946 <dt>[XML10]
2947 <dd><a name="refsXML10"></a> Tim Bray, Jean Paoli, C. M. Sperberg-McQueen, Eve Maler, Fran&ccedil;ois Yergeau, editors; "<cite>Extensible Markup Language (XML ) 1.0 (Third Edition)</cite>", W3C Recommendation, 4 February 2004
2948 <dd>(<a href="http://www.w3.org/TR/REC-xml/"><code>http://www.w3.org/TR/REC-xm l/</code></a>)
2949
2950 <dt>[XMLNAMES]
2951 <dd><a name="refsXMLNAMES"></a> Tim Bray, Dave Hollander, Andrew Layman, edito rs; "<cite>Namespaces in XML</cite>", W3C Recommendation, 14 January 1999
2952 <dd>(<a href="http://www.w3.org/TR/REC-xml-names/"><code>http://www.w3.org/TR/ REC-xml-names/</code></a>)
2953
2954 <dt>[YACC]
2955 <dd><a name="refsYACC"></a> S. C. Johnson; "<cite>YACC &mdash; Yet another com piler compiler</cite>", Technical Report, Murray Hill, 1975
2956
2957 </dl>
2958 </body>
2959 </html>
OLDNEW
« no previous file with comments | « chrome/test/data/dromaeo/tests/jslib-style-jquery.html ('k') | chrome/test/data/dromaeo/tests/jslib-traverse-jquery.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698