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