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