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