diff options
author | Ray Cromwell <cromwellian@gmail.com> | 2009-05-15 00:25:16 +0000 |
---|---|---|
committer | Ray Cromwell <cromwellian@gmail.com> | 2009-05-15 00:25:16 +0000 |
commit | 67086efa4ae77fee844703ae4af9b30001d624cb (patch) | |
tree | 6fd8146628cd8932f6fd9e23ee19c95c564de7ee /samples/src | |
parent | 7557842d252c50ca4751ba545abb1e52e2a7a285 (diff) | |
download | gwtquery-67086efa4ae77fee844703ae4af9b30001d624cb.tar.gz gwtquery-67086efa4ae77fee844703ae4af9b30001d624cb.zip |
Fixes to star-ratings plugin
Added "horse race" visualization to selector benchmark
Diffstat (limited to 'samples/src')
-rw-r--r-- | samples/src/main/java/gwtquery/samples/client/GwtQueryBenchModule.java | 383 | ||||
-rw-r--r-- | samples/src/main/java/gwtquery/samples/public/GwtQueryBench.html | 3640 | ||||
-rw-r--r-- | samples/src/main/java/gwtquery/samples/public/dojo.js | 16 | ||||
-rw-r--r-- | samples/src/main/java/gwtquery/samples/public/dojobench.html | 3172 | ||||
-rw-r--r-- | samples/src/main/java/gwtquery/samples/public/grass-texture.jpg | bin | 0 -> 451098 bytes | |||
-rw-r--r-- | samples/src/main/java/gwtquery/samples/public/horse.png | bin | 0 -> 57027 bytes | |||
-rw-r--r-- | samples/src/main/java/gwtquery/samples/public/jquery-1.3.1.js | 4242 | ||||
-rw-r--r-- | samples/src/main/java/gwtquery/samples/public/jquerybench.html | 3172 | ||||
-rw-r--r-- | samples/src/main/java/gwtquery/samples/public/prototype-1.6.0.3.js | 4320 | ||||
-rw-r--r-- | samples/src/main/java/gwtquery/samples/public/prototypebench.html | 3172 | ||||
-rw-r--r-- | samples/src/main/java/gwtquery/samples/public/racetrack.html | 68 |
11 files changed, 20358 insertions, 1827 deletions
diff --git a/samples/src/main/java/gwtquery/samples/client/GwtQueryBenchModule.java b/samples/src/main/java/gwtquery/samples/client/GwtQueryBenchModule.java index 6ddf6690..55355a35 100644 --- a/samples/src/main/java/gwtquery/samples/client/GwtQueryBenchModule.java +++ b/samples/src/main/java/gwtquery/samples/client/GwtQueryBenchModule.java @@ -4,209 +4,260 @@ import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
-import com.google.gwt.user.client.DeferredCommand;
-import com.google.gwt.user.client.IncrementalCommand;
import com.google.gwt.query.client.DeferredGQuery;
import com.google.gwt.query.client.SelectorEngine;
-import static com.google.gwt.query.client.GQuery.$;
-
+import com.google.gwt.user.client.DeferredCommand;
+import com.google.gwt.user.client.IncrementalCommand;
+import com.google.gwt.user.client.DOM;
+
public class GwtQueryBenchModule implements EntryPoint {
- private StringBuffer log = new StringBuffer();
+ private StringBuffer log = new StringBuffer();
- private static final int MIN_TIME = 200;
+ private static final int MIN_TIME = 200;
- private static final String GCOMPILED = "gcompiled";
+ private static final String GCOMPILED = "gwt";
- private static final String DOMASSISTANT = "dresult";
+ private static final String JQUERY = "jquery";
- private static final String GDYNAMIC = "gresult";
+ private static final String GDYNAMIC = "gwtdynamic";
- public void onModuleLoad() {
- final MySelectors m = GWT.create(MySelectors.class);
+ private static final String DOJO = "dojo";
- final DeferredGQuery dg[] = m.getAllSelectors();
- initResultsTable(dg, "Compiled GQuery", GCOMPILED, "DOMAssistant-2.7" /*"DOMAssistant 2.7" */,
- DOMASSISTANT, "Dynamic GQuery", GDYNAMIC);
- runBenchmarks(dg, new GQueryCompiledBenchmark(),
- new DomAssistantBenchmark(), new GQueryDynamicBenchmark());
- }
+ private static final String PROTOTYPE = "prototype";
- public interface Benchmark {
+ public void onModuleLoad() {
+ final MySelectors m = GWT.create(MySelectors.class);
- public int runSelector(DeferredGQuery dq, String selector);
+ final DeferredGQuery dg[] = m.getAllSelectors();
+ initResultsTable(dg, "Compiled GQuery", GCOMPILED, "jQuery"
+ /*"DOMAssistant 2.7" */, JQUERY, "Dojo", DOJO, "Prototype", PROTOTYPE);
+ runBenchmarks(dg, new GQueryCompiledBenchmark(), new JQueryBenchmark(),
+ new DojoBenchmark(), new PrototypeBenchmark());
+ }
- String getId();
- }
+ public interface Benchmark {
+ public int runSelector(DeferredGQuery dq, String selector);
- public void runBenchmarks(final DeferredGQuery[] dg,
- final Benchmark... benchmark) {
- DeferredCommand.addCommand(new IncrementalCommand() {
- int selectorNumber = 0;
- int numCalls = 0;
- int benchMarkNumber = 0;
- double totalTimes[] = new double[benchmark.length];
- long cumTime = 0;
-
- int numRuns = 0;
- int winner = -1;
- double winTime = Double.MAX_VALUE;
- public boolean execute() {
- if (benchMarkNumber >= benchmark.length) {
- benchMarkNumber = 0;
- numCalls = 0;
- cumTime = 0;
- numRuns = 0;
- setResultClass(benchmark[winner].getId(), selectorNumber, "win");
- for (int i = 0; i < benchmark.length; i++) {
- if (i != winner)
- setResultClass(benchmark[i].getId(), selectorNumber, "lose");
- }
- selectorNumber++;
- winner = -1;
- winTime = Double.MAX_VALUE;
- if (selectorNumber >= dg.length) {
- double min = Double.MAX_VALUE;
- for (int i = 0; i < totalTimes.length; i++) {
- if (totalTimes[i] < min) min = totalTimes[i];
- }
- for (int i = 0; i < totalTimes.length; i++) {
- d(benchmark[i].getId(), dg.length, (((int) (totalTimes[i] * 100)) / 100.0) + " ms");
- setResultClass(benchmark[i].getId(),
- dg.length, totalTimes[i] <= min ? "win" : "lose");
- }
- return false;
- }
- }
- DeferredGQuery d = dg[selectorNumber];
- long start = System.currentTimeMillis();
- int num = 0;
- long end = start;
- Benchmark m = benchmark[benchMarkNumber];
- String selector = d.getSelector();
-
- do {
- num += m.runSelector(d, selector);
- end = System.currentTimeMillis();
- numCalls++;
- } while (end - start < MIN_TIME);
- double runtime = (double) (end - start) / numCalls;
- if (runtime < winTime) {
- winTime = runtime;
- winner = benchMarkNumber;
- }
- d(m.getId(), selectorNumber, runtime, (num / numCalls));
- totalTimes[benchMarkNumber] += runtime;
- numCalls = 0;
- benchMarkNumber++;
- return true;
- }
- });
- }
+ String getId();
+ }
- private void setResultClass(String id, int i, String clz) {
- Element td = Document.get().getElementById(id + i);
- td.setClassName(clz);
- }
+ public void runBenchmarks(final DeferredGQuery[] dg,
+ final Benchmark... benchmark) {
+ DeferredCommand.addCommand(new IncrementalCommand() {
+ int selectorNumber = 0;
- private void d(String type, int i, String text) {
- Element td = Document.get().getElementById(type + i);
- td.setInnerHTML(text);
- }
+ int numCalls = 0;
- private void d(String type, int i, double v, int i1) {
+ int benchMarkNumber = 0;
- Element td = Document.get().getElementById(type + i);
- td.setInnerHTML(
- "" + (((int) (v * 100)) / 100.0) + " ms, found " + i1 + " nodes");
- }
+ double totalTimes[] = new double[benchmark.length];
- private void initResultsTable(DeferredGQuery[] dg, String... options) {
- int numRows = dg.length;
- Document doc = Document.get();
- Element table = doc.getElementById("resultstable");
- Element thead = doc.createTHeadElement();
- table.appendChild(thead);
- Element selectorHeader = doc.createTHElement();
- Element theadtr = doc.createTRElement();
- selectorHeader.setInnerHTML("Selector");
- theadtr.appendChild(selectorHeader);
- thead.appendChild(theadtr);
-
- Element tbody = doc.createTBodyElement();
- table.appendChild(tbody);
-
- for (int i = 0; i < options.length; i += 2) {
- Element th = doc.createTHElement();
- th.setInnerHTML(options[i]);
- theadtr.appendChild(th);
- }
- for (int i = 0; i < numRows; i++) {
- Element tr = doc.createTRElement();
- Element lab = doc.createTHElement();
- lab.setInnerHTML(dg[i].getSelector());
- tr.appendChild(lab);
- for (int j = 0; j < options.length; j += 2) {
- Element placeholder = doc.createTDElement();
- placeholder.setInnerHTML("Not Tested");
- placeholder.setId(options[j + 1] + i);
- tr.appendChild(placeholder);
+ double runTimes[] = new double[benchmark.length];
+
+ long cumTime = 0;
+
+ int numRuns = 0;
+
+ int winner = -1;
+
+ double winTime = Double.MAX_VALUE;
+
+ public boolean execute() {
+ if (benchMarkNumber >= benchmark.length) {
+ benchMarkNumber = 0;
+ numCalls = 0;
+ cumTime = 0;
+ numRuns = 0;
+ setResultClass(benchmark[winner].getId(), selectorNumber, "win");
+ double totalMovement = (790.0 - 124.0) / dg.length;
+ moveHorse(benchmark[winner].getId(), totalMovement);
+
+ for (int i = 0; i < benchmark.length; i++) {
+ if (i != winner) {
+ moveHorse(benchmark[i].getId(),
+ (int) (totalMovement * (double)(winTime
+ / (double) runTimes[i])));
+ setResultClass(benchmark[i].getId(), selectorNumber, "lose");
+ }
+ }
+ selectorNumber++;
+ winner = -1;
+ winTime = Double.MAX_VALUE;
+ if (selectorNumber >= dg.length) {
+ double min = Double.MAX_VALUE;
+ for (int i = 0; i < totalTimes.length; i++) {
+ if (totalTimes[i] < min) {
+ min = totalTimes[i];
+ }
}
- tbody.appendChild(tr);
+ for (int i = 0; i < totalTimes.length; i++) {
+ d(benchmark[i].getId(), dg.length,
+ (((int) (totalTimes[i] * 100)) / 100.0) + " ms");
+ setResultClass(benchmark[i].getId(), dg.length,
+ totalTimes[i] <= min ? "win" : "lose");
+ }
+ return false;
+ }
}
- Element totalRow = doc.createTRElement();
- Element totalLab = doc.createTHElement();
- totalLab.setInnerHTML("Total");
- totalRow.appendChild(totalLab);
- for (int j = 0; j < options.length; j += 2) {
- Element placeholder = doc.createTDElement();
- placeholder.setInnerHTML("0");
- placeholder.setId(options[j + 1] + numRows);
- totalRow.appendChild(placeholder);
+ DeferredGQuery d = dg[selectorNumber];
+ long start = System.currentTimeMillis();
+ int num = 0;
+ long end = start;
+ Benchmark m = benchmark[benchMarkNumber];
+ String selector = d.getSelector();
+
+ do {
+ num += m.runSelector(d, selector);
+ end = System.currentTimeMillis();
+ numCalls++;
+ } while (end - start < MIN_TIME);
+ double runtime = (double) (end - start) / numCalls;
+ if (runtime < winTime) {
+ winTime = runtime;
+ winner = benchMarkNumber;
}
- tbody.appendChild(totalRow);
+ runTimes[benchMarkNumber] = runtime;
+ d(m.getId(), selectorNumber, runtime, (num / numCalls));
+ totalTimes[benchMarkNumber] += runtime;
+ numCalls = 0;
+ benchMarkNumber++;
+ return true;
+ }
+ });
+ }
+
+ private native void moveHorse(String id, double totalMovement) /*-{
+ $wnd.moveHorse(id, totalMovement);
+ }-*/;
+
+ private void setResultClass(String id, int i, String clz) {
+ Element td = Document.get().getElementById(id + i);
+ td.setClassName(clz);
+ }
+
+ private void d(String type, int i, String text) {
+ Element td = Document.get().getElementById(type + i);
+ td.setInnerHTML(text);
+ DOM.scrollIntoView((com.google.gwt.user.client.Element) td);
+ }
+
+ private void d(String type, int i, double v, int i1) {
+
+ Element td = Document.get().getElementById(type + i);
+ td.setInnerHTML(
+ "" + (((int) (v * 100)) / 100.0) + " ms, found " + i1 + " nodes");
+ }
+
+ private void initResultsTable(DeferredGQuery[] dg, String... options) {
+ int numRows = dg.length;
+ Document doc = Document.get();
+ Element table = doc.getElementById("resultstable");
+ Element thead = doc.createTHeadElement();
+ table.appendChild(thead);
+ Element selectorHeader = doc.createTHElement();
+ Element theadtr = doc.createTRElement();
+ selectorHeader.setInnerHTML("Selector");
+ theadtr.appendChild(selectorHeader);
+ thead.appendChild(theadtr);
+
+ Element tbody = doc.createTBodyElement();
+ table.appendChild(tbody);
+
+ for (int i = 0; i < options.length; i += 2) {
+ Element th = doc.createTHElement();
+ th.setInnerHTML(options[i]);
+ theadtr.appendChild(th);
+ }
+ for (int i = 0; i < numRows; i++) {
+ Element tr = doc.createTRElement();
+ Element lab = doc.createTHElement();
+ lab.setInnerHTML(dg[i].getSelector());
+ tr.appendChild(lab);
+ for (int j = 0; j < options.length; j += 2) {
+ Element placeholder = doc.createTDElement();
+ placeholder.setInnerHTML("Not Tested");
+ placeholder.setId(options[j + 1] + i);
+ tr.appendChild(placeholder);
+ }
+ tbody.appendChild(tr);
}
+ Element totalRow = doc.createTRElement();
+ Element totalLab = doc.createTHElement();
+ totalLab.setInnerHTML("Total");
+ totalRow.appendChild(totalLab);
+ for (int j = 0; j < options.length; j += 2) {
+ Element placeholder = doc.createTDElement();
+ placeholder.setInnerHTML("0");
+ placeholder.setId(options[j + 1] + numRows);
+ totalRow.appendChild(placeholder);
+ }
+ tbody.appendChild(totalRow);
+ }
+
+ private void d(String s) {
+ log.append(s + "<br>");
+ }
+
+ private static class GQueryCompiledBenchmark implements Benchmark {
- private void d(String s) {
- log.append(s + "<br>");
+ public int runSelector(DeferredGQuery dq, String selector) {
+ return dq.array(null).getLength();
}
-
- private static class GQueryCompiledBenchmark implements Benchmark {
- public int runSelector(DeferredGQuery dq, String selector) {
- return dq.array(null).getLength();
- }
+ public String getId() {
+ return GCOMPILED;
+ }
+ }
- public String getId() {
- return GCOMPILED;
- }
+ private static class JQueryBenchmark implements Benchmark {
+
+ public native int runSelector(DeferredGQuery dq, String selector) /*-{
+ return $wnd.jquerybenchmark(selector);
+ }-*/;
+
+ public String getId() {
+ return JQUERY;
}
+ }
- private static class DomAssistantBenchmark implements Benchmark {
+ private static class DojoBenchmark implements Benchmark {
- public native int runSelector(DeferredGQuery dq, String selector) /*-{
- return $wnd.$(selector).length;
+ public native int runSelector(DeferredGQuery dq, String selector) /*-{
+ return $wnd.dojobenchmark(selector);
}-*/;
- public String getId() {
- return DOMASSISTANT;
- }
+ public String getId() {
+ return DOJO;
}
+ }
- private static class GQueryDynamicBenchmark implements Benchmark {
- private SelectorEngine engine;
+ private static class PrototypeBenchmark implements Benchmark {
- private GQueryDynamicBenchmark() {
- engine = new SelectorEngine();
- }
+ public native int runSelector(DeferredGQuery dq, String selector) /*-{
+ return $wnd.prototypebenchmark(selector);
+ }-*/;
- public int runSelector(DeferredGQuery dq, String selector) {
- return engine.select(selector, Document.get()).getLength();
- }
+ public String getId() {
+ return PROTOTYPE;
+ }
+ }
- public String getId() {
- return GDYNAMIC;
- }
+ private static class GQueryDynamicBenchmark implements Benchmark {
+
+ private SelectorEngine engine;
+
+ private GQueryDynamicBenchmark() {
+ engine = new SelectorEngine();
+ }
+
+ public int runSelector(DeferredGQuery dq, String selector) {
+ return engine.select(selector, Document.get()).getLength();
+ }
+
+ public String getId() {
+ return GDYNAMIC;
}
+ }
}
diff --git a/samples/src/main/java/gwtquery/samples/public/GwtQueryBench.html b/samples/src/main/java/gwtquery/samples/public/GwtQueryBench.html index d09e880e..ada6fc3d 100644 --- a/samples/src/main/java/gwtquery/samples/public/GwtQueryBench.html +++ b/samples/src/main/java/gwtquery/samples/public/GwtQueryBench.html @@ -1,711 +1,862 @@ <html>
<head>
- <title>GQuery</title>
- <!--<script type="text/javascript" src="jquery-1.2.3.js"></script>-->
- <!--<script type="text/javascript" src="ext-base.js"></script>-->
- <!--<script type="text/javascript" src="ext-all.js"></script>-->
- <script type="text/javascript" src="DOMAssistantComplete-2.7.js"></script>
- <script language="javascript" src="gwtquery.samples.GwtQueryBench.nocache.js"></script>
- <!--<script language="javascript" src="http://dev.jquery.com/~john/speed/js/jquery.js"></script>-->
- <!--<script type="text/javascript">-->
- <!--$(document).ready(function() {-->
- <!--alert("div ~ div size ="+$("div ~ div").size());-->
- <!--})-->
- <!--</script>-->
- <style>
- .win { background-color: green; color: white }
- .tie { background-color: orange; color: white }
- .lose { background-color: red; color: white }
- .broke { background-color: black; color: white}
-
- </style>
+ <title>GQuery</title>
+ <!--<script type="text/javascript" src="jquery-1.2.3.js"></script>-->
+ <!--<script type="text/javascript" src="ext-base.js"></script>-->
+ <!--<script type="text/javascript" src="ext-all.js"></script>-->
+ <script type="text/javascript" src="DOMAssistantComplete-2.7.js"></script>
+ <script language="javascript"
+ src="gwtquery.samples.GwtQueryBench.nocache.js"></script>
+ <!--<script language="javascript" src="http://dev.jquery.com/~john/speed/js/jquery.js"></script>-->
+ <!--<script type="text/javascript">-->
+ <!--$(document).ready(function() {-->
+ <!--alert("div ~ div size ="+$("div ~ div").size());-->
+ <!--})-->
+ <!--</script>-->
+ <style>
+ .win {
+ background-color: green;
+ color: white
+ }
+
+ .tie {
+ background-color: orange;
+ color: white
+ }
+
+ .lose {
+ background-color: red;
+ color: white
+ }
+
+ .broke {
+ background-color: black;
+ color: white
+ }
+
+ </style>
</head>
<body>
-<h2 style="font-family: Verdana; text-decoration: underline">GWTSpeed - GWTQuery benchmarks</h2>
-<table id="resultstable" border="1" style="border-collapse: collapse">
-
+<h2 style="font-family: Verdana; text-decoration: underline">GWTSpeed - GWTQuery
+ benchmarks</h2>
+<iframe id="racetrack" src="racetrack.html" width="800" height="310" frameborder="0" marginheight="0" marginwidth="0"></iframe>
+<iframe id="jquerybench" src="jquerybench.html" style="display: none"></iframe>
+<iframe id="dojobench" src="dojobench.html" style="display: none"></iframe>
+<iframe id="prototypebench" src="prototypebench.html" style="display: none"></iframe>
+
+<code style="display: block; height: 200px; width:780px; overflow-y:scroll">
+<table id="resultstable" border="1" style="width: 780px; border-collapse: collapse; height: 200px">
+
</table>
- <div style="display: none" class="head">
- <p><a href="http://www.w3.org/"><img height=48 alt=W3C src="http://www.w3.org/Icons/w3c_home" width=72></a>
+</code>
+<div style="display: none">
+<div style="display: none" class="head">
+ <p><a href="http://www.w3.org/"><img height=48 alt=W3C
+ src="http://www.w3.org/Icons/w3c_home"
+ width=72></a>
- <h1 id="title">Selectors</h1>
+ <h1 id="title">Selectors</h1>
- <h2>W3C Working Draft 15 December 2005</h2>
+ <h2>W3C Working Draft 15 December 2005</h2>
- <dl>
+ <dl>
- <dt>This version:
+ <dt>This version:
- <dd><a href="http://www.w3.org/TR/2005/WD-css3-selectors-20051215">
- http://www.w3.org/TR/2005/WD-css3-selectors-20051215</a>
+ <dd><a href="http://www.w3.org/TR/2005/WD-css3-selectors-20051215">
+ http://www.w3.org/TR/2005/WD-css3-selectors-20051215</a>
- <dt>Latest version:
+ <dt>Latest version:
- <dd><a href="http://www.w3.org/TR/css3-selectors">
- http://www.w3.org/TR/css3-selectors</a>
+ <dd><a href="http://www.w3.org/TR/css3-selectors">
+ http://www.w3.org/TR/css3-selectors</a>
- <dt>Previous version:
+ <dt>Previous version:
- <dd><a href="http://www.w3.org/TR/2001/CR-css3-selectors-20011113">
- http://www.w3.org/TR/2001/CR-css3-selectors-20011113</a>
+ <dd><a href="http://www.w3.org/TR/2001/CR-css3-selectors-20011113">
+ http://www.w3.org/TR/2001/CR-css3-selectors-20011113</a>
- <dt><a name=editors-list></a>Editors:
+ <dt><a name=editors-list></a>Editors:
- <dd class="vcard"><span class="fn">Daniel Glazman</span> (Invited Expert)</dd>
+ <dd class="vcard"><span class="fn">Daniel Glazman</span> (Invited
+ Expert)
+ </dd>
- <dd class="vcard"><a lang="tr" class="url fn" href="http://www.tantek.com/">Tantek Çelik</a> (Invited Expert)
+ <dd class="vcard"><a lang="tr" class="url fn"
+ href="http://www.tantek.com/">Tantek Çelik</a>
+ (Invited Expert)
- <dd class="vcard"><a href="mailto:ian@hixie.ch" class="url fn">Ian Hickson</a> (<span
- class="company"><a href="http://www.google.com/">Google</a></span>)
+ <dd class="vcard"><a href="mailto:ian@hixie.ch" class="url fn">Ian
+ Hickson</a> (<span
+ class="company"><a
+ href="http://www.google.com/">Google</a></span>)
- <dd class="vcard"><span class="fn">Peter Linss</span> (former editor, <span class="company"><a
- href="http://www.netscape.com/">Netscape/AOL</a></span>)
+ <dd class="vcard"><span class="fn">Peter Linss</span> (former
+ editor, <span class="company"><a
+ href="http://www.netscape.com/">Netscape/AOL</a></span>)
- <dd class="vcard"><span class="fn">John Williams</span> (former editor, <span class="company"><a
- href="http://www.quark.com/">Quark, Inc.</a></span>)
+ <dd class="vcard"><span class="fn">John Williams</span> (former editor, <span
+ class="company"><a
+ href="http://www.quark.com/">Quark, Inc.</a></span>)
- </dl>
+ </dl>
- <p class="copyright"><a
- href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">
- Copyright</a> © 2005 <a href="http://www.w3.org/"><abbr
- title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup>
- (<a href="http://www.csail.mit.edu/"><abbr title="Massachusetts
+ <p class="copyright"><a
+ href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">
+ Copyright</a> © 2005 <a href="http://www.w3.org/"><abbr
+ title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup>
+ (<a href="http://www.csail.mit.edu/"><abbr title="Massachusetts
Institute of Technology">MIT</abbr></a>, <a
- href="http://www.ercim.org/"><acronym title="European Research
+ href="http://www.ercim.org/"><acronym title="European Research
Consortium for Informatics and Mathematics">ERCIM</acronym></a>, <a
- href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C
- <a
- href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
- <a
- href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>,
- <a
- href="http://www.w3.org/Consortium/Legal/copyright-documents">document
- use</a> rules apply.
-
- <hr title="Separator for header">
+ href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved.
+ W3C
+ <a
+ href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
+ <a
+ href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>,
+ <a
+ href="http://www.w3.org/Consortium/Legal/copyright-documents">document
+ use</a> rules apply.
+
+ <hr title="Separator for header">
- </div>
+</div>
- <h2><a name=abstract></a>Abstract</h2>
+<h2><a name=abstract></a>Abstract</h2>
- <p><em>Selectors</em> are patterns that match against elements in a
- tree. Selectors have been optimized for use with HTML and XML, and
- are designed to be usable in performance-critical code.</p>
+<p><em>Selectors</em> are patterns that match against elements in a
+ tree. Selectors have been optimized for use with HTML and XML, and
+ are designed to be usable in performance-critical code.</p>
- <p><acronym title="Cascading Style Sheets">CSS</acronym> (Cascading
- Style Sheets) is a language for describing the rendering of <acronym
- title="Hypertext Markup Language">HTML</acronym> and <acronym
- title="Extensible Markup Language">XML</acronym> documents on
- screen, on paper, in speech, etc. CSS uses Selectors for binding
- style properties to elements in the document. This document
- describes extensions to the selectors defined in CSS level 2. These
- extended selectors will be used by CSS level 3.
+<p><acronym title="Cascading Style Sheets">CSS</acronym> (Cascading
+ Style Sheets) is a language for describing the rendering of <acronym
+ title="Hypertext Markup Language">HTML</acronym> and <acronym
+ title="Extensible Markup Language">XML</acronym> documents on
+ screen, on paper, in speech, etc. CSS uses Selectors for binding
+ style properties to elements in the document. This document
+ describes extensions to the selectors defined in CSS level 2. These
+ extended selectors will be used by CSS level 3.
- <p>Selectors define the following function:</p>
+<p>Selectors define the following function:</p>
- <pre>expression ∗ element → boolean</pre>
+<pre>expression ∗ element → boolean</pre>
- <p>That is, given an element and a selector, this specification
- defines whether that element matches the selector.</p>
+<p>That is, given an element and a selector, this specification
+ defines whether that element matches the selector.</p>
- <p>These expressions can also be used, for instance, to select a set
- of elements, or a single element from a set of elements, by
- evaluating the expression across all the elements in a
- subtree. <acronym title="Simple Tree Transformation
+<p>These expressions can also be used, for instance, to select a set
+ of elements, or a single element from a set of elements, by
+ evaluating the expression across all the elements in a
+ subtree. <acronym title="Simple Tree Transformation
Sheets">STTS</acronym> (Simple Tree Transformation Sheets), a
- language for transforming XML trees, uses this mechanism. <a href="#refsSTTS">[STTS]</a></p>
+ language for transforming XML trees, uses this mechanism. <a
+ href="#refsSTTS">[STTS]</a></p>
+
+<h2><a name=status></a>Status of this document</h2>
+
+<p><em>This section describes the status of this document at the
+ time of its publication. Other documents may supersede this
+ document. A list of current W3C publications and the latest revision
+ of this technical report can be found in the <a
+ href="http://www.w3.org/TR/">W3C technical reports index at
+ http://www.w3.org/TR/.</a></em></p>
+
+<p>This document describes the selectors that already exist in <a
+ href="#refsCSS1"><abbr title="CSS level 1">CSS1</abbr></a> and <a
+ href="#refsCSS21"><abbr title="CSS level 2">CSS2</abbr></a>, and
+ also proposes new selectors for <abbr title="CSS level
+ 3">CSS3</abbr> and other languages that may need them.</p>
- <h2><a name=status></a>Status of this document</h2>
+<p>The CSS Working Group doesn't expect that all implementations of
+ CSS3 will have to implement all selectors. Instead, there will
+ probably be a small number of variants of CSS3, called profiles. For
+ example, it may be that only a profile for interactive user agents
+ will include all of the selectors.</p>
+
+<p>This specification is a last call working draft for the the <a
+ href="http://www.w3.org/Style/CSS/members">CSS Working Group</a>
+ (<a href="/Style/">Style Activity</a>). This
+ document is a revision of the <a
+ href="http://www.w3.org/TR/2001/CR-css3-selectors-20011113/">Candidate
+ Recommendation dated 2001 November 13</a>, and has incorporated
+ implementation feedback received in the past few years. It is
+ expected that this last call will proceed straight to Proposed
+ Recommendation stage since it is believed that interoperability will
+ be demonstrable.</p>
+
+<p>All persons are encouraged to review and implement this
+ specification and return comments to the (<a
+ href="http://lists.w3.org/Archives/Public/www-style/">archived</a>)
+ public mailing list <a
+ href="http://www.w3.org/Mail/Lists.html#www-style">www-style</a>
+ (see <a href="http://www.w3.org/Mail/Request">instructions</a>). W3C
+ Members can also send comments directly to the CSS Working
+ Group.
+ The deadline for comments is 14 January 2006.</p>
+
+<p>This is still a draft document and may be updated, replaced, or
+ obsoleted by other documents at any time. It is inappropriate to
+ cite a W3C Working Draft as other than "work in progress".
+
+<p>This document may be available in <a
+ href="http://www.w3.org/Style/css3-selectors-updates/translations">translation</a>.
+ The English version of this specification is the only normative
+ version.
+
+<div class="subtoc">
+
+ <h2><a name=contents>Table of contents</a></h2>
+
+ <ul class="toc">
+ <li class="tocline2"><a href="#context">1. Introduction</a>
+ <ul>
+ <li><a href="#dependencies">1.1. Dependencies</a></li>
+ <li><a href="#terminology">1.2. Terminology</a></li>
+ <li><a href="#changesFromCSS2">1.3. Changes from CSS2</a></li>
+ </ul>
+ <li class="tocline2"><a href="#selectors">2. Selectors</a>
+ <li class="tocline2"><a href="#casesens">3. Case sensitivity</a>
+ <li class="tocline2"><a href="#selector-syntax">4. Selector syntax</a>
+ <li class="tocline2"><a href="#grouping">5. Groups of selectors</a>
+ <li class="tocline2"><a href="#simple-selectors">6. Simple selectors</a>
+ <ul class="toc">
+ <li class="tocline3"><a href="#type-selectors">6.1. Type
+ selectors</a>
+ <ul class="toc">
+ <li class="tocline4"><a href="#typenmsp">6.1.1. Type
+ selectors and namespaces</a></li>
+ </ul>
+ <li class="tocline3"><a href="#universal-selector">6.2.
+ Universal selector</a>
+ <ul>
+ <li><a href="#univnmsp">6.2.1. Universal selector and
+ namespaces</a></li>
+ </ul>
+ <li class="tocline3"><a href="#attribute-selectors">6.3.
+ Attribute selectors</a>
+ <ul class="toc">
+ <li class="tocline4"><a
+ href="#attribute-representation">6.3.1.
+ Representation of attributes and attributes
+ values</a>
+ <li><a href="#attribute-substrings">6.3.2. Substring
+ matching attribute selectors</a>
+ <li class="tocline4"><a href="#attrnmsp">6.3.3.
+ Attribute selectors and namespaces</a>
+ <li class="tocline4"><a href="#def-values">6.3.4.
+ Default attribute values in DTDs</a></li>
+ </ul>
+ <li class="tocline3"><a href="#class-html">6.4. Class
+ selectors</a>
+ <li class="tocline3"><a href="#id-selectors">6.5. ID
+ selectors</a>
+ <li class="tocline3"><a href="#pseudo-classes">6.6.
+ Pseudo-classes</a>
+ <ul class="toc">
+ <li class="tocline4"><a href="#dynamic-pseudos">6.6.1.
+ Dynamic pseudo-classes</a>
+ <li class="tocline4"><a href="#target-pseudo">6.6.2. The
+ :target pseudo-class</a>
+ <li class="tocline4"><a href="#lang-pseudo">6.6.3. The
+ :lang() pseudo-class</a>
+ <li class="tocline4"><a href="#UIstates">6.6.4. UI
+ element states pseudo-classes</a>
+ <li class="tocline4"><a href="#structural-pseudos">6.6.5.
+ Structural pseudo-classes</a>
+ <ul>
+ <li><a href="#root-pseudo">:root
+ pseudo-class</a>
+ <li><a href="#nth-child-pseudo">:nth-child()
+ pseudo-class</a>
+ <li><a href="#nth-last-child-pseudo">:nth-last-child()</a>
+ <li><a href="#nth-of-type-pseudo">:nth-of-type()
+ pseudo-class</a>
+ <li><a href="#nth-last-of-type-pseudo">:nth-last-of-type()</a>
+ <li><a href="#first-child-pseudo">:first-child
+ pseudo-class</a>
+ <li><a href="#last-child-pseudo">:last-child
+ pseudo-class</a>
+ <li><a href="#first-of-type-pseudo">:first-of-type
+ pseudo-class</a>
+ <li><a href="#last-of-type-pseudo">:last-of-type
+ pseudo-class</a>
+ <li><a href="#only-child-pseudo">:only-child
+ pseudo-class</a>
+ <li><a href="#only-of-type-pseudo">:only-of-type
+ pseudo-class</a>
+ <li><a href="#empty-pseudo">:empty
+ pseudo-class</a></li>
+ </ul>
+ <li class="tocline4"><a href="#negation">6.6.7. The
+ negation pseudo-class</a></li>
+ </ul>
+ </li>
+ </ul>
+ <li><a href="#pseudo-elements">7. Pseudo-elements</a>
+ <ul>
+ <li><a href="#first-line">7.1. The ::first-line
+ pseudo-element</a>
+ <li><a href="#first-letter">7.2. The ::first-letter
+ pseudo-element</a>
+ <li><a href="#UIfragments">7.3. The ::selection
+ pseudo-element</a>
+ <li><a href="#gen-content">7.4. The ::before and ::after
+ pseudo-elements</a></li>
+ </ul>
+ <li class="tocline2"><a href="#combinators">8. Combinators</a>
+ <ul class="toc">
+ <li class="tocline3"><a href="#descendant-combinators">8.1.
+ Descendant combinators</a>
+ <li class="tocline3"><a href="#child-combinators">8.2. Child
+ combinators</a>
+ <li class="tocline3"><a href="#sibling-combinators">8.3. Sibling
+ combinators</a>
+ <ul class="toc">
+ <li class="tocline4"><a
+ href="#adjacent-sibling-combinators">8.3.1.
+ Adjacent sibling combinator</a>
+ <li class="tocline4"><a
+ href="#general-sibling-combinators">8.3.2.
+ General sibling combinator</a></li>
+ </ul>
+ </li>
+ </ul>
+ <li class="tocline2"><a href="#specificity">9. Calculating a selector's
+ specificity</a>
+ <li class="tocline2"><a href="#w3cselgrammar">10. The grammar of
+ Selectors</a>
+ <ul class="toc">
+ <li class="tocline3"><a href="#grammar">10.1. Grammar</a>
+ <li class="tocline3"><a href="#lex">10.2. Lexical scanner</a>
+ </li>
+ </ul>
+ <li class="tocline2"><a href="#downlevel">11. Namespaces and down-level
+ clients</a>
+ <li class="tocline2"><a href="#profiling">12. Profiles</a>
+ <li><a href="#Conformance">13. Conformance and requirements</a>
+ <li><a href="#Tests">14. Tests</a>
+ <li><a href="#ACKS">15. Acknowledgements</a>
+ <li class="tocline2"><a href="#references">16. References</a>
+ </ul>
- <p><em>This section describes the status of this document at the
- time of its publication. Other documents may supersede this
- document. A list of current W3C publications and the latest revision
- of this technical report can be found in the <a
- href="http://www.w3.org/TR/">W3C technical reports index at
- http://www.w3.org/TR/.</a></em></p>
+</div>
- <p>This document describes the selectors that already exist in <a
- href="#refsCSS1"><abbr title="CSS level 1">CSS1</abbr></a> and <a
- href="#refsCSS21"><abbr title="CSS level 2">CSS2</abbr></a>, and
- also proposes new selectors for <abbr title="CSS level
- 3">CSS3</abbr> and other languages that may need them.</p>
+<h2><a name=context>1. Introduction</a></h2>
+
+<h3><a name=dependencies></a>1.1. Dependencies</h3>
+
+<p>Some features of this specification are specific to CSS, or have
+ particular limitations or rules specific to CSS. In this
+ specification, these have been described in terms of CSS2.1. <a
+ href="#refsCSS21">[CSS21]</a></p>
+
+<h3><a name=terminology></a>1.2. Terminology</h3>
+
+<p>All of the text of this specification is normative except
+ examples, notes, and sections explicitly marked as
+ non-normative.</p>
+
+<h3><a name=changesFromCSS2></a>1.3. Changes from CSS2</h3>
+
+<p><em>This section is non-normative.</em></p>
+
+<p>The main differences between the selectors in CSS2 and those in
+ Selectors are:
+
+<ul>
+
+ <li>the list of basic definitions (selector, group of selectors,
+ simple selector, etc.) has been changed; in particular, what was
+ referred to in CSS2 as a simple selector is now called a sequence
+ of simple selectors, and the term "simple selector" is now used for
+ the components of this sequence
+ </li>
+
+ <li>an optional namespace component is now allowed in type element
+ selectors, the universal selector and attribute selectors
+ </li>
+
+ <li>a <a href="#general-sibling-combinators">new combinator</a> has been
+ introduced
+ </li>
+
+ <li>new simple selectors including substring matching attribute
+ selectors, and new pseudo-classes
+ </li>
+
+ <li>new pseudo-elements, and introduction of the "::" convention
+ for pseudo-elements
+ </li>
- <p>The CSS Working Group doesn't expect that all implementations of
- CSS3 will have to implement all selectors. Instead, there will
- probably be a small number of variants of CSS3, called profiles. For
- example, it may be that only a profile for interactive user agents
- will include all of the selectors.</p>
-
- <p>This specification is a last call working draft for the the <a
- href="http://www.w3.org/Style/CSS/members">CSS Working Group</a>
- (<a href="/Style/">Style Activity</a>). This
- document is a revision of the <a
- href="http://www.w3.org/TR/2001/CR-css3-selectors-20011113/">Candidate
- Recommendation dated 2001 November 13</a>, and has incorporated
- implementation feedback received in the past few years. It is
- expected that this last call will proceed straight to Proposed
- Recommendation stage since it is believed that interoperability will
- be demonstrable.</p>
-
- <p>All persons are encouraged to review and implement this
- specification and return comments to the (<a
- href="http://lists.w3.org/Archives/Public/www-style/">archived</a>)
- public mailing list <a
- href="http://www.w3.org/Mail/Lists.html#www-style">www-style</a>
- (see <a href="http://www.w3.org/Mail/Request">instructions</a>). W3C
- Members can also send comments directly to the CSS Working
- Group.
- The deadline for comments is 14 January 2006.</p>
-
- <p>This is still a draft document and may be updated, replaced, or
- obsoleted by other documents at any time. It is inappropriate to
- cite a W3C Working Draft as other than "work in progress".
-
- <p>This document may be available in <a
- href="http://www.w3.org/Style/css3-selectors-updates/translations">translation</a>.
- The English version of this specification is the only normative
- version.
-
- <div class="subtoc">
-
- <h2><a name=contents>Table of contents</a></h2>
-
- <ul class="toc">
- <li class="tocline2"><a href="#context">1. Introduction</a>
- <ul>
- <li><a href="#dependencies">1.1. Dependencies</a> </li>
- <li><a href="#terminology">1.2. Terminology</a> </li>
- <li><a href="#changesFromCSS2">1.3. Changes from CSS2</a> </li>
- </ul>
- <li class="tocline2"><a href="#selectors">2. Selectors</a>
- <li class="tocline2"><a href="#casesens">3. Case sensitivity</a>
- <li class="tocline2"><a href="#selector-syntax">4. Selector syntax</a>
- <li class="tocline2"><a href="#grouping">5. Groups of selectors</a>
- <li class="tocline2"><a href="#simple-selectors">6. Simple selectors</a>
- <ul class="toc">
- <li class="tocline3"><a href="#type-selectors">6.1. Type selectors</a>
- <ul class="toc">
- <li class="tocline4"><a href="#typenmsp">6.1.1. Type selectors and namespaces</a></li>
- </ul>
- <li class="tocline3"><a href="#universal-selector">6.2. Universal selector</a>
- <ul>
- <li><a href="#univnmsp">6.2.1. Universal selector and namespaces</a></li>
- </ul>
- <li class="tocline3"><a href="#attribute-selectors">6.3. Attribute selectors</a>
- <ul class="toc">
- <li class="tocline4"><a href="#attribute-representation">6.3.1. Representation of attributes and attributes values</a>
- <li><a href="#attribute-substrings">6.3.2. Substring matching attribute selectors</a>
- <li class="tocline4"><a href="#attrnmsp">6.3.3. Attribute selectors and namespaces</a>
- <li class="tocline4"><a href="#def-values">6.3.4. Default attribute values in DTDs</a></li>
- </ul>
- <li class="tocline3"><a href="#class-html">6.4. Class selectors</a>
- <li class="tocline3"><a href="#id-selectors">6.5. ID selectors</a>
- <li class="tocline3"><a href="#pseudo-classes">6.6. Pseudo-classes</a>
- <ul class="toc">
- <li class="tocline4"><a href="#dynamic-pseudos">6.6.1. Dynamic pseudo-classes</a>
- <li class="tocline4"><a href="#target-pseudo">6.6.2. The :target pseudo-class</a>
- <li class="tocline4"><a href="#lang-pseudo">6.6.3. The :lang() pseudo-class</a>
- <li class="tocline4"><a href="#UIstates">6.6.4. UI element states pseudo-classes</a>
- <li class="tocline4"><a href="#structural-pseudos">6.6.5. Structural pseudo-classes</a>
- <ul>
- <li><a href="#root-pseudo">:root pseudo-class</a>
- <li><a href="#nth-child-pseudo">:nth-child() pseudo-class</a>
- <li><a href="#nth-last-child-pseudo">:nth-last-child()</a>
- <li><a href="#nth-of-type-pseudo">:nth-of-type() pseudo-class</a>
- <li><a href="#nth-last-of-type-pseudo">:nth-last-of-type()</a>
- <li><a href="#first-child-pseudo">:first-child pseudo-class</a>
- <li><a href="#last-child-pseudo">:last-child pseudo-class</a>
- <li><a href="#first-of-type-pseudo">:first-of-type pseudo-class</a>
- <li><a href="#last-of-type-pseudo">:last-of-type pseudo-class</a>
- <li><a href="#only-child-pseudo">:only-child pseudo-class</a>
- <li><a href="#only-of-type-pseudo">:only-of-type pseudo-class</a>
- <li><a href="#empty-pseudo">:empty pseudo-class</a></li>
- </ul>
- <li class="tocline4"><a href="#negation">6.6.7. The negation pseudo-class</a></li>
- </ul>
- </li>
- </ul>
- <li><a href="#pseudo-elements">7. Pseudo-elements</a>
- <ul>
- <li><a href="#first-line">7.1. The ::first-line pseudo-element</a>
- <li><a href="#first-letter">7.2. The ::first-letter pseudo-element</a>
- <li><a href="#UIfragments">7.3. The ::selection pseudo-element</a>
- <li><a href="#gen-content">7.4. The ::before and ::after pseudo-elements</a></li>
- </ul>
- <li class="tocline2"><a href="#combinators">8. Combinators</a>
- <ul class="toc">
- <li class="tocline3"><a href="#descendant-combinators">8.1. Descendant combinators</a>
- <li class="tocline3"><a href="#child-combinators">8.2. Child combinators</a>
- <li class="tocline3"><a href="#sibling-combinators">8.3. Sibling combinators</a>
- <ul class="toc">
- <li class="tocline4"><a href="#adjacent-sibling-combinators">8.3.1. Adjacent sibling combinator</a>
- <li class="tocline4"><a href="#general-sibling-combinators">8.3.2. General sibling combinator</a></li>
- </ul>
- </li>
- </ul>
- <li class="tocline2"><a href="#specificity">9. Calculating a selector's specificity</a>
- <li class="tocline2"><a href="#w3cselgrammar">10. The grammar of Selectors</a>
- <ul class="toc">
- <li class="tocline3"><a href="#grammar">10.1. Grammar</a>
- <li class="tocline3"><a href="#lex">10.2. Lexical scanner</a></li>
- </ul>
- <li class="tocline2"><a href="#downlevel">11. Namespaces and down-level clients</a>
- <li class="tocline2"><a href="#profiling">12. Profiles</a>
- <li><a href="#Conformance">13. Conformance and requirements</a>
- <li><a href="#Tests">14. Tests</a>
- <li><a href="#ACKS">15. Acknowledgements</a>
- <li class="tocline2"><a href="#references">16. References</a>
- </ul>
-
- </div>
-
- <h2><a name=context>1. Introduction</a></h2>
-
- <h3><a name=dependencies></a>1.1. Dependencies</h3>
-
- <p>Some features of this specification are specific to CSS, or have
- particular limitations or rules specific to CSS. In this
- specification, these have been described in terms of CSS2.1. <a
- href="#refsCSS21">[CSS21]</a></p>
-
- <h3><a name=terminology></a>1.2. Terminology</h3>
-
- <p>All of the text of this specification is normative except
- examples, notes, and sections explicitly marked as
- non-normative.</p>
-
- <h3><a name=changesFromCSS2></a>1.3. Changes from CSS2</h3>
-
- <p><em>This section is non-normative.</em></p>
-
- <p>The main differences between the selectors in CSS2 and those in
- Selectors are:
-
- <ul>
-
- <li>the list of basic definitions (selector, group of selectors,
- simple selector, etc.) has been changed; in particular, what was
- referred to in CSS2 as a simple selector is now called a sequence
- of simple selectors, and the term "simple selector" is now used for
- the components of this sequence</li>
-
- <li>an optional namespace component is now allowed in type element
- selectors, the universal selector and attribute selectors</li>
-
- <li>a <a href="#general-sibling-combinators">new combinator</a> has been introduced</li>
-
- <li>new simple selectors including substring matching attribute
- selectors, and new pseudo-classes</li>
-
- <li>new pseudo-elements, and introduction of the "::" convention
- for pseudo-elements</li>
-
- <li>the grammar has been rewritten</li>
-
- <li>profiles to be added to specifications integrating Selectors
- and defining the set of selectors which is actually supported by
- each specification</li>
-
- <li>Selectors are now a CSS3 Module and an independent
- specification; other specifications can now refer to this document
- independently of CSS</li>
-
- <li>the specification now has its own test suite</li>
-
- </ul>
+ <li>the grammar has been rewritten</li>
+
+ <li>profiles to be added to specifications integrating Selectors
+ and defining the set of selectors which is actually supported by
+ each specification
+ </li>
+
+ <li>Selectors are now a CSS3 Module and an independent
+ specification; other specifications can now refer to this document
+ independently of CSS
+ </li>
+
+ <li>the specification now has its own test suite</li>
+
+</ul>
<h2><a name=selectors></a>2. Selectors</h2>
<p><em>This section is non-normative, as it merely summarizes the
-following sections.</em></p>
+ following sections.</em></p>
<p>A Selector represents a structure. This structure can be used as a
-condition (e.g. in a CSS rule) that determines which elements a
-selector matches in the document tree, or as a flat description of the
-HTML or XML fragment corresponding to that structure.</p>
+ condition (e.g. in a CSS rule) that determines which elements a
+ selector matches in the document tree, or as a flat description of the
+ HTML or XML fragment corresponding to that structure.</p>
<p>Selectors may range from simple element names to rich contextual
-representations.</p>
+ representations.</p>
<p>The following table summarizes the Selector syntax:</p>
<table class="selectorsReview">
- <thead>
- <tr>
+<thead>
+<tr>
<th class="pattern">Pattern</th>
<th class="meaning">Meaning</th>
<th class="described">Described in section</th>
- <th class="origin">First defined in CSS level</th></tr>
- <tbody>
- <tr>
+ <th class="origin">First defined in CSS level</th>
+</tr>
+<tbody>
+<tr>
<td class="pattern">*</td>
<td class="meaning">any element</td>
<td class="described"><a
- href="#universal-selector">Universal
- selector</a></td>
- <td class="origin">2</td></tr>
- <tr>
+ href="#universal-selector">Universal
+ selector</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
<td class="pattern">E</td>
<td class="meaning">an element of type E</td>
<td class="described"><a
- href="#type-selectors">Type selector</a></td>
- <td class="origin">1</td></tr>
- <tr>
+ href="#type-selectors">Type selector</a></td>
+ <td class="origin">1</td>
+</tr>
+<tr>
<td class="pattern">E[foo]</td>
<td class="meaning">an E element with a "foo" attribute</td>
<td class="described"><a
- href="#attribute-selectors">Attribute
- selectors</a></td>
- <td class="origin">2</td></tr>
- <tr>
+ href="#attribute-selectors">Attribute
+ selectors</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
<td class="pattern">E[foo="bar"]</td>
<td class="meaning">an E element whose "foo" attribute value is exactly
- equal to "bar"</td>
+ equal to "bar"
+ </td>
<td class="described"><a
- href="#attribute-selectors">Attribute
- selectors</a></td>
- <td class="origin">2</td></tr>
- <tr>
+ href="#attribute-selectors">Attribute
+ selectors</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
<td class="pattern">E[foo~="bar"]</td>
<td class="meaning">an E element whose "foo" attribute value is a list of
- space-separated values, one of which is exactly equal to "bar"</td>
+ space-separated values, one of which is exactly equal to "bar"
+ </td>
<td class="described"><a
- href="#attribute-selectors">Attribute
- selectors</a></td>
- <td class="origin">2</td></tr>
- <tr>
+ href="#attribute-selectors">Attribute
+ selectors</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
<td class="pattern">E[foo^="bar"]</td>
<td class="meaning">an E element whose "foo" attribute value begins exactly
- with the string "bar"</td>
+ with the string "bar"
+ </td>
<td class="described"><a
- href="#attribute-selectors">Attribute
- selectors</a></td>
- <td class="origin">3</td></tr>
- <tr>
+ href="#attribute-selectors">Attribute
+ selectors</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
<td class="pattern">E[foo$="bar"]</td>
<td class="meaning">an E element whose "foo" attribute value ends exactly
- with the string "bar"</td>
+ with the string "bar"
+ </td>
<td class="described"><a
- href="#attribute-selectors">Attribute
- selectors</a></td>
- <td class="origin">3</td></tr>
- <tr>
+ href="#attribute-selectors">Attribute
+ selectors</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
<td class="pattern">E[foo*="bar"]</td>
<td class="meaning">an E element whose "foo" attribute value contains the
- substring "bar"</td>
+ substring "bar"
+ </td>
<td class="described"><a
- href="#attribute-selectors">Attribute
- selectors</a></td>
- <td class="origin">3</td></tr>
- <tr>
+ href="#attribute-selectors">Attribute
+ selectors</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
<td class="pattern">E[hreflang|="en"]</td>
- <td class="meaning">an E element whose "hreflang" attribute has a hyphen-separated
- list of values beginning (from the left) with "en"</td>
+ <td class="meaning">an E element whose "hreflang" attribute has a
+ hyphen-separated
+ list of values beginning (from the left) with "en"
+ </td>
<td class="described"><a
- href="#attribute-selectors">Attribute
- selectors</a></td>
- <td class="origin">2</td></tr>
- <tr>
+ href="#attribute-selectors">Attribute
+ selectors</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
<td class="pattern">E:root</td>
<td class="meaning">an E element, root of the document</td>
<td class="described"><a
- href="#structural-pseudos">Structural
- pseudo-classes</a></td>
- <td class="origin">3</td></tr>
- <tr>
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
<td class="pattern">E:nth-child(n)</td>
<td class="meaning">an E element, the n-th child of its parent</td>
<td class="described"><a
- href="#structural-pseudos">Structural
- pseudo-classes</a></td>
- <td class="origin">3</td></tr>
- <tr>
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
<td class="pattern">E:nth-last-child(n)</td>
<td class="meaning">an E element, the n-th child of its parent, counting
- from the last one</td>
+ from the last one
+ </td>
<td class="described"><a
- href="#structural-pseudos">Structural
- pseudo-classes</a></td>
- <td class="origin">3</td></tr>
- <tr>
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
<td class="pattern">E:nth-of-type(n)</td>
<td class="meaning">an E element, the n-th sibling of its type</td>
<td class="described"><a
- href="#structural-pseudos">Structural
- pseudo-classes</a></td>
- <td class="origin">3</td></tr>
- <tr>
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
<td class="pattern">E:nth-last-of-type(n)</td>
<td class="meaning">an E element, the n-th sibling of its type, counting
- from the last one</td>
+ from the last one
+ </td>
<td class="described"><a
- href="#structural-pseudos">Structural
- pseudo-classes</a></td>
- <td class="origin">3</td></tr>
- <tr>
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
<td class="pattern">E:first-child</td>
<td class="meaning">an E element, first child of its parent</td>
<td class="described"><a
- href="#structural-pseudos">Structural
- pseudo-classes</a></td>
- <td class="origin">2</td></tr>
- <tr>
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
<td class="pattern">E:last-child</td>
<td class="meaning">an E element, last child of its parent</td>
<td class="described"><a
- href="#structural-pseudos">Structural
- pseudo-classes</a></td>
- <td class="origin">3</td></tr>
- <tr>
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
<td class="pattern">E:first-of-type</td>
<td class="meaning">an E element, first sibling of its type</td>
<td class="described"><a
- href="#structural-pseudos">Structural
- pseudo-classes</a></td>
- <td class="origin">3</td></tr>
- <tr>
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
<td class="pattern">E:last-of-type</td>
<td class="meaning">an E element, last sibling of its type</td>
<td class="described"><a
- href="#structural-pseudos">Structural
- pseudo-classes</a></td>
- <td class="origin">3</td></tr>
- <tr>
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
<td class="pattern">E:only-child</td>
<td class="meaning">an E element, only child of its parent</td>
<td class="described"><a
- href="#structural-pseudos">Structural
- pseudo-classes</a></td>
- <td class="origin">3</td></tr>
- <tr>
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
<td class="pattern">E:only-of-type</td>
<td class="meaning">an E element, only sibling of its type</td>
<td class="described"><a
- href="#structural-pseudos">Structural
- pseudo-classes</a></td>
- <td class="origin">3</td></tr>
- <tr>
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
<td class="pattern">E:empty</td>
<td class="meaning">an E element that has no children (including text
- nodes)</td>
+ nodes)
+ </td>
<td class="described"><a
- href="#structural-pseudos">Structural
- pseudo-classes</a></td>
- <td class="origin">3</td></tr>
- <tr>
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
<td class="pattern">E:link<br>E:visited</td>
<td class="meaning">an E element being the source anchor of a hyperlink of
- which the target is not yet visited (:link) or already visited
- (:visited)</td>
+ which the target is not yet visited (:link) or already visited
+ (:visited)
+ </td>
<td class="described"><a
- href="#link">The link
- pseudo-classes</a></td>
- <td class="origin">1</td></tr>
- <tr>
+ href="#link">The link
+ pseudo-classes</a></td>
+ <td class="origin">1</td>
+</tr>
+<tr>
<td class="pattern">E:active<br>E:hover<br>E:focus</td>
<td class="meaning">an E element during certain user actions</td>
<td class="described"><a
- href="#useraction-pseudos">The user
- action pseudo-classes</a></td>
- <td class="origin">1 and 2</td></tr>
- <tr>
+ href="#useraction-pseudos">The user
+ action pseudo-classes</a></td>
+ <td class="origin">1 and 2</td>
+</tr>
+<tr>
<td class="pattern">E:target</td>
<td class="meaning">an E element being the target of the referring URI</td>
<td class="described"><a
- href="#target-pseudo">The target
- pseudo-class</a></td>
- <td class="origin">3</td></tr>
- <tr>
+ href="#target-pseudo">The target
+ pseudo-class</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
<td class="pattern">E:lang(fr)</td>
<td class="meaning">an element of type E in language "fr" (the document
- language specifies how language is determined)</td>
+ language specifies how language is determined)
+ </td>
<td class="described"><a
- href="#lang-pseudo">The :lang()
- pseudo-class</a></td>
- <td class="origin">2</td></tr>
- <tr>
+ href="#lang-pseudo">The :lang()
+ pseudo-class</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
<td class="pattern">E:enabled<br>E:disabled</td>
<td class="meaning">a user interface element E which is enabled or
- disabled</td>
+ disabled
+ </td>
<td class="described"><a
- href="#UIstates">The UI element states
- pseudo-classes</a></td>
- <td class="origin">3</td></tr>
- <tr>
+ href="#UIstates">The UI element states
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
<td class="pattern">E:checked<!--<br>E:indeterminate--></td>
<td class="meaning">a user interface element E which is checked<!-- or in an
- indeterminate state--> (for instance a radio-button or checkbox)</td>
+ indeterminate state--> (for instance a radio-button or checkbox)
+ </td>
<td class="described"><a
- href="#UIstates">The UI element states
- pseudo-classes</a></td>
- <td class="origin">3</td></tr>
- <tr>
+ href="#UIstates">The UI element states
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
<td class="pattern">E::first-line</td>
<td class="meaning">the first formatted line of an E element</td>
<td class="described"><a
- href="#first-line">The ::first-line
- pseudo-element</a></td>
- <td class="origin">1</td></tr>
- <tr>
+ href="#first-line">The ::first-line
+ pseudo-element</a></td>
+ <td class="origin">1</td>
+</tr>
+<tr>
<td class="pattern">E::first-letter</td>
<td class="meaning">the first formatted letter of an E element</td>
<td class="described"><a
- href="#first-letter">The ::first-letter
- pseudo-element</a></td>
- <td class="origin">1</td></tr>
- <tr>
+ href="#first-letter">The ::first-letter
+ pseudo-element</a></td>
+ <td class="origin">1</td>
+</tr>
+<tr>
<td class="pattern">E::selection</td>
<td class="meaning">the portion of an E element that is currently
- selected/highlighted by the user</td>
+ selected/highlighted by the user
+ </td>
<td class="described"><a
- href="#UIfragments">The UI element
- fragments pseudo-elements</a></td>
- <td class="origin">3</td></tr>
- <tr>
+ href="#UIfragments">The UI element
+ fragments pseudo-elements</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
<td class="pattern">E::before</td>
<td class="meaning">generated content before an E element</td>
<td class="described"><a
- href="#gen-content">The ::before
- pseudo-element</a></td>
- <td class="origin">2</td></tr>
- <tr>
+ href="#gen-content">The ::before
+ pseudo-element</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
<td class="pattern">E::after</td>
<td class="meaning">generated content after an E element</td>
<td class="described"><a
- href="#gen-content">The ::after
- pseudo-element</a></td>
- <td class="origin">2</td></tr>
- <tr>
+ href="#gen-content">The ::after
+ pseudo-element</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
<td class="pattern">E.warning</td>
<td class="meaning">an E element whose class is
-"warning" (the document language specifies how class is determined).</td>
+ "warning" (the document language specifies how class is determined).
+ </td>
<td class="described"><a
- href="#class-html">Class
- selectors</a></td>
- <td class="origin">1</td></tr>
- <tr>
+ href="#class-html">Class
+ selectors</a></td>
+ <td class="origin">1</td>
+</tr>
+<tr>
<td class="pattern">E#myid</td>
<td class="meaning">an E element with ID equal to "myid".</td>
<td class="described"><a
- href="#id-selectors">ID
- selectors</a></td>
- <td class="origin">1</td></tr>
- <tr>
+ href="#id-selectors">ID
+ selectors</a></td>
+ <td class="origin">1</td>
+</tr>
+<tr>
<td class="pattern">E:not(s)</td>
<td class="meaning">an E element that does not match simple selector s</td>
<td class="described"><a
- href="#negation">Negation
- pseudo-class</a></td>
- <td class="origin">3</td></tr>
- <tr>
+ href="#negation">Negation
+ pseudo-class</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
<td class="pattern">E F</td>
<td class="meaning">an F element descendant of an E element</td>
<td class="described"><a
- href="#descendant-combinators">Descendant
- combinator</a></td>
- <td class="origin">1</td></tr>
- <tr>
+ href="#descendant-combinators">Descendant
+ combinator</a></td>
+ <td class="origin">1</td>
+</tr>
+<tr>
<td class="pattern">E > F</td>
<td class="meaning">an F element child of an E element</td>
<td class="described"><a
- href="#child-combinators">Child
- combinator</a></td>
- <td class="origin">2</td></tr>
- <tr>
+ href="#child-combinators">Child
+ combinator</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
<td class="pattern">E + F</td>
<td class="meaning">an F element immediately preceded by an E element</td>
<td class="described"><a
- href="#adjacent-sibling-combinators">Adjacent sibling combinator</a></td>
- <td class="origin">2</td></tr>
- <tr>
+ href="#adjacent-sibling-combinators">Adjacent sibling combinator</a>
+ </td>
+ <td class="origin">2</td>
+</tr>
+<tr>
<td class="pattern">E ~ F</td>
<td class="meaning">an F element preceded by an E element</td>
<td class="described"><a
- href="#general-sibling-combinators">General sibling combinator</a></td>
- <td class="origin">3</td></tr></tbody></table>
+ href="#general-sibling-combinators">General sibling combinator</a>
+ </td>
+ <td class="origin">3</td>
+</tr>
+</tbody>
+</table>
<p>The meaning of each selector is derived from the table above by
-prepending "matches" to the contents of each cell in the "Meaning"
-column.</p>
+ prepending "matches" to the contents of each cell in the "Meaning"
+ column.</p>
<h2><a name=casesens>3. Case sensitivity</a></h2>
<p>The case sensitivity of document language element names, attribute
-names, and attribute values in selectors depends on the document
-language. For example, in HTML, element names are case-insensitive,
-but in XML, they are case-sensitive.</p>
+ names, and attribute values in selectors depends on the document
+ language. For example, in HTML, element names are case-insensitive,
+ but in XML, they are case-sensitive.</p>
<h2><a name=selector-syntax>4. Selector syntax</a></h2>
<p>A <dfn><a name=selector>selector</a></dfn> is a chain of one
-or more <a href="#sequence">sequences of simple selectors</a>
-separated by <a href="#combinators">combinators</a>.</p>
+ or more <a href="#sequence">sequences of simple selectors</a>
+ separated by <a href="#combinators">combinators</a>.</p>
<p>A <dfn><a name=sequence>sequence of simple selectors</a></dfn>
-is a chain of <a href="#simple-selectors-dfn">simple selectors</a>
-that are not separated by a <a href="#combinators">combinator</a>. It
-always begins with a <a href="#type-selectors">type selector</a> or a
-<a href="#universal-selector">universal selector</a>. No other type
-selector or universal selector is allowed in the sequence.</p>
+ is a chain of <a href="#simple-selectors-dfn">simple selectors</a>
+ that are not separated by a <a href="#combinators">combinator</a>. It
+ always begins with a <a href="#type-selectors">type selector</a> or a
+ <a href="#universal-selector">universal selector</a>. No other type
+ selector or universal selector is allowed in the sequence.</p>
<p>A <dfn><a name=simple-selectors-dfn></a><a
-href="#simple-selectors">simple selector</a></dfn> is either a <a
-href="#type-selectors">type selector</a>, <a
-href="#universal-selector">universal selector</a>, <a
-href="#attribute-selectors">attribute selector</a>, <a
-href="#class-html">class selector</a>, <a
-href="#id-selectors">ID selector</a>, <a
-href="#content-selectors">content selector</a>, or <a
-href="#pseudo-classes">pseudo-class</a>. One <a
-href="#pseudo-elements">pseudo-element</a> may be appended to the last
-sequence of simple selectors.</p>
+ href="#simple-selectors">simple selector</a></dfn> is either a <a
+ href="#type-selectors">type selector</a>, <a
+ href="#universal-selector">universal selector</a>, <a
+ href="#attribute-selectors">attribute selector</a>, <a
+ href="#class-html">class selector</a>, <a
+ href="#id-selectors">ID selector</a>, <a
+ href="#content-selectors">content selector</a>, or <a
+ href="#pseudo-classes">pseudo-class</a>. One <a
+ href="#pseudo-elements">pseudo-element</a> may be appended to the last
+ sequence of simple selectors.</p>
<p><dfn>Combinators</dfn> are: white space, "greater-than
-sign" (U+003E, <code>></code>), "plus sign" (U+002B,
-<code>+</code>) and "tilde" (U+007E, <code>~</code>). White
-space may appear between a combinator and the simple selectors around
-it. <a name=whitespace></a>Only the characters "space" (U+0020), "tab"
-(U+0009), "line feed" (U+000A), "carriage return" (U+000D), and "form
-feed" (U+000C) can occur in white space. Other space-like characters,
-such as "em-space" (U+2003) and "ideographic space" (U+3000), are
-never part of white space.</p>
+ sign" (U+003E, <code>></code>), "plus sign" (U+002B,
+ <code>+</code>) and "tilde" (U+007E, <code>~</code>). White
+ space may appear between a combinator and the simple selectors around
+ it. <a name=whitespace></a>Only the characters "space" (U+0020), "tab"
+ (U+0009), "line feed" (U+000A), "carriage return" (U+000D), and "form
+ feed" (U+000C) can occur in white space. Other space-like characters,
+ such as "em-space" (U+2003) and "ideographic space" (U+3000), are
+ never part of white space.</p>
<p>The elements of a document tree that are represented by a selector
-are the <dfn><a name=subject></a>subjects of the selector</dfn>. A
-selector consisting of a single sequence of simple selectors
-represents any element satisfying its requirements. Prepending another
-sequence of simple selectors and a combinator to a sequence imposes
-additional matching constraints, so the subjects of a selector are
-always a subset of the elements represented by the last sequence of
-simple selectors.</p>
+ are the <dfn><a name=subject></a>subjects of the selector</dfn>. A
+ selector consisting of a single sequence of simple selectors
+ represents any element satisfying its requirements. Prepending another
+ sequence of simple selectors and a combinator to a sequence imposes
+ additional matching constraints, so the subjects of a selector are
+ always a subset of the elements represented by the last sequence of
+ simple selectors.</p>
<p>An empty selector, containing no sequence of simple selectors and
-no pseudo-element, is an <a href="#Conformance">invalid
-selector</a>.</p>
+ no pseudo-element, is an <a href="#Conformance">invalid
+ selector</a>.</p>
<h2><a name=grouping>5. Groups of selectors</a></h2>
<p>When several selectors share the same declarations, they may be
-grouped into a comma-separated list. (A comma is U+002C.)</p>
+ grouped into a comma-separated list. (A comma is U+002C.)</p>
<div class="example">
-<p>CSS examples:</p>
-<p>In this example, we condense three rules with identical
-declarations into one. Thus,</p>
+ <p>CSS examples:</p>
+
+ <p>In this example, we condense three rules with identical
+ declarations into one. Thus,</p>
<pre>h1 { font-family: sans-serif }
h2 { font-family: sans-serif }
h3 { font-family: sans-serif }</pre>
-<p>is equivalent to:</p>
-<pre>h1, h2, h3 { font-family: sans-serif }</pre>
+ <p>is equivalent to:</p>
+ <pre>h1, h2, h3 { font-family: sans-serif }</pre>
</div>
<p><strong>Warning</strong>: the equivalence is true in this example
-because all the selectors are valid selectors. If just one of these
-selectors were invalid, the entire group of selectors would be
-invalid. This would invalidate the rule for all three heading
-elements, whereas in the former case only one of the three individual
-heading rules would be invalidated.</p>
+ because all the selectors are valid selectors. If just one of these
+ selectors were invalid, the entire group of selectors would be
+ invalid. This would invalidate the rule for all three heading
+ elements, whereas in the former case only one of the three individual
+ heading rules would be invalidated.</p>
<h2><a name=simple-selectors>6. Simple selectors</a></h2>
@@ -713,69 +864,74 @@ heading rules would be invalidated.</p> <h3><a name=type-selectors>6.1. Type selector</a></h3>
<p>A <dfn>type selector</dfn> is the name of a document language
-element type. A type selector represents an instance of the element
-type in the document tree.</p>
+ element type. A type selector represents an instance of the element
+ type in the document tree.</p>
<div class="example">
- <p>Example:</p>
- <p>The following selector represents an <code>h1</code> element in the document tree:</p>
- <pre>h1</pre>
+ <p>Example:</p>
+
+ <p>The following selector represents an <code>h1</code> element in the
+ document tree:</p>
+ <pre>h1</pre>
</div>
<h4><a name=typenmsp>6.1.1. Type selectors and namespaces</a></h4>
<p>Type selectors allow an optional namespace (<a
-href="#refsXMLNAMES">[XMLNAMES]</a>) component. A namespace prefix
-that has been previously declared may be prepended to the element name
-separated by the namespace separator "vertical bar"
-(U+007C, <code>|</code>).</p>
+ href="#refsXMLNAMES">[XMLNAMES]</a>) component. A namespace prefix
+ that has been previously declared may be prepended to the element name
+ separated by the namespace separator "vertical bar"
+ (U+007C, <code>|</code>).</p>
<p>The namespace component may be left empty to indicate that the
-selector is only to represent elements with no declared namespace.</p>
+ selector is only to represent elements with no declared namespace.</p>
<p>An asterisk may be used for the namespace prefix, indicating that
-the selector represents elements in any namespace (including elements
-with no namespace).</p>
+ the selector represents elements in any namespace (including elements
+ with no namespace).</p>
<p>Element type selectors that have no namespace component (no
-namespace separator), represent elements without regard to the
-element's namespace (equivalent to "<code>*|</code>") unless a default
-namespace has been declared. If a default namespace has been declared,
-the selector will represent only elements in the default
-namespace.</p>
+ namespace separator), represent elements without regard to the
+ element's namespace (equivalent to "<code>*|</code>") unless a default
+ namespace has been declared. If a default namespace has been declared,
+ the selector will represent only elements in the default
+ namespace.</p>
<p>A type selector containing a namespace prefix that has not been
-previously declared is an <a href="#Conformance">invalid</a> selector.
-The mechanism for declaring a namespace prefix is left up to the
-language implementing Selectors. In CSS, such a mechanism is defined
-in the General Syntax module.</p>
+ previously declared is an <a href="#Conformance">invalid</a> selector.
+ The mechanism for declaring a namespace prefix is left up to the
+ language implementing Selectors. In CSS, such a mechanism is defined
+ in the General Syntax module.</p>
<p>In a namespace-aware client, element type selectors will only match
-against the <a
-href="http://www.w3.org/TR/REC-xml-names/#NT-LocalPart">local part</a>
-of the element's <a
-href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">qualified
-name</a>. See <a href="#downlevel">below</a> for notes about matching
-behaviors in down-level clients.</p>
+ against the <a
+ href="http://www.w3.org/TR/REC-xml-names/#NT-LocalPart">local
+ part</a>
+ of the element's <a
+ href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">qualified
+ name</a>. See <a href="#downlevel">below</a> for notes about matching
+ behaviors in down-level clients.</p>
<p>In summary:</p>
<dl>
- <dt><code>ns|E</code></dt>
- <dd>elements with name E in namespace ns</dd>
- <dt><code>*|E</code></dt>
- <dd>elements with name E in any namespace, including those without any
- declared namespace</dd>
- <dt><code>|E</code></dt>
- <dd>elements with name E without any declared namespace</dd>
- <dt><code>E</code></dt>
- <dd>if no default namespace has been specified, this is equivalent to *|E.
- Otherwise it is equivalent to ns|E where ns is the default namespace.</dd>
+ <dt><code>ns|E</code></dt>
+ <dd>elements with name E in namespace ns</dd>
+ <dt><code>*|E</code></dt>
+ <dd>elements with name E in any namespace, including those without any
+ declared namespace
+ </dd>
+ <dt><code>|E</code></dt>
+ <dd>elements with name E without any declared namespace</dd>
+ <dt><code>E</code></dt>
+ <dd>if no default namespace has been specified, this is equivalent to *|E.
+ Otherwise it is equivalent to ns|E where ns is the default namespace.
+ </dd>
</dl>
<div class="example">
- <p>CSS examples:</p>
+ <p>CSS examples:</p>
<pre>@namespace foo url(http://www.example.com);
foo|h1 { color: blue }
@@ -784,163 +940,176 @@ behaviors in down-level clients.</p> *|h1 { color: green }
h1 { color: green }</pre>
- <p>The first rule will match only <code>h1</code> elements in the
- "http://www.example.com" namespace.</p>
+ <p>The first rule will match only <code>h1</code> elements in the
+ "http://www.example.com" namespace.</p>
- <p>The second rule will match all elements in the
- "http://www.example.com" namespace.</p>
+ <p>The second rule will match all elements in the
+ "http://www.example.com" namespace.</p>
- <p>The third rule will match only <code>h1</code> elements without
- any declared namespace.</p>
+ <p>The third rule will match only <code>h1</code> elements without
+ any declared namespace.</p>
- <p>The fourth rule will match <code>h1</code> elements in any
- namespace (including those without any declared namespace).</p>
+ <p>The fourth rule will match <code>h1</code> elements in any
+ namespace (including those without any declared namespace).</p>
- <p>The last rule is equivalent to the fourth rule because no default
- namespace has been defined.</p>
+ <p>The last rule is equivalent to the fourth rule because no default
+ namespace has been defined.</p>
</div>
-<h3><a name=universal-selector>6.2. Universal selector</a> </h3>
+<h3><a name=universal-selector>6.2. Universal selector</a></h3>
<p>The <dfn>universal selector</dfn>, written "asterisk"
-(<code>*</code>), represents the qualified name of any element
-type. It represents any single element in the document tree in any
-namespace (including those without any declared namespace) if no
-default namespace has been specified. If a default namespace has been
-specified, see <a href="#univnmsp">Universal selector and
-Namespaces</a> below.</p>
+ (<code>*</code>), represents the qualified name of any element
+ type. It represents any single element in the document tree in any
+ namespace (including those without any declared namespace) if no
+ default namespace has been specified. If a default namespace has been
+ specified, see <a href="#univnmsp">Universal selector and
+ Namespaces</a> below.</p>
<p>If the universal selector is not the only component of a sequence
-of simple selectors, the <code>*</code> may be omitted.</p>
+ of simple selectors, the <code>*</code> may be omitted.</p>
<div class="example">
- <p>Examples:</p>
- <ul>
- <li><code>*[hreflang|=en]</code> and <code>[hreflang|=en]</code> are equivalent,</li>
- <li><code>*.warning</code> and <code>.warning</code> are equivalent,</li>
- <li><code>*#myid</code> and <code>#myid</code> are equivalent.</li>
- </ul>
+ <p>Examples:</p>
+ <ul>
+ <li><code>*[hreflang|=en]</code> and <code>[hreflang|=en]</code> are
+ equivalent,
+ </li>
+ <li><code>*.warning</code> and <code>.warning</code> are equivalent,
+ </li>
+ <li><code>*#myid</code> and <code>#myid</code> are equivalent.</li>
+ </ul>
</div>
<p class="note"><strong>Note:</strong> it is recommended that the
-<code>*</code>, representing the universal selector, not be
-omitted.</p>
+ <code>*</code>, representing the universal selector, not be
+ omitted.</p>
<h4><a name=univnmsp>6.2.1. Universal selector and namespaces</a></h4>
<p>The universal selector allows an optional namespace component. It
-is used as follows:</p>
+ is used as follows:</p>
<dl>
- <dt><code>ns|*</code></dt>
- <dd>all elements in namespace ns</dd>
- <dt><code>*|*</code></dt>
- <dd>all elements</dd>
- <dt><code>|*</code></dt>
- <dd>all elements without any declared namespace</dd>
- <dt><code>*</code></dt>
- <dd>if no default namespace has been specified, this is equivalent to *|*.
- Otherwise it is equivalent to ns|* where ns is the default namespace.</dd>
+ <dt><code>ns|*</code></dt>
+ <dd>all elements in namespace ns</dd>
+ <dt><code>*|*</code></dt>
+ <dd>all elements</dd>
+ <dt><code>|*</code></dt>
+ <dd>all elements without any declared namespace</dd>
+ <dt><code>*</code></dt>
+ <dd>if no default namespace has been specified, this is equivalent to *|*.
+ Otherwise it is equivalent to ns|* where ns is the default namespace.
+ </dd>
</dl>
<p>A universal selector containing a namespace prefix that has not
-been previously declared is an <a href="#Conformance">invalid</a>
-selector. The mechanism for declaring a namespace prefix is left up
-to the language implementing Selectors. In CSS, such a mechanism is
-defined in the General Syntax module.</p>
+ been previously declared is an <a href="#Conformance">invalid</a>
+ selector. The mechanism for declaring a namespace prefix is left up
+ to the language implementing Selectors. In CSS, such a mechanism is
+ defined in the General Syntax module.</p>
<h3><a name=attribute-selectors>6.3. Attribute selectors</a></h3>
<p>Selectors allow the representation of an element's attributes. When
-a selector is used as an expression to match against an element,
-attribute selectors must be considered to match an element if that
-element has an attribute that matches the attribute represented by the
-attribute selector.</p>
+ a selector is used as an expression to match against an element,
+ attribute selectors must be considered to match an element if that
+ element has an attribute that matches the attribute represented by the
+ attribute selector.</p>
<h4><a name=attribute-representation>6.3.1. Attribute presence and values
-selectors</a></h4>
+ selectors</a></h4>
<p>CSS2 introduced four attribute selectors:</p>
<dl>
- <dt><code>[att]</code>
- <dd>Represents an element with the <code>att</code> attribute, whatever the value of
- the attribute.</dd>
- <dt><code>[att=val]</code></dt>
- <dd>Represents an element with the <code>att</code> attribute whose value is exactly
- "val".</dd>
- <dt><code>[att~=val]</code></dt>
- <dd>Represents an element with the <code>att</code> attribute whose value is a <a
- href="#whitespace">whitespace</a>-separated list of words, one of
- which is exactly "val". If "val" contains whitespace, it will never
- represent anything (since the words are <em>separated</em> by
- spaces).</dd>
- <dt><code>[att|=val]</code>
- <dd>Represents an element with the <code>att</code> attribute, its value either
- being exactly "val" or beginning with "val" immediately followed by
- "-" (U+002D). This is primarily intended to allow language subcode
- matches (e.g., the <code>hreflang</code> attribute on the
- <code>link</code> element in HTML) as described in RFC 3066 (<a
- href="#refsRFC3066">[RFC3066]</a>). For <code>lang</code> (or
- <code>xml:lang</code>) language subcode matching, please see <a
- href="#lang-pseudo">the <code>:lang</code> pseudo-class</a>.</dd>
+ <dt><code>[att]</code>
+ <dd>Represents an element with the <code>att</code> attribute, whatever the
+ value of
+ the attribute.
+ </dd>
+ <dt><code>[att=val]</code></dt>
+ <dd>Represents an element with the <code>att</code> attribute whose value is
+ exactly
+ "val".
+ </dd>
+ <dt><code>[att~=val]</code></dt>
+ <dd>Represents an element with the <code>att</code> attribute whose value is
+ a <a
+ href="#whitespace">whitespace</a>-separated list of words, one
+ of
+ which is exactly "val". If "val" contains whitespace, it will never
+ represent anything (since the words are <em>separated</em> by
+ spaces).
+ </dd>
+ <dt><code>[att|=val]</code>
+ <dd>Represents an element with the <code>att</code> attribute, its value
+ either
+ being exactly "val" or beginning with "val" immediately followed by
+ "-" (U+002D). This is primarily intended to allow language subcode
+ matches (e.g., the <code>hreflang</code> attribute on the
+ <code>link</code> element in HTML) as described in RFC 3066 (<a
+ href="#refsRFC3066">[RFC3066]</a>). For <code>lang</code> (or
+ <code>xml:lang</code>) language subcode matching, please see <a
+ href="#lang-pseudo">the <code>:lang</code> pseudo-class</a>.
+ </dd>
</dl>
<p>Attribute values must be identifiers or strings. The
-case-sensitivity of attribute names and values in selectors depends on
-the document language.</p>
+ case-sensitivity of attribute names and values in selectors depends on
+ the document language.</p>
<div class="example">
- <p>Examples:</p>
+ <p>Examples:</p>
- <p>The following attribute selector represents an <code>h1</code>
- element that carries the <code>title</code> attribute, whatever its
- value:</p>
+ <p>The following attribute selector represents an <code>h1</code>
+ element that carries the <code>title</code> attribute, whatever its
+ value:</p>
- <pre>h1[title]</pre>
+ <pre>h1[title]</pre>
- <p>In the following example, the selector represents a
- <code>span</code> element whose <code>class</code> attribute has
- exactly the value "example":</p>
+ <p>In the following example, the selector represents a
+ <code>span</code> element whose <code>class</code> attribute has
+ exactly the value "example":</p>
- <pre>span[class="example"]</pre>
+ <pre>span[class="example"]</pre>
- <p>Multiple attribute selectors can be used to represent several
- attributes of an element, or several conditions on the same
- attribute. Here, the selector represents a <code>span</code> element
- whose <code>hello</code> attribute has exactly the value "Cleveland"
- and whose <code>goodbye</code> attribute has exactly the value
- "Columbus":</p>
+ <p>Multiple attribute selectors can be used to represent several
+ attributes of an element, or several conditions on the same
+ attribute. Here, the selector represents a <code>span</code> element
+ whose <code>hello</code> attribute has exactly the value "Cleveland"
+ and whose <code>goodbye</code> attribute has exactly the value
+ "Columbus":</p>
- <pre>span[hello="Cleveland"][goodbye="Columbus"]</pre>
+ <pre>span[hello="Cleveland"][goodbye="Columbus"]</pre>
- <p>The following selectors illustrate the differences between "="
- and "~=". The first selector will represent, for example, the value
- "copyright copyleft copyeditor" on a <code>rel</code> attribute. The
- second selector will only represent an <code>a</code> element with
- an <code>href</code> attribute having the exact value
- "http://www.w3.org/".</p>
+ <p>The following selectors illustrate the differences between "="
+ and "~=". The first selector will represent, for example, the value
+ "copyright copyleft copyeditor" on a <code>rel</code> attribute. The
+ second selector will only represent an <code>a</code> element with
+ an <code>href</code> attribute having the exact value
+ "http://www.w3.org/".</p>
<pre>a[rel~="copyright"]
a[href="http://www.w3.org/"]</pre>
- <p>The following selector represents a <code>link</code> element
- whose <code>hreflang</code> attribute is exactly "fr".</p>
+ <p>The following selector represents a <code>link</code> element
+ whose <code>hreflang</code> attribute is exactly "fr".</p>
- <pre>link[hreflang=fr]</pre>
+ <pre>link[hreflang=fr]</pre>
- <p>The following selector represents a <code>link</code> element for
- which the values of the <code>hreflang</code> attribute begins with
- "en", including "en", "en-US", and "en-cockney":</p>
+ <p>The following selector represents a <code>link</code> element for
+ which the values of the <code>hreflang</code> attribute begins with
+ "en", including "en", "en-US", and "en-cockney":</p>
- <pre>link[hreflang|="en"]</pre>
+ <pre>link[hreflang|="en"]</pre>
- <p>Similarly, the following selectors represents a
- <code>DIALOGUE</code> element whenever it has one of two different
- values for an attribute <code>character</code>:</p>
+ <p>Similarly, the following selectors represents a
+ <code>DIALOGUE</code> element whenever it has one of two different
+ values for an attribute <code>character</code>:</p>
<pre>DIALOGUE[character=romeo]
DIALOGUE[character=juliet]</pre>
@@ -948,173 +1117,183 @@ DIALOGUE[character=juliet]</pre> </div>
<h4><a name=attribute-substrings></a>6.3.2. Substring matching attribute
-selectors</h4>
+ selectors</h4>
<p>Three additional attribute selectors are provided for matching
-substrings in the value of an attribute:</p>
+ substrings in the value of an attribute:</p>
<dl>
- <dt><code>[att^=val]</code></dt>
- <dd>Represents an element with the <code>att</code> attribute whose value begins
- with the prefix "val".</dd>
- <dt><code>[att$=val]</code>
- <dd>Represents an element with the <code>att</code> attribute whose value ends with
- the suffix "val".</dd>
- <dt><code>[att*=val]</code>
- <dd>Represents an element with the <code>att</code> attribute whose value contains
- at least one instance of the substring "val".</dd>
+ <dt><code>[att^=val]</code></dt>
+ <dd>Represents an element with the <code>att</code> attribute whose value
+ begins
+ with the prefix "val".
+ </dd>
+ <dt><code>[att$=val]</code>
+ <dd>Represents an element with the <code>att</code> attribute whose value
+ ends with
+ the suffix "val".
+ </dd>
+ <dt><code>[att*=val]</code>
+ <dd>Represents an element with the <code>att</code> attribute whose value
+ contains
+ at least one instance of the substring "val".
+ </dd>
</dl>
<p>Attribute values must be identifiers or strings. The
-case-sensitivity of attribute names in selectors depends on the
-document language.</p>
+ case-sensitivity of attribute names in selectors depends on the
+ document language.</p>
<div class="example">
- <p>Examples:</p>
- <p>The following selector represents an HTML <code>object</code>, referencing an
- image:</p>
- <pre>object[type^="image/"]</pre>
- <p>The following selector represents an HTML anchor <code>a</code> with an
- <code>href</code> attribute whose value ends with ".html".</p>
- <pre>a[href$=".html"]</pre>
- <p>The following selector represents an HTML paragraph with a <code>title</code>
- attribute whose value contains the substring "hello"</p>
- <pre>p[title*="hello"]</pre>
+ <p>Examples:</p>
+
+ <p>The following selector represents an HTML <code>object</code>,
+ referencing an
+ image:</p>
+ <pre>object[type^="image/"]</pre>
+ <p>The following selector represents an HTML anchor <code>a</code> with an
+ <code>href</code> attribute whose value ends with ".html".</p>
+ <pre>a[href$=".html"]</pre>
+ <p>The following selector represents an HTML paragraph with a
+ <code>title</code>
+ attribute whose value contains the substring "hello"</p>
+ <pre>p[title*="hello"]</pre>
</div>
<h4><a name=attrnmsp>6.3.3. Attribute selectors and namespaces</a></h4>
<p>Attribute selectors allow an optional namespace component to the
-attribute name. A namespace prefix that has been previously declared
-may be prepended to the attribute name separated by the namespace
-separator "vertical bar" (<code>|</code>). In keeping with
-the Namespaces in the XML recommendation, default namespaces do not
-apply to attributes, therefore attribute selectors without a namespace
-component apply only to attributes that have no declared namespace
-(equivalent to "<code>|attr</code>"). An asterisk may be used for the
-namespace prefix indicating that the selector is to match all
-attribute names without regard to the attribute's namespace.
+ attribute name. A namespace prefix that has been previously declared
+ may be prepended to the attribute name separated by the namespace
+ separator "vertical bar" (<code>|</code>). In keeping with
+ the Namespaces in the XML recommendation, default namespaces do not
+ apply to attributes, therefore attribute selectors without a namespace
+ component apply only to attributes that have no declared namespace
+ (equivalent to "<code>|attr</code>"). An asterisk may be used for the
+ namespace prefix indicating that the selector is to match all
+ attribute names without regard to the attribute's namespace.
<p>An attribute selector with an attribute name containing a namespace
-prefix that has not been previously declared is an <a
-href="#Conformance">invalid</a> selector. The mechanism for declaring
-a namespace prefix is left up to the language implementing Selectors.
-In CSS, such a mechanism is defined in the General Syntax module.
+ prefix that has not been previously declared is an <a
+ href="#Conformance">invalid</a> selector. The mechanism for
+ declaring
+ a namespace prefix is left up to the language implementing Selectors.
+ In CSS, such a mechanism is defined in the General Syntax module.
<div class="example">
- <p>CSS examples:</p>
+ <p>CSS examples:</p>
<pre>@namespace foo "http://www.example.com";
[foo|att=val] { color: blue }
[*|att] { color: yellow }
[|att] { color: green }
[att] { color: green }</pre>
- <p>The first rule will match only elements with the attribute
- <code>att</code> in the "http://www.example.com" namespace with the
- value "val".</p>
+ <p>The first rule will match only elements with the attribute
+ <code>att</code> in the "http://www.example.com" namespace with the
+ value "val".</p>
- <p>The second rule will match only elements with the attribute
- <code>att</code> regardless of the namespace of the attribute
- (including no declared namespace).</p>
+ <p>The second rule will match only elements with the attribute
+ <code>att</code> regardless of the namespace of the attribute
+ (including no declared namespace).</p>
- <p>The last two rules are equivalent and will match only elements
- with the attribute <code>att</code> where the attribute is not
- declared to be in a namespace.</p>
+ <p>The last two rules are equivalent and will match only elements
+ with the attribute <code>att</code> where the attribute is not
+ declared to be in a namespace.</p>
</div>
<h4><a name=def-values>6.3.4. Default attribute values in DTDs</a></h4>
<p>Attribute selectors represent explicitly set attribute values in
-the document tree. Default attribute values may be defined in a DTD or
-elsewhere, but cannot always be selected by attribute
-selectors. Selectors should be designed so that they work even if the
-default values are not included in the document tree.</p>
+ the document tree. Default attribute values may be defined in a DTD or
+ elsewhere, but cannot always be selected by attribute
+ selectors. Selectors should be designed so that they work even if the
+ default values are not included in the document tree.</p>
<p>More precisely, a UA is <em>not</em> required to read an "external
-subset" of the DTD but <em>is</em> required to look for default
-attribute values in the document's "internal subset." (See <a
-href="#refsXML10">[XML10]</a> for definitions of these subsets.)</p>
+ subset" of the DTD but <em>is</em> required to look for default
+ attribute values in the document's "internal subset." (See <a
+ href="#refsXML10">[XML10]</a> for definitions of these subsets.)</p>
<p>A UA that recognizes an XML namespace <a
-href="#refsXMLNAMES">[XMLNAMES]</a> is not required to use its
-knowledge of that namespace to treat default attribute values as if
-they were present in the document. (For example, an XHTML UA is not
-required to use its built-in knowledge of the XHTML DTD.)</p>
+ href="#refsXMLNAMES">[XMLNAMES]</a> is not required to use its
+ knowledge of that namespace to treat default attribute values as if
+ they were present in the document. (For example, an XHTML UA is not
+ required to use its built-in knowledge of the XHTML DTD.)</p>
<p class="note"><strong>Note:</strong> Typically, implementations
-choose to ignore external subsets.</p>
+ choose to ignore external subsets.</p>
<div class="example">
-<p>Example:</p>
+ <p>Example:</p>
-<p>Consider an element EXAMPLE with an attribute "notation" that has a
-default value of "decimal". The DTD fragment might be</p>
+ <p>Consider an element EXAMPLE with an attribute "notation" that has a
+ default value of "decimal". The DTD fragment might be</p>
-<pre class="dtd-example"><!ATTLIST EXAMPLE notation (decimal,octal) "decimal"></pre>
+ <pre class="dtd-example"><!ATTLIST EXAMPLE notation (decimal,octal) "decimal"></pre>
-<p>If the style sheet contains the rules</p>
+ <p>If the style sheet contains the rules</p>
<pre>EXAMPLE[notation=decimal] { /*... default property settings ...*/ }
EXAMPLE[notation=octal] { /*... other settings...*/ }</pre>
-<p>the first rule will not match elements whose "notation" attribute
-is set by default, i.e. not set explicitly. To catch all cases, the
-attribute selector for the default value must be dropped:</p>
+ <p>the first rule will not match elements whose "notation" attribute
+ is set by default, i.e. not set explicitly. To catch all cases, the
+ attribute selector for the default value must be dropped:</p>
<pre>EXAMPLE { /*... default property settings ...*/ }
EXAMPLE[notation=octal] { /*... other settings...*/ }</pre>
-<p>Here, because the selector <code>EXAMPLE[notation=octal]</code> is
-more specific than the tag
-selector alone, the style declarations in the second rule will override
-those in the first for elements that have a "notation" attribute value
-of "octal". Care has to be taken that all property declarations that
-are to apply only to the default case are overridden in the non-default
-cases' style rules.</p>
+ <p>Here, because the selector <code>EXAMPLE[notation=octal]</code> is
+ more specific than the tag
+ selector alone, the style declarations in the second rule will override
+ those in the first for elements that have a "notation" attribute value
+ of "octal". Care has to be taken that all property declarations that
+ are to apply only to the default case are overridden in the non-default
+ cases' style rules.</p>
</div>
<h3><a name=class-html>6.4. Class selectors</a></h3>
<p>Working with HTML, authors may use the period (U+002E,
-<code>.</code>) notation as an alternative to the <code>~=</code>
-notation when representing the <code>class</code> attribute. Thus, for
-HTML, <code>div.value</code> and <code>div[class~=value]</code> have
-the same meaning. The attribute value must immediately follow the
-"period" (<code>.</code>).</p>
+ <code>.</code>) notation as an alternative to the <code>~=</code>
+ notation when representing the <code>class</code> attribute. Thus, for
+ HTML, <code>div.value</code> and <code>div[class~=value]</code> have
+ the same meaning. The attribute value must immediately follow the
+ "period" (<code>.</code>).</p>
<p>UAs may apply selectors using the period (.) notation in XML
-documents if the UA has namespace-specific knowledge that allows it to
-determine which attribute is the "class" attribute for the
-respective namespace. One such example of namespace-specific knowledge
-is the prose in the specification for a particular namespace (e.g. SVG
-1.0 <a href="#refsSVG">[SVG]</a> describes the <a
-href="http://www.w3.org/TR/2001/PR-SVG-20010719/styling.html#ClassAttribute">SVG
-"class" attribute</a> and how a UA should interpret it, and
-similarly MathML 1.01 <a href="#refsMATH">[MATH]</a> describes the <a
-href="http://www.w3.org/1999/07/REC-MathML-19990707/chapter2.html#sec2.3.4">MathML
-"class" attribute</a>.)</p>
+ documents if the UA has namespace-specific knowledge that allows it to
+ determine which attribute is the "class" attribute for the
+ respective namespace. One such example of namespace-specific knowledge
+ is the prose in the specification for a particular namespace (e.g. SVG
+ 1.0 <a href="#refsSVG">[SVG]</a> describes the <a
+ href="http://www.w3.org/TR/2001/PR-SVG-20010719/styling.html#ClassAttribute">SVG
+ "class" attribute</a> and how a UA should interpret it, and
+ similarly MathML 1.01 <a href="#refsMATH">[MATH]</a> describes the <a
+ href="http://www.w3.org/1999/07/REC-MathML-19990707/chapter2.html#sec2.3.4">MathML
+ "class" attribute</a>.)</p>
<div class="example">
- <p>CSS examples:</p>
+ <p>CSS examples:</p>
- <p>We can assign style information to all elements with
- <code>class~="pastoral"</code> as follows:</p>
+ <p>We can assign style information to all elements with
+ <code>class~="pastoral"</code> as follows:</p>
- <pre>*.pastoral { color: green } /* all elements with class~=pastoral */</pre>
+ <pre>*.pastoral { color: green } /* all elements with class~=pastoral */</pre>
- <p>or just</p>
+ <p>or just</p>
- <pre>.pastoral { color: green } /* all elements with class~=pastoral */</pre>
+ <pre>.pastoral { color: green } /* all elements with class~=pastoral */</pre>
- <p>The following assigns style only to H1 elements with
- <code>class~="pastoral"</code>:</p>
+ <p>The following assigns style only to H1 elements with
+ <code>class~="pastoral"</code>:</p>
- <pre>H1.pastoral { color: green } /* H1 elements with class~=pastoral */</pre>
+ <pre>H1.pastoral { color: green } /* H1 elements with class~=pastoral */</pre>
- <p>Given these rules, the first H1 instance below would not have
- green text, while the second would:</p>
+ <p>Given these rules, the first H1 instance below would not have
+ green text, while the second would:</p>
<pre><H1>Not green</H1>
<H1 class="pastoral">Very green</H1></pre>
@@ -1122,249 +1301,256 @@ href="http://www.w3.org/1999/07/REC-MathML-19990707/chapter2.html#sec2.3.4">Math </div>
<p>To represent a subset of "class" values, each value must be preceded
-by a ".", in any order.</P>
+ by a ".", in any order.</P>
<div class="example">
- <p>CSS example:</p>
+ <p>CSS example:</p>
- <p>The following rule matches any P element whose "class" attribute
- has been assigned a list of <a
- href="#whitespace">whitespace</a>-separated values that includes
- "pastoral" and "marine":</p>
+ <p>The following rule matches any P element whose "class" attribute
+ has been assigned a list of <a
+ href="#whitespace">whitespace</a>-separated values that includes
+ "pastoral" and "marine":</p>
- <pre>p.pastoral.marine { color: green }</pre>
+ <pre>p.pastoral.marine { color: green }</pre>
- <p>This rule matches when <code>class="pastoral blue aqua
- marine"</code> but does not match for <code>class="pastoral
- blue"</code>.</p>
+ <p>This rule matches when <code>class="pastoral blue aqua
+ marine"</code> but does not match for <code>class="pastoral
+ blue"</code>.</p>
</div>
<p class="note"><strong>Note:</strong> Because CSS gives considerable
-power to the "class" attribute, authors could conceivably design their
-own "document language" based on elements with almost no associated
-presentation (such as DIV and SPAN in HTML) and assigning style
-information through the "class" attribute. Authors should avoid this
-practice since the structural elements of a document language often
-have recognized and accepted meanings and author-defined classes may
-not.</p>
+ power to the "class" attribute, authors could conceivably design their
+ own "document language" based on elements with almost no associated
+ presentation (such as DIV and SPAN in HTML) and assigning style
+ information through the "class" attribute. Authors should avoid this
+ practice since the structural elements of a document language often
+ have recognized and accepted meanings and author-defined classes may
+ not.</p>
<p class="note"><strong>Note:</strong> If an element has multiple
-class attributes, their values must be concatenated with spaces
-between the values before searching for the class. As of this time the
-working group is not aware of any manner in which this situation can
-be reached, however, so this behavior is explicitly non-normative in
-this specification.</p>
+ class attributes, their values must be concatenated with spaces
+ between the values before searching for the class. As of this time the
+ working group is not aware of any manner in which this situation can
+ be reached, however, so this behavior is explicitly non-normative in
+ this specification.</p>
<h3><a name=id-selectors>6.5. ID selectors</a></h3>
<p>Document languages may contain attributes that are declared to be
-of type ID. What makes attributes of type ID special is that no two
-such attributes can have the same value in a document, regardless of
-the type of the elements that carry them; whatever the document
-language, an ID typed attribute can be used to uniquely identify its
-element. In HTML all ID attributes are named "id"; XML applications
-may name ID attributes differently, but the same restriction
-applies.</p>
+ of type ID. What makes attributes of type ID special is that no two
+ such attributes can have the same value in a document, regardless of
+ the type of the elements that carry them; whatever the document
+ language, an ID typed attribute can be used to uniquely identify its
+ element. In HTML all ID attributes are named "id"; XML applications
+ may name ID attributes differently, but the same restriction
+ applies.</p>
<p>An ID-typed attribute of a document language allows authors to
-assign an identifier to one element instance in the document tree. W3C
-ID selectors represent an element instance based on its identifier. An
-ID selector contains a "number sign" (U+0023,
-<code>#</code>) immediately followed by the ID value, which must be an
-identifier.</p>
+ assign an identifier to one element instance in the document tree. W3C
+ ID selectors represent an element instance based on its identifier. An
+ ID selector contains a "number sign" (U+0023,
+ <code>#</code>) immediately followed by the ID value, which must be an
+ identifier.</p>
<p>Selectors does not specify how a UA knows the ID-typed attribute of
-an element. The UA may, e.g., read a document's DTD, have the
-information hard-coded or ask the user.
+ an element. The UA may, e.g., read a document's DTD, have the
+ information hard-coded or ask the user.
<div class="example">
- <p>Examples:</p>
- <p>The following ID selector represents an <code>h1</code> element
- whose ID-typed attribute has the value "chapter1":</p>
- <pre>h1#chapter1</pre>
- <p>The following ID selector represents any element whose ID-typed
- attribute has the value "chapter1":</p>
- <pre>#chapter1</pre>
- <p>The following selector represents any element whose ID-typed
- attribute has the value "z98y".</p>
- <pre>*#z98y</pre>
+ <p>Examples:</p>
+
+ <p>The following ID selector represents an <code>h1</code> element
+ whose ID-typed attribute has the value "chapter1":</p>
+ <pre>h1#chapter1</pre>
+ <p>The following ID selector represents any element whose ID-typed
+ attribute has the value "chapter1":</p>
+ <pre>#chapter1</pre>
+ <p>The following selector represents any element whose ID-typed
+ attribute has the value "z98y".</p>
+ <pre>*#z98y</pre>
</div>
<p class="note"><strong>Note.</strong> In XML 1.0 <a
-href="#refsXML10">[XML10]</a>, the information about which attribute
-contains an element's IDs is contained in a DTD or a schema. When
-parsing XML, UAs do not always read the DTD, and thus may not know
-what the ID of an element is (though a UA may have namespace-specific
-knowledge that allows it to determine which attribute is the ID
-attribute for that namespace). If a style sheet designer knows or
-suspects that a UA may not know what the ID of an element is, he
-should use normal attribute selectors instead:
-<code>[name=p371]</code> instead of <code>#p371</code>. Elements in
-XML 1.0 documents without a DTD do not have IDs at all.</p>
+ href="#refsXML10">[XML10]</a>, the information about which attribute
+ contains an element's IDs is contained in a DTD or a schema. When
+ parsing XML, UAs do not always read the DTD, and thus may not know
+ what the ID of an element is (though a UA may have namespace-specific
+ knowledge that allows it to determine which attribute is the ID
+ attribute for that namespace). If a style sheet designer knows or
+ suspects that a UA may not know what the ID of an element is, he
+ should use normal attribute selectors instead:
+ <code>[name=p371]</code> instead of <code>#p371</code>. Elements in
+ XML 1.0 documents without a DTD do not have IDs at all.</p>
<p>If an element has multiple ID attributes, all of them must be
-treated as IDs for that element for the purposes of the ID
-selector. Such a situation could be reached using mixtures of xml:id,
-DOM3 Core, XML DTDs, and namespace-specific knowledge.</p>
+ treated as IDs for that element for the purposes of the ID
+ selector. Such a situation could be reached using mixtures of xml:id,
+ DOM3 Core, XML DTDs, and namespace-specific knowledge.</p>
<h3><a name=pseudo-classes>6.6. Pseudo-classes</a></h3>
<p>The pseudo-class concept is introduced to permit selection based on
-information that lies outside of the document tree or that cannot be
-expressed using the other simple selectors.</p>
+ information that lies outside of the document tree or that cannot be
+ expressed using the other simple selectors.</p>
<p>A pseudo-class always consists of a "colon"
-(<code>:</code>) followed by the name of the pseudo-class and
-optionally by a value between parentheses.</p>
+ (<code>:</code>) followed by the name of the pseudo-class and
+ optionally by a value between parentheses.</p>
<p>Pseudo-classes are allowed in all sequences of simple selectors
-contained in a selector. Pseudo-classes are allowed anywhere in
-sequences of simple selectors, after the leading type selector or
-universal selector (possibly omitted). Pseudo-class names are
-case-insensitive. Some pseudo-classes are mutually exclusive, while
-others can be applied simultaneously to the same
-element. Pseudo-classes may be dynamic, in the sense that an element
-may acquire or lose a pseudo-class while a user interacts with the
-document.</p>
+ contained in a selector. Pseudo-classes are allowed anywhere in
+ sequences of simple selectors, after the leading type selector or
+ universal selector (possibly omitted). Pseudo-class names are
+ case-insensitive. Some pseudo-classes are mutually exclusive, while
+ others can be applied simultaneously to the same
+ element. Pseudo-classes may be dynamic, in the sense that an element
+ may acquire or lose a pseudo-class while a user interacts with the
+ document.</p>
<h4><a name=dynamic-pseudos>6.6.1. Dynamic pseudo-classes</a></h4>
<p>Dynamic pseudo-classes classify elements on characteristics other
-than their name, attributes, or content, in principle characteristics
-that cannot be deduced from the document tree.</p>
+ than their name, attributes, or content, in principle characteristics
+ that cannot be deduced from the document tree.</p>
<p>Dynamic pseudo-classes do not appear in the document source or
-document tree.</p>
+ document tree.</p>
<h5>The <a name=link>link pseudo-classes: :link and :visited</a></h5>
<p>User agents commonly display unvisited links differently from
-previously visited ones. Selectors
-provides the pseudo-classes <code>:link</code> and
-<code>:visited</code> to distinguish them:</p>
+ previously visited ones. Selectors
+ provides the pseudo-classes <code>:link</code> and
+ <code>:visited</code> to distinguish them:</p>
<ul>
- <li>The <code>:link</code> pseudo-class applies to links that have
- not yet been visited.</li>
- <li>The <code>:visited</code> pseudo-class applies once the link has
- been visited by the user. </li>
+ <li>The <code>:link</code> pseudo-class applies to links that have
+ not yet been visited.
+ </li>
+ <li>The <code>:visited</code> pseudo-class applies once the link has
+ been visited by the user.
+ </li>
</ul>
<p>After some amount of time, user agents may choose to return a
-visited link to the (unvisited) ':link' state.</p>
+ visited link to the (unvisited) ':link' state.</p>
<p>The two states are mutually exclusive.</p>
<div class="example">
- <p>Example:</p>
+ <p>Example:</p>
- <p>The following selector represents links carrying class
- <code>external</code> and already visited:</p>
+ <p>The following selector represents links carrying class
+ <code>external</code> and already visited:</p>
- <pre>a.external:visited</pre>
+ <pre>a.external:visited</pre>
</div>
<p class="note"><strong>Note:</strong> It is possible for style sheet
-authors to abuse the :link and :visited pseudo-classes to determine
-which sites a user has visited without the user's consent.
+ authors to abuse the :link and :visited pseudo-classes to determine
+ which sites a user has visited without the user's consent.
<p>UAs may therefore treat all links as unvisited links, or implement
-other measures to preserve the user's privacy while rendering visited
-and unvisited links differently.</p>
+ other measures to preserve the user's privacy while rendering visited
+ and unvisited links differently.</p>
<h5>The <a name=useraction-pseudos>user action pseudo-classes
-:hover, :active, and :focus</a></h5>
+ :hover, :active, and :focus</a></h5>
<p>Interactive user agents sometimes change the rendering in response
-to user actions. Selectors provides
-three pseudo-classes for the selection of an element the user is
-acting on.</p>
+ to user actions. Selectors provides
+ three pseudo-classes for the selection of an element the user is
+ acting on.</p>
<ul>
- <li>The <code>:hover</code> pseudo-class applies while the user
- designates an element with a pointing device, but does not activate
- it. For example, a visual user agent could apply this pseudo-class
- when the cursor (mouse pointer) hovers over a box generated by the
- element. User agents not that do not support <a
- href="http://www.w3.org/TR/REC-CSS2/media.html#interactive-media-group">interactive
- media</a> do not have to support this pseudo-class. Some conforming
- user agents that support <a
- href="http://www.w3.org/TR/REC-CSS2/media.html#interactive-media-group">interactive
- media</a> may not be able to support this pseudo-class (e.g., a pen
- device that does not detect hovering).</li>
-
- <li>The <code>:active</code> pseudo-class applies while an element
- is being activated by the user. For example, between the times the
- user presses the mouse button and releases it.</li>
-
- <li>The <code>:focus</code> pseudo-class applies while an element
- has the focus (accepts keyboard or mouse events, or other forms of
- input). </li>
+ <li>The <code>:hover</code> pseudo-class applies while the user
+ designates an element with a pointing device, but does not activate
+ it. For example, a visual user agent could apply this pseudo-class
+ when the cursor (mouse pointer) hovers over a box generated by the
+ element. User agents not that do not support <a
+ href="http://www.w3.org/TR/REC-CSS2/media.html#interactive-media-group">interactive
+ media</a> do not have to support this pseudo-class. Some conforming
+ user agents that support <a
+ href="http://www.w3.org/TR/REC-CSS2/media.html#interactive-media-group">interactive
+ media</a> may not be able to support this pseudo-class (e.g., a pen
+ device that does not detect hovering).
+ </li>
+
+ <li>The <code>:active</code> pseudo-class applies while an element
+ is being activated by the user. For example, between the times the
+ user presses the mouse button and releases it.
+ </li>
+
+ <li>The <code>:focus</code> pseudo-class applies while an element
+ has the focus (accepts keyboard or mouse events, or other forms of
+ input).
+ </li>
</ul>
<p>There may be document language or implementation specific limits on
-which elements can become <code>:active</code> or acquire
-<code>:focus</code>.</p>
+ which elements can become <code>:active</code> or acquire
+ <code>:focus</code>.</p>
<p>These pseudo-classes are not mutually exclusive. An element may
-match several pseudo-classes at the same time.</p>
+ match several pseudo-classes at the same time.</p>
<p>Selectors doesn't define if the parent of an element that is
-':active' or ':hover' is also in that state.</p>
+ ':active' or ':hover' is also in that state.</p>
<div class="example">
- <p>Examples:</p>
+ <p>Examples:</p>
<pre>a:link /* unvisited links */
a:visited /* visited links */
a:hover /* user hovers */
a:active /* active links */</pre>
- <p>An example of combining dynamic pseudo-classes:</p>
+ <p>An example of combining dynamic pseudo-classes:</p>
<pre>a:focus
a:focus:hover</pre>
- <p>The last selector matches <code>a</code> elements that are in
- the pseudo-class :focus and in the pseudo-class :hover.</p>
+ <p>The last selector matches <code>a</code> elements that are in
+ the pseudo-class :focus and in the pseudo-class :hover.</p>
</div>
<p class="note"><strong>Note:</strong> An element can be both ':visited'
-and ':active' (or ':link' and ':active').</p>
+ and ':active' (or ':link' and ':active').</p>
<h4><a name=target-pseudo>6.6.2. The target pseudo-class :target</a></h4>
<p>Some URIs refer to a location within a resource. This kind of URI
-ends with a "number sign" (#) followed by an anchor
-identifier (called the fragment identifier).</p>
+ ends with a "number sign" (#) followed by an anchor
+ identifier (called the fragment identifier).</p>
<p>URIs with fragment identifiers link to a certain element within the
-document, known as the target element. For instance, here is a URI
-pointing to an anchor named <code>section_2</code> in an HTML
-document:</p>
+ document, known as the target element. For instance, here is a URI
+ pointing to an anchor named <code>section_2</code> in an HTML
+ document:</p>
<pre>http://example.com/html/top.html#section_2</pre>
<p>A target element can be represented by the <code>:target</code>
-pseudo-class. If the document's URI has no fragment identifier, then
-the document has no target element.</p>
+ pseudo-class. If the document's URI has no fragment identifier, then
+ the document has no target element.</p>
<div class="example">
- <p>Example:</p>
- <pre>p.note:target</pre>
- <p>This selector represents a <code>p</code> element of class
- <code>note</code> that is the target element of the referring
- URI.</p>
+ <p>Example:</p>
+ <pre>p.note:target</pre>
+ <p>This selector represents a <code>p</code> element of class
+ <code>note</code> that is the target element of the referring
+ URI.</p>
</div>
<div class="example">
- <p>CSS example:</p>
- <p>Here, the <code>:target</code> pseudo-class is used to make the
- target element red and place an image before it, if there is one:</p>
+ <p>CSS example:</p>
+
+ <p>Here, the <code>:target</code> pseudo-class is used to make the
+ target element red and place an image before it, if there is one:</p>
<pre>*:target { color : red }
*:target::before { content : url(target.png) }</pre>
</div>
@@ -1372,40 +1558,41 @@ the document has no target element.</p> <h4><a name=lang-pseudo>6.6.3. The language pseudo-class :lang</a></h4>
<p>If the document language specifies how the human language of an
-element is determined, it is possible to write selectors that
-represent an element based on its language. For example, in HTML <a
-href="#refsHTML4">[HTML4]</a>, the language is determined by a
-combination of the <code>lang</code> attribute, the <code>meta</code>
-element, and possibly by information from the protocol (such as HTTP
-headers). XML uses an attribute called <code>xml:lang</code>, and
-there may be other document language-specific methods for determining
-the language.</p>
+ element is determined, it is possible to write selectors that
+ represent an element based on its language. For example, in HTML <a
+ href="#refsHTML4">[HTML4]</a>, the language is determined by a
+ combination of the <code>lang</code> attribute, the <code>meta</code>
+ element, and possibly by information from the protocol (such as HTTP
+ headers). XML uses an attribute called <code>xml:lang</code>, and
+ there may be other document language-specific methods for determining
+ the language.</p>
<p>The pseudo-class <code>:lang(C)</code> represents an element that
-is in language C. Whether an element is represented by a
-<code>:lang()</code> selector is based solely on the identifier C
-being either equal to, or a hyphen-separated substring of, the
-element's language value, in the same way as if performed by the <a
-href="#attribute-representation">'|='</a> operator in attribute
-selectors. The identifier C does not have to be a valid language
-name.</p>
+ is in language C. Whether an element is represented by a
+ <code>:lang()</code> selector is based solely on the identifier C
+ being either equal to, or a hyphen-separated substring of, the
+ element's language value, in the same way as if performed by the <a
+ href="#attribute-representation">'|='</a> operator in attribute
+ selectors. The identifier C does not have to be a valid language
+ name.</p>
<p>C must not be empty. (If it is, the selector is invalid.)</p>
<p class="note"><strong>Note:</strong> It is recommended that
-documents and protocols indicate language using codes from RFC 3066 <a
-href="#refsRFC3066">[RFC3066]</a> or its successor, and by means of
-"xml:lang" attributes in the case of XML-based documents <a
-href="#refsXML10">[XML10]</a>. See <a
-href="http://www.w3.org/International/questions/qa-lang-2or3.html">
-"FAQ: Two-letter or three-letter language codes."</a></p>
+ documents and protocols indicate language using codes from RFC 3066 <a
+ href="#refsRFC3066">[RFC3066]</a> or its successor, and by means of
+ "xml:lang" attributes in the case of XML-based documents <a
+ href="#refsXML10">[XML10]</a>. See <a
+ href="http://www.w3.org/International/questions/qa-lang-2or3.html">
+ "FAQ: Two-letter or three-letter language codes."</a></p>
<div class="example">
- <p>Examples:</p>
- <p>The two following selectors represent an HTML document that is in
- Belgian, French, or German. The two next selectors represent
- <code>q</code> quotations in an arbitrary element in Belgian, French,
- or German.</p>
+ <p>Examples:</p>
+
+ <p>The two following selectors represent an HTML document that is in
+ Belgian, French, or German. The two next selectors represent
+ <code>q</code> quotations in an arbitrary element in Belgian, French,
+ or German.</p>
<pre>html:lang(fr-be)
html:lang(de)
:lang(fr-be) > q
@@ -1417,56 +1604,56 @@ html:lang(de) <h5><a name=enableddisabled>The :enabled and :disabled pseudo-classes</a></h5>
<p>The <code>:enabled</code> pseudo-class allows authors to customize
-the look of user interface elements that are enabled — which the
-user can select or activate in some fashion (e.g. clicking on a button
-with a mouse). There is a need for such a pseudo-class because there
-is no way to programmatically specify the default appearance of say,
-an enabled <code>input</code> element without also specifying what it
-would look like when it was disabled.</p>
+ the look of user interface elements that are enabled — which the
+ user can select or activate in some fashion (e.g. clicking on a button
+ with a mouse). There is a need for such a pseudo-class because there
+ is no way to programmatically specify the default appearance of say,
+ an enabled <code>input</code> element without also specifying what it
+ would look like when it was disabled.</p>
<p>Similar to <code>:enabled</code>, <code>:disabled</code> allows the
-author to specify precisely how a disabled or inactive user interface
-element should look.</p>
+ author to specify precisely how a disabled or inactive user interface
+ element should look.</p>
-<p>Most elements will be neither enabled nor disabled. An element is
-enabled if the user can either activate it or transfer the focus to
-it. An element is disabled if it could be enabled, but the user cannot
-presently activate it or transfer focus to it.</p>
+<p>Most elements will be neither enabled nor disabled. An element is
+ enabled if the user can either activate it or transfer the focus to
+ it. An element is disabled if it could be enabled, but the user cannot
+ presently activate it or transfer focus to it.</p>
<h5><a name=checked>The :checked pseudo-class</a></h5>
<p>Radio and checkbox elements can be toggled by the user. Some menu
-items are "checked" when the user selects them. When such elements are
-toggled "on" the <code>:checked</code> pseudo-class applies. The
-<code>:checked</code> pseudo-class initially applies to such elements
-that have the HTML4 <code>selected</code> and <code>checked</code>
-attributes as described in <a
-href="http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.2.1">Section
-17.2.1 of HTML4</a>, but of course the user can toggle "off" such
-elements in which case the <code>:checked</code> pseudo-class would no
-longer apply. While the <code>:checked</code> pseudo-class is dynamic
-in nature, and is altered by user action, since it can also be based
-on the presence of the semantic HTML4 <code>selected</code> and
-<code>checked</code> attributes, it applies to all media.
+ items are "checked" when the user selects them. When such elements are
+ toggled "on" the <code>:checked</code> pseudo-class applies. The
+ <code>:checked</code> pseudo-class initially applies to such elements
+ that have the HTML4 <code>selected</code> and <code>checked</code>
+ attributes as described in <a
+ href="http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.2.1">Section
+ 17.2.1 of HTML4</a>, but of course the user can toggle "off" such
+ elements in which case the <code>:checked</code> pseudo-class would no
+ longer apply. While the <code>:checked</code> pseudo-class is dynamic
+ in nature, and is altered by user action, since it can also be based
+ on the presence of the semantic HTML4 <code>selected</code> and
+ <code>checked</code> attributes, it applies to all media.
<h5><a name=indeterminate>The :indeterminate pseudo-class</a></h5>
<div class="note">
-<p>Radio and checkbox elements can be toggled by the user, but are
-sometimes in an indeterminate state, neither checked nor unchecked.
-This can be due to an element attribute, or DOM manipulation.</p>
+ <p>Radio and checkbox elements can be toggled by the user, but are
+ sometimes in an indeterminate state, neither checked nor unchecked.
+ This can be due to an element attribute, or DOM manipulation.</p>
-<p>A future version of this specification may introduce an
-<code>:indeterminate</code> pseudo-class that applies to such elements.
-<!--While the <code>:indeterminate</code> pseudo-class is dynamic in
-nature, and is altered by user action, since it can also be based on
-the presence of an element attribute, it applies to all media.</p>
-
-<p>Components of a radio-group initialized with no pre-selected choice
-are an example of :indeterminate state.--></p>
+ <p>A future version of this specification may introduce an
+ <code>:indeterminate</code> pseudo-class that applies to such elements.
+ <!--While the <code>:indeterminate</code> pseudo-class is dynamic in
+ nature, and is altered by user action, since it can also be based on
+ the presence of an element attribute, it applies to all media.</p>
+
+ <p>Components of a radio-group initialized with no pre-selected choice
+ are an example of :indeterminate state.--></p>
</div>
@@ -1474,47 +1661,48 @@ are an example of :indeterminate state.--></p> <h4><a name=structural-pseudos>6.6.5. Structural pseudo-classes</a></h4>
<p>Selectors introduces the concept of <dfn>structural
-pseudo-classes</dfn> to permit selection based on extra information that lies in
-the document tree but cannot be represented by other simple selectors or
-combinators.
+ pseudo-classes</dfn> to permit selection based on extra information that
+ lies in
+ the document tree but cannot be represented by other simple selectors or
+ combinators.
<p>Note that standalone pieces of PCDATA (text nodes in the DOM) are
-not counted when calculating the position of an element in the list of
-children of its parent. When calculating the position of an element in
-the list of children of its parent, the index numbering starts at 1.
+ not counted when calculating the position of an element in the list of
+ children of its parent. When calculating the position of an element in
+ the list of children of its parent, the index numbering starts at 1.
<h5><a name=root-pseudo>:root pseudo-class</a></h5>
<p>The <code>:root</code> pseudo-class represents an element that is
-the root of the document. In HTML 4, this is always the
-<code>HTML</code> element.
+ the root of the document. In HTML 4, this is always the
+ <code>HTML</code> element.
<h5><a name=nth-child-pseudo>:nth-child() pseudo-class</a></h5>
<p>The
-<code>:nth-child(<var>a</var><code>n</code>+<var>b</var>)</code>
-pseudo-class notation represents an element that has
-<var>a</var><code>n</code>+<var>b</var>-1 siblings
-<strong>before</strong> it in the document tree, for a given positive
-integer or zero value of <code>n</code>, and has a parent element. In
-other words, this matches the <var>b</var>th child of an element after
-all the children have been split into groups of <var>a</var> elements
-each. For example, this allows the selectors to address every other
-row in a table, and could be used to alternate the color
-of paragraph text in a cycle of four. The <var>a</var> and
-<var>b</var> values must be zero, negative integers or positive
-integers. The index of the first child of an element is 1.
+ <code>:nth-child(<var>a</var><code>n</code>+<var>b</var>)</code>
+ pseudo-class notation represents an element that has
+ <var>a</var><code>n</code>+<var>b</var>-1 siblings
+ <strong>before</strong> it in the document tree, for a given positive
+ integer or zero value of <code>n</code>, and has a parent element. In
+ other words, this matches the <var>b</var>th child of an element after
+ all the children have been split into groups of <var>a</var> elements
+ each. For example, this allows the selectors to address every other
+ row in a table, and could be used to alternate the color
+ of paragraph text in a cycle of four. The <var>a</var> and
+ <var>b</var> values must be zero, negative integers or positive
+ integers. The index of the first child of an element is 1.
<p>In addition to this, <code>:nth-child()</code> can take
-'<code>odd</code>' and '<code>even</code>' as arguments instead.
-'<code>odd</code>' has the same signification as <code>2n+1</code>,
-and '<code>even</code>' has the same signification as <code>2n</code>.
+ '<code>odd</code>' and '<code>even</code>' as arguments instead.
+ '<code>odd</code>' has the same signification as <code>2n+1</code>,
+ and '<code>even</code>' has the same signification as <code>2n</code>.
<div class="example">
-<p>Examples:</p>
+ <p>Examples:</p>
<pre>tr:nth-child(2n+1) /* represents every odd row of an HTML table */
tr:nth-child(odd) /* same */
tr:nth-child(2n) /* represents every even row of an HTML table */
@@ -1528,14 +1716,14 @@ p:nth-child(4n+4) { color: purple; }</pre> </div>
<p>When <var>a</var>=0, no repeating is used, so for example
-<code>:nth-child(0n+5)</code> matches only the fifth child. When
-<var>a</var>=0, the <var>a</var><code>n</code> part need not be
-included, so the syntax simplifies to
-<code>:nth-child(<var>b</var>)</code> and the last example simplifies
-to <code>:nth-child(5)</code>.
+ <code>:nth-child(0n+5)</code> matches only the fifth child. When
+ <var>a</var>=0, the <var>a</var><code>n</code> part need not be
+ included, so the syntax simplifies to
+ <code>:nth-child(<var>b</var>)</code> and the last example simplifies
+ to <code>:nth-child(5)</code>.
<div class="example">
-<p>Examples:</p>
+ <p>Examples:</p>
<pre>foo:nth-child(0n+1) /* represents an element foo, first child of its parent element */
foo:nth-child(1) /* same */</pre>
</div>
@@ -1543,8 +1731,9 @@ foo:nth-child(1) /* same */</pre> <p>When <var>a</var>=1, the number may be omitted from the rule.
<div class="example">
-<p>Examples:</p>
-<p>The following selectors are therefore equivalent:</p>
+ <p>Examples:</p>
+
+ <p>The following selectors are therefore equivalent:</p>
<pre>bar:nth-child(1n+0) /* represents all bar elements, specificity (0,1,1) */
bar:nth-child(n+0) /* same */
bar:nth-child(n) /* same */
@@ -1552,33 +1741,33 @@ bar /* same but lower specificity (0,0,1) */</pre> </div>
<p>If <var>b</var>=0, then every <var>a</var>th element is picked. In
-such a case, the <var>b</var> part may be omitted.
+ such a case, the <var>b</var> part may be omitted.
<div class="example">
-<p>Examples:</p>
+ <p>Examples:</p>
<pre>tr:nth-child(2n+0) /* represents every even row of an HTML table */
tr:nth-child(2n) /* same */</pre>
</div>
<p>If both <var>a</var> and <var>b</var> are equal to zero, the
-pseudo-class represents no element in the document tree.</p>
+ pseudo-class represents no element in the document tree.</p>
<p>The value <var>a</var> can be negative, but only the positive
-values of <var>a</var><code>n</code>+<var>b</var>, for
-<code>n</code>≥0, may represent an element in the document
-tree.</p>
+ values of <var>a</var><code>n</code>+<var>b</var>, for
+ <code>n</code>≥0, may represent an element in the document
+ tree.</p>
<div class="example">
-<p>Example:</p>
-<pre>html|tr:nth-child(-n+6) /* represents the 6 first rows of XHTML tables */</pre>
+ <p>Example:</p>
+ <pre>html|tr:nth-child(-n+6) /* represents the 6 first rows of XHTML tables */</pre>
</div>
<p>When the value <var>b</var> is negative, the "+" character in the
-expression must be removed (it is effectively replaced by the "-"
-character indicating the negative value of <var>b</var>).</p>
+ expression must be removed (it is effectively replaced by the "-"
+ character indicating the negative value of <var>b</var>).</p>
<div class="example">
-<p>Examples:</p>
+ <p>Examples:</p>
<pre>:nth-child(10n-1) /* represents the 9th, 19th, 29th, etc, element */
:nth-child(10n+9) /* Same */
:nth-child(10n+-1) /* Syntactically invalid, and would be ignored */</pre>
@@ -1588,17 +1777,17 @@ character indicating the negative value of <var>b</var>).</p> <h5><a name=nth-last-child-pseudo>:nth-last-child() pseudo-class</a></h5>
<p>The <code>:nth-last-child(<var>a</var>n+<var>b</var>)</code>
-pseudo-class notation represents an element that has
-<var>a</var><code>n</code>+<var>b</var>-1 siblings
-<strong>after</strong> it in the document tree, for a given positive
-integer or zero value of <code>n</code>, and has a parent element. See
-<code>:nth-child()</code> pseudo-class for the syntax of its argument.
-It also accepts the '<code>even</code>' and '<code>odd</code>' values
-as arguments.
+ pseudo-class notation represents an element that has
+ <var>a</var><code>n</code>+<var>b</var>-1 siblings
+ <strong>after</strong> it in the document tree, for a given positive
+ integer or zero value of <code>n</code>, and has a parent element. See
+ <code>:nth-child()</code> pseudo-class for the syntax of its argument.
+ It also accepts the '<code>even</code>' and '<code>odd</code>' values
+ as arguments.
<div class="example">
-<p>Examples:</p>
+ <p>Examples:</p>
<pre>tr:nth-last-child(-n+2) /* represents the two last rows of an HTML table */
foo:nth-last-child(odd) /* represents all odd foo elements in their parent element,
@@ -1609,20 +1798,21 @@ foo:nth-last-child(odd) /* represents all odd foo elements in their parent el <h5><a name=nth-of-type-pseudo>:nth-of-type() pseudo-class</a></h5>
<p>The <code>:nth-of-type(<var>a</var>n+<var>b</var>)</code>
-pseudo-class notation represents an element that has
-<var>a</var><code>n</code>+<var>b</var>-1 siblings with the same
-element name <strong>before</strong> it in the document tree, for a
-given zero or positive integer value of <code>n</code>, and has a
-parent element. In other words, this matches the <var>b</var>th child
-of that type after all the children of that type have been split into
-groups of a elements each. See <code>:nth-child()</code> pseudo-class
-for the syntax of its argument. It also accepts the
-'<code>even</code>' and '<code>odd</code>' values.
+ pseudo-class notation represents an element that has
+ <var>a</var><code>n</code>+<var>b</var>-1 siblings with the same
+ element name <strong>before</strong> it in the document tree, for a
+ given zero or positive integer value of <code>n</code>, and has a
+ parent element. In other words, this matches the <var>b</var>th child
+ of that type after all the children of that type have been split into
+ groups of a elements each. See <code>:nth-child()</code> pseudo-class
+ for the syntax of its argument. It also accepts the
+ '<code>even</code>' and '<code>odd</code>' values.
<div class="example">
-<p>CSS example:</p>
-<p>This allows an author to alternate the position of floated images:</p>
+ <p>CSS example:</p>
+
+ <p>This allows an author to alternate the position of floated images:</p>
<pre>img:nth-of-type(2n+1) { float: right; }
img:nth-of-type(2n) { float: left; }</pre>
</div>
@@ -1631,81 +1821,90 @@ img:nth-of-type(2n) { float: left; }</pre> <h5><a name=nth-last-of-type-pseudo>:nth-last-of-type() pseudo-class</a></h5>
<p>The <code>:nth-last-of-type(<var>a</var>n+<var>b</var>)</code>
-pseudo-class notation represents an element that has
-<var>a</var><code>n</code>+<var>b</var>-1 siblings with the same
-element name <strong>after</strong> it in the document tree, for a
-given zero or positive integer value of <code>n</code>, and has a
-parent element. See <code>:nth-child()</code> pseudo-class for the
-syntax of its argument. It also accepts the '<code>even</code>' and '<code>odd</code>' values.
+ pseudo-class notation represents an element that has
+ <var>a</var><code>n</code>+<var>b</var>-1 siblings with the same
+ element name <strong>after</strong> it in the document tree, for a
+ given zero or positive integer value of <code>n</code>, and has a
+ parent element. See <code>:nth-child()</code> pseudo-class for the
+ syntax of its argument. It also accepts the '<code>even</code>' and '<code>odd</code>'
+ values.
<div class="example">
- <p>Example:</p>
- <p>To represent all <code>h2</code> children of an XHTML
- <code>body</code> except the first and last, one could use the
- following selector:</p>
- <pre>body > h2:nth-of-type(n+2):nth-last-of-type(n+2)</pre>
- <p>In this case, one could also use <code>:not()</code>, although the
- selector ends up being just as long:</p>
- <pre>body > h2:not(:first-of-type):not(:last-of-type)</pre>
+ <p>Example:</p>
+
+ <p>To represent all <code>h2</code> children of an XHTML
+ <code>body</code> except the first and last, one could use the
+ following selector:</p>
+ <pre>body > h2:nth-of-type(n+2):nth-last-of-type(n+2)</pre>
+ <p>In this case, one could also use <code>:not()</code>, although the
+ selector ends up being just as long:</p>
+ <pre>body > h2:not(:first-of-type):not(:last-of-type)</pre>
</div>
<h5><a name=first-child-pseudo>:first-child pseudo-class</a></h5>
-<p>Same as <code>:nth-child(1)</code>. The <code>:first-child</code> pseudo-class
-represents an element that is the first child of some other element.
+<p>Same as <code>:nth-child(1)</code>. The <code>:first-child</code>
+ pseudo-class
+ represents an element that is the first child of some other element.
<div class="example">
- <p>Examples:</p>
- <p>The following selector represents a <code>p</code> element that is
- the first child of a <code>div</code> element:</p>
- <pre>div > p:first-child</pre>
- <p>This selector can represent the <code>p</code> inside the
- <code>div</code> of the following fragment:</p>
+ <p>Examples:</p>
+
+ <p>The following selector represents a <code>p</code> element that is
+ the first child of a <code>div</code> element:</p>
+ <pre>div > p:first-child</pre>
+ <p>This selector can represent the <code>p</code> inside the
+ <code>div</code> of the following fragment:</p>
<pre><p> The last P before the note.</p>
<div class="note">
<p> The first P inside the note.</p>
-</div></pre>but cannot represent the second <code>p</code> in the following
-fragment:
+</div></pre>
+ but cannot represent the second <code>p</code> in the following
+ fragment:
<pre><p> The last P before the note.</p>
<div class="note">
<h2> Note </h2>
<p> The first P inside the note.</p>
</div></pre>
- <p>The following two selectors are usually equivalent:</p>
+ <p>The following two selectors are usually equivalent:</p>
<pre>* > a:first-child /* a is first child of any element */
a:first-child /* Same (assuming a is not the root element) */</pre>
</div>
<h5><a name=last-child-pseudo>:last-child pseudo-class</a></h5>
-<p>Same as <code>:nth-last-child(1)</code>. The <code>:last-child</code> pseudo-class
-represents an element that is the last child of some other element.
+<p>Same as <code>:nth-last-child(1)</code>. The <code>:last-child</code>
+ pseudo-class
+ represents an element that is the last child of some other element.
<div class="example">
- <p>Example:</p>
- <p>The following selector represents a list item <code>li</code> that
- is the last child of an ordered list <code>ol</code>.
- <pre>ol > li:last-child</pre>
+ <p>Example:</p>
+
+ <p>The following selector represents a list item <code>li</code> that
+ is the last child of an ordered list <code>ol</code>.
+ <pre>ol > li:last-child</pre>
</div>
<h5><a name=first-of-type-pseudo>:first-of-type pseudo-class</a></h5>
-<p>Same as <code>:nth-of-type(1)</code>. The <code>:first-of-type</code> pseudo-class
-represents an element that is the first sibling of its type in the list of
-children of its parent element.
+<p>Same as <code>:nth-of-type(1)</code>. The <code>:first-of-type</code>
+ pseudo-class
+ represents an element that is the first sibling of its type in the list of
+ children of its parent element.
<div class="example">
-<p>Example:</p>
-<p>The following selector represents a definition title
-<code>dt</code> inside a definition list <code>dl</code>, this
-<code>dt</code> being the first of its type in the list of children of
-its parent element.</p>
-<pre>dl dt:first-of-type</pre>
-<p>It is a valid description for the first two <code>dt</code>
-elements in the following example but not for the third one:</p>
+ <p>Example:</p>
+
+ <p>The following selector represents a definition title
+ <code>dt</code> inside a definition list <code>dl</code>, this
+ <code>dt</code> being the first of its type in the list of children of
+ its parent element.</p>
+ <pre>dl dt:first-of-type</pre>
+ <p>It is a valid description for the first two <code>dt</code>
+ elements in the following example but not for the third one:</p>
<pre><dl>
<dt>gigogne</dt>
<dd>
@@ -1722,55 +1921,59 @@ elements in the following example but not for the third one:</p> <h5><a name=last-of-type-pseudo>:last-of-type pseudo-class</a></h5>
<p>Same as <code>:nth-last-of-type(1)</code>. The
-<code>:last-of-type</code> pseudo-class represents an element that is
-the last sibling of its type in the list of children of its parent
-element.</p>
+ <code>:last-of-type</code> pseudo-class represents an element that is
+ the last sibling of its type in the list of children of its parent
+ element.</p>
<div class="example">
- <p>Example:</p>
- <p>The following selector represents the last data cell
- <code>td</code> of a table row.</p>
- <pre>tr > td:last-of-type</pre>
+ <p>Example:</p>
+
+ <p>The following selector represents the last data cell
+ <code>td</code> of a table row.</p>
+ <pre>tr > td:last-of-type</pre>
</div>
<h5><a name=only-child-pseudo>:only-child pseudo-class</a></h5>
<p>Represents an element that has a parent element and whose parent
-element has no other element children. Same as
-<code>:first-child:last-child</code> or
-<code>:nth-child(1):nth-last-child(1)</code>, but with a lower
-specificity.</p>
+ element has no other element children. Same as
+ <code>:first-child:last-child</code> or
+ <code>:nth-child(1):nth-last-child(1)</code>, but with a lower
+ specificity.</p>
<h5><a name=only-of-type-pseudo>:only-of-type pseudo-class</a></h5>
<p>Represents an element that has a parent element and whose parent
-element has no other element children with the same element name. Same
-as <code>:first-of-type:last-of-type</code> or
-<code>:nth-of-type(1):nth-last-of-type(1)</code>, but with a lower
-specificity.</p>
+ element has no other element children with the same element name. Same
+ as <code>:first-of-type:last-of-type</code> or
+ <code>:nth-of-type(1):nth-last-of-type(1)</code>, but with a lower
+ specificity.</p>
<h5><a name=empty-pseudo></a>:empty pseudo-class</h5>
<p>The <code>:empty</code> pseudo-class represents an element that has
-no children at all. In terms of the DOM, only element nodes and text
-nodes (including CDATA nodes and entity references) whose data has a
-non-zero length must be considered as affecting emptiness; comments,
-PIs, and other nodes must not affect whether an element is considered
-empty or not.</p>
+ no children at all. In terms of the DOM, only element nodes and text
+ nodes (including CDATA nodes and entity references) whose data has a
+ non-zero length must be considered as affecting emptiness; comments,
+ PIs, and other nodes must not affect whether an element is considered
+ empty or not.</p>
<div class="example">
- <p>Examples:</p>
- <p><code>p:empty</code> is a valid representation of the following fragment:</p>
- <pre><p></p></pre>
- <p><code>foo:empty</code> is not a valid representation for the
- following fragments:</p>
- <pre><foo>bar</foo></pre>
- <pre><foo><bar>bla</bar></foo></pre>
- <pre><foo>this is not <bar>:empty</bar></foo></pre>
+ <p>Examples:</p>
+
+ <p><code>p:empty</code> is a valid representation of the following fragment:
+ </p>
+ <pre><p></p></pre>
+ <p><code>foo:empty</code> is not a valid representation for the
+ following fragments:</p>
+ <pre><foo>bar</foo></pre>
+ <pre><foo><bar>bla</bar></foo></pre>
+ <pre><foo>this is not <bar>:empty</bar></foo></pre>
</div>
-<h4><a name=content-selectors>6.6.6. Blank</a></h4> <!-- It's the Return of Appendix H!!! Run away! -->
+<h4><a name=content-selectors>6.6.6. Blank</a></h4>
+<!-- It's the Return of Appendix H!!! Run away! -->
<p>This section intentionally left blank.</p>
<!-- (used to be :contains()) -->
@@ -1778,100 +1981,102 @@ empty or not.</p> <h4><a name=negation></a>6.6.7. The negation pseudo-class</h4>
<p>The negation pseudo-class, <code>:not(<var>X</var>)</code>, is a
-functional notation taking a <a href="#simple-selectors-dfn">simple
-selector</a> (excluding the negation pseudo-class itself and
-pseudo-elements) as an argument. It represents an element that is not
-represented by the argument.
+ functional notation taking a <a href="#simple-selectors-dfn">simple
+ selector</a> (excluding the negation pseudo-class itself and
+ pseudo-elements) as an argument. It represents an element that is not
+ represented by the argument.
-<!-- pseudo-elements are not simple selectors, so the above paragraph
+ <!-- pseudo-elements are not simple selectors, so the above paragraph
may be a bit confusing -->
<div class="example">
- <p>Examples:</p>
- <p>The following CSS selector matches all <code>button</code>
- elements in an HTML document that are not disabled.</p>
- <pre>button:not([DISABLED])</pre>
- <p>The following selector represents all but <code>FOO</code>
- elements.</p>
- <pre>*:not(FOO)</pre>
- <p>The following group of selectors represents all HTML elements
- except links.</p>
- <pre>html|*:not(:link):not(:visited)</pre>
+ <p>Examples:</p>
+
+ <p>The following CSS selector matches all <code>button</code>
+ elements in an HTML document that are not disabled.</p>
+ <pre>button:not([DISABLED])</pre>
+ <p>The following selector represents all but <code>FOO</code>
+ elements.</p>
+ <pre>*:not(FOO)</pre>
+ <p>The following group of selectors represents all HTML elements
+ except links.</p>
+ <pre>html|*:not(:link):not(:visited)</pre>
</div>
<p>Default namespace declarations do not affect the argument of the
-negation pseudo-class unless the argument is a universal selector or a
-type selector.</p>
+ negation pseudo-class unless the argument is a universal selector or a
+ type selector.</p>
<div class="example">
- <p>Examples:</p>
- <p>Assuming that the default namespace is bound to
- "http://example.com/", the following selector represents all
- elements that are not in that namespace:</p>
- <pre>*|*:not(*)</pre>
- <p>The following CSS selector matches any element being hovered,
- regardless of its namespace. In particular, it is not limited to
- only matching elements in the default namespace that are not being
- hovered, and elements not in the default namespace don't match the
- rule when they <em>are</em> being hovered.</p>
- <pre>*|*:not(:hover)</pre>
+ <p>Examples:</p>
+
+ <p>Assuming that the default namespace is bound to
+ "http://example.com/", the following selector represents all
+ elements that are not in that namespace:</p>
+ <pre>*|*:not(*)</pre>
+ <p>The following CSS selector matches any element being hovered,
+ regardless of its namespace. In particular, it is not limited to
+ only matching elements in the default namespace that are not being
+ hovered, and elements not in the default namespace don't match the
+ rule when they <em>are</em> being hovered.</p>
+ <pre>*|*:not(:hover)</pre>
</div>
<p class="note"><strong>Note</strong>: the :not() pseudo allows
-useless selectors to be written. For instance <code>:not(*|*)</code>,
-which represents no element at all, or <code>foo:not(bar)</code>,
-which is equivalent to <code>foo</code> but with a higher
-specificity.</p>
+ useless selectors to be written. For instance <code>:not(*|*)</code>,
+ which represents no element at all, or <code>foo:not(bar)</code>,
+ which is equivalent to <code>foo</code> but with a higher
+ specificity.</p>
<h3><a name=pseudo-elements>7. Pseudo-elements</a></h3>
<p>Pseudo-elements create abstractions about the document tree beyond
-those specified by the document language. For instance, document
-languages do not offer mechanisms to access the first letter or first
-line of an element's content. Pseudo-elements allow designers to refer
-to this otherwise inaccessible information. Pseudo-elements may also
-provide designers a way to refer to content that does not exist in the
-source document (e.g., the <code>::before</code> and
-<code>::after</code> pseudo-elements give access to generated
-content).</p>
+ those specified by the document language. For instance, document
+ languages do not offer mechanisms to access the first letter or first
+ line of an element's content. Pseudo-elements allow designers to refer
+ to this otherwise inaccessible information. Pseudo-elements may also
+ provide designers a way to refer to content that does not exist in the
+ source document (e.g., the <code>::before</code> and
+ <code>::after</code> pseudo-elements give access to generated
+ content).</p>
<p>A pseudo-element is made of two colons (<code>::</code>) followed
-by the name of the pseudo-element.</p>
+ by the name of the pseudo-element.</p>
<p>This <code>::</code> notation is introduced by the current document
-in order to establish a discrimination between pseudo-classes and
-pseudo-elements. For compatibility with existing style sheets, user
-agents must also accept the previous one-colon notation for
-pseudo-elements introduced in CSS levels 1 and 2 (namely,
-<code>:first-line</code>, <code>:first-letter</code>,
-<code>:before</code> and <code>:after</code>). This compatibility is
-not allowed for the new pseudo-elements introduced in CSS level 3.</p>
+ in order to establish a discrimination between pseudo-classes and
+ pseudo-elements. For compatibility with existing style sheets, user
+ agents must also accept the previous one-colon notation for
+ pseudo-elements introduced in CSS levels 1 and 2 (namely,
+ <code>:first-line</code>, <code>:first-letter</code>,
+ <code>:before</code> and <code>:after</code>). This compatibility is
+ not allowed for the new pseudo-elements introduced in CSS level 3.</p>
<p>Only one pseudo-element may appear per selector, and if present it
-must appear after the sequence of simple selectors that represents the
-<a href="#subject">subjects</a> of the selector. <span class="note">A
+ must appear after the sequence of simple selectors that represents the
+ <a href="#subject">subjects</a> of the selector. <span class="note">A
future version of this specification may allow multiple
pesudo-elements per selector.</span></p>
<h4><a name=first-line>7.1. The ::first-line pseudo-element</a></h4>
<p>The <code>::first-line</code> pseudo-element describes the contents
-of the first formatted line of an element.
+ of the first formatted line of an element.
<div class="example">
-<p>CSS example:</p>
-<pre>p::first-line { text-transform: uppercase }</pre>
-<p>The above rule means "change the letters of the first line of every
-paragraph to uppercase".</p>
+ <p>CSS example:</p>
+ <pre>p::first-line { text-transform: uppercase }</pre>
+ <p>The above rule means "change the letters of the first line of every
+ paragraph to uppercase".</p>
</div>
<p>The selector <code>p::first-line</code> does not match any real
-HTML element. It does match a pseudo-element that conforming user
-agents will insert at the beginning of every paragraph.</p>
+ HTML element. It does match a pseudo-element that conforming user
+ agents will insert at the beginning of every paragraph.</p>
<p>Note that the length of the first line depends on a number of
-factors, including the width of the page, the font size, etc. Thus,
-an ordinary HTML paragraph such as:</p>
+ factors, including the width of the page, the font size, etc. Thus,
+ an ordinary HTML paragraph such as:</p>
<pre>
<P>This is a somewhat long HTML
@@ -1893,8 +2098,8 @@ ordinary lines in the paragraph. </pre>
<p>This paragraph might be "rewritten" by user agents to include the
-<em>fictional tag sequence</em> for <code>::first-line</code>. This
-fictional tag sequence helps to show how properties are inherited.</p>
+ <em>fictional tag sequence</em> for <code>::first-line</code>. This
+ fictional tag sequence helps to show how properties are inherited.</p>
<pre>
<P><b><P::first-line></b> This is a somewhat long HTML
@@ -1906,9 +2111,9 @@ paragraph.</P> </pre>
<p>If a pseudo-element breaks up a real element, the desired effect
-can often be described by a fictional tag sequence that closes and
-then re-opens the element. Thus, if we mark up the previous paragraph
-with a <code>span</code> element:</p>
+ can often be described by a fictional tag sequence that closes and
+ then re-opens the element. Thus, if we mark up the previous paragraph
+ with a <code>span</code> element:</p>
<pre>
<P><b><SPAN class="test"></b> This is a somewhat long HTML
@@ -1920,13 +2125,14 @@ paragraph.</P> </pre>
<p>the user agent could simulate start and end tags for
-<code>span</code> when inserting the fictional tag sequence for
-<code>::first-line</code>.
+ <code>span</code> when inserting the fictional tag sequence for
+ <code>::first-line</code>.
<pre>
<P><P::first-line><b><SPAN class="test"></b> This is a
somewhat long HTML
-paragraph that will <b></SPAN></b></P::first-line><b><SPAN class="test"></b> be
+paragraph that will <b></SPAN></b></P::first-line><b><SPAN
+ class="test"></b> be
broken into several
lines.<b></SPAN></b> The first line will be identified
by a fictional tag sequence. The other lines
@@ -1935,33 +2141,34 @@ paragraph.</P> </pre>
<p>In CSS, the <code>::first-line</code> pseudo-element can only be
-attached to a block-level element, an inline-block, a table-caption,
-or a table-cell.</p>
+ attached to a block-level element, an inline-block, a table-caption,
+ or a table-cell.</p>
<p><a name="first-formatted-line"></a>The "first formatted line" of an
-element may occur inside a
-block-level descendant in the same flow (i.e., a block-level
-descendant that is not positioned and not a float). E.g., the first
-line of the <code>div</code> in <code><DIV><P>This
-line...</P></DIV></code> is the first line of the <code>p</code> (assuming
-that both <code>p</code> and <code>div</code> are block-level).
+ element may occur inside a
+ block-level descendant in the same flow (i.e., a block-level
+ descendant that is not positioned and not a float). E.g., the first
+ line of the <code>div</code> in <code><DIV><P>This
+ line...</P></DIV></code> is the first line of the <code>p</code>
+ (assuming
+ that both <code>p</code> and <code>div</code> are block-level).
<p>The first line of a table-cell or inline-block cannot be the first
-formatted line of an ancestor element. Thus, in <code><DIV><P
-STYLE="display: inline-block">Hello<BR>Goodbye</P>
-etcetera</DIV></code> the first formatted line of the
-<code>div</code> is not the line "Hello".
+ formatted line of an ancestor element. Thus, in <code><DIV><P
+ STYLE="display: inline-block">Hello<BR>Goodbye</P>
+ etcetera</DIV></code> the first formatted line of the
+ <code>div</code> is not the line "Hello".
<p class="note">Note that the first line of the <code>p</code> in this
-fragment: <code><p><br>First...</code> doesn't contain any
-letters (assuming the default style for <code>br</code> in HTML
-4). The word "First" is not on the first formatted line.
+ fragment: <code><p><br>First...</code> doesn't contain any
+ letters (assuming the default style for <code>br</code> in HTML
+ 4). The word "First" is not on the first formatted line.
<p>A UA should act as if the fictional start tags of the
-<code>::first-line</code> pseudo-elements were nested just inside the
-innermost enclosing block-level element. (Since CSS1 and CSS2 were
-silent on this case, authors should not rely on this behavior.) Here
-is an example. The fictional tag sequence for</p>
+ <code>::first-line</code> pseudo-elements were nested just inside the
+ innermost enclosing block-level element. (Since CSS1 and CSS2 were
+ silent on this case, authors should not rely on this behavior.) Here
+ is an example. The fictional tag sequence for</p>
<pre>
<DIV>
@@ -1980,43 +2187,46 @@ is an example. The fictional tag sequence for</p> </pre>
<p>The <code>::first-line</code> pseudo-element is similar to an
-inline-level element, but with certain restrictions. In CSS, the
-following properties apply to a <code>::first-line</code>
-pseudo-element: font properties, color property, background
-properties, 'word-spacing', 'letter-spacing', 'text-decoration',
-'vertical-align', 'text-transform', 'line-height'. UAs may apply other
-properties as well.</p>
+ inline-level element, but with certain restrictions. In CSS, the
+ following properties apply to a <code>::first-line</code>
+ pseudo-element: font properties, color property, background
+ properties, 'word-spacing', 'letter-spacing', 'text-decoration',
+ 'vertical-align', 'text-transform', 'line-height'. UAs may apply other
+ properties as well.</p>
<h4><a name=first-letter>7.2. The ::first-letter pseudo-element</a></h4>
<p>The <code>::first-letter</code> pseudo-element represents the first
-letter of the first line of a block, if it is not preceded by any
-other content (such as images or inline tables) on its line. The
-::first-letter pseudo-element may be used for "initial caps" and "drop
-caps", which are common typographical effects. This type of initial
-letter is similar to an inline-level element if its 'float' property
-is 'none'; otherwise, it is similar to a floated element.</p>
+ letter of the first line of a block, if it is not preceded by any
+ other content (such as images or inline tables) on its line. The
+ ::first-letter pseudo-element may be used for "initial caps" and "drop
+ caps", which are common typographical effects. This type of initial
+ letter is similar to an inline-level element if its 'float' property
+ is 'none'; otherwise, it is similar to a floated element.</p>
<p>In CSS, these are the properties that apply to <code>::first-letter</code>
-pseudo-elements: font properties, 'text-decoration', 'text-transform',
-'letter-spacing', 'word-spacing' (when appropriate), 'line-height',
-'float', 'vertical-align' (only if 'float' is 'none'), margin
-properties, padding properties, border properties, color property,
-background properties. UAs may apply other properties as well. To
-allow UAs to render a typographically correct drop cap or initial cap,
-the UA may choose a line-height, width and height based on the shape
-of the letter, unlike for normal elements.</p>
+ pseudo-elements: font properties, 'text-decoration', 'text-transform',
+ 'letter-spacing', 'word-spacing' (when appropriate), 'line-height',
+ 'float', 'vertical-align' (only if 'float' is 'none'), margin
+ properties, padding properties, border properties, color property,
+ background properties. UAs may apply other properties as well. To
+ allow UAs to render a typographically correct drop cap or initial cap,
+ the UA may choose a line-height, width and height based on the shape
+ of the letter, unlike for normal elements.</p>
<div class="example">
-<p>Example:</p>
-<p>This example shows a possible rendering of an initial cap. Note
-that the 'line-height' that is inherited by the <code>::first-letter</code>
-pseudo-element is 1.1, but the UA in this example has computed the
-height of the first letter differently, so that it doesn't cause any
-unnecessary space between the first two lines. Also note that the
-fictional start tag of the first letter is inside the <span>span</span>, and thus
-the font weight of the first letter is normal, not bold as the <span>span</span>:
+ <p>Example:</p>
+
+ <p>This example shows a possible rendering of an initial cap. Note
+ that the 'line-height' that is inherited by the
+ <code>::first-letter</code>
+ pseudo-element is 1.1, but the UA in this example has computed the
+ height of the first letter differently, so that it doesn't cause any
+ unnecessary space between the first two lines. Also note that the
+ fictional start tag of the first letter is inside the <span>span</span>,
+ and thus
+ the font weight of the first letter is normal, not bold as the <span>span</span>:
<pre>
p { line-height: 1.1 }
p::first-letter { font-size: 3em; font-weight: normal }
@@ -2027,13 +2237,15 @@ Erbarremt over my en mijn benaeuwde vesten<br> En arme burgery, en op mijn volcx gebed<br>
En dagelix geschrey de bange stad ontzet.
</pre>
-<div class="figure">
-<p><img src="initial-cap.png" alt="Image illustrating the ::first-letter pseudo-element">
-</div>
+ <div class="figure">
+ <p><img src="initial-cap.png"
+ alt="Image illustrating the ::first-letter pseudo-element">
+ </div>
</div>
<div class="example">
-<p>The following CSS will make a drop cap initial letter span about two lines:</p>
+ <p>The following CSS will make a drop cap initial letter span about two
+ lines:</p>
<pre>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
@@ -2053,13 +2265,15 @@ En dagelix geschrey de bange stad ontzet. </HTML>
</pre>
-<p>This example might be formatted as follows:</p>
+ <p>This example might be formatted as follows:</p>
-<div class="figure">
-<P><img src="first-letter.gif" alt="Image illustrating the combined effect of the ::first-letter and ::first-line pseudo-elements"></p>
-</div>
+ <div class="figure">
+ <P><img src="first-letter.gif"
+ alt="Image illustrating the combined effect of the ::first-letter and ::first-line pseudo-elements">
+ </p>
+ </div>
-<p>The <span class="index-inst" title="fictional tag
+ <p>The <span class="index-inst" title="fictional tag
sequence">fictional tag sequence</span> is:</p>
<pre>
@@ -2073,99 +2287,103 @@ few words of an article in the Economist. </P>
</pre>
-<p>Note that the <code>::first-letter</code> pseudo-element tags abut
-the content (i.e., the initial character), while the ::first-line
-pseudo-element start tag is inserted right after the start tag of the
-block element.</p> </div>
+ <p>Note that the <code>::first-letter</code> pseudo-element tags abut
+ the content (i.e., the initial character), while the ::first-line
+ pseudo-element start tag is inserted right after the start tag of the
+ block element.</p></div>
<p>In order to achieve traditional drop caps formatting, user agents
-may approximate font sizes, for example to align baselines. Also, the
-glyph outline may be taken into account when formatting.</p>
+ may approximate font sizes, for example to align baselines. Also, the
+ glyph outline may be taken into account when formatting.</p>
<p>Punctuation (i.e, characters defined in Unicode in the "open" (Ps),
-"close" (Pe), "initial" (Pi). "final" (Pf) and "other" (Po)
-punctuation classes), that precedes or follows the first letter should
-be included. <a href="#refsUNICODE">[UNICODE]</a></p>
+ "close" (Pe), "initial" (Pi). "final" (Pf) and "other" (Po)
+ punctuation classes), that precedes or follows the first letter should
+ be included. <a href="#refsUNICODE">[UNICODE]</a></p>
<div class="figure">
-<P><img src="first-letter2.gif" alt="Quotes that precede the
+ <P><img src="first-letter2.gif" alt="Quotes that precede the
first letter should be included."></p>
</div>
<p>The <code>::first-letter</code> also applies if the first letter is
-in fact a digit, e.g., the "6" in "67 million dollars is a lot of
-money."</p>
+ in fact a digit, e.g., the "6" in "67 million dollars is a lot of
+ money."</p>
<p>In CSS, the <code>::first-letter</code> pseudo-element applies to
-block, list-item, table-cell, table-caption, and inline-block
-elements. <span class="note">A future version of this specification
+ block, list-item, table-cell, table-caption, and inline-block
+ elements. <span class="note">A future version of this specification
may allow this pesudo-element to apply to more element
types.</span></p>
<p>The <code>::first-letter</code> pseudo-element can be used with all
-such elements that contain text, or that have a descendant in the same
-flow that contains text. A UA should act as if the fictional start tag
-of the ::first-letter pseudo-element is just before the first text of
-the element, even if that first text is in a descendant.</p>
+ such elements that contain text, or that have a descendant in the same
+ flow that contains text. A UA should act as if the fictional start tag
+ of the ::first-letter pseudo-element is just before the first text of
+ the element, even if that first text is in a descendant.</p>
<div class="example">
-<p>Example:</p>
-<p>The fictional tag sequence for this HTMLfragment:
+ <p>Example:</p>
+
+ <p>The fictional tag sequence for this HTMLfragment:
<pre><div>
<p>The first text.</pre>
-<p>is:
+ <p>is:
<pre><div>
<p><div::first-letter><p::first-letter>T</...></...>he first text.</pre>
</div>
<p>The first letter of a table-cell or inline-block cannot be the
-first letter of an ancestor element. Thus, in <code><DIV><P
-STYLE="display: inline-block">Hello<BR>Goodbye</P>
-etcetera</DIV></code> the first letter of the <code>div</code> is not the
-letter "H". In fact, the <code>div</code> doesn't have a first letter.
+ first letter of an ancestor element. Thus, in <code><DIV><P
+ STYLE="display: inline-block">Hello<BR>Goodbye</P>
+ etcetera</DIV></code> the first letter of the <code>div</code> is
+ not the
+ letter "H". In fact, the <code>div</code> doesn't have a first letter.
<p>The first letter must occur on the <a
-href="#first-formatted-line">first formatted line.</a> For example, in
-this fragment: <code><p><br>First...</code> the first line
-doesn't contain any letters and <code>::first-letter</code> doesn't
-match anything (assuming the default style for <code>br</code> in HTML
-4). In particular, it does not match the "F" of "First."
+ href="#first-formatted-line">first formatted line.</a> For example, in
+ this fragment: <code><p><br>First...</code> the first line
+ doesn't contain any letters and <code>::first-letter</code> doesn't
+ match anything (assuming the default style for <code>br</code> in HTML
+ 4). In particular, it does not match the "F" of "First."
<p>In CSS, if an element is a list item ('display: list-item'), the
-<code>::first-letter</code> applies to the first letter in the
-principal box after the marker. UAs may ignore
-<code>::first-letter</code> on list items with 'list-style-position:
-inside'. If an element has <code>::before</code> or
-<code>::after</code> content, the <code>::first-letter</code> applies
-to the first letter of the element <em>including</em> that content.
+ <code>::first-letter</code> applies to the first letter in the
+ principal box after the marker. UAs may ignore
+ <code>::first-letter</code> on list items with 'list-style-position:
+ inside'. If an element has <code>::before</code> or
+ <code>::after</code> content, the <code>::first-letter</code> applies
+ to the first letter of the element <em>including</em> that content.
<div class="example">
-<p>Example:</p>
-<p>After the rule 'p::before {content: "Note: "}', the selector
-'p::first-letter' matches the "N" of "Note".</p>
+ <p>Example:</p>
+
+ <p>After the rule 'p::before {content: "Note: "}', the selector
+ 'p::first-letter' matches the "N" of "Note".</p>
</div>
<p>Some languages may have specific rules about how to treat certain
-letter combinations. In Dutch, for example, if the letter combination
-"ij" appears at the beginning of a word, both letters should be
-considered within the <code>::first-letter</code> pseudo-element.
+ letter combinations. In Dutch, for example, if the letter combination
+ "ij" appears at the beginning of a word, both letters should be
+ considered within the <code>::first-letter</code> pseudo-element.
<p>If the letters that would form the ::first-letter are not in the
-same element, such as "'T" in <code><p>'<em>T...</code>, the UA
-may create a ::first-letter pseudo-element from one of the elements,
-both elements, or simply not create a pseudo-element.</p>
+ same element, such as "'T" in <code><p>'<em>T...</code>, the UA
+ may create a ::first-letter pseudo-element from one of the elements,
+ both elements, or simply not create a pseudo-element.</p>
<p>Similarly, if the first letter(s) of the block are not at the start
-of the line (for example due to bidirectional reordering), then the UA
-need not create the pseudo-element(s).
+ of the line (for example due to bidirectional reordering), then the UA
+ need not create the pseudo-element(s).
<div class="example">
-<p>Example:</p>
-<p><a name="overlapping-example">The following example</a> illustrates
-how overlapping pseudo-elements may interact. The first letter of
-each P element will be green with a font size of '24pt'. The rest of
-the first formatted line will be 'blue' while the rest of the
-paragraph will be 'red'.</p>
+ <p>Example:</p>
+
+ <p><a name="overlapping-example">The following example</a> illustrates
+ how overlapping pseudo-elements may interact. The first letter of
+ each P element will be green with a font size of '24pt'. The rest of
+ the first formatted line will be 'blue' while the rest of the
+ paragraph will be 'red'.</p>
<pre>p { color: red; font-size: 12pt }
p::first-letter { color: green; font-size: 200% }
@@ -2173,7 +2391,7 @@ p::first-line { color: blue } <P>Some text that ends up on two lines</P></pre>
-<p>Assuming that a line break will occur before the word "ends", the
+ <p>Assuming that a line break will occur before the word "ends", the
<span class="index-inst" title="fictional tag sequence">fictional tag
sequence</span> for this fragment might be:</p>
@@ -2186,158 +2404,167 @@ S ends up on two lines
</P></pre>
-<p>Note that the <code>::first-letter</code> element is inside the <code>::first-line</code>
-element. Properties set on <code>::first-line</code> are inherited by
-<code>::first-letter</code>, but are overridden if the same property is set on
-<code>::first-letter</code>.</p>
+ <p>Note that the <code>::first-letter</code> element is inside the <code>::first-line</code>
+ element. Properties set on <code>::first-line</code> are inherited by
+ <code>::first-letter</code>, but are overridden if the same property is
+ set on
+ <code>::first-letter</code>.</p>
</div>
-<h4><a name=UIfragments>7.3.</a> <a name=selection>The ::selection pseudo-element</a></h4>
+<h4><a name=UIfragments>7.3.</a> <a name=selection>The ::selection
+ pseudo-element</a></h4>
<p>The <code>::selection</code> pseudo-element applies to the portion
-of a document that has been highlighted by the user. This also
-applies, for example, to selected text within an editable text
-field. This pseudo-element should not be confused with the <code><a
-href="#checked">:checked</a></code> pseudo-class (which used to be
-named <code>:selected</code>)
+ of a document that has been highlighted by the user. This also
+ applies, for example, to selected text within an editable text
+ field. This pseudo-element should not be confused with the <code><a
+ href="#checked">:checked</a></code> pseudo-class (which used to be
+ named <code>:selected</code>)
<p>Although the <code>::selection</code> pseudo-element is dynamic in
-nature, and is altered by user action, it is reasonable to expect that
-when a UA re-renders to a static medium (such as a printed page, see
-<a href="#refsCSS21">[CSS21]</a>) which was originally rendered to a
-dynamic medium (like screen), the UA may wish to transfer the current
-<code>::selection</code> state to that other medium, and have all the
-appropriate formatting and rendering take effect as well. This is not
-required — UAs may omit the <code>::selection</code>
-pseudo-element for static media.
+ nature, and is altered by user action, it is reasonable to expect that
+ when a UA re-renders to a static medium (such as a printed page, see
+ <a href="#refsCSS21">[CSS21]</a>) which was originally rendered to a
+ dynamic medium (like screen), the UA may wish to transfer the current
+ <code>::selection</code> state to that other medium, and have all the
+ appropriate formatting and rendering take effect as well. This is not
+ required — UAs may omit the <code>::selection</code>
+ pseudo-element for static media.
<p>These are the CSS properties that apply to <code>::selection</code>
-pseudo-elements: color, background, cursor (optional), outline
-(optional). The computed value of the 'background-image' property on
-<code>::selection</code> may be ignored.
+ pseudo-elements: color, background, cursor (optional), outline
+ (optional). The computed value of the 'background-image' property on
+ <code>::selection</code> may be ignored.
<h4><a name=gen-content>7.4. The ::before and ::after pseudo-elements</a></h4>
<p>The <code>::before</code> and <code>::after</code> pseudo-elements
-can be used to describe generated content before or after an element's
-content. They are explained in CSS 2.1 <a
-href="#refsCSS21">[CSS21]</a>.</p>
+ can be used to describe generated content before or after an element's
+ content. They are explained in CSS 2.1 <a
+ href="#refsCSS21">[CSS21]</a>.</p>
<p>When the <code>::first-letter</code> and <code>::first-line</code>
-pseudo-elements are combined with <code>::before</code> and
-<code>::after</code>, they apply to the first letter or line of the
-element including the inserted text.</p>
+ pseudo-elements are combined with <code>::before</code> and
+ <code>::after</code>, they apply to the first letter or line of the
+ element including the inserted text.</p>
<h2><a name=combinators>8. Combinators</a></h2>
<h3><a name=descendant-combinators>8.1. Descendant combinator</a></h3>
<p>At times, authors may want selectors to describe an element that is
-the descendant of another element in the document tree (e.g., "an
-<code>EM</code> element that is contained within an <code>H1</code>
-element"). Descendant combinators express such a relationship. A
-descendant combinator is <a href="#whitespace">white space</a> that
-separates two sequences of simple selectors. A selector of the form
-"<code>A B</code>" represents an element <code>B</code> that is an
-arbitrary descendant of some ancestor element <code>A</code>.
+ the descendant of another element in the document tree (e.g., "an
+ <code>EM</code> element that is contained within an <code>H1</code>
+ element"). Descendant combinators express such a relationship. A
+ descendant combinator is <a href="#whitespace">white space</a> that
+ separates two sequences of simple selectors. A selector of the form
+ "<code>A B</code>" represents an element <code>B</code> that is an
+ arbitrary descendant of some ancestor element <code>A</code>.
<div class="example">
- <p>Examples:</p>
- <p>For example, consider the following selector:</p>
- <pre>h1 em</pre>
- <p>It represents an <code>em</code> element being the descendant of
- an <code>h1</code> element. It is a correct and valid, but partial,
- description of the following fragment:</p>
+ <p>Examples:</p>
+
+ <p>For example, consider the following selector:</p>
+ <pre>h1 em</pre>
+ <p>It represents an <code>em</code> element being the descendant of
+ an <code>h1</code> element. It is a correct and valid, but partial,
+ description of the following fragment:</p>
<pre><h1>This <span class="myclass">headline
is <em>very</em> important</span></h1></pre>
- <p>The following selector:</p>
- <pre>div * p</pre>
- <p>represents a <code>p</code> element that is a grandchild or later
- descendant of a <code>div</code> element. Note the whitespace on
- either side of the "*" is not part of the universal selector; the
- whitespace is a combinator indicating that the DIV must be the
- ancestor of some element, and that that element must be an ancestor
- of the P.</p>
- <p>The following selector, which combines descendant combinators and
- <a href="#attribute-selectors">attribute selectors</a>, represents an
- element that (1) has the <code>href</code> attribute set and (2) is
- inside a <code>p</code> that is itself inside a <code>div</code>:</p>
- <pre>div p *[href]</pre>
+ <p>The following selector:</p>
+ <pre>div * p</pre>
+ <p>represents a <code>p</code> element that is a grandchild or later
+ descendant of a <code>div</code> element. Note the whitespace on
+ either side of the "*" is not part of the universal selector; the
+ whitespace is a combinator indicating that the DIV must be the
+ ancestor of some element, and that that element must be an ancestor
+ of the P.</p>
+
+ <p>The following selector, which combines descendant combinators and
+ <a href="#attribute-selectors">attribute selectors</a>, represents an
+ element that (1) has the <code>href</code> attribute set and (2) is
+ inside a <code>p</code> that is itself inside a <code>div</code>:</p>
+ <pre>div p *[href]</pre>
</div>
<h3><a name=child-combinators>8.2. Child combinators</a></h3>
<p>A <dfn>child combinator</dfn> describes a childhood relationship
-between two elements. A child combinator is made of the
-"greater-than sign" (<code>></code>) character and
-separates two sequences of simple selectors.
+ between two elements. A child combinator is made of the
+ "greater-than sign" (<code>></code>) character and
+ separates two sequences of simple selectors.
<div class="example">
- <p>Examples:</p>
- <p>The following selector represents a <code>p</code> element that is
- child of <code>body</code>:</p>
- <pre>body > p</pre>
- <p>The following example combines descendant combinators and child
- combinators.</p>
- <pre>div ol>li p</pre><!-- LEAVE THOSE SPACES OUT! see below -->
- <p>It represents a <code>p</code> element that is a descendant of an
- <code>li</code> element; the <code>li</code> element must be the
- child of an <code>ol</code> element; the <code>ol</code> element must
- be a descendant of a <code>div</code>. Notice that the optional white
- space around the ">" combinator has been left out.</p>
+ <p>Examples:</p>
+
+ <p>The following selector represents a <code>p</code> element that is
+ child of <code>body</code>:</p>
+ <pre>body > p</pre>
+ <p>The following example combines descendant combinators and child
+ combinators.</p>
+ <pre>div ol>li p</pre>
+ <!-- LEAVE THOSE SPACES OUT! see below -->
+ <p>It represents a <code>p</code> element that is a descendant of an
+ <code>li</code> element; the <code>li</code> element must be the
+ child of an <code>ol</code> element; the <code>ol</code> element must
+ be a descendant of a <code>div</code>. Notice that the optional white
+ space around the ">" combinator has been left out.</p>
</div>
<p>For information on selecting the first child of an element, please
-see the section on the <code><a
-href="#structural-pseudos">:first-child</a></code> pseudo-class
-above.</p>
+ see the section on the <code><a
+ href="#structural-pseudos">:first-child</a></code> pseudo-class
+ above.</p>
<h3><a name=sibling-combinators>8.3. Sibling combinators</a></h3>
<p>There are two different sibling combinators: the adjacent sibling
-combinator and the general sibling combinator. In both cases,
-non-element nodes (e.g. text between elements) are ignored when
-considering adjacency of elements.</p>
+ combinator and the general sibling combinator. In both cases,
+ non-element nodes (e.g. text between elements) are ignored when
+ considering adjacency of elements.</p>
-<h4><a name=adjacent-sibling-combinators>8.3.1. Adjacent sibling combinator</a></h4>
+<h4><a name=adjacent-sibling-combinators>8.3.1. Adjacent sibling combinator</a>
+</h4>
<p>The adjacent sibling combinator is made of the "plus
-sign" (U+002B, <code>+</code>) character that separates two
-sequences of simple selectors. The elements represented by the two
-sequences share the same parent in the document tree and the element
-represented by the first sequence immediately precedes the element
-represented by the second one.</p>
+ sign" (U+002B, <code>+</code>) character that separates two
+ sequences of simple selectors. The elements represented by the two
+ sequences share the same parent in the document tree and the element
+ represented by the first sequence immediately precedes the element
+ represented by the second one.</p>
<div class="example">
- <p>Examples:</p>
- <p>The following selector represents a <code>p</code> element
- immediately following a <code>math</code> element:</p>
- <pre>math + p</pre>
- <p>The following selector is conceptually similar to the one in the
- previous example, except that it adds an attribute selector — it
- adds a constraint to the <code>h1</code> element, that it must have
- <code>class="opener"</code>:</p>
- <pre>h1.opener + h2</pre>
+ <p>Examples:</p>
+
+ <p>The following selector represents a <code>p</code> element
+ immediately following a <code>math</code> element:</p>
+ <pre>math + p</pre>
+ <p>The following selector is conceptually similar to the one in the
+ previous example, except that it adds an attribute selector — it
+ adds a constraint to the <code>h1</code> element, that it must have
+ <code>class="opener"</code>:</p>
+ <pre>h1.opener + h2</pre>
</div>
-<h4><a name=general-sibling-combinators>8.3.2. General sibling combinator</a></h4>
+<h4><a name=general-sibling-combinators>8.3.2. General sibling combinator</a>
+</h4>
<p>The general sibling combinator is made of the "tilde"
-(U+007E, <code>~</code>) character that separates two sequences of
-simple selectors. The elements represented by the two sequences share
-the same parent in the document tree and the element represented by
-the first sequence precedes (not necessarily immediately) the element
-represented by the second one.</p>
+ (U+007E, <code>~</code>) character that separates two sequences of
+ simple selectors. The elements represented by the two sequences share
+ the same parent in the document tree and the element represented by
+ the first sequence precedes (not necessarily immediately) the element
+ represented by the second one.</p>
<div class="example">
- <p>Example:</p>
- <pre>h1 ~ pre</pre>
- <p>represents a <code>pre</code> element following an <code>h1</code>. It
- is a correct and valid, but partial, description of:</p>
+ <p>Example:</p>
+ <pre>h1 ~ pre</pre>
+ <p>represents a <code>pre</code> element following an <code>h1</code>. It
+ is a correct and valid, but partial, description of:</p>
<pre><h1>Definition of the function a</h1>
<p>Function a(x) has to be applied to all figures in the table.</p>
<pre>function a(x) = 12x/13.5</pre></pre>
@@ -2348,21 +2575,23 @@ represented by the second one.</p> <p>A selector's specificity is calculated as follows:</p>
<ul>
- <li>count the number of ID selectors in the selector (= a)</li>
- <li>count the number of class selectors, attributes selectors, and pseudo-classes in the selector (= b)</li>
- <li>count the number of element names in the selector (= c)</li>
- <li>ignore pseudo-elements</li>
+ <li>count the number of ID selectors in the selector (= a)</li>
+ <li>count the number of class selectors, attributes selectors, and
+ pseudo-classes in the selector (= b)
+ </li>
+ <li>count the number of element names in the selector (= c)</li>
+ <li>ignore pseudo-elements</li>
</ul>
<p>Selectors inside <a href="#negation">the negation pseudo-class</a>
-are counted like any other, but the negation itself does not count as
-a pseudo-class.</p>
+ are counted like any other, but the negation itself does not count as
+ a pseudo-class.</p>
<p>Concatenating the three numbers a-b-c (in a number system with a
-large base) gives the specificity.</p>
+ large base) gives the specificity.</p>
<div class="example">
-<p>Examples:</p>
+ <p>Examples:</p>
<pre>* /* a=0 b=0 c=0 -> specificity = 0 */
LI /* a=0 b=0 c=1 -> specificity = 1 */
UL LI /* a=0 b=0 c=2 -> specificity = 2 */
@@ -2376,26 +2605,26 @@ LI.red.level /* a=0 b=2 c=1 -> specificity = 21 */ </div>
<p class="note"><strong>Note:</strong> the specificity of the styles
-specified in an HTML <code>style</code> attribute is described in CSS
-2.1. <a href="#refsCSS21">[CSS21]</a>.</p>
+ specified in an HTML <code>style</code> attribute is described in CSS
+ 2.1. <a href="#refsCSS21">[CSS21]</a>.</p>
<h2><a name=w3cselgrammar>10. The grammar of Selectors</a></h2>
<h3><a name=grammar>10.1. Grammar</a></h3>
-<p>The grammar below defines the syntax of Selectors. It is globally
-LL(1) and can be locally LL(2) (but note that most UA's should not use
-it directly, since it doesn't express the parsing conventions). The
-format of the productions is optimized for human consumption and some
-shorthand notations beyond Yacc (see <a href="#refsYACC">[YACC]</a>)
-are used:</p>
+<p>The grammar below defines the syntax of Selectors. It is globally
+ LL(1) and can be locally LL(2) (but note that most UA's should not use
+ it directly, since it doesn't express the parsing conventions). The
+ format of the productions is optimized for human consumption and some
+ shorthand notations beyond Yacc (see <a href="#refsYACC">[YACC]</a>)
+ are used:</p>
<ul>
- <li><b>*</b>: 0 or more
- <li><b>+</b>: 1 or more
- <li><b>?</b>: 0 or 1
- <li><b>|</b>: separates alternatives
- <li><b>[ ]</b>: grouping </li>
+ <li><b>*</b>: 0 or more
+ <li><b>+</b>: 1 or more
+ <li><b>?</b>: 0 or 1
+ <li><b>|</b>: separates alternatives
+ <li><b>[ ]</b>: grouping</li>
</ul>
<p>The productions are:</p>
@@ -2480,14 +2709,14 @@ negation_arg <h3><a name=lex>10.2. Lexical scanner</a></h3>
<p>The following is the <a name=x3>tokenizer</a>, written in Flex (see
-<a href="#refsFLEX">[FLEX]</a>) notation. The tokenizer is
-case-insensitive.</p>
+ <a href="#refsFLEX">[FLEX]</a>) notation. The tokenizer is
+ case-insensitive.</p>
<p>The two occurrences of "\377" represent the highest character
-number that current versions of Flex can deal with (decimal 255). They
-should be read as "\4177777" (decimal 1114111), which is the highest
-possible code point in Unicode/ISO-10646. <a
-href="#refsUNICODE">[UNICODE]</a></p>
+ number that current versions of Flex can deal with (decimal 255). They
+ should be read as "\4177777" (decimal 1114111), which is the highest
+ possible code point in Unicode/ISO-10646. <a
+ href="#refsUNICODE">[UNICODE]</a></p>
<pre>%option case-insensitive
@@ -2543,269 +2772,325 @@ U\+[0-9a-f?]{1,6}(-[0-9a-f]{1,6})? return UNICODE_RANGE; . return *yytext;</pre>
-
<h2><a name=downlevel>11. Namespaces and down-level clients</a></h2>
<p>An important issue is the interaction of CSS selectors with XML
-documents in web clients that were produced prior to this
-document. Unfortunately, due to the fact that namespaces must be
-matched based on the URI which identifies the namespace, not the
-namespace prefix, some mechanism is required to identify namespaces in
-CSS by their URI as well. Without such a mechanism, it is impossible
-to construct a CSS style sheet which will properly match selectors in
-all cases against a random set of XML documents. However, given
-complete knowledge of the XML document to which a style sheet is to be
-applied, and a limited use of namespaces within the XML document, it
-is possible to construct a style sheet in which selectors would match
-elements and attributes correctly.</p>
+ documents in web clients that were produced prior to this
+ document. Unfortunately, due to the fact that namespaces must be
+ matched based on the URI which identifies the namespace, not the
+ namespace prefix, some mechanism is required to identify namespaces in
+ CSS by their URI as well. Without such a mechanism, it is impossible
+ to construct a CSS style sheet which will properly match selectors in
+ all cases against a random set of XML documents. However, given
+ complete knowledge of the XML document to which a style sheet is to be
+ applied, and a limited use of namespaces within the XML document, it
+ is possible to construct a style sheet in which selectors would match
+ elements and attributes correctly.</p>
<p>It should be noted that a down-level CSS client will (if it
-properly conforms to CSS forward compatible parsing rules) ignore all
-<code>@namespace</code> at-rules, as well as all style rules that make
-use of namespace qualified element type or attribute selectors. The
-syntax of delimiting namespace prefixes in CSS was deliberately chosen
-so that down-level CSS clients would ignore the style rules rather
-than possibly match them incorrectly.</p>
+ properly conforms to CSS forward compatible parsing rules) ignore all
+ <code>@namespace</code> at-rules, as well as all style rules that make
+ use of namespace qualified element type or attribute selectors. The
+ syntax of delimiting namespace prefixes in CSS was deliberately chosen
+ so that down-level CSS clients would ignore the style rules rather
+ than possibly match them incorrectly.</p>
<p>The use of default namespaces in CSS makes it possible to write
-element type selectors that will function in both namespace aware CSS
-clients as well as down-level clients. It should be noted that
-down-level clients may incorrectly match selectors against XML
-elements in other namespaces.</p>
+ element type selectors that will function in both namespace aware CSS
+ clients as well as down-level clients. It should be noted that
+ down-level clients may incorrectly match selectors against XML
+ elements in other namespaces.</p>
<p>The following are scenarios and examples in which it is possible to
-construct style sheets which would function properly in web clients
-that do not implement this proposal.</p>
+ construct style sheets which would function properly in web clients
+ that do not implement this proposal.</p>
<ol>
- <li>
-
- <p>The XML document does not use namespaces.</p>
-
- <ul>
-
- <li>In this case, it is obviously not necessary to declare or use
- namespaces in the style sheet. Standard CSS element type and
- attribute selectors will function adequately in a down-level
- client.</li>
-
- <li>In a CSS namespace aware client, the default behavior of
- element selectors matching without regard to namespace will
- function properly against all elements, since no namespaces are
- present. However, the use of specific element type selectors that
- match only elements that have no namespace ("<code>|name</code>")
- will guarantee that selectors will match only XML elements that do
- not have a declared namespace. </li>
-
- </ul>
-
- </li>
-
- <li>
-
- <p>The XML document defines a single, default namespace used
- throughout the document. No namespace prefixes are used in element
- names.</p>
-
- <ul>
-
- <li>In this case, a down-level client will function as if
- namespaces were not used in the XML document at all. Standard CSS
- element type and attribute selectors will match against all
- elements. </li>
-
- </ul>
-
- </li>
-
- <li>
-
- <p>The XML document does <b>not</b> use a default namespace, all
- namespace prefixes used are known to the style sheet author, and
- there is a direct mapping between namespace prefixes and namespace
- URIs. (A given prefix may only be mapped to one namespace URI
- throughout the XML document; there may be multiple prefixes mapped
- to the same URI).</p>
-
- <ul>
-
- <li>In this case, the down-level client will view and match
- element type and attribute selectors based on their fully
- qualified name, not the local part as outlined in the <a
- href="#typenmsp">Type selectors and Namespaces</a> section. CSS
- selectors may be declared using an escaped colon "<code>\:</code>"
- to describe the fully qualified names, e.g.
- "<code>html\:h1</code>" will match
- <code><html:h1></code>. Selectors using the qualified name
- will only match XML elements that use the same prefix. Other
- namespace prefixes used in the XML that are mapped to the same URI
- will not match as expected unless additional CSS style rules are
- declared for them.</li>
-
- <li>Note that selectors declared in this fashion will
- <em>only</em> match in down-level clients. A CSS namespace aware
- client will match element type and attribute selectors based on
- the name's local part. Selectors declared with the fully
- qualified name will not match (unless there is no namespace prefix
- in the fully qualified name).</li>
-
- </ul>
-
- </li>
-
- </ol>
+ <li>
+
+ <p>The XML document does not use namespaces.</p>
+
+ <ul>
+
+ <li>In this case, it is obviously not necessary to declare or use
+ namespaces in the style sheet. Standard CSS element type and
+ attribute selectors will function adequately in a down-level
+ client.
+ </li>
+
+ <li>In a CSS namespace aware client, the default behavior of
+ element selectors matching without regard to namespace will
+ function properly against all elements, since no namespaces are
+ present. However, the use of specific element type selectors
+ that
+ match only elements that have no namespace ("<code>|name</code>")
+ will guarantee that selectors will match only XML elements that
+ do
+ not have a declared namespace.
+ </li>
+
+ </ul>
+
+ </li>
+
+ <li>
+
+ <p>The XML document defines a single, default namespace used
+ throughout the document. No namespace prefixes are used in element
+ names.</p>
+
+ <ul>
+
+ <li>In this case, a down-level client will function as if
+ namespaces were not used in the XML document at all. Standard
+ CSS
+ element type and attribute selectors will match against all
+ elements.
+ </li>
+
+ </ul>
+
+ </li>
+
+ <li>
+
+ <p>The XML document does <b>not</b> use a default namespace, all
+ namespace prefixes used are known to the style sheet author, and
+ there is a direct mapping between namespace prefixes and namespace
+ URIs. (A given prefix may only be mapped to one namespace URI
+ throughout the XML document; there may be multiple prefixes mapped
+ to the same URI).</p>
+
+ <ul>
+
+ <li>In this case, the down-level client will view and match
+ element type and attribute selectors based on their fully
+ qualified name, not the local part as outlined in the <a
+ href="#typenmsp">Type selectors and Namespaces</a>
+ section. CSS
+ selectors may be declared using an escaped colon
+ "<code>\:</code>"
+ to describe the fully qualified names, e.g.
+ "<code>html\:h1</code>" will match
+ <code><html:h1></code>. Selectors using the qualified name
+ will only match XML elements that use the same prefix. Other
+ namespace prefixes used in the XML that are mapped to the same
+ URI
+ will not match as expected unless additional CSS style rules are
+ declared for them.
+ </li>
+
+ <li>Note that selectors declared in this fashion will
+ <em>only</em> match in down-level clients. A CSS namespace aware
+ client will match element type and attribute selectors based on
+ the name's local part. Selectors declared with the fully
+ qualified name will not match (unless there is no namespace
+ prefix
+ in the fully qualified name).
+ </li>
+
+ </ul>
+
+ </li>
+
+</ol>
<p>In other scenarios: when the namespace prefixes used in the XML are
-not known in advance by the style sheet author; or a combination of
-elements with no namespace are used in conjunction with elements using
-a default namespace; or the same namespace prefix is mapped to
-<em>different</em> namespace URIs within the same document, or in
-different documents; it is impossible to construct a CSS style sheet
-that will function properly against all elements in those documents,
-unless, the style sheet is written using a namespace URI syntax (as
-outlined in this document or similar) and the document is processed by
-a CSS and XML namespace aware client.</p>
+ not known in advance by the style sheet author; or a combination of
+ elements with no namespace are used in conjunction with elements using
+ a default namespace; or the same namespace prefix is mapped to
+ <em>different</em> namespace URIs within the same document, or in
+ different documents; it is impossible to construct a CSS style sheet
+ that will function properly against all elements in those documents,
+ unless, the style sheet is written using a namespace URI syntax (as
+ outlined in this document or similar) and the document is processed by
+ a CSS and XML namespace aware client.</p>
<h2><a name=profiling>12. Profiles</a></h2>
<p>Each specification using Selectors must define the subset of W3C
-Selectors it allows and excludes, and describe the local meaning of
-all the components of that subset.</p>
+ Selectors it allows and excludes, and describe the local meaning of
+ all the components of that subset.</p>
<p>Non normative examples:
<div class="profile">
-<table class="tprofile">
- <tbody>
- <tr>
- <th class="title" colspan=2>Selectors profile</th></tr>
- <tr>
- <th>Specification</th>
- <td>CSS level 1</td></tr>
- <tr>
- <th>Accepts</th>
- <td>type selectors<br>class selectors<br>ID selectors<br>:link,
- :visited and :active pseudo-classes<br>descendant combinator
- <br>::first-line and ::first-letter pseudo-elements</td></tr>
- <tr>
- <th>Excludes</th>
- <td>
-
-<p>universal selector<br>attribute selectors<br>:hover and :focus
- pseudo-classes<br>:target pseudo-class<br>:lang() pseudo-class<br>all UI
- element states pseudo-classes<br>all structural
- pseudo-classes<br>negation pseudo-class<br>all
- UI element fragments pseudo-elements<br>::before and ::after
- pseudo-elements<br>child combinators<br>sibling combinators
-
-<p>namespaces</td></tr>
- <tr>
- <th>Extra constraints</th>
- <td>only one class selector allowed per sequence of simple
- selectors</td></tr></tbody></table><br><br>
-<table class="tprofile">
- <tbody>
- <tr>
- <th class="title" colspan=2>Selectors profile</th></tr>
- <tr>
- <th>Specification</th>
- <td>CSS level 2</td></tr>
- <tr>
- <th>Accepts</th>
- <td>type selectors<br>universal selector<br>attribute presence and
- values selectors<br>class selectors<br>ID selectors<br>:link, :visited,
- :active, :hover, :focus, :lang() and :first-child pseudo-classes
- <br>descendant combinator<br>child combinator<br>adjacent sibling
- combinator<br>::first-line and ::first-letter pseudo-elements<br>::before
- and ::after pseudo-elements</td></tr>
- <tr>
- <th>Excludes</th>
- <td>
-
-<p>content selectors<br>substring matching attribute
- selectors<br>:target pseudo-classes<br>all UI element
- states pseudo-classes<br>all structural pseudo-classes other
- than :first-child<br>negation pseudo-class<br>all UI element
- fragments pseudo-elements<br>general sibling combinators
-
-<p>namespaces</td></tr>
- <tr>
- <th>Extra constraints</th>
- <td>more than one class selector per sequence of simple selectors (CSS1
- constraint) allowed</td></tr></tbody></table>
-
-<p>In CSS, selectors express pattern matching rules that determine which style
-rules apply to elements in the document tree.
-
-<p>The following selector (CSS level 2) will <b>match</b> all anchors <code>a</code>
-with attribute <code>name</code> set inside a section 1 header <code>h1</code>:
-<pre>h1 a[name]</pre>
-
-<p>All CSS declarations attached to such a selector are applied to elements
-matching it. </div>
+ <table class="tprofile">
+ <tbody>
+ <tr>
+ <th class="title" colspan=2>Selectors profile</th>
+ </tr>
+ <tr>
+ <th>Specification</th>
+ <td>CSS level 1</td>
+ </tr>
+ <tr>
+ <th>Accepts</th>
+ <td>type selectors<br>class selectors<br>ID selectors<br>:link,
+ :visited and :active pseudo-classes<br>descendant combinator
+ <br>::first-line and ::first-letter pseudo-elements
+ </td>
+ </tr>
+ <tr>
+ <th>Excludes</th>
+ <td>
+
+ <p>universal selector<br>attribute selectors<br>:hover and
+ :focus
+ pseudo-classes<br>:target pseudo-class<br>:lang()
+ pseudo-class<br>all UI
+ element states pseudo-classes<br>all structural
+ pseudo-classes<br>negation pseudo-class<br>all
+ UI element fragments pseudo-elements<br>::before and ::after
+ pseudo-elements<br>child combinators<br>sibling combinators
+
+ <p>namespaces</td>
+ </tr>
+ <tr>
+ <th>Extra constraints</th>
+ <td>only one class selector allowed per sequence of simple
+ selectors
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ <br><br>
+ <table class="tprofile">
+ <tbody>
+ <tr>
+ <th class="title" colspan=2>Selectors profile</th>
+ </tr>
+ <tr>
+ <th>Specification</th>
+ <td>CSS level 2</td>
+ </tr>
+ <tr>
+ <th>Accepts</th>
+ <td>type selectors<br>universal selector<br>attribute presence and
+ values selectors<br>class selectors<br>ID selectors<br>:link,
+ :visited,
+ :active, :hover, :focus, :lang() and :first-child pseudo-classes
+ <br>descendant combinator<br>child combinator<br>adjacent
+ sibling
+ combinator<br>::first-line and ::first-letter
+ pseudo-elements<br>::before
+ and ::after pseudo-elements
+ </td>
+ </tr>
+ <tr>
+ <th>Excludes</th>
+ <td>
+
+ <p>content selectors<br>substring matching attribute
+ selectors<br>:target pseudo-classes<br>all UI element
+ states pseudo-classes<br>all structural pseudo-classes other
+ than :first-child<br>negation pseudo-class<br>all UI element
+ fragments pseudo-elements<br>general sibling combinators
+
+ <p>namespaces</td>
+ </tr>
+ <tr>
+ <th>Extra constraints</th>
+ <td>more than one class selector per sequence of simple selectors
+ (CSS1
+ constraint) allowed
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+ <p>In CSS, selectors express pattern matching rules that determine which
+ style
+ rules apply to elements in the document tree.
+
+ <p>The following selector (CSS level 2) will <b>match</b> all anchors <code>a</code>
+ with attribute <code>name</code> set inside a section 1 header
+ <code>h1</code>:
+ <pre>h1 a[name]</pre>
+
+ <p>All CSS declarations attached to such a selector are applied to elements
+ matching it.</div>
<div class="profile">
-<table class="tprofile">
- <tbody>
- <tr>
- <th class="title" colspan=2>Selectors profile</th></tr>
- <tr>
- <th>Specification</th>
- <td>STTS 3</td>
- </tr>
- <tr>
- <th>Accepts</th>
- <td>
-
-<p>type selectors<br>universal selectors<br>attribute selectors<br>class
- selectors<br>ID selectors<br>all structural pseudo-classes<br>
- all combinators
-
-<p>namespaces</td></tr>
- <tr>
- <th>Excludes</th>
- <td>non-accepted pseudo-classes<br>pseudo-elements<br></td></tr>
- <tr>
- <th>Extra constraints</th>
- <td>some selectors and combinators are not allowed in fragment
- descriptions on the right side of STTS declarations.</td></tr></tbody></table>
-
-<p>Selectors can be used in STTS 3 in two different
- manners:
-<ol>
- <li>a selection mechanism equivalent to CSS selection mechanism: declarations
- attached to a given selector are applied to elements matching that selector,
- <li>fragment descriptions that appear on the right side of declarations.
-</li></ol></div>
+ <table class="tprofile">
+ <tbody>
+ <tr>
+ <th class="title" colspan=2>Selectors profile</th>
+ </tr>
+ <tr>
+ <th>Specification</th>
+ <td>STTS 3</td>
+ </tr>
+ <tr>
+ <th>Accepts</th>
+ <td>
+
+ <p>type selectors<br>universal selectors<br>attribute
+ selectors<br>class
+ selectors<br>ID selectors<br>all structural
+ pseudo-classes<br>
+ all combinators
+
+ <p>namespaces</td>
+ </tr>
+ <tr>
+ <th>Excludes</th>
+ <td>non-accepted pseudo-classes<br>pseudo-elements<br></td>
+ </tr>
+ <tr>
+ <th>Extra constraints</th>
+ <td>some selectors and combinators are not allowed in fragment
+ descriptions on the right side of STTS declarations.
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+ <p>Selectors can be used in STTS 3 in two different
+ manners:
+ <ol>
+ <li>a selection mechanism equivalent to CSS selection mechanism:
+ declarations
+ attached to a given selector are applied to elements matching that
+ selector,
+ <li>fragment descriptions that appear on the right side of declarations.
+ </li>
+ </ol>
+</div>
<h2><a name=Conformance></a>13. Conformance and requirements</h2>
<p>This section defines conformance with the present specification only.
<p>The inability of a user agent to implement part of this specification due to
-the limitations of a particular device (e.g., non interactive user agents will
-probably not implement dynamic pseudo-classes because they make no sense without
-interactivity) does not imply non-conformance.
+ the limitations of a particular device (e.g., non interactive user agents
+ will
+ probably not implement dynamic pseudo-classes because they make no sense
+ without
+ interactivity) does not imply non-conformance.
<p>All specifications reusing Selectors must contain a <a
-href="#profiling">Profile</a> listing the
-subset of Selectors it accepts or excludes, and describing the constraints
-it adds to the current specification.
+ href="#profiling">Profile</a> listing the
+ subset of Selectors it accepts or excludes, and describing the constraints
+ it adds to the current specification.
-<p>Invalidity is caused by a parsing error, e.g. an unrecognized token or a token
-which is not allowed at the current parsing point.
+<p>Invalidity is caused by a parsing error, e.g. an unrecognized token or a
+ token
+ which is not allowed at the current parsing point.
<p>User agents must observe the rules for handling parsing errors:
<ul>
- <li>a simple selector containing an undeclared namespace prefix is invalid</li>
- <li>a selector containing an invalid simple selector, an invalid combinator
- or an invalid token is invalid. </li>
- <li>a group of selectors containing an invalid selector is invalid.</li>
+ <li>a simple selector containing an undeclared namespace prefix is invalid
+ </li>
+ <li>a selector containing an invalid simple selector, an invalid combinator
+ or an invalid token is invalid.
+ </li>
+ <li>a group of selectors containing an invalid selector is invalid.</li>
</ul>
<p>Specifications reusing Selectors must define how to handle parsing
-errors. (In the case of CSS, the entire rule in which the selector is
-used is dropped.)</p>
+ errors. (In the case of CSS, the entire rule in which the selector is
+ used is dropped.)</p>
<!-- Apparently all these references are out of date:
<p>Implementations of this specification must behave as
@@ -2820,76 +3105,109 @@ specification.</p>--> <h2><a name=Tests></a>14. Tests</h2>
<p>This specification has <a
-href="http://www.w3.org/Style/CSS/Test/CSS3/Selectors/current/">a test
-suite</a> allowing user agents to verify their basic conformance to
-the specification. This test suite does not pretend to be exhaustive
-and does not cover all possible combined cases of Selectors.</p>
+ href="http://www.w3.org/Style/CSS/Test/CSS3/Selectors/current/">a test
+ suite</a> allowing user agents to verify their basic conformance to
+ the specification. This test suite does not pretend to be exhaustive
+ and does not cover all possible combined cases of Selectors.</p>
<h2><a name=ACKS></a>15. Acknowledgements</h2>
<p>The CSS working group would like to thank everyone who has sent
-comments on this specification over the years.</p>
+ comments on this specification over the years.</p>
<p>The working group would like to extend special thanks to Donna
-McManus, Justin Baker, Joel Sklar, and Molly Ives Brower who perfermed
-the final editorial review.</p>
+ McManus, Justin Baker, Joel Sklar, and Molly Ives Brower who perfermed
+ the final editorial review.</p>
<h2><a name=references>16. References</a></h2>
<dl class="refs">
- <dt>[CSS1]
- <dd><a name=refsCSS1></a> Bert Bos, Håkon Wium Lie; "<cite>Cascading Style Sheets, level 1</cite>", W3C Recommendation, 17 Dec 1996, revised 11 Jan 1999
- <dd>(<code><a href="http://www.w3.org/TR/REC-CSS1">http://www.w3.org/TR/REC-CSS1</a></code>)
-
- <dt>[CSS21]
- <dd><a name=refsCSS21></a> Bert Bos, Tantek Çelik, Ian Hickson, Håkon Wium Lie, editors; "<cite>Cascading Style Sheets, level 2 revision 1</cite>", W3C Working Draft, 13 June 2005
- <dd>(<code><a href="http://www.w3.org/TR/CSS21">http://www.w3.org/TR/CSS21</a></code>)
-
- <dt>[CWWW]
- <dd><a name=refsCWWW></a> Martin J. Dürst, François Yergeau, Misha Wolf, Asmus Freytag, Tex Texin, editors; "<cite>Character Model for the World Wide Web</cite>", W3C Recommendation, 15 February 2005
- <dd>(<code><a href="http://www.w3.org/TR/charmod/">http://www.w3.org/TR/charmod/</a></code>)
-
- <dt>[FLEX]
- <dd><a name="refsFLEX"></a> "<cite>Flex: The Lexical Scanner Generator</cite>", Version 2.3.7, ISBN 1882114213
-
- <dt>[HTML4]
- <dd><a name="refsHTML4"></a> Dave Ragget, Arnaud Le Hors, Ian Jacobs, editors; "<cite>HTML 4.01 Specification</cite>", W3C Recommendation, 24 December 1999
- <dd>(<a href="http://www.w3.org/TR/html4/"><code>http://www.w3.org/TR/html4/</code></a>)
-
- <dt>[MATH]
- <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
- <dd>(<code><a href="http://www.w3.org/TR/REC-MathML/">http://www.w3.org/TR/REC-MathML/</a></code>)
-
- <dt>[RFC3066]
- <dd><a name="refsRFC3066"></a> H. Alvestrand; "<cite>Tags for the Identification of Languages</cite>", Request for Comments 3066, January 2001
- <dd>(<a href="http://www.ietf.org/rfc/rfc3066.txt"><code>http://www.ietf.org/rfc/rfc3066.txt</code></a>)
-
- <dt>[STTS]
- <dd><a name=refsSTTS></a> Daniel Glazman; "<cite>Simple Tree Transformation Sheets 3</cite>", Electricité de France, submission to the W3C, 11 November 1998
- <dd>(<code><a href="http://www.w3.org/TR/NOTE-STTS3">http://www.w3.org/TR/NOTE-STTS3</a></code>)
-
- <dt>[SVG]
- <dd><a name="refsSVG"></a> Jon Ferraiolo, 藤沢 淳, Dean Jackson, editors; "<cite>Scalable Vector Graphics (SVG) 1.1 Specification</cite>", W3C Recommendation, 14 January 2003
- <dd>(<code><a href="http://www.w3.org/TR/SVG/">http://www.w3.org/TR/SVG/</a></code>)
-
- <dt>[UNICODE]</dt>
- <dd><a name="refsUNICODE"></a> <cite><a
- 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>.
- <dd>(<code><a href="http://www.unicode.org/versions/">http://www.unicode.org/versions/</a></code>)</dd>
-
- <dt>[XML10]
- <dd><a name="refsXML10"></a> Tim Bray, Jean Paoli, C. M. Sperberg-McQueen, Eve Maler, François Yergeau, editors; "<cite>Extensible Markup Language (XML) 1.0 (Third Edition)</cite>", W3C Recommendation, 4 February 2004
- <dd>(<a href="http://www.w3.org/TR/REC-xml/"><code>http://www.w3.org/TR/REC-xml/</code></a>)
-
- <dt>[XMLNAMES]
- <dd><a name="refsXMLNAMES"></a> Tim Bray, Dave Hollander, Andrew Layman, editors; "<cite>Namespaces in XML</cite>", W3C Recommendation, 14 January 1999
- <dd>(<a href="http://www.w3.org/TR/REC-xml-names/"><code>http://www.w3.org/TR/REC-xml-names/</code></a>)
-
- <dt>[YACC]
- <dd><a name="refsYACC"></a> S. C. Johnson; "<cite>YACC — Yet another compiler compiler</cite>", Technical Report, Murray Hill, 1975
+ <dt>[CSS1]
+ <dd><a name=refsCSS1></a> Bert Bos, Håkon Wium Lie; "<cite>Cascading
+ Style Sheets, level 1</cite>", W3C Recommendation, 17 Dec 1996, revised
+ 11 Jan 1999
+ <dd>(<code><a href="http://www.w3.org/TR/REC-CSS1">http://www.w3.org/TR/REC-CSS1</a></code>)
+
+ <dt>[CSS21]
+ <dd><a name=refsCSS21></a> Bert Bos, Tantek Çelik, Ian Hickson, Håkon
+ Wium Lie, editors; "<cite>Cascading Style Sheets, level 2 revision
+ 1</cite>", W3C Working Draft, 13 June 2005
+ <dd>(<code><a
+ href="http://www.w3.org/TR/CSS21">http://www.w3.org/TR/CSS21</a></code>)
+
+ <dt>[CWWW]
+ <dd><a name=refsCWWW></a> Martin J. Dürst, François Yergeau,
+ Misha Wolf, Asmus Freytag, Tex Texin, editors; "<cite>Character Model
+ for the World Wide Web</cite>", W3C Recommendation, 15 February 2005
+ <dd>(<code><a href="http://www.w3.org/TR/charmod/">http://www.w3.org/TR/charmod/</a></code>)
+
+ <dt>[FLEX]
+ <dd><a name="refsFLEX"></a> "<cite>Flex: The Lexical Scanner
+ Generator</cite>", Version 2.3.7, ISBN 1882114213
+
+ <dt>[HTML4]
+ <dd><a name="refsHTML4"></a> Dave Ragget, Arnaud Le Hors, Ian Jacobs,
+ editors; "<cite>HTML 4.01 Specification</cite>", W3C Recommendation, 24
+ December 1999
+ <dd>
+ (<a href="http://www.w3.org/TR/html4/"><code>http://www.w3.org/TR/html4/</code></a>)
+
+ <dt>[MATH]
+ <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
+ <dd>(<code><a href="http://www.w3.org/TR/REC-MathML/">http://www.w3.org/TR/REC-MathML/</a></code>)
+
+ <dt>[RFC3066]
+ <dd><a name="refsRFC3066"></a> H. Alvestrand; "<cite>Tags for the
+ Identification of Languages</cite>", Request for Comments 3066, January
+ 2001
+ <dd>(<a href="http://www.ietf.org/rfc/rfc3066.txt"><code>http://www.ietf.org/rfc/rfc3066.txt</code></a>)
+
+ <dt>[STTS]
+ <dd><a name=refsSTTS></a> Daniel Glazman; "<cite>Simple Tree Transformation
+ Sheets 3</cite>", Electricité de France, submission to the W3C,
+ 11 November 1998
+ <dd>(<code><a href="http://www.w3.org/TR/NOTE-STTS3">http://www.w3.org/TR/NOTE-STTS3</a></code>)
+
+ <dt>[SVG]
+ <dd><a name="refsSVG"></a> Jon Ferraiolo, 藤沢 淳, Dean
+ Jackson, editors; "<cite>Scalable Vector Graphics (SVG) 1.1
+ Specification</cite>", W3C Recommendation, 14 January 2003
+ <dd>(<code><a href="http://www.w3.org/TR/SVG/">http://www.w3.org/TR/SVG/</a></code>)
+
+ <dt>[UNICODE]</dt>
+ <dd><a name="refsUNICODE"></a> <cite><a
+ 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>.
+ <dd>(<code><a href="http://www.unicode.org/versions/">http://www.unicode.org/versions/</a></code>)
+ </dd>
+
+ <dt>[XML10]
+ <dd><a name="refsXML10"></a> Tim Bray, Jean Paoli, C. M. Sperberg-McQueen,
+ Eve Maler, François Yergeau, editors; "<cite>Extensible Markup
+ Language (XML) 1.0 (Third Edition)</cite>", W3C Recommendation, 4
+ February 2004
+ <dd>(<a href="http://www.w3.org/TR/REC-xml/"><code>http://www.w3.org/TR/REC-xml/</code></a>)
+
+ <dt>[XMLNAMES]
+ <dd><a name="refsXMLNAMES"></a> Tim Bray, Dave Hollander, Andrew Layman,
+ editors; "<cite>Namespaces in XML</cite>", W3C Recommendation, 14
+ January 1999
+ <dd>(<a href="http://www.w3.org/TR/REC-xml-names/"><code>http://www.w3.org/TR/REC-xml-names/</code></a>)
+
+ <dt>[YACC]
+ <dd><a name="refsYACC"></a> S. C. Johnson; "<cite>YACC — Yet another
+ compiler compiler</cite>", Technical Report, Murray Hill, 1975
</dl>
+</div>
</body>
</html>
diff --git a/samples/src/main/java/gwtquery/samples/public/dojo.js b/samples/src/main/java/gwtquery/samples/public/dojo.js new file mode 100644 index 00000000..ee6504c9 --- /dev/null +++ b/samples/src/main/java/gwtquery/samples/public/dojo.js @@ -0,0 +1,16 @@ +/* + Copyright (c) 2004-2009, The Dojo Foundation All Rights Reserved. + Available via Academic Free License >= 2.1 OR the modified BSD license. + see: http://dojotoolkit.org/license for details +*/ + +/* + This is a compiled version of Dojo, built for deployment and not for + development. To get an editable version, please visit: + + http://dojotoolkit.org + + for documentation and information on getting the source. +*/ + +(function(){var _1=null;if((_1||(typeof djConfig!="undefined"&&djConfig.scopeMap))&&(typeof window!="undefined")){var _2="",_3="",_4="",_5={},_6={};_1=_1||djConfig.scopeMap;for(var i=0;i<_1.length;i++){var _8=_1[i];_2+="var "+_8[0]+" = {}; "+_8[1]+" = "+_8[0]+";"+_8[1]+"._scopeName = '"+_8[1]+"';";_3+=(i==0?"":",")+_8[0];_4+=(i==0?"":",")+_8[1];_5[_8[0]]=_8[1];_6[_8[1]]=_8[0];}eval(_2+"dojo._scopeArgs = ["+_4+"];");dojo._scopePrefixArgs=_3;dojo._scopePrefix="(function("+_3+"){";dojo._scopeSuffix="})("+_4+")";dojo._scopeMap=_5;dojo._scopeMapRev=_6;}(function(){if(typeof this["loadFirebugConsole"]=="function"){this["loadFirebugConsole"]();}else{this.console=this.console||{};var cn=["assert","count","debug","dir","dirxml","error","group","groupEnd","info","profile","profileEnd","time","timeEnd","trace","warn","log"];var i=0,tn;while((tn=cn[i++])){if(!console[tn]){(function(){var _c=tn+"";console[_c]=("log" in console)?function(){var a=Array.apply({},arguments);a.unshift(_c+":");console["log"](a.join(" "));}:function(){};})();}}}if(typeof dojo=="undefined"){this.dojo={_scopeName:"dojo",_scopePrefix:"",_scopePrefixArgs:"",_scopeSuffix:"",_scopeMap:{},_scopeMapRev:{}};}var d=dojo;if(typeof dijit=="undefined"){this.dijit={_scopeName:"dijit"};}if(typeof dojox=="undefined"){this.dojox={_scopeName:"dojox"};}if(!d._scopeArgs){d._scopeArgs=[dojo,dijit,dojox];}d.global=this;d.config={isDebug:false,debugAtAllCosts:false};if(typeof djConfig!="undefined"){for(var _f in djConfig){d.config[_f]=djConfig[_f];}}dojo.locale=d.config.locale;var rev="$Rev: 17468 $".match(/\d+/);dojo.version={major:1,minor:3,patch:1,flag:"",revision:rev?+rev[0]:NaN,toString:function(){with(d.version){return major+"."+minor+"."+patch+flag+" ("+revision+")";}}};if(typeof OpenAjax!="undefined"){OpenAjax.hub.registerLibrary(dojo._scopeName,"http://dojotoolkit.org",d.version.toString());}var _11={};dojo._mixin=function(obj,_13){for(var x in _13){if(_11[x]===undefined||_11[x]!=_13[x]){obj[x]=_13[x];}}if(d.isIE&&_13){var p=_13.toString;if(typeof p=="function"&&p!=obj.toString&&p!=_11.toString&&p!="\nfunction toString() {\n [native code]\n}\n"){obj.toString=_13.toString;}}return obj;};dojo.mixin=function(obj,_17){if(!obj){obj={};}for(var i=1,l=arguments.length;i<l;i++){d._mixin(obj,arguments[i]);}return obj;};dojo._getProp=function(_1a,_1b,_1c){var obj=_1c||d.global;for(var i=0,p;obj&&(p=_1a[i]);i++){if(i==0&&this._scopeMap[p]){p=this._scopeMap[p];}obj=(p in obj?obj[p]:(_1b?obj[p]={}:undefined));}return obj;};dojo.setObject=function(_20,_21,_22){var _23=_20.split("."),p=_23.pop(),obj=d._getProp(_23,true,_22);return obj&&p?(obj[p]=_21):undefined;};dojo.getObject=function(_26,_27,_28){return d._getProp(_26.split("."),_27,_28);};dojo.exists=function(_29,obj){return !!d.getObject(_29,false,obj);};dojo["eval"]=function(_2b){return d.global.eval?d.global.eval(_2b):eval(_2b);};d.deprecated=d.experimental=function(){};})();(function(){var d=dojo;d.mixin(d,{_loadedModules:{},_inFlightCount:0,_hasResource:{},_modulePrefixes:{dojo:{name:"dojo",value:"."},doh:{name:"doh",value:"../util/doh"},tests:{name:"tests",value:"tests"}},_moduleHasPrefix:function(_2d){var mp=this._modulePrefixes;return !!(mp[_2d]&&mp[_2d].value);},_getModulePrefix:function(_2f){var mp=this._modulePrefixes;if(this._moduleHasPrefix(_2f)){return mp[_2f].value;}return _2f;},_loadedUrls:[],_postLoad:false,_loaders:[],_unloaders:[],_loadNotifying:false});dojo._loadPath=function(_31,_32,cb){var uri=((_31.charAt(0)=="/"||_31.match(/^\w+:/))?"":this.baseUrl)+_31;try{return !_32?this._loadUri(uri,cb):this._loadUriAndCheck(uri,_32,cb);}catch(e){console.error(e);return false;}};dojo._loadUri=function(uri,cb){if(this._loadedUrls[uri]){return true;}var _37=this._getText(uri,true);if(!_37){return false;}this._loadedUrls[uri]=true;this._loadedUrls.push(uri);if(cb){_37="("+_37+")";}else{_37=this._scopePrefix+_37+this._scopeSuffix;}if(d.isMoz){_37+="\r\n//@ sourceURL="+uri;}var _38=d["eval"](_37);if(cb){cb(_38);}return true;};dojo._loadUriAndCheck=function(uri,_3a,cb){var ok=false;try{ok=this._loadUri(uri,cb);}catch(e){console.error("failed loading "+uri+" with error: "+e);}return !!(ok&&this._loadedModules[_3a]);};dojo.loaded=function(){this._loadNotifying=true;this._postLoad=true;var mll=d._loaders;this._loaders=[];for(var x=0;x<mll.length;x++){mll[x]();}this._loadNotifying=false;if(d._postLoad&&d._inFlightCount==0&&mll.length){d._callLoaded();}};dojo.unloaded=function(){var mll=d._unloaders;while(mll.length){(mll.pop())();}};d._onto=function(arr,obj,fn){if(!fn){arr.push(obj);}else{if(fn){var _43=(typeof fn=="string")?obj[fn]:fn;arr.push(function(){_43.call(obj);});}}};dojo.addOnLoad=function(obj,_45){d._onto(d._loaders,obj,_45);if(d._postLoad&&d._inFlightCount==0&&!d._loadNotifying){d._callLoaded();}};var dca=d.config.addOnLoad;if(dca){d.addOnLoad[(dca instanceof Array?"apply":"call")](d,dca);}dojo._modulesLoaded=function(){if(d._postLoad){return;}if(d._inFlightCount>0){console.warn("files still in flight!");return;}d._callLoaded();};dojo._callLoaded=function(){if(typeof setTimeout=="object"||(dojo.config.useXDomain&&d.isOpera)){if(dojo.isAIR){setTimeout(function(){dojo.loaded();},0);}else{setTimeout(dojo._scopeName+".loaded();",0);}}else{d.loaded();}};dojo._getModuleSymbols=function(_47){var _48=_47.split(".");for(var i=_48.length;i>0;i--){var _4a=_48.slice(0,i).join(".");if((i==1)&&!this._moduleHasPrefix(_4a)){_48[0]="../"+_48[0];}else{var _4b=this._getModulePrefix(_4a);if(_4b!=_4a){_48.splice(0,i,_4b);break;}}}return _48;};dojo._global_omit_module_check=false;dojo.loadInit=function(_4c){_4c();};dojo._loadModule=dojo.require=function(_4d,_4e){_4e=this._global_omit_module_check||_4e;var _4f=this._loadedModules[_4d];if(_4f){return _4f;}var _50=this._getModuleSymbols(_4d).join("/")+".js";var _51=(!_4e)?_4d:null;var ok=this._loadPath(_50,_51);if(!ok&&!_4e){throw new Error("Could not load '"+_4d+"'; last tried '"+_50+"'");}if(!_4e&&!this._isXDomain){_4f=this._loadedModules[_4d];if(!_4f){throw new Error("symbol '"+_4d+"' is not defined after loading '"+_50+"'");}}return _4f;};dojo.provide=function(_53){_53=_53+"";return (d._loadedModules[_53]=d.getObject(_53,true));};dojo.platformRequire=function(_54){var _55=_54.common||[];var _56=_55.concat(_54[d._name]||_54["default"]||[]);for(var x=0;x<_56.length;x++){var _58=_56[x];if(_58.constructor==Array){d._loadModule.apply(d,_58);}else{d._loadModule(_58);}}};dojo.requireIf=function(_59,_5a){if(_59===true){var _5b=[];for(var i=1;i<arguments.length;i++){_5b.push(arguments[i]);}d.require.apply(d,_5b);}};dojo.requireAfterIf=d.requireIf;dojo.registerModulePath=function(_5d,_5e){d._modulePrefixes[_5d]={name:_5d,value:_5e};};dojo.requireLocalization=function(_5f,_60,_61,_62){d.require("dojo.i18n");d.i18n._requireLocalization.apply(d.hostenv,arguments);};var ore=new RegExp("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$");var ire=new RegExp("^((([^\\[:]+):)?([^@]+)@)?(\\[([^\\]]+)\\]|([^\\[:]*))(:([0-9]+))?$");dojo._Url=function(){var n=null;var _a=arguments;var uri=[_a[0]];for(var i=1;i<_a.length;i++){if(!_a[i]){continue;}var _69=new d._Url(_a[i]+"");var _6a=new d._Url(uri[0]+"");if(_69.path==""&&!_69.scheme&&!_69.authority&&!_69.query){if(_69.fragment!=n){_6a.fragment=_69.fragment;}_69=_6a;}else{if(!_69.scheme){_69.scheme=_6a.scheme;if(!_69.authority){_69.authority=_6a.authority;if(_69.path.charAt(0)!="/"){var _6b=_6a.path.substring(0,_6a.path.lastIndexOf("/")+1)+_69.path;var _6c=_6b.split("/");for(var j=0;j<_6c.length;j++){if(_6c[j]=="."){if(j==_6c.length-1){_6c[j]="";}else{_6c.splice(j,1);j--;}}else{if(j>0&&!(j==1&&_6c[0]=="")&&_6c[j]==".."&&_6c[j-1]!=".."){if(j==(_6c.length-1)){_6c.splice(j,1);_6c[j-1]="";}else{_6c.splice(j-1,2);j-=2;}}}}_69.path=_6c.join("/");}}}}uri=[];if(_69.scheme){uri.push(_69.scheme,":");}if(_69.authority){uri.push("//",_69.authority);}uri.push(_69.path);if(_69.query){uri.push("?",_69.query);}if(_69.fragment){uri.push("#",_69.fragment);}}this.uri=uri.join("");var r=this.uri.match(ore);this.scheme=r[2]||(r[1]?"":n);this.authority=r[4]||(r[3]?"":n);this.path=r[5];this.query=r[7]||(r[6]?"":n);this.fragment=r[9]||(r[8]?"":n);if(this.authority!=n){r=this.authority.match(ire);this.user=r[3]||n;this.password=r[4]||n;this.host=r[6]||r[7];this.port=r[9]||n;}};dojo._Url.prototype.toString=function(){return this.uri;};dojo.moduleUrl=function(_6f,url){var loc=d._getModuleSymbols(_6f).join("/");if(!loc){return null;}if(loc.lastIndexOf("/")!=loc.length-1){loc+="/";}var _72=loc.indexOf(":");if(loc.charAt(0)!="/"&&(_72==-1||_72>loc.indexOf("/"))){loc=d.baseUrl+loc;}return new d._Url(loc,url);};})();if(typeof window!="undefined"){dojo.isBrowser=true;dojo._name="browser";(function(){var d=dojo;if(document&&document.getElementsByTagName){var _74=document.getElementsByTagName("script");var _75=/dojo(\.xd)?\.js(\W|$)/i;for(var i=0;i<_74.length;i++){var src=_74[i].getAttribute("src");if(!src){continue;}var m=src.match(_75);if(m){if(!d.config.baseUrl){d.config.baseUrl=src.substring(0,m.index);}var cfg=_74[i].getAttribute("djConfig");if(cfg){var _7a=eval("({ "+cfg+" })");for(var x in _7a){dojo.config[x]=_7a[x];}}break;}}}d.baseUrl=d.config.baseUrl;var n=navigator;var dua=n.userAgent,dav=n.appVersion,tv=parseFloat(dav);if(dua.indexOf("Opera")>=0){d.isOpera=tv;}if(dua.indexOf("AdobeAIR")>=0){d.isAIR=1;}d.isKhtml=(dav.indexOf("Konqueror")>=0)?tv:0;d.isWebKit=parseFloat(dua.split("WebKit/")[1])||undefined;d.isChrome=parseFloat(dua.split("Chrome/")[1])||undefined;var _80=Math.max(dav.indexOf("WebKit"),dav.indexOf("Safari"),0);if(_80&&!dojo.isChrome){d.isSafari=parseFloat(dav.split("Version/")[1]);if(!d.isSafari||parseFloat(dav.substr(_80+7))<=419.3){d.isSafari=2;}}if(dua.indexOf("Gecko")>=0&&!d.isKhtml&&!d.isWebKit){d.isMozilla=d.isMoz=tv;}if(d.isMoz){d.isFF=parseFloat(dua.split("Firefox/")[1]||dua.split("Minefield/")[1]||dua.split("Shiretoko/")[1])||undefined;}if(document.all&&!d.isOpera){d.isIE=parseFloat(dav.split("MSIE ")[1])||undefined;if(d.isIE>=8&&document.documentMode!=5){d.isIE=document.documentMode;}}if(dojo.isIE&&window.location.protocol==="file:"){dojo.config.ieForceActiveXXhr=true;}var cm=document.compatMode;d.isQuirks=cm=="BackCompat"||cm=="QuirksMode"||d.isIE<6;d.locale=dojo.config.locale||(d.isIE?n.userLanguage:n.language).toLowerCase();d._XMLHTTP_PROGIDS=["Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0"];d._xhrObj=function(){var _82,_83;if(!dojo.isIE||!dojo.config.ieForceActiveXXhr){try{_82=new XMLHttpRequest();}catch(e){}}if(!_82){for(var i=0;i<3;++i){var _85=d._XMLHTTP_PROGIDS[i];try{_82=new ActiveXObject(_85);}catch(e){_83=e;}if(_82){d._XMLHTTP_PROGIDS=[_85];break;}}}if(!_82){throw new Error("XMLHTTP not available: "+_83);}return _82;};d._isDocumentOk=function(_86){var _87=_86.status||0;return (_87>=200&&_87<300)||_87==304||_87==1223||(!_87&&(location.protocol=="file:"||location.protocol=="chrome:"));};var _88=window.location+"";var _89=document.getElementsByTagName("base");var _8a=(_89&&_89.length>0);d._getText=function(uri,_8c){var _8d=this._xhrObj();if(!_8a&&dojo._Url){uri=(new dojo._Url(_88,uri)).toString();}if(d.config.cacheBust){uri+="";uri+=(uri.indexOf("?")==-1?"?":"&")+String(d.config.cacheBust).replace(/\W+/g,"");}_8d.open("GET",uri,false);try{_8d.send(null);if(!d._isDocumentOk(_8d)){var err=Error("Unable to load "+uri+" status:"+_8d.status);err.status=_8d.status;err.responseText=_8d.responseText;throw err;}}catch(e){if(_8c){return null;}throw e;}return _8d.responseText;};var _w=window;var _90=function(_91,fp){var _93=_w[_91]||function(){};_w[_91]=function(){fp.apply(_w,arguments);_93.apply(_w,arguments);};};d._windowUnloaders=[];d.windowUnloaded=function(){var mll=d._windowUnloaders;while(mll.length){(mll.pop())();}};var _95=0;d.addOnWindowUnload=function(obj,_97){d._onto(d._windowUnloaders,obj,_97);if(!_95){_95=1;_90("onunload",d.windowUnloaded);}};var _98=0;d.addOnUnload=function(obj,_9a){d._onto(d._unloaders,obj,_9a);if(!_98){_98=1;_90("onbeforeunload",dojo.unloaded);}};})();dojo._initFired=false;dojo._loadInit=function(e){dojo._initFired=true;var _9c=e&&e.type?e.type.toLowerCase():"load";if(arguments.callee.initialized||(_9c!="domcontentloaded"&&_9c!="load")){return;}arguments.callee.initialized=true;if("_khtmlTimer" in dojo){clearInterval(dojo._khtmlTimer);delete dojo._khtmlTimer;}if(dojo._inFlightCount==0){dojo._modulesLoaded();}};if(!dojo.config.afterOnLoad){if(document.addEventListener){if(dojo.isWebKit>525||dojo.isOpera||dojo.isFF>=3||(dojo.isMoz&&dojo.config.enableMozDomContentLoaded===true)){document.addEventListener("DOMContentLoaded",dojo._loadInit,null);}window.addEventListener("load",dojo._loadInit,null);}if(dojo.isAIR){window.addEventListener("load",dojo._loadInit,null);}else{if((dojo.isWebKit<525)||dojo.isKhtml){dojo._khtmlTimer=setInterval(function(){if(/loaded|complete/.test(document.readyState)){dojo._loadInit();}},10);}}}if(dojo.isIE){if(!dojo.config.afterOnLoad){document.write("<scr"+"ipt defer src=\"//:\" "+"onreadystatechange=\"if(this.readyState=='complete'){"+dojo._scopeName+"._loadInit();}\">"+"</scr"+"ipt>");}try{document.namespaces.add("v","urn:schemas-microsoft-com:vml");document.createStyleSheet().addRule("v\\:*","behavior:url(#default#VML); display:inline-block");}catch(e){}}}(function(){var mp=dojo.config["modulePaths"];if(mp){for(var _9e in mp){dojo.registerModulePath(_9e,mp[_9e]);}}})();if(dojo.config.isDebug){dojo.require("dojo._firebug.firebug");}if(dojo.config.debugAtAllCosts){dojo.config.useXDomain=true;dojo.require("dojo._base._loader.loader_xd");dojo.require("dojo._base._loader.loader_debug");dojo.require("dojo.i18n");}if(!dojo._hasResource["dojo._base.lang"]){dojo._hasResource["dojo._base.lang"]=true;dojo.provide("dojo._base.lang");dojo.isString=function(it){return !!arguments.length&&it!=null&&(typeof it=="string"||it instanceof String);};dojo.isArray=function(it){return it&&(it instanceof Array||typeof it=="array");};dojo.isFunction=(function(){var _a1=function(it){var t=typeof it;return it&&(t=="function"||it instanceof Function);};return dojo.isSafari?function(it){if(typeof it=="function"&&it=="[object NodeList]"){return false;}return _a1(it);}:_a1;})();dojo.isObject=function(it){return it!==undefined&&(it===null||typeof it=="object"||dojo.isArray(it)||dojo.isFunction(it));};dojo.isArrayLike=function(it){var d=dojo;return it&&it!==undefined&&!d.isString(it)&&!d.isFunction(it)&&!(it.tagName&&it.tagName.toLowerCase()=="form")&&(d.isArray(it)||isFinite(it.length));};dojo.isAlien=function(it){return it&&!dojo.isFunction(it)&&/\{\s*\[native code\]\s*\}/.test(String(it));};dojo.extend=function(_a9,_aa){for(var i=1,l=arguments.length;i<l;i++){dojo._mixin(_a9.prototype,arguments[i]);}return _a9;};dojo._hitchArgs=function(_ad,_ae){var pre=dojo._toArray(arguments,2);var _b0=dojo.isString(_ae);return function(){var _b1=dojo._toArray(arguments);var f=_b0?(_ad||dojo.global)[_ae]:_ae;return f&&f.apply(_ad||this,pre.concat(_b1));};};dojo.hitch=function(_b3,_b4){if(arguments.length>2){return dojo._hitchArgs.apply(dojo,arguments);}if(!_b4){_b4=_b3;_b3=null;}if(dojo.isString(_b4)){_b3=_b3||dojo.global;if(!_b3[_b4]){throw (["dojo.hitch: scope[\"",_b4,"\"] is null (scope=\"",_b3,"\")"].join(""));}return function(){return _b3[_b4].apply(_b3,arguments||[]);};}return !_b3?_b4:function(){return _b4.apply(_b3,arguments||[]);};};dojo.delegate=dojo._delegate=(function(){function TMP(){};return function(obj,_b7){TMP.prototype=obj;var tmp=new TMP();if(_b7){dojo._mixin(tmp,_b7);}return tmp;};})();(function(){var _b9=function(obj,_bb,_bc){return (_bc||[]).concat(Array.prototype.slice.call(obj,_bb||0));};var _bd=function(obj,_bf,_c0){var arr=_c0||[];for(var x=_bf||0;x<obj.length;x++){arr.push(obj[x]);}return arr;};dojo._toArray=dojo.isIE?function(obj){return ((obj.item)?_bd:_b9).apply(this,arguments);}:_b9;})();dojo.partial=function(_c4){var arr=[null];return dojo.hitch.apply(dojo,arr.concat(dojo._toArray(arguments)));};dojo.clone=function(o){if(!o){return o;}if(dojo.isArray(o)){var r=[];for(var i=0;i<o.length;++i){r.push(dojo.clone(o[i]));}return r;}if(!dojo.isObject(o)){return o;}if(o.nodeType&&o.cloneNode){return o.cloneNode(true);}if(o instanceof Date){return new Date(o.getTime());}r=new o.constructor();for(i in o){if(!(i in r)||r[i]!=o[i]){r[i]=dojo.clone(o[i]);}}return r;};dojo.trim=String.prototype.trim?function(str){return str.trim();}:function(str){return str.replace(/^\s\s*/,"").replace(/\s\s*$/,"");};}if(!dojo._hasResource["dojo._base.declare"]){dojo._hasResource["dojo._base.declare"]=true;dojo.provide("dojo._base.declare");dojo.declare=function(_cb,_cc,_cd){var dd=arguments.callee,_cf;if(dojo.isArray(_cc)){_cf=_cc;_cc=_cf.shift();}if(_cf){dojo.forEach(_cf,function(m,i){if(!m){throw (_cb+": mixin #"+i+" is null");}_cc=dd._delegate(_cc,m);});}var _d2=dd._delegate(_cc);_cd=_cd||{};_d2.extend(_cd);dojo.extend(_d2,{declaredClass:_cb,_constructor:_cd.constructor});_d2.prototype.constructor=_d2;return dojo.setObject(_cb,_d2);};dojo.mixin(dojo.declare,{_delegate:function(_d3,_d4){var bp=(_d3||0).prototype,mp=(_d4||0).prototype,dd=dojo.declare;var _d8=dd._makeCtor();dojo.mixin(_d8,{superclass:bp,mixin:mp,extend:dd._extend});if(_d3){_d8.prototype=dojo._delegate(bp);}dojo.extend(_d8,dd._core,mp||0,{_constructor:null,preamble:null});_d8.prototype.constructor=_d8;_d8.prototype.declaredClass=(bp||0).declaredClass+"_"+(mp||0).declaredClass;return _d8;},_extend:function(_d9){var i,fn;for(i in _d9){if(dojo.isFunction(fn=_d9[i])&&!0[i]){fn.nom=i;fn.ctor=this;}}dojo.extend(this,_d9);},_makeCtor:function(){return function(){this._construct(arguments);};},_core:{_construct:function(_dc){var c=_dc.callee,s=c.superclass,ct=s&&s.constructor,m=c.mixin,mct=m&&m.constructor,a=_dc,ii,fn;if(a[0]){if(((fn=a[0].preamble))){a=fn.apply(this,a)||a;}}if((fn=c.prototype.preamble)){a=fn.apply(this,a)||a;}if(ct&&ct.apply){ct.apply(this,a);}if(mct&&mct.apply){mct.apply(this,a);}if((ii=c.prototype._constructor)){ii.apply(this,_dc);}if(this.constructor.prototype==c.prototype&&(ct=this.postscript)){ct.apply(this,_dc);}},_findMixin:function(_e5){var c=this.constructor,p,m;while(c){p=c.superclass;m=c.mixin;if(m==_e5||(m instanceof _e5.constructor)){return p;}if(m&&m._findMixin&&(m=m._findMixin(_e5))){return m;}c=p&&p.constructor;}},_findMethod:function(_e9,_ea,_eb,has){var p=_eb,c,m,f;do{c=p.constructor;m=c.mixin;if(m&&(m=this._findMethod(_e9,_ea,m,has))){return m;}if((f=p[_e9])&&(has==(f==_ea))){return p;}p=c.superclass;}while(p);return !has&&(p=this._findMixin(_eb))&&this._findMethod(_e9,_ea,p,has);},inherited:function(_f1,_f2,_f3){var a=arguments;if(!dojo.isString(a[0])){_f3=_f2;_f2=_f1;_f1=_f2.callee.nom;}a=_f3||_f2;var c=_f2.callee,p=this.constructor.prototype,fn,mp;if(this[_f1]!=c||p[_f1]==c){mp=(c.ctor||0).superclass||this._findMethod(_f1,c,p,true);if(!mp){throw (this.declaredClass+": inherited method \""+_f1+"\" mismatch");}p=this._findMethod(_f1,c,mp,false);}fn=p&&p[_f1];if(!fn){throw (mp.declaredClass+": inherited method \""+_f1+"\" not found");}return fn.apply(this,a);}}});}if(!dojo._hasResource["dojo._base.connect"]){dojo._hasResource["dojo._base.connect"]=true;dojo.provide("dojo._base.connect");dojo._listener={getDispatcher:function(){return function(){var ap=Array.prototype,c=arguments.callee,ls=c._listeners,t=c.target;var r=t&&t.apply(this,arguments);var lls;lls=[].concat(ls);for(var i in lls){if(!(i in ap)){lls[i].apply(this,arguments);}}return r;};},add:function(_100,_101,_102){_100=_100||dojo.global;var f=_100[_101];if(!f||!f._listeners){var d=dojo._listener.getDispatcher();d.target=f;d._listeners=[];f=_100[_101]=d;}return f._listeners.push(_102);},remove:function(_105,_106,_107){var f=(_105||dojo.global)[_106];if(f&&f._listeners&&_107--){delete f._listeners[_107];}}};dojo.connect=function(obj,_10a,_10b,_10c,_10d){var a=arguments,args=[],i=0;args.push(dojo.isString(a[0])?null:a[i++],a[i++]);var a1=a[i+1];args.push(dojo.isString(a1)||dojo.isFunction(a1)?a[i++]:null,a[i++]);for(var l=a.length;i<l;i++){args.push(a[i]);}return dojo._connect.apply(this,args);};dojo._connect=function(obj,_113,_114,_115){var l=dojo._listener,h=l.add(obj,_113,dojo.hitch(_114,_115));return [obj,_113,h,l];};dojo.disconnect=function(_118){if(_118&&_118[0]!==undefined){dojo._disconnect.apply(this,_118);delete _118[0];}};dojo._disconnect=function(obj,_11a,_11b,_11c){_11c.remove(obj,_11a,_11b);};dojo._topics={};dojo.subscribe=function(_11d,_11e,_11f){return [_11d,dojo._listener.add(dojo._topics,_11d,dojo.hitch(_11e,_11f))];};dojo.unsubscribe=function(_120){if(_120){dojo._listener.remove(dojo._topics,_120[0],_120[1]);}};dojo.publish=function(_121,args){var f=dojo._topics[_121];if(f){f.apply(this,args||[]);}};dojo.connectPublisher=function(_124,obj,_126){var pf=function(){dojo.publish(_124,arguments);};return (_126)?dojo.connect(obj,_126,pf):dojo.connect(obj,pf);};}if(!dojo._hasResource["dojo._base.Deferred"]){dojo._hasResource["dojo._base.Deferred"]=true;dojo.provide("dojo._base.Deferred");dojo.Deferred=function(_128){this.chain=[];this.id=this._nextId();this.fired=-1;this.paused=0;this.results=[null,null];this.canceller=_128;this.silentlyCancelled=false;};dojo.extend(dojo.Deferred,{_nextId:(function(){var n=1;return function(){return n++;};})(),cancel:function(){var err;if(this.fired==-1){if(this.canceller){err=this.canceller(this);}else{this.silentlyCancelled=true;}if(this.fired==-1){if(!(err instanceof Error)){var res=err;var msg="Deferred Cancelled";if(err&&err.toString){msg+=": "+err.toString();}err=new Error(msg);err.dojoType="cancel";err.cancelResult=res;}this.errback(err);}}else{if((this.fired==0)&&(this.results[0] instanceof dojo.Deferred)){this.results[0].cancel();}}},_resback:function(res){this.fired=((res instanceof Error)?1:0);this.results[this.fired]=res;this._fire();},_check:function(){if(this.fired!=-1){if(!this.silentlyCancelled){throw new Error("already called!");}this.silentlyCancelled=false;return;}},callback:function(res){this._check();this._resback(res);},errback:function(res){this._check();if(!(res instanceof Error)){res=new Error(res);}this._resback(res);},addBoth:function(cb,cbfn){var _132=dojo.hitch.apply(dojo,arguments);return this.addCallbacks(_132,_132);},addCallback:function(cb,cbfn){return this.addCallbacks(dojo.hitch.apply(dojo,arguments));},addErrback:function(cb,cbfn){return this.addCallbacks(null,dojo.hitch.apply(dojo,arguments));},addCallbacks:function(cb,eb){this.chain.push([cb,eb]);if(this.fired>=0){this._fire();}return this;},_fire:function(){var _139=this.chain;var _13a=this.fired;var res=this.results[_13a];var self=this;var cb=null;while((_139.length>0)&&(this.paused==0)){var f=_139.shift()[_13a];if(!f){continue;}var func=function(){var ret=f(res);if(typeof ret!="undefined"){res=ret;}_13a=((res instanceof Error)?1:0);if(res instanceof dojo.Deferred){cb=function(res){self._resback(res);self.paused--;if((self.paused==0)&&(self.fired>=0)){self._fire();}};this.paused++;}};if(dojo.config.debugAtAllCosts){func.call(this);}else{try{func.call(this);}catch(err){_13a=1;res=err;}}}this.fired=_13a;this.results[_13a]=res;if((cb)&&(this.paused)){res.addBoth(cb);}}});}if(!dojo._hasResource["dojo._base.json"]){dojo._hasResource["dojo._base.json"]=true;dojo.provide("dojo._base.json");dojo.fromJson=function(json){return eval("("+json+")");};dojo._escapeString=function(str){return ("\""+str.replace(/(["\\])/g,"\\$1")+"\"").replace(/[\f]/g,"\\f").replace(/[\b]/g,"\\b").replace(/[\n]/g,"\\n").replace(/[\t]/g,"\\t").replace(/[\r]/g,"\\r");};dojo.toJsonIndentStr="\t";dojo.toJson=function(it,_145,_146){if(it===undefined){return "undefined";}var _147=typeof it;if(_147=="number"||_147=="boolean"){return it+"";}if(it===null){return "null";}if(dojo.isString(it)){return dojo._escapeString(it);}var _148=arguments.callee;var _149;_146=_146||"";var _14a=_145?_146+dojo.toJsonIndentStr:"";var tf=it.__json__||it.json;if(dojo.isFunction(tf)){_149=tf.call(it);if(it!==_149){return _148(_149,_145,_14a);}}if(it.nodeType&&it.cloneNode){throw new Error("Can't serialize DOM nodes");}var sep=_145?" ":"";var _14d=_145?"\n":"";if(dojo.isArray(it)){var res=dojo.map(it,function(obj){var val=_148(obj,_145,_14a);if(typeof val!="string"){val="undefined";}return _14d+_14a+val;});return "["+res.join(","+sep)+_14d+_146+"]";}if(_147=="function"){return null;}var _151=[],key;for(key in it){var _153,val;if(typeof key=="number"){_153="\""+key+"\"";}else{if(typeof key=="string"){_153=dojo._escapeString(key);}else{continue;}}val=_148(it[key],_145,_14a);if(typeof val!="string"){continue;}_151.push(_14d+_14a+_153+":"+sep+val);}return "{"+_151.join(","+sep)+_14d+_146+"}";};}if(!dojo._hasResource["dojo._base.array"]){dojo._hasResource["dojo._base.array"]=true;dojo.provide("dojo._base.array");(function(){var _155=function(arr,obj,cb){return [dojo.isString(arr)?arr.split(""):arr,obj||dojo.global,dojo.isString(cb)?new Function("item","index","array",cb):cb];};dojo.mixin(dojo,{indexOf:function(_159,_15a,_15b,_15c){var step=1,end=_159.length||0,i=0;if(_15c){i=end-1;step=end=-1;}if(_15b!=undefined){i=_15b;}if((_15c&&i>end)||i<end){for(;i!=end;i+=step){if(_159[i]==_15a){return i;}}}return -1;},lastIndexOf:function(_15f,_160,_161){return dojo.indexOf(_15f,_160,_161,true);},forEach:function(arr,_163,_164){if(!arr||!arr.length){return;}var _p=_155(arr,_164,_163);arr=_p[0];for(var i=0,l=arr.length;i<l;++i){_p[2].call(_p[1],arr[i],i,arr);}},_everyOrSome:function(_168,arr,_16a,_16b){var _p=_155(arr,_16b,_16a);arr=_p[0];for(var i=0,l=arr.length;i<l;++i){var _16f=!!_p[2].call(_p[1],arr[i],i,arr);if(_168^_16f){return _16f;}}return _168;},every:function(arr,_171,_172){return this._everyOrSome(true,arr,_171,_172);},some:function(arr,_174,_175){return this._everyOrSome(false,arr,_174,_175);},map:function(arr,_177,_178){var _p=_155(arr,_178,_177);arr=_p[0];var _17a=(arguments[3]?(new arguments[3]()):[]);for(var i=0,l=arr.length;i<l;++i){_17a.push(_p[2].call(_p[1],arr[i],i,arr));}return _17a;},filter:function(arr,_17e,_17f){var _p=_155(arr,_17f,_17e);arr=_p[0];var _181=[];for(var i=0,l=arr.length;i<l;++i){if(_p[2].call(_p[1],arr[i],i,arr)){_181.push(arr[i]);}}return _181;}});})();}if(!dojo._hasResource["dojo._base.Color"]){dojo._hasResource["dojo._base.Color"]=true;dojo.provide("dojo._base.Color");(function(){var d=dojo;dojo.Color=function(_185){if(_185){this.setColor(_185);}};dojo.Color.named={black:[0,0,0],silver:[192,192,192],gray:[128,128,128],white:[255,255,255],maroon:[128,0,0],red:[255,0,0],purple:[128,0,128],fuchsia:[255,0,255],green:[0,128,0],lime:[0,255,0],olive:[128,128,0],yellow:[255,255,0],navy:[0,0,128],blue:[0,0,255],teal:[0,128,128],aqua:[0,255,255]};dojo.extend(dojo.Color,{r:255,g:255,b:255,a:1,_set:function(r,g,b,a){var t=this;t.r=r;t.g=g;t.b=b;t.a=a;},setColor:function(_18b){if(d.isString(_18b)){d.colorFromString(_18b,this);}else{if(d.isArray(_18b)){d.colorFromArray(_18b,this);}else{this._set(_18b.r,_18b.g,_18b.b,_18b.a);if(!(_18b instanceof d.Color)){this.sanitize();}}}return this;},sanitize:function(){return this;},toRgb:function(){var t=this;return [t.r,t.g,t.b];},toRgba:function(){var t=this;return [t.r,t.g,t.b,t.a];},toHex:function(){var arr=d.map(["r","g","b"],function(x){var s=this[x].toString(16);return s.length<2?"0"+s:s;},this);return "#"+arr.join("");},toCss:function(_191){var t=this,rgb=t.r+", "+t.g+", "+t.b;return (_191?"rgba("+rgb+", "+t.a:"rgb("+rgb)+")";},toString:function(){return this.toCss(true);}});dojo.blendColors=function(_194,end,_196,obj){var t=obj||new d.Color();d.forEach(["r","g","b","a"],function(x){t[x]=_194[x]+(end[x]-_194[x])*_196;if(x!="a"){t[x]=Math.round(t[x]);}});return t.sanitize();};dojo.colorFromRgb=function(_19a,obj){var m=_19a.toLowerCase().match(/^rgba?\(([\s\.,0-9]+)\)/);return m&&dojo.colorFromArray(m[1].split(/\s*,\s*/),obj);};dojo.colorFromHex=function(_19d,obj){var t=obj||new d.Color(),bits=(_19d.length==4)?4:8,mask=(1<<bits)-1;_19d=Number("0x"+_19d.substr(1));if(isNaN(_19d)){return null;}d.forEach(["b","g","r"],function(x){var c=_19d&mask;_19d>>=bits;t[x]=bits==4?17*c:c;});t.a=1;return t;};dojo.colorFromArray=function(a,obj){var t=obj||new d.Color();t._set(Number(a[0]),Number(a[1]),Number(a[2]),Number(a[3]));if(isNaN(t.a)){t.a=1;}return t.sanitize();};dojo.colorFromString=function(str,obj){var a=d.Color.named[str];return a&&d.colorFromArray(a,obj)||d.colorFromRgb(str,obj)||d.colorFromHex(str,obj);};})();}if(!dojo._hasResource["dojo._base"]){dojo._hasResource["dojo._base"]=true;dojo.provide("dojo._base");}if(!dojo._hasResource["dojo._base.window"]){dojo._hasResource["dojo._base.window"]=true;dojo.provide("dojo._base.window");dojo.doc=window["document"]||null;dojo.body=function(){return dojo.doc.body||dojo.doc.getElementsByTagName("body")[0];};dojo.setContext=function(_1aa,_1ab){dojo.global=_1aa;dojo.doc=_1ab;};dojo.withGlobal=function(_1ac,_1ad,_1ae,_1af){var _1b0=dojo.global;try{dojo.global=_1ac;return dojo.withDoc.call(null,_1ac.document,_1ad,_1ae,_1af);}finally{dojo.global=_1b0;}};dojo.withDoc=function(_1b1,_1b2,_1b3,_1b4){var _1b5=dojo.doc,_1b6=dojo._bodyLtr;try{dojo.doc=_1b1;delete dojo._bodyLtr;if(_1b3&&dojo.isString(_1b2)){_1b2=_1b3[_1b2];}return _1b2.apply(_1b3,_1b4||[]);}finally{dojo.doc=_1b5;if(_1b6!==undefined){dojo._bodyLtr=_1b6;}}};}if(!dojo._hasResource["dojo._base.event"]){dojo._hasResource["dojo._base.event"]=true;dojo.provide("dojo._base.event");(function(){var del=(dojo._event_listener={add:function(node,name,fp){if(!node){return;}name=del._normalizeEventName(name);fp=del._fixCallback(name,fp);var _1bb=name;if(!dojo.isIE&&(name=="mouseenter"||name=="mouseleave")){var ofp=fp;name=(name=="mouseenter")?"mouseover":"mouseout";fp=function(e){if(dojo.isFF<=2){try{e.relatedTarget.tagName;}catch(e2){return;}}if(!dojo.isDescendant(e.relatedTarget,node)){return ofp.call(this,e);}};}node.addEventListener(name,fp,false);return fp;},remove:function(node,_1bf,_1c0){if(node){_1bf=del._normalizeEventName(_1bf);if(!dojo.isIE&&(_1bf=="mouseenter"||_1bf=="mouseleave")){_1bf=(_1bf=="mouseenter")?"mouseover":"mouseout";}node.removeEventListener(_1bf,_1c0,false);}},_normalizeEventName:function(name){return name.slice(0,2)=="on"?name.slice(2):name;},_fixCallback:function(name,fp){return name!="keypress"?fp:function(e){return fp.call(this,del._fixEvent(e,this));};},_fixEvent:function(evt,_1c6){switch(evt.type){case "keypress":del._setKeyChar(evt);break;}return evt;},_setKeyChar:function(evt){evt.keyChar=evt.charCode?String.fromCharCode(evt.charCode):"";evt.charOrCode=evt.keyChar||evt.keyCode;},_punctMap:{106:42,111:47,186:59,187:43,188:44,189:45,190:46,191:47,192:96,219:91,220:92,221:93,222:39}});dojo.fixEvent=function(evt,_1c9){return del._fixEvent(evt,_1c9);};dojo.stopEvent=function(evt){evt.preventDefault();evt.stopPropagation();};var _1cb=dojo._listener;dojo._connect=function(obj,_1cd,_1ce,_1cf,_1d0){var _1d1=obj&&(obj.nodeType||obj.attachEvent||obj.addEventListener);var lid=_1d1?(_1d0?2:1):0,l=[dojo._listener,del,_1cb][lid];var h=l.add(obj,_1cd,dojo.hitch(_1ce,_1cf));return [obj,_1cd,h,lid];};dojo._disconnect=function(obj,_1d6,_1d7,_1d8){([dojo._listener,del,_1cb][_1d8]).remove(obj,_1d6,_1d7);};dojo.keys={BACKSPACE:8,TAB:9,CLEAR:12,ENTER:13,SHIFT:16,CTRL:17,ALT:18,PAUSE:19,CAPS_LOCK:20,ESCAPE:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT_ARROW:37,UP_ARROW:38,RIGHT_ARROW:39,DOWN_ARROW:40,INSERT:45,DELETE:46,HELP:47,LEFT_WINDOW:91,RIGHT_WINDOW:92,SELECT:93,NUMPAD_0:96,NUMPAD_1:97,NUMPAD_2:98,NUMPAD_3:99,NUMPAD_4:100,NUMPAD_5:101,NUMPAD_6:102,NUMPAD_7:103,NUMPAD_8:104,NUMPAD_9:105,NUMPAD_MULTIPLY:106,NUMPAD_PLUS:107,NUMPAD_ENTER:108,NUMPAD_MINUS:109,NUMPAD_PERIOD:110,NUMPAD_DIVIDE:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,F13:124,F14:125,F15:126,NUM_LOCK:144,SCROLL_LOCK:145};if(dojo.isIE){var _1d9=function(e,code){try{return (e.keyCode=code);}catch(e){return 0;}};var iel=dojo._listener;var _1dd=(dojo._ieListenersName="_"+dojo._scopeName+"_listeners");if(!dojo.config._allow_leaks){_1cb=iel=dojo._ie_listener={handlers:[],add:function(_1de,_1df,_1e0){_1de=_1de||dojo.global;var f=_1de[_1df];if(!f||!f[_1dd]){var d=dojo._getIeDispatcher();d.target=f&&(ieh.push(f)-1);d[_1dd]=[];f=_1de[_1df]=d;}return f[_1dd].push(ieh.push(_1e0)-1);},remove:function(_1e4,_1e5,_1e6){var f=(_1e4||dojo.global)[_1e5],l=f&&f[_1dd];if(f&&l&&_1e6--){delete ieh[l[_1e6]];delete l[_1e6];}}};var ieh=iel.handlers;}dojo.mixin(del,{add:function(node,_1ea,fp){if(!node){return;}_1ea=del._normalizeEventName(_1ea);if(_1ea=="onkeypress"){var kd=node.onkeydown;if(!kd||!kd[_1dd]||!kd._stealthKeydownHandle){var h=del.add(node,"onkeydown",del._stealthKeyDown);kd=node.onkeydown;kd._stealthKeydownHandle=h;kd._stealthKeydownRefs=1;}else{kd._stealthKeydownRefs++;}}return iel.add(node,_1ea,del._fixCallback(fp));},remove:function(node,_1ef,_1f0){_1ef=del._normalizeEventName(_1ef);iel.remove(node,_1ef,_1f0);if(_1ef=="onkeypress"){var kd=node.onkeydown;if(--kd._stealthKeydownRefs<=0){iel.remove(node,"onkeydown",kd._stealthKeydownHandle);delete kd._stealthKeydownHandle;}}},_normalizeEventName:function(_1f2){return _1f2.slice(0,2)!="on"?"on"+_1f2:_1f2;},_nop:function(){},_fixEvent:function(evt,_1f4){if(!evt){var w=_1f4&&(_1f4.ownerDocument||_1f4.document||_1f4).parentWindow||window;evt=w.event;}if(!evt){return (evt);}evt.target=evt.srcElement;evt.currentTarget=(_1f4||evt.srcElement);evt.layerX=evt.offsetX;evt.layerY=evt.offsetY;var se=evt.srcElement,doc=(se&&se.ownerDocument)||document;var _1f8=((dojo.isIE<6)||(doc["compatMode"]=="BackCompat"))?doc.body:doc.documentElement;var _1f9=dojo._getIeDocumentElementOffset();evt.pageX=evt.clientX+dojo._fixIeBiDiScrollLeft(_1f8.scrollLeft||0)-_1f9.x;evt.pageY=evt.clientY+(_1f8.scrollTop||0)-_1f9.y;if(evt.type=="mouseover"){evt.relatedTarget=evt.fromElement;}if(evt.type=="mouseout"){evt.relatedTarget=evt.toElement;}evt.stopPropagation=del._stopPropagation;evt.preventDefault=del._preventDefault;return del._fixKeys(evt);},_fixKeys:function(evt){switch(evt.type){case "keypress":var c=("charCode" in evt?evt.charCode:evt.keyCode);if(c==10){c=0;evt.keyCode=13;}else{if(c==13||c==27){c=0;}else{if(c==3){c=99;}}}evt.charCode=c;del._setKeyChar(evt);break;}return evt;},_stealthKeyDown:function(evt){var kp=evt.currentTarget.onkeypress;if(!kp||!kp[_1dd]){return;}var k=evt.keyCode;var _1ff=k!=13&&k!=32&&k!=27&&(k<48||k>90)&&(k<96||k>111)&&(k<186||k>192)&&(k<219||k>222);if(_1ff||evt.ctrlKey){var c=_1ff?0:k;if(evt.ctrlKey){if(k==3||k==13){return;}else{if(c>95&&c<106){c-=48;}else{if((!evt.shiftKey)&&(c>=65&&c<=90)){c+=32;}else{c=del._punctMap[c]||c;}}}}var faux=del._synthesizeEvent(evt,{type:"keypress",faux:true,charCode:c});kp.call(evt.currentTarget,faux);evt.cancelBubble=faux.cancelBubble;evt.returnValue=faux.returnValue;_1d9(evt,faux.keyCode);}},_stopPropagation:function(){this.cancelBubble=true;},_preventDefault:function(){this.bubbledKeyCode=this.keyCode;if(this.ctrlKey){_1d9(this,0);}this.returnValue=false;}});dojo.stopEvent=function(evt){evt=evt||window.event;del._stopPropagation.call(evt);del._preventDefault.call(evt);};}del._synthesizeEvent=function(evt,_204){var faux=dojo.mixin({},evt,_204);del._setKeyChar(faux);faux.preventDefault=function(){evt.preventDefault();};faux.stopPropagation=function(){evt.stopPropagation();};return faux;};if(dojo.isOpera){dojo.mixin(del,{_fixEvent:function(evt,_207){switch(evt.type){case "keypress":var c=evt.which;if(c==3){c=99;}c=c<41&&!evt.shiftKey?0:c;if(evt.ctrlKey&&!evt.shiftKey&&c>=65&&c<=90){c+=32;}return del._synthesizeEvent(evt,{charCode:c});}return evt;}});}if(dojo.isWebKit){del._add=del.add;del._remove=del.remove;dojo.mixin(del,{add:function(node,_20a,fp){if(!node){return;}var _20c=del._add(node,_20a,fp);if(del._normalizeEventName(_20a)=="keypress"){_20c._stealthKeyDownHandle=del._add(node,"keydown",function(evt){var k=evt.keyCode;var _20f=k!=13&&k!=32&&k!=27&&(k<48||k>90)&&(k<96||k>111)&&(k<186||k>192)&&(k<219||k>222);if(_20f||evt.ctrlKey){var c=_20f?0:k;if(evt.ctrlKey){if(k==3||k==13){return;}else{if(c>95&&c<106){c-=48;}else{if(!evt.shiftKey&&c>=65&&c<=90){c+=32;}else{c=del._punctMap[c]||c;}}}}var faux=del._synthesizeEvent(evt,{type:"keypress",faux:true,charCode:c});fp.call(evt.currentTarget,faux);}});}return _20c;},remove:function(node,_213,_214){if(node){if(_214._stealthKeyDownHandle){del._remove(node,"keydown",_214._stealthKeyDownHandle);}del._remove(node,_213,_214);}},_fixEvent:function(evt,_216){switch(evt.type){case "keypress":if(evt.faux){return evt;}var c=evt.charCode;c=c>=32?c:0;return del._synthesizeEvent(evt,{charCode:c,faux:true});}return evt;}});}})();if(dojo.isIE){dojo._ieDispatcher=function(args,_219){var ap=Array.prototype,h=dojo._ie_listener.handlers,c=args.callee,ls=c[dojo._ieListenersName],t=h[c.target];var r=t&&t.apply(_219,args);var lls=[].concat(ls);for(var i in lls){var f=h[lls[i]];if(!(i in ap)&&f){f.apply(_219,args);}}return r;};dojo._getIeDispatcher=function(){return new Function(dojo._scopeName+"._ieDispatcher(arguments, this)");};dojo._event_listener._fixCallback=function(fp){var f=dojo._event_listener._fixEvent;return function(e){return fp.call(this,f(e,this));};};}}if(!dojo._hasResource["dojo._base.html"]){dojo._hasResource["dojo._base.html"]=true;dojo.provide("dojo._base.html");try{document.execCommand("BackgroundImageCache",false,true);}catch(e){}if(dojo.isIE||dojo.isOpera){dojo.byId=function(id,doc){if(dojo.isString(id)){var _d=doc||dojo.doc;var te=_d.getElementById(id);if(te&&(te.attributes.id.value==id||te.id==id)){return te;}else{var eles=_d.all[id];if(!eles||eles.nodeName){eles=[eles];}var i=0;while((te=eles[i++])){if((te.attributes&&te.attributes.id&&te.attributes.id.value==id)||te.id==id){return te;}}}}else{return id;}};}else{dojo.byId=function(id,doc){return dojo.isString(id)?(doc||dojo.doc).getElementById(id):id;};}(function(){var d=dojo;var _22f=null;d.addOnWindowUnload(function(){_22f=null;});dojo._destroyElement=dojo.destroy=function(node){node=d.byId(node);try{if(!_22f||_22f.ownerDocument!=node.ownerDocument){_22f=node.ownerDocument.createElement("div");}_22f.appendChild(node.parentNode?node.parentNode.removeChild(node):node);_22f.innerHTML="";}catch(e){}};dojo.isDescendant=function(node,_232){try{node=d.byId(node);_232=d.byId(_232);while(node){if(node===_232){return true;}node=node.parentNode;}}catch(e){}return false;};dojo.setSelectable=function(node,_234){node=d.byId(node);if(d.isMozilla){node.style.MozUserSelect=_234?"":"none";}else{if(d.isKhtml||d.isWebKit){node.style.KhtmlUserSelect=_234?"auto":"none";}else{if(d.isIE){var v=(node.unselectable=_234?"":"on");d.query("*",node).forEach("item.unselectable = '"+v+"'");}}}};var _236=function(node,ref){var _239=ref.parentNode;if(_239){_239.insertBefore(node,ref);}};var _23a=function(node,ref){var _23d=ref.parentNode;if(_23d){if(_23d.lastChild==ref){_23d.appendChild(node);}else{_23d.insertBefore(node,ref.nextSibling);}}};dojo.place=function(node,_23f,_240){_23f=d.byId(_23f);if(d.isString(node)){node=node.charAt(0)=="<"?d._toDom(node,_23f.ownerDocument):d.byId(node);}if(typeof _240=="number"){var cn=_23f.childNodes;if(!cn.length||cn.length<=_240){_23f.appendChild(node);}else{_236(node,cn[_240<0?0:_240]);}}else{switch(_240){case "before":_236(node,_23f);break;case "after":_23a(node,_23f);break;case "replace":_23f.parentNode.replaceChild(node,_23f);break;case "only":d.empty(_23f);_23f.appendChild(node);break;case "first":if(_23f.firstChild){_236(node,_23f.firstChild);break;}default:_23f.appendChild(node);}}return node;};dojo.boxModel="content-box";if(d.isIE){var _dcm=document.compatMode;d.boxModel=_dcm=="BackCompat"||_dcm=="QuirksMode"||d.isIE<6?"border-box":"content-box";}var gcs;if(d.isWebKit){gcs=function(node){var s;if(node instanceof HTMLElement){var dv=node.ownerDocument.defaultView;s=dv.getComputedStyle(node,null);if(!s&&node.style){node.style.display="";s=dv.getComputedStyle(node,null);}}return s||{};};}else{if(d.isIE){gcs=function(node){return node.nodeType==1?node.currentStyle:{};};}else{gcs=function(node){return node instanceof HTMLElement?node.ownerDocument.defaultView.getComputedStyle(node,null):{};};}}dojo.getComputedStyle=gcs;if(!d.isIE){d._toPixelValue=function(_249,_24a){return parseFloat(_24a)||0;};}else{d._toPixelValue=function(_24b,_24c){if(!_24c){return 0;}if(_24c=="medium"){return 4;}if(_24c.slice&&_24c.slice(-2)=="px"){return parseFloat(_24c);}with(_24b){var _24d=style.left;var _24e=runtimeStyle.left;runtimeStyle.left=currentStyle.left;try{style.left=_24c;_24c=style.pixelLeft;}catch(e){_24c=0;}style.left=_24d;runtimeStyle.left=_24e;}return _24c;};}var px=d._toPixelValue;var astr="DXImageTransform.Microsoft.Alpha";var af=function(n,f){try{return n.filters.item(astr);}catch(e){return f?{}:null;}};dojo._getOpacity=d.isIE?function(node){try{return af(node).Opacity/100;}catch(e){return 1;}}:function(node){return gcs(node).opacity;};dojo._setOpacity=d.isIE?function(node,_257){var ov=_257*100;node.style.zoom=1;af(node,1).Enabled=!(_257==1);if(!af(node)){node.style.filter+=" progid:"+astr+"(Opacity="+ov+")";}else{af(node,1).Opacity=ov;}if(node.nodeName.toLowerCase()=="tr"){d.query("> td",node).forEach(function(i){d._setOpacity(i,_257);});}return _257;}:function(node,_25b){return node.style.opacity=_25b;};var _25c={left:true,top:true};var _25d=/margin|padding|width|height|max|min|offset/;var _25e=function(node,type,_261){type=type.toLowerCase();if(d.isIE){if(_261=="auto"){if(type=="height"){return node.offsetHeight;}if(type=="width"){return node.offsetWidth;}}if(type=="fontweight"){switch(_261){case 700:return "bold";case 400:default:return "normal";}}}if(!(type in _25c)){_25c[type]=_25d.test(type);}return _25c[type]?px(node,_261):_261;};var _262=d.isIE?"styleFloat":"cssFloat",_263={"cssFloat":_262,"styleFloat":_262,"float":_262};dojo.style=function(node,_265,_266){var n=d.byId(node),args=arguments.length,op=(_265=="opacity");_265=_263[_265]||_265;if(args==3){return op?d._setOpacity(n,_266):n.style[_265]=_266;}if(args==2&&op){return d._getOpacity(n);}var s=gcs(n);if(args==2&&!d.isString(_265)){for(var x in _265){d.style(node,x,_265[x]);}return s;}return (args==1)?s:_25e(n,_265,s[_265]||n.style[_265]);};dojo._getPadExtents=function(n,_26d){var s=_26d||gcs(n),l=px(n,s.paddingLeft),t=px(n,s.paddingTop);return {l:l,t:t,w:l+px(n,s.paddingRight),h:t+px(n,s.paddingBottom)};};dojo._getBorderExtents=function(n,_272){var ne="none",s=_272||gcs(n),bl=(s.borderLeftStyle!=ne?px(n,s.borderLeftWidth):0),bt=(s.borderTopStyle!=ne?px(n,s.borderTopWidth):0);return {l:bl,t:bt,w:bl+(s.borderRightStyle!=ne?px(n,s.borderRightWidth):0),h:bt+(s.borderBottomStyle!=ne?px(n,s.borderBottomWidth):0)};};dojo._getPadBorderExtents=function(n,_278){var s=_278||gcs(n),p=d._getPadExtents(n,s),b=d._getBorderExtents(n,s);return {l:p.l+b.l,t:p.t+b.t,w:p.w+b.w,h:p.h+b.h};};dojo._getMarginExtents=function(n,_27d){var s=_27d||gcs(n),l=px(n,s.marginLeft),t=px(n,s.marginTop),r=px(n,s.marginRight),b=px(n,s.marginBottom);if(d.isWebKit&&(s.position!="absolute")){r=l;}return {l:l,t:t,w:l+r,h:t+b};};dojo._getMarginBox=function(node,_284){var s=_284||gcs(node),me=d._getMarginExtents(node,s);var l=node.offsetLeft-me.l,t=node.offsetTop-me.t,p=node.parentNode;if(d.isMoz){var sl=parseFloat(s.left),st=parseFloat(s.top);if(!isNaN(sl)&&!isNaN(st)){l=sl,t=st;}else{if(p&&p.style){var pcs=gcs(p);if(pcs.overflow!="visible"){var be=d._getBorderExtents(p,pcs);l+=be.l,t+=be.t;}}}}else{if(d.isOpera||(d.isIE>7&&!d.isQuirks)){if(p){be=d._getBorderExtents(p);l-=be.l;t-=be.t;}}}return {l:l,t:t,w:node.offsetWidth+me.w,h:node.offsetHeight+me.h};};dojo._getContentBox=function(node,_28f){var s=_28f||gcs(node),pe=d._getPadExtents(node,s),be=d._getBorderExtents(node,s),w=node.clientWidth,h;if(!w){w=node.offsetWidth,h=node.offsetHeight;}else{h=node.clientHeight,be.w=be.h=0;}if(d.isOpera){pe.l+=be.l;pe.t+=be.t;}return {l:pe.l,t:pe.t,w:w-pe.w-be.w,h:h-pe.h-be.h};};dojo._getBorderBox=function(node,_296){var s=_296||gcs(node),pe=d._getPadExtents(node,s),cb=d._getContentBox(node,s);return {l:cb.l-pe.l,t:cb.t-pe.t,w:cb.w+pe.w,h:cb.h+pe.h};};dojo._setBox=function(node,l,t,w,h,u){u=u||"px";var s=node.style;if(!isNaN(l)){s.left=l+u;}if(!isNaN(t)){s.top=t+u;}if(w>=0){s.width=w+u;}if(h>=0){s.height=h+u;}};dojo._isButtonTag=function(node){return node.tagName=="BUTTON"||node.tagName=="INPUT"&&node.getAttribute("type").toUpperCase()=="BUTTON";};dojo._usesBorderBox=function(node){var n=node.tagName;return d.boxModel=="border-box"||n=="TABLE"||d._isButtonTag(node);};dojo._setContentSize=function(node,_2a5,_2a6,_2a7){if(d._usesBorderBox(node)){var pb=d._getPadBorderExtents(node,_2a7);if(_2a5>=0){_2a5+=pb.w;}if(_2a6>=0){_2a6+=pb.h;}}d._setBox(node,NaN,NaN,_2a5,_2a6);};dojo._setMarginBox=function(node,_2aa,_2ab,_2ac,_2ad,_2ae){var s=_2ae||gcs(node),bb=d._usesBorderBox(node),pb=bb?_2b2:d._getPadBorderExtents(node,s);if(d.isWebKit){if(d._isButtonTag(node)){var ns=node.style;if(_2ac>=0&&!ns.width){ns.width="4px";}if(_2ad>=0&&!ns.height){ns.height="4px";}}}var mb=d._getMarginExtents(node,s);if(_2ac>=0){_2ac=Math.max(_2ac-pb.w-mb.w,0);}if(_2ad>=0){_2ad=Math.max(_2ad-pb.h-mb.h,0);}d._setBox(node,_2aa,_2ab,_2ac,_2ad);};var _2b2={l:0,t:0,w:0,h:0};dojo.marginBox=function(node,box){var n=d.byId(node),s=gcs(n),b=box;return !b?d._getMarginBox(n,s):d._setMarginBox(n,b.l,b.t,b.w,b.h,s);};dojo.contentBox=function(node,box){var n=d.byId(node),s=gcs(n),b=box;return !b?d._getContentBox(n,s):d._setContentSize(n,b.w,b.h,s);};var _2bf=function(node,prop){if(!(node=(node||0).parentNode)){return 0;}var val,_2c3=0,_b=d.body();while(node&&node.style){if(gcs(node).position=="fixed"){return 0;}val=node[prop];if(val){_2c3+=val-0;if(node==_b){break;}}node=node.parentNode;}return _2c3;};dojo._docScroll=function(){var _b=d.body(),_w=d.global,de=d.doc.documentElement;return {y:(_w.pageYOffset||de.scrollTop||_b.scrollTop||0),x:(_w.pageXOffset||d._fixIeBiDiScrollLeft(de.scrollLeft)||_b.scrollLeft||0)};};dojo._isBodyLtr=function(){return ("_bodyLtr" in d)?d._bodyLtr:d._bodyLtr=gcs(d.body()).direction=="ltr";};dojo._getIeDocumentElementOffset=function(){var de=d.doc.documentElement;if(d.isIE<7){return {x:d._isBodyLtr()||window.parent==window?de.clientLeft:de.offsetWidth-de.clientWidth-de.clientLeft,y:de.clientTop};}else{if(d.isIE<8){return {x:de.getBoundingClientRect().left,y:de.getBoundingClientRect().top};}else{return {x:0,y:0};}}};dojo._fixIeBiDiScrollLeft=function(_2c9){var dd=d.doc;if(d.isIE<8&&!d._isBodyLtr()){var de=dd.compatMode=="BackCompat"?dd.body:dd.documentElement;return _2c9+de.clientWidth-de.scrollWidth;}return _2c9;};dojo._abs=function(node,_2cd){var db=d.body(),dh=d.body().parentNode,ret;if(node["getBoundingClientRect"]){var _2d1=node.getBoundingClientRect();ret={x:_2d1.left,y:_2d1.top};if(d.isFF>=3){var cs=gcs(dh);ret.x-=px(dh,cs.marginLeft)+px(dh,cs.borderLeftWidth);ret.y-=px(dh,cs.marginTop)+px(dh,cs.borderTopWidth);}if(d.isIE){var _2d3=d._getIeDocumentElementOffset();ret.x-=_2d3.x+(d.isQuirks?db.clientLeft:0);ret.y-=_2d3.y+(d.isQuirks?db.clientTop:0);}}else{ret={x:0,y:0};if(node["offsetParent"]){ret.x-=_2bf(node,"scrollLeft");ret.y-=_2bf(node,"scrollTop");var _2d4=node;do{var n=_2d4.offsetLeft,t=_2d4.offsetTop;ret.x+=isNaN(n)?0:n;ret.y+=isNaN(t)?0:t;cs=gcs(_2d4);if(_2d4!=node){if(d.isFF){ret.x+=2*px(_2d4,cs.borderLeftWidth);ret.y+=2*px(_2d4,cs.borderTopWidth);}else{ret.x+=px(_2d4,cs.borderLeftWidth);ret.y+=px(_2d4,cs.borderTopWidth);}}if(d.isFF&&cs.position=="static"){var _2d7=_2d4.parentNode;while(_2d7!=_2d4.offsetParent){var pcs=gcs(_2d7);if(pcs.position=="static"){ret.x+=px(_2d4,pcs.borderLeftWidth);ret.y+=px(_2d4,pcs.borderTopWidth);}_2d7=_2d7.parentNode;}}_2d4=_2d4.offsetParent;}while((_2d4!=dh)&&_2d4);}else{if(node.x&&node.y){ret.x+=isNaN(node.x)?0:node.x;ret.y+=isNaN(node.y)?0:node.y;}}}if(_2cd){var _2d9=d._docScroll();ret.x+=_2d9.x;ret.y+=_2d9.y;}return ret;};dojo.coords=function(node,_2db){var n=d.byId(node),s=gcs(n),mb=d._getMarginBox(n,s);var abs=d._abs(n,_2db);mb.x=abs.x;mb.y=abs.y;return mb;};var _2e0=d.isIE<8;var _2e1=function(name){switch(name.toLowerCase()){case "tabindex":return _2e0?"tabIndex":"tabindex";case "readonly":return "readOnly";case "class":return "className";case "for":case "htmlfor":return _2e0?"htmlFor":"for";default:return name;}};var _2e3={colspan:"colSpan",enctype:"enctype",frameborder:"frameborder",method:"method",rowspan:"rowSpan",scrolling:"scrolling",shape:"shape",span:"span",type:"type",valuetype:"valueType",classname:"className",innerhtml:"innerHTML"};dojo.hasAttr=function(node,name){node=d.byId(node);var _2e6=_2e1(name);_2e6=_2e6=="htmlFor"?"for":_2e6;var attr=node.getAttributeNode&&node.getAttributeNode(_2e6);return attr?attr.specified:false;};var _2e8={},_ctr=0,_2ea=dojo._scopeName+"attrid",_2eb={col:1,colgroup:1,table:1,tbody:1,tfoot:1,thead:1,tr:1,title:1};dojo.attr=function(node,name,_2ee){node=d.byId(node);var args=arguments.length;if(args==2&&!d.isString(name)){for(var x in name){d.attr(node,x,name[x]);}return;}name=_2e1(name);if(args==3){if(d.isFunction(_2ee)){var _2f1=d.attr(node,_2ea);if(!_2f1){_2f1=_ctr++;d.attr(node,_2ea,_2f1);}if(!_2e8[_2f1]){_2e8[_2f1]={};}var h=_2e8[_2f1][name];if(h){d.disconnect(h);}else{try{delete node[name];}catch(e){}}_2e8[_2f1][name]=d.connect(node,name,_2ee);}else{if(typeof _2ee=="boolean"){node[name]=_2ee;}else{if(name==="style"&&!d.isString(_2ee)){d.style(node,_2ee);}else{if(name=="className"){node.className=_2ee;}else{if(name==="innerHTML"){if(d.isIE&&node.tagName.toLowerCase() in _2eb){d.empty(node);node.appendChild(d._toDom(_2ee,node.ownerDocument));}else{node[name]=_2ee;}}else{node.setAttribute(name,_2ee);}}}}}}else{var prop=_2e3[name.toLowerCase()];if(prop){return node[prop];}var _2f4=node[name];return (typeof _2f4=="boolean"||typeof _2f4=="function")?_2f4:(d.hasAttr(node,name)?node.getAttribute(name):null);}};dojo.removeAttr=function(node,name){d.byId(node).removeAttribute(_2e1(name));};dojo.create=function(tag,_2f8,_2f9,pos){var doc=d.doc;if(_2f9){_2f9=d.byId(_2f9);doc=_2f9.ownerDocument;}if(d.isString(tag)){tag=doc.createElement(tag);}if(_2f8){d.attr(tag,_2f8);}if(_2f9){d.place(tag,_2f9,pos);}return tag;};d.empty=d.isIE?function(node){node=d.byId(node);for(var c;c=node.lastChild;){d.destroy(c);}}:function(node){d.byId(node).innerHTML="";};var _2ff={option:["select"],tbody:["table"],thead:["table"],tfoot:["table"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","thead","tr"],legend:["fieldset"],caption:["table"],colgroup:["table"],col:["table","colgroup"],li:["ul"]},_300=/<\s*([\w\:]+)/,_301={},_302=0,_303="__"+d._scopeName+"ToDomId";for(var _304 in _2ff){var tw=_2ff[_304];tw.pre=_304=="option"?"<select multiple=\"multiple\">":"<"+tw.join("><")+">";tw.post="</"+tw.reverse().join("></")+">";}d._toDom=function(frag,doc){doc=doc||d.doc;var _308=doc[_303];if(!_308){doc[_303]=_308=++_302+"";_301[_308]=doc.createElement("div");}frag+="";var _309=frag.match(_300),tag=_309?_309[1].toLowerCase():"",_30b=_301[_308],wrap,i,fc,df;if(_309&&_2ff[tag]){wrap=_2ff[tag];_30b.innerHTML=wrap.pre+frag+wrap.post;for(i=wrap.length;i;--i){_30b=_30b.firstChild;}}else{_30b.innerHTML=frag;}if(_30b.childNodes.length==1){return _30b.removeChild(_30b.firstChild);}df=doc.createDocumentFragment();while(fc=_30b.firstChild){df.appendChild(fc);}return df;};var _30f="className";dojo.hasClass=function(node,_311){return ((" "+d.byId(node)[_30f]+" ").indexOf(" "+_311+" ")>=0);};dojo.addClass=function(node,_313){node=d.byId(node);var cls=node[_30f];if((" "+cls+" ").indexOf(" "+_313+" ")<0){node[_30f]=cls+(cls?" ":"")+_313;}};dojo.removeClass=function(node,_316){node=d.byId(node);var t=d.trim((" "+node[_30f]+" ").replace(" "+_316+" "," "));if(node[_30f]!=t){node[_30f]=t;}};dojo.toggleClass=function(node,_319,_31a){if(_31a===undefined){_31a=!d.hasClass(node,_319);}d[_31a?"addClass":"removeClass"](node,_319);};})();}if(!dojo._hasResource["dojo._base.NodeList"]){dojo._hasResource["dojo._base.NodeList"]=true;dojo.provide("dojo._base.NodeList");(function(){var d=dojo;var ap=Array.prototype,aps=ap.slice,apc=ap.concat;var tnl=function(a){a.constructor=d.NodeList;dojo._mixin(a,d.NodeList.prototype);return a;};var _321=function(f,a,o){a=[0].concat(aps.call(a,0));o=o||d.global;return function(node){a[0]=node;return f.apply(o,a);};};var _326=function(f,o){return function(){this.forEach(_321(f,arguments,o));return this;};};var _329=function(f,o){return function(){return this.map(_321(f,arguments,o));};};var _32c=function(f,o){return function(){return this.filter(_321(f,arguments,o));};};var _32f=function(f,g,o){return function(){var a=arguments,body=_321(f,a,o);if(g.call(o||d.global,a)){return this.map(body);}this.forEach(body);return this;};};var _335=function(a){return a.length==1&&d.isString(a[0]);};var _337=function(node){var p=node.parentNode;if(p){p.removeChild(node);}};dojo.NodeList=function(){return tnl(Array.apply(null,arguments));};var nl=d.NodeList,nlp=nl.prototype;nl._wrap=tnl;nl._adaptAsMap=_329;nl._adaptAsForEach=_326;nl._adaptAsFilter=_32c;nl._adaptWithCondition=_32f;d.forEach(["slice","splice"],function(name){var f=ap[name];nlp[name]=function(){return tnl(f.apply(this,arguments));};});d.forEach(["indexOf","lastIndexOf","every","some"],function(name){var f=d[name];nlp[name]=function(){return f.apply(d,[this].concat(aps.call(arguments,0)));};});d.forEach(["attr","style"],function(name){nlp[name]=_32f(d[name],_335);});d.forEach(["connect","addClass","removeClass","toggleClass","empty"],function(name){nlp[name]=_326(d[name]);});dojo.extend(dojo.NodeList,{concat:function(item){var t=d.isArray(this)?this:aps.call(this,0),m=d.map(arguments,function(a){return a&&!d.isArray(a)&&(a.constructor===NodeList||a.constructor==nl)?aps.call(a,0):a;});return tnl(apc.apply(t,m));},map:function(func,obj){return tnl(d.map(this,func,obj));},forEach:function(_348,_349){d.forEach(this,_348,_349);return this;},coords:_329(d.coords),place:function(_34a,_34b){var item=d.query(_34a)[0];return this.forEach(function(node){d.place(node,item,_34b);});},orphan:function(_34e){return (_34e?d._filterQueryResult(this,_34e):this).forEach(_337);},adopt:function(_34f,_350){return d.query(_34f).place(item[0],_350);},query:function(_351){if(!_351){return this;}var ret=this.map(function(node){return d.query(_351,node).filter(function(_354){return _354!==undefined;});});return tnl(apc.apply([],ret));},filter:function(_355){var a=arguments,_357=this,_358=0;if(d.isString(_355)){_357=d._filterQueryResult(this,a[0]);if(a.length==1){return _357;}_358=1;}return tnl(d.filter(_357,a[_358],a[_358+1]));},addContent:function(_359,_35a){var c=d.isString(_359)?d._toDom(_359,this[0]&&this[0].ownerDocument):_359,i,l=this.length-1;for(i=0;i<l;++i){d.place(c.cloneNode(true),this[i],_35a);}if(l>=0){d.place(c,this[l],_35a);}return this;},instantiate:function(_35d,_35e){var c=d.isFunction(_35d)?_35d:d.getObject(_35d);_35e=_35e||{};return this.forEach(function(node){new c(_35e,node);});},at:function(){var t=new dojo.NodeList();d.forEach(arguments,function(i){if(this[i]){t.push(this[i]);}},this);return t;}});d.forEach(["blur","focus","change","click","error","keydown","keypress","keyup","load","mousedown","mouseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","submit"],function(evt){var _oe="on"+evt;nlp[_oe]=function(a,b){return this.connect(_oe,a,b);};});})();}if(!dojo._hasResource["dojo._base.query"]){dojo._hasResource["dojo._base.query"]=true;if(typeof dojo!="undefined"){dojo.provide("dojo._base.query");}(function(d){var trim=d.trim;var each=d.forEach;var qlc=d._queryListCtor=d.NodeList;var _36b=d.isString;var _36c=function(){return d.doc;};var _36d=(d.isWebKit&&((_36c().compatMode)=="BackCompat"));var _36e=!!_36c().firstChild["children"]?"children":"childNodes";var _36f=">~+";var _370=false;var _371=function(){return true;};var _372=function(_373){if(_36f.indexOf(_373.slice(-1))>=0){_373+=" * ";}else{_373+=" ";}var ts=function(s,e){return trim(_373.slice(s,e));};var _377=[];var _378=-1,_379=-1,_37a=-1,_37b=-1,_37c=-1,inId=-1,_37e=-1,lc="",cc="",_381;var x=0,ql=_373.length,_384=null,_cp=null;var _386=function(){if(_37e>=0){var tv=(_37e==x)?null:ts(_37e,x);_384[(_36f.indexOf(tv)<0)?"tag":"oper"]=tv;_37e=-1;}};var _388=function(){if(inId>=0){_384.id=ts(inId,x).replace(/\\/g,"");inId=-1;}};var _389=function(){if(_37c>=0){_384.classes.push(ts(_37c+1,x).replace(/\\/g,""));_37c=-1;}};var _38a=function(){_388();_386();_389();};var _38b=function(){_38a();if(_37b>=0){_384.pseudos.push({name:ts(_37b+1,x)});}_384.loops=(_384.pseudos.length||_384.attrs.length||_384.classes.length);_384.oquery=_384.query=ts(_381,x);_384.otag=_384.tag=(_384["oper"])?null:(_384.tag||"*");if(_384.tag){_384.tag=_384.tag.toUpperCase();}if(_377.length&&(_377[_377.length-1].oper)){_384.infixOper=_377.pop();_384.query=_384.infixOper.query+" "+_384.query;}_377.push(_384);_384=null;};for(;lc=cc,cc=_373.charAt(x),x<ql;x++){if(lc=="\\"){continue;}if(!_384){_381=x;_384={query:null,pseudos:[],attrs:[],classes:[],tag:null,oper:null,id:null,getTag:function(){return (_370)?this.otag:this.tag;}};_37e=x;}if(_378>=0){if(cc=="]"){if(!_cp.attr){_cp.attr=ts(_378+1,x);}else{_cp.matchFor=ts((_37a||_378+1),x);}var cmf=_cp.matchFor;if(cmf){if((cmf.charAt(0)=="\"")||(cmf.charAt(0)=="'")){_cp.matchFor=cmf.slice(1,-1);}}_384.attrs.push(_cp);_cp=null;_378=_37a=-1;}else{if(cc=="="){var _38d=("|~^$*".indexOf(lc)>=0)?lc:"";_cp.type=_38d+cc;_cp.attr=ts(_378+1,x-_38d.length);_37a=x+1;}}}else{if(_379>=0){if(cc==")"){if(_37b>=0){_cp.value=ts(_379+1,x);}_37b=_379=-1;}}else{if(cc=="#"){_38a();inId=x+1;}else{if(cc=="."){_38a();_37c=x;}else{if(cc==":"){_38a();_37b=x;}else{if(cc=="["){_38a();_378=x;_cp={};}else{if(cc=="("){if(_37b>=0){_cp={name:ts(_37b+1,x),value:null};_384.pseudos.push(_cp);}_379=x;}else{if((cc==" ")&&(lc!=cc)){_38b();}}}}}}}}}return _377;};var _38e=function(_38f,_390){if(!_38f){return _390;}if(!_390){return _38f;}return function(){return _38f.apply(window,arguments)&&_390.apply(window,arguments);};};var _391=function(i,arr){var r=arr||[];if(i){r.push(i);}return r;};var _395=function(n){return (1==n.nodeType);};var _397="";var _398=function(elem,attr){if(!elem){return _397;}if(attr=="class"){return elem.className||_397;}if(attr=="for"){return elem.htmlFor||_397;}if(attr=="style"){return elem.style.cssText||_397;}return (_370?elem.getAttribute(attr):elem.getAttribute(attr,2))||_397;};var _39b={"*=":function(attr,_39d){return function(elem){return (_398(elem,attr).indexOf(_39d)>=0);};},"^=":function(attr,_3a0){return function(elem){return (_398(elem,attr).indexOf(_3a0)==0);};},"$=":function(attr,_3a3){var tval=" "+_3a3;return function(elem){var ea=" "+_398(elem,attr);return (ea.lastIndexOf(_3a3)==(ea.length-_3a3.length));};},"~=":function(attr,_3a8){var tval=" "+_3a8+" ";return function(elem){var ea=" "+_398(elem,attr)+" ";return (ea.indexOf(tval)>=0);};},"|=":function(attr,_3ad){var _3ae=" "+_3ad+"-";return function(elem){var ea=" "+_398(elem,attr);return ((ea==_3ad)||(ea.indexOf(_3ae)==0));};},"=":function(attr,_3b2){return function(elem){return (_398(elem,attr)==_3b2);};}};var _3b4=(typeof _36c().firstChild.nextElementSibling=="undefined");var _ns=!_3b4?"nextElementSibling":"nextSibling";var _ps=!_3b4?"previousElementSibling":"previousSibling";var _3b7=(_3b4?_395:_371);var _3b8=function(node){while(node=node[_ps]){if(_3b7(node)){return false;}}return true;};var _3ba=function(node){while(node=node[_ns]){if(_3b7(node)){return false;}}return true;};var _3bc=function(node){var root=node.parentNode;var i=0,tret=root[_36e],ci=(node["_i"]||-1),cl=(root["_l"]||-1);if(!tret){return -1;}var l=tret.length;if(cl==l&&ci>=0&&cl>=0){return ci;}root["_l"]=l;ci=-1;for(var te=root["firstElementChild"]||root["firstChild"];te;te=te[_ns]){if(_3b7(te)){te["_i"]=++i;if(node===te){ci=i;}}}return ci;};var _3c5=function(elem){return !((_3bc(elem))%2);};var _3c7=function(elem){return ((_3bc(elem))%2);};var _3c9={"checked":function(name,_3cb){return function(elem){return !!d.attr(elem,"checked");};},"first-child":function(){return _3b8;},"last-child":function(){return _3ba;},"only-child":function(name,_3ce){return function(node){if(!_3b8(node)){return false;}if(!_3ba(node)){return false;}return true;};},"empty":function(name,_3d1){return function(elem){var cn=elem.childNodes;var cnl=elem.childNodes.length;for(var x=cnl-1;x>=0;x--){var nt=cn[x].nodeType;if((nt===1)||(nt==3)){return false;}}return true;};},"contains":function(name,_3d8){var cz=_3d8.charAt(0);if(cz=="\""||cz=="'"){_3d8=_3d8.slice(1,-1);}return function(elem){return (elem.innerHTML.indexOf(_3d8)>=0);};},"not":function(name,_3dc){var p=_372(_3dc)[0];var _3de={el:1};if(p.tag!="*"){_3de.tag=1;}if(!p.classes.length){_3de.classes=1;}var ntf=_3e0(p,_3de);return function(elem){return (!ntf(elem));};},"nth-child":function(name,_3e3){var pi=parseInt;if(_3e3=="odd"){return _3c7;}else{if(_3e3=="even"){return _3c5;}}if(_3e3.indexOf("n")!=-1){var _3e5=_3e3.split("n",2);var pred=_3e5[0]?((_3e5[0]=="-")?-1:pi(_3e5[0])):1;var idx=_3e5[1]?pi(_3e5[1]):0;var lb=0,ub=-1;if(pred>0){if(idx<0){idx=(idx%pred)&&(pred+(idx%pred));}else{if(idx>0){if(idx>=pred){lb=idx-idx%pred;}idx=idx%pred;}}}else{if(pred<0){pred*=-1;if(idx>0){ub=idx;idx=idx%pred;}}}if(pred>0){return function(elem){var i=_3bc(elem);return (i>=lb)&&(ub<0||i<=ub)&&((i%pred)==idx);};}else{_3e3=idx;}}var _3ec=pi(_3e3);return function(elem){return (_3bc(elem)==_3ec);};}};var _3ee=(d.isIE)?function(cond){var clc=cond.toLowerCase();if(clc=="class"){cond="className";}return function(elem){return (_370?elem.getAttribute(cond):elem[cond]||elem[clc]);};}:function(cond){return function(elem){return (elem&&elem.getAttribute&&elem.hasAttribute(cond));};};var _3e0=function(_3f4,_3f5){if(!_3f4){return _371;}_3f5=_3f5||{};var ff=null;if(!("el" in _3f5)){ff=_38e(ff,_395);}if(!("tag" in _3f5)){if(_3f4.tag!="*"){ff=_38e(ff,function(elem){return (elem&&(elem.tagName==_3f4.getTag()));});}}if(!("classes" in _3f5)){each(_3f4.classes,function(_3f8,idx,arr){var re=new RegExp("(?:^|\\s)"+_3f8+"(?:\\s|$)");ff=_38e(ff,function(elem){return re.test(elem.className);});ff.count=idx;});}if(!("pseudos" in _3f5)){each(_3f4.pseudos,function(_3fd){var pn=_3fd.name;if(_3c9[pn]){ff=_38e(ff,_3c9[pn](pn,_3fd.value));}});}if(!("attrs" in _3f5)){each(_3f4.attrs,function(attr){var _400;var a=attr.attr;if(attr.type&&_39b[attr.type]){_400=_39b[attr.type](a,attr.matchFor);}else{if(a.length){_400=_3ee(a);}}if(_400){ff=_38e(ff,_400);}});}if(!("id" in _3f5)){if(_3f4.id){ff=_38e(ff,function(elem){return (!!elem&&(elem.id==_3f4.id));});}}if(!ff){if(!("default" in _3f5)){ff=_371;}}return ff;};var _403=function(_404){return function(node,ret,bag){while(node=node[_ns]){if(_3b4&&(!_395(node))){continue;}if((!bag||_408(node,bag))&&_404(node)){ret.push(node);}break;}return ret;};};var _409=function(_40a){return function(root,ret,bag){var te=root[_ns];while(te){if(_3b7(te)){if(bag&&!_408(te,bag)){break;}if(_40a(te)){ret.push(te);}}te=te[_ns];}return ret;};};var _40f=function(_410){_410=_410||_371;return function(root,ret,bag){var te,x=0,tret=root[_36e];while(te=tret[x++]){if(_3b7(te)&&(!bag||_408(te,bag))&&(_410(te,x))){ret.push(te);}}return ret;};};var _417=function(node,root){var pn=node.parentNode;while(pn){if(pn==root){break;}pn=pn.parentNode;}return !!pn;};var _41b={};var _41c=function(_41d){var _41e=_41b[_41d.query];if(_41e){return _41e;}var io=_41d.infixOper;var oper=(io?io.oper:"");var _421=_3e0(_41d,{el:1});var qt=_41d.tag;var _423=("*"==qt);var ecs=_36c()["getElementsByClassName"];if(!oper){if(_41d.id){_421=(!_41d.loops&&_423)?_371:_3e0(_41d,{el:1,id:1});_41e=function(root,arr){var te=d.byId(_41d.id,(root.ownerDocument||root));if(!te||!_421(te)){return;}if(9==root.nodeType){return _391(te,arr);}else{if(_417(te,root)){return _391(te,arr);}}};}else{if(ecs&&/\{\s*\[native code\]\s*\}/.test(String(ecs))&&_41d.classes.length&&!_36d){_421=_3e0(_41d,{el:1,classes:1,id:1});var _428=_41d.classes.join(" ");_41e=function(root,arr,bag){var ret=_391(0,arr),te,x=0;var tret=root.getElementsByClassName(_428);while((te=tret[x++])){if(_421(te,root)&&_408(te,bag)){ret.push(te);}}return ret;};}else{if(!_423&&!_41d.loops){_41e=function(root,arr,bag){var ret=_391(0,arr),te,x=0;var tret=root.getElementsByTagName(_41d.getTag());while((te=tret[x++])){if(_408(te,bag)){ret.push(te);}}return ret;};}else{_421=_3e0(_41d,{el:1,tag:1,id:1});_41e=function(root,arr,bag){var ret=_391(0,arr),te,x=0;var tret=root.getElementsByTagName(_41d.getTag());while((te=tret[x++])){if(_421(te,root)&&_408(te,bag)){ret.push(te);}}return ret;};}}}}else{var _43e={el:1};if(_423){_43e.tag=1;}_421=_3e0(_41d,_43e);if("+"==oper){_41e=_403(_421);}else{if("~"==oper){_41e=_409(_421);}else{if(">"==oper){_41e=_40f(_421);}}}}return _41b[_41d.query]=_41e;};var _43f=function(root,_441){var _442=_391(root),qp,x,te,qpl=_441.length,bag,ret;for(var i=0;i<qpl;i++){ret=[];qp=_441[i];x=_442.length-1;if(x>0){bag={};ret.nozip=true;}var gef=_41c(qp);while(te=_442[x--]){gef(te,ret,bag);}if(!ret.length){break;}_442=ret;}return ret;};var _44b={},_44c={};var _44d=function(_44e){var _44f=_372(trim(_44e));if(_44f.length==1){var tef=_41c(_44f[0]);return function(root){var r=tef(root,new qlc());if(r){r.nozip=true;}return r;};}return function(root){return _43f(root,_44f);};};var nua=navigator.userAgent;var wk="WebKit/";var _456=(d.isWebKit&&(nua.indexOf(wk)>0)&&(parseFloat(nua.split(wk)[1])>528));var _457=d.isIE?"commentStrip":"nozip";var qsa="querySelectorAll";var _459=(!!_36c()[qsa]&&(!d.isSafari||(d.isSafari>3.1)||_456));var _45a=function(_45b,_45c){if(_459){var _45d=_44c[_45b];if(_45d&&!_45c){return _45d;}}var _45e=_44b[_45b];if(_45e){return _45e;}var qcz=_45b.charAt(0);var _460=(-1==_45b.indexOf(" "));if((_45b.indexOf("#")>=0)&&(_460)){_45c=true;}var _461=(_459&&(!_45c)&&(_36f.indexOf(qcz)==-1)&&(!d.isIE||(_45b.indexOf(":")==-1))&&(!(_36d&&(_45b.indexOf(".")>=0)))&&(_45b.indexOf(":contains")==-1)&&(_45b.indexOf("|=")==-1));if(_461){var tq=(_36f.indexOf(_45b.charAt(_45b.length-1))>=0)?(_45b+" *"):_45b;return _44c[_45b]=function(root){try{if(!((9==root.nodeType)||_460)){throw "";}var r=root[qsa](tq);r[_457]=true;return r;}catch(e){return _45a(_45b,true)(root);}};}else{var _465=_45b.split(/\s*,\s*/);return _44b[_45b]=((_465.length<2)?_44d(_45b):function(root){var _467=0,ret=[],tp;while((tp=_465[_467++])){ret=ret.concat(_44d(tp)(root));}return ret;});}};var _46a=0;var _46b=d.isIE?function(node){if(_370){return (node.getAttribute("_uid")||node.setAttribute("_uid",++_46a)||_46a);}else{return node.uniqueID;}}:function(node){return (node._uid||(node._uid=++_46a));};var _408=function(node,bag){if(!bag){return 1;}var id=_46b(node);if(!bag[id]){return bag[id]=1;}return 0;};var _471="_zipIdx";var _zip=function(arr){if(arr&&arr.nozip){return (qlc._wrap)?qlc._wrap(arr):arr;}var ret=new qlc();if(!arr||!arr.length){return ret;}if(arr[0]){ret.push(arr[0]);}if(arr.length<2){return ret;}_46a++;if(d.isIE&&_370){var _475=_46a+"";arr[0].setAttribute(_471,_475);for(var x=1,te;te=arr[x];x++){if(arr[x].getAttribute(_471)!=_475){ret.push(te);}te.setAttribute(_471,_475);}}else{if(d.isIE&&arr.commentStrip){try{for(var x=1,te;te=arr[x];x++){if(_395(te)){ret.push(te);}}}catch(e){}}else{if(arr[0]){arr[0][_471]=_46a;}for(var x=1,te;te=arr[x];x++){if(arr[x][_471]!=_46a){ret.push(te);}te[_471]=_46a;}}}return ret;};d.query=function(_478,root){qlc=d._queryListCtor;if(!_478){return new qlc();}if(_478.constructor==qlc){return _478;}if(!_36b(_478)){return new qlc(_478);}if(_36b(root)){root=d.byId(root);if(!root){return new qlc();}}root=root||_36c();var od=root.ownerDocument||root.documentElement;_370=(root.contentType&&root.contentType=="application/xml")||(d.isOpera&&(root.doctype||od.toString()=="[object XMLDocument]"))||(!!od)&&(d.isIE?od.xml:(root.xmlVersion||od.xmlVersion));var r=_45a(_478)(root);if(r&&r.nozip&&!qlc._wrap){return r;}return _zip(r);};d.query.pseudos=_3c9;d._filterQueryResult=function(_47c,_47d){var _47e=new d._queryListCtor();var _47f=_3e0(_372(_47d)[0]);for(var x=0,te;te=_47c[x];x++){if(_47f(te)){_47e.push(te);}}return _47e;};})(this["queryPortability"]||this["acme"]||dojo);}if(!dojo._hasResource["dojo._base.xhr"]){dojo._hasResource["dojo._base.xhr"]=true;dojo.provide("dojo._base.xhr");(function(){var _d=dojo;function _483(obj,name,_486){var val=obj[name];if(_d.isString(val)){obj[name]=[val,_486];}else{if(_d.isArray(val)){val.push(_486);}else{obj[name]=_486;}}};dojo.formToObject=function(_488){var ret={};var _48a="file|submit|image|reset|button|";_d.forEach(dojo.byId(_488).elements,function(item){var _in=item.name;var type=(item.type||"").toLowerCase();if(_in&&type&&_48a.indexOf(type)==-1&&!item.disabled){if(type=="radio"||type=="checkbox"){if(item.checked){_483(ret,_in,item.value);}}else{if(item.multiple){ret[_in]=[];_d.query("option",item).forEach(function(opt){if(opt.selected){_483(ret,_in,opt.value);}});}else{_483(ret,_in,item.value);if(type=="image"){ret[_in+".x"]=ret[_in+".y"]=ret[_in].x=ret[_in].y=0;}}}}});return ret;};dojo.objectToQuery=function(map){var enc=encodeURIComponent;var _491=[];var _492={};for(var name in map){var _494=map[name];if(_494!=_492[name]){var _495=enc(name)+"=";if(_d.isArray(_494)){for(var i=0;i<_494.length;i++){_491.push(_495+enc(_494[i]));}}else{_491.push(_495+enc(_494));}}}return _491.join("&");};dojo.formToQuery=function(_497){return _d.objectToQuery(_d.formToObject(_497));};dojo.formToJson=function(_498,_499){return _d.toJson(_d.formToObject(_498),_499);};dojo.queryToObject=function(str){var ret={};var qp=str.split("&");var dec=decodeURIComponent;_d.forEach(qp,function(item){if(item.length){var _49f=item.split("=");var name=dec(_49f.shift());var val=dec(_49f.join("="));if(_d.isString(ret[name])){ret[name]=[ret[name]];}if(_d.isArray(ret[name])){ret[name].push(val);}else{ret[name]=val;}}});return ret;};dojo._blockAsync=false;dojo._contentHandlers={text:function(xhr){return xhr.responseText;},json:function(xhr){return _d.fromJson(xhr.responseText||null);},"json-comment-filtered":function(xhr){if(!dojo.config.useCommentedJson){console.warn("Consider using the standard mimetype:application/json."+" json-commenting can introduce security issues. To"+" decrease the chances of hijacking, use the standard the 'json' handler and"+" prefix your json with: {}&&\n"+"Use djConfig.useCommentedJson=true to turn off this message.");}var _4a5=xhr.responseText;var _4a6=_4a5.indexOf("/*");var _4a7=_4a5.lastIndexOf("*/");if(_4a6==-1||_4a7==-1){throw new Error("JSON was not comment filtered");}return _d.fromJson(_4a5.substring(_4a6+2,_4a7));},javascript:function(xhr){return _d.eval(xhr.responseText);},xml:function(xhr){var _4aa=xhr.responseXML;if(_d.isIE&&(!_4aa||!_4aa.documentElement)){var ms=function(n){return "MSXML"+n+".DOMDocument";};var dp=["Microsoft.XMLDOM",ms(6),ms(4),ms(3),ms(2)];_d.some(dp,function(p){try{var dom=new ActiveXObject(p);dom.async=false;dom.loadXML(xhr.responseText);_4aa=dom;}catch(e){return false;}return true;});}return _4aa;}};dojo._contentHandlers["json-comment-optional"]=function(xhr){var _4b1=_d._contentHandlers;if(xhr.responseText&&xhr.responseText.indexOf("/*")!=-1){return _4b1["json-comment-filtered"](xhr);}else{return _4b1["json"](xhr);}};dojo._ioSetArgs=function(args,_4b3,_4b4,_4b5){var _4b6={args:args,url:args.url};var _4b7=null;if(args.form){var form=_d.byId(args.form);var _4b9=form.getAttributeNode("action");_4b6.url=_4b6.url||(_4b9?_4b9.value:null);_4b7=_d.formToObject(form);}var _4ba=[{}];if(_4b7){_4ba.push(_4b7);}if(args.content){_4ba.push(args.content);}if(args.preventCache){_4ba.push({"dojo.preventCache":new Date().valueOf()});}_4b6.query=_d.objectToQuery(_d.mixin.apply(null,_4ba));_4b6.handleAs=args.handleAs||"text";var d=new _d.Deferred(_4b3);d.addCallbacks(_4b4,function(_4bc){return _4b5(_4bc,d);});var ld=args.load;if(ld&&_d.isFunction(ld)){d.addCallback(function(_4be){return ld.call(args,_4be,_4b6);});}var err=args.error;if(err&&_d.isFunction(err)){d.addErrback(function(_4c0){return err.call(args,_4c0,_4b6);});}var _4c1=args.handle;if(_4c1&&_d.isFunction(_4c1)){d.addBoth(function(_4c2){return _4c1.call(args,_4c2,_4b6);});}d.ioArgs=_4b6;return d;};var _4c3=function(dfd){dfd.canceled=true;var xhr=dfd.ioArgs.xhr;var _at=typeof xhr.abort;if(_at=="function"||_at=="object"||_at=="unknown"){xhr.abort();}var err=dfd.ioArgs.error;if(!err){err=new Error("xhr cancelled");err.dojoType="cancel";}return err;};var _4c8=function(dfd){var ret=_d._contentHandlers[dfd.ioArgs.handleAs](dfd.ioArgs.xhr);return ret===undefined?null:ret;};var _4cb=function(_4cc,dfd){console.error(_4cc);return _4cc;};var _4ce=null;var _4cf=[];var _4d0=function(){var now=(new Date()).getTime();if(!_d._blockAsync){for(var i=0,tif;i<_4cf.length&&(tif=_4cf[i]);i++){var dfd=tif.dfd;var func=function(){if(!dfd||dfd.canceled||!tif.validCheck(dfd)){_4cf.splice(i--,1);}else{if(tif.ioCheck(dfd)){_4cf.splice(i--,1);tif.resHandle(dfd);}else{if(dfd.startTime){if(dfd.startTime+(dfd.ioArgs.args.timeout||0)<now){_4cf.splice(i--,1);var err=new Error("timeout exceeded");err.dojoType="timeout";dfd.errback(err);dfd.cancel();}}}}};if(dojo.config.debugAtAllCosts){func.call(this);}else{try{func.call(this);}catch(e){dfd.errback(e);}}}}if(!_4cf.length){clearInterval(_4ce);_4ce=null;return;}};dojo._ioCancelAll=function(){try{_d.forEach(_4cf,function(i){try{i.dfd.cancel();}catch(e){}});}catch(e){}};if(_d.isIE){_d.addOnWindowUnload(_d._ioCancelAll);}_d._ioWatch=function(dfd,_4d9,_4da,_4db){var args=dfd.ioArgs.args;if(args.timeout){dfd.startTime=(new Date()).getTime();}_4cf.push({dfd:dfd,validCheck:_4d9,ioCheck:_4da,resHandle:_4db});if(!_4ce){_4ce=setInterval(_4d0,50);}if(args.sync){_4d0();}};var _4dd="application/x-www-form-urlencoded";var _4de=function(dfd){return dfd.ioArgs.xhr.readyState;};var _4e0=function(dfd){return 4==dfd.ioArgs.xhr.readyState;};var _4e2=function(dfd){var xhr=dfd.ioArgs.xhr;if(_d._isDocumentOk(xhr)){dfd.callback(dfd);}else{var err=new Error("Unable to load "+dfd.ioArgs.url+" status:"+xhr.status);err.status=xhr.status;err.responseText=xhr.responseText;dfd.errback(err);}};dojo._ioAddQueryToUrl=function(_4e6){if(_4e6.query.length){_4e6.url+=(_4e6.url.indexOf("?")==-1?"?":"&")+_4e6.query;_4e6.query=null;}};dojo.xhr=function(_4e7,args,_4e9){var dfd=_d._ioSetArgs(args,_4c3,_4c8,_4cb);dfd.ioArgs.xhr=_d._xhrObj(dfd.ioArgs.args);if(_4e9){if("postData" in args){dfd.ioArgs.query=args.postData;}else{if("putData" in args){dfd.ioArgs.query=args.putData;}}}else{_d._ioAddQueryToUrl(dfd.ioArgs);}var _4eb=dfd.ioArgs;var xhr=_4eb.xhr;xhr.open(_4e7,_4eb.url,args.sync!==true,args.user||undefined,args.password||undefined);if(args.headers){for(var hdr in args.headers){if(hdr.toLowerCase()==="content-type"&&!args.contentType){args.contentType=args.headers[hdr];}else{xhr.setRequestHeader(hdr,args.headers[hdr]);}}}xhr.setRequestHeader("Content-Type",args.contentType||_4dd);if(!args.headers||!args.headers["X-Requested-With"]){xhr.setRequestHeader("X-Requested-With","XMLHttpRequest");}if(dojo.config.debugAtAllCosts){xhr.send(_4eb.query);}else{try{xhr.send(_4eb.query);}catch(e){dfd.ioArgs.error=e;dfd.cancel();}}_d._ioWatch(dfd,_4de,_4e0,_4e2);xhr=null;return dfd;};dojo.xhrGet=function(args){return _d.xhr("GET",args);};dojo.rawXhrPost=dojo.xhrPost=function(args){return _d.xhr("POST",args,true);};dojo.rawXhrPut=dojo.xhrPut=function(args){return _d.xhr("PUT",args,true);};dojo.xhrDelete=function(args){return _d.xhr("DELETE",args);};})();}if(!dojo._hasResource["dojo._base.fx"]){dojo._hasResource["dojo._base.fx"]=true;dojo.provide("dojo._base.fx");(function(){var d=dojo;var _4f3=d.mixin;dojo._Line=function(_4f4,end){this.start=_4f4;this.end=end;};dojo._Line.prototype.getValue=function(n){return ((this.end-this.start)*n)+this.start;};d.declare("dojo._Animation",null,{constructor:function(args){_4f3(this,args);if(d.isArray(this.curve)){this.curve=new d._Line(this.curve[0],this.curve[1]);}},duration:350,repeat:0,rate:10,_percent:0,_startRepeatCount:0,_fire:function(evt,args){if(this[evt]){if(dojo.config.debugAtAllCosts){this[evt].apply(this,args||[]);}else{try{this[evt].apply(this,args||[]);}catch(e){console.error("exception in animation handler for:",evt);console.error(e);}}}return this;},play:function(_4fa,_4fb){var _t=this;if(_t._delayTimer){_t._clearTimer();}if(_4fb){_t._stopTimer();_t._active=_t._paused=false;_t._percent=0;}else{if(_t._active&&!_t._paused){return _t;}}_t._fire("beforeBegin");var de=_4fa||_t.delay,_p=dojo.hitch(_t,"_play",_4fb);if(de>0){_t._delayTimer=setTimeout(_p,de);return _t;}_p();return _t;},_play:function(_4ff){var _t=this;if(_t._delayTimer){_t._clearTimer();}_t._startTime=new Date().valueOf();if(_t._paused){_t._startTime-=_t.duration*_t._percent;}_t._endTime=_t._startTime+_t.duration;_t._active=true;_t._paused=false;var _501=_t.curve.getValue(_t._percent);if(!_t._percent){if(!_t._startRepeatCount){_t._startRepeatCount=_t.repeat;}_t._fire("onBegin",[_501]);}_t._fire("onPlay",[_501]);_t._cycle();return _t;},pause:function(){var _t=this;if(_t._delayTimer){_t._clearTimer();}_t._stopTimer();if(!_t._active){return _t;}_t._paused=true;_t._fire("onPause",[_t.curve.getValue(_t._percent)]);return _t;},gotoPercent:function(_503,_504){var _t=this;_t._stopTimer();_t._active=_t._paused=true;_t._percent=_503;if(_504){_t.play();}return _t;},stop:function(_506){var _t=this;if(_t._delayTimer){_t._clearTimer();}if(!_t._timer){return _t;}_t._stopTimer();if(_506){_t._percent=1;}_t._fire("onStop",[_t.curve.getValue(_t._percent)]);_t._active=_t._paused=false;return _t;},status:function(){if(this._active){return this._paused?"paused":"playing";}return "stopped";},_cycle:function(){var _t=this;if(_t._active){var curr=new Date().valueOf();var step=(curr-_t._startTime)/(_t._endTime-_t._startTime);if(step>=1){step=1;}_t._percent=step;if(_t.easing){step=_t.easing(step);}_t._fire("onAnimate",[_t.curve.getValue(step)]);if(_t._percent<1){_t._startTimer();}else{_t._active=false;if(_t.repeat>0){_t.repeat--;_t.play(null,true);}else{if(_t.repeat==-1){_t.play(null,true);}else{if(_t._startRepeatCount){_t.repeat=_t._startRepeatCount;_t._startRepeatCount=0;}}}_t._percent=0;_t._fire("onEnd");_t._stopTimer();}}return _t;},_clearTimer:function(){clearTimeout(this._delayTimer);delete this._delayTimer;}});var ctr=0,_50c=[],_50d=null,_50e={run:function(){}};dojo._Animation.prototype._startTimer=function(){if(!this._timer){this._timer=d.connect(_50e,"run",this,"_cycle");ctr++;}if(!_50d){_50d=setInterval(d.hitch(_50e,"run"),this.rate);}};dojo._Animation.prototype._stopTimer=function(){if(this._timer){d.disconnect(this._timer);this._timer=null;ctr--;}if(ctr<=0){clearInterval(_50d);_50d=null;ctr=0;}};var _50f=d.isIE?function(node){var ns=node.style;if(!ns.width.length&&d.style(node,"width")=="auto"){ns.width="auto";}}:function(){};dojo._fade=function(args){args.node=d.byId(args.node);var _513=_4f3({properties:{}},args),_514=(_513.properties.opacity={});_514.start=!("start" in _513)?function(){return +d.style(_513.node,"opacity")||0;}:_513.start;_514.end=_513.end;var anim=d.animateProperty(_513);d.connect(anim,"beforeBegin",d.partial(_50f,_513.node));return anim;};dojo.fadeIn=function(args){return d._fade(_4f3({end:1},args));};dojo.fadeOut=function(args){return d._fade(_4f3({end:0},args));};dojo._defaultEasing=function(n){return 0.5+((Math.sin((n+1.5)*Math.PI))/2);};var _519=function(_51a){this._properties=_51a;for(var p in _51a){var prop=_51a[p];if(prop.start instanceof d.Color){prop.tempColor=new d.Color();}}};_519.prototype.getValue=function(r){var ret={};for(var p in this._properties){var prop=this._properties[p],_521=prop.start;if(_521 instanceof d.Color){ret[p]=d.blendColors(_521,prop.end,r,prop.tempColor).toCss();}else{if(!d.isArray(_521)){ret[p]=((prop.end-_521)*r)+_521+(p!="opacity"?prop.units||"px":0);}}}return ret;};dojo.animateProperty=function(args){args.node=d.byId(args.node);if(!args.easing){args.easing=d._defaultEasing;}var anim=new d._Animation(args);d.connect(anim,"beforeBegin",anim,function(){var pm={};for(var p in this.properties){if(p=="width"||p=="height"){this.node.display="block";}var prop=this.properties[p];prop=pm[p]=_4f3({},(d.isObject(prop)?prop:{end:prop}));if(d.isFunction(prop.start)){prop.start=prop.start();}if(d.isFunction(prop.end)){prop.end=prop.end();}var _527=(p.toLowerCase().indexOf("color")>=0);function _528(node,p){var v={height:node.offsetHeight,width:node.offsetWidth}[p];if(v!==undefined){return v;}v=d.style(node,p);return (p=="opacity")?+v:(_527?v:parseFloat(v));};if(!("end" in prop)){prop.end=_528(this.node,p);}else{if(!("start" in prop)){prop.start=_528(this.node,p);}}if(_527){prop.start=new d.Color(prop.start);prop.end=new d.Color(prop.end);}else{prop.start=(p=="opacity")?+prop.start:parseFloat(prop.start);}}this.curve=new _519(pm);});d.connect(anim,"onAnimate",d.hitch(d,"style",anim.node));return anim;};dojo.anim=function(node,_52d,_52e,_52f,_530,_531){return d.animateProperty({node:node,duration:_52e||d._Animation.prototype.duration,properties:_52d,easing:_52f,onEnd:_530}).play(_531||0);};})();}if(!dojo._hasResource["dojo._base.browser"]){dojo._hasResource["dojo._base.browser"]=true;dojo.provide("dojo._base.browser");dojo.forEach(dojo.config.require,function(i){dojo["require"](i);});}if(dojo.config.afterOnLoad&&dojo.isBrowser){window.setTimeout(dojo._loadInit,1000);}})(); diff --git a/samples/src/main/java/gwtquery/samples/public/dojobench.html b/samples/src/main/java/gwtquery/samples/public/dojobench.html new file mode 100644 index 00000000..8f225a54 --- /dev/null +++ b/samples/src/main/java/gwtquery/samples/public/dojobench.html @@ -0,0 +1,3172 @@ +<html>
+<head>
+ <title>JQuery</title>
+ <script type="text/javascript" src="dojo.js"></script>
+ <script type="text/javascript">
+ window.parent.dojobenchmark = function(sel) {
+ return dojo.query(sel).length;
+ }
+ </script>
+</head>
+<body>
+<div style="display: none">
+<div style="display: none" class="head">
+ <p><a href="http://www.w3.org/"><img height=48 alt=W3C
+ src="http://www.w3.org/Icons/w3c_home"
+ width=72></a>
+
+ <h1 id="title">Selectors</h1>
+
+ <h2>W3C Working Draft 15 December 2005</h2>
+
+ <dl>
+
+ <dt>This version:
+
+ <dd><a href="http://www.w3.org/TR/2005/WD-css3-selectors-20051215">
+ http://www.w3.org/TR/2005/WD-css3-selectors-20051215</a>
+
+ <dt>Latest version:
+
+ <dd><a href="http://www.w3.org/TR/css3-selectors">
+ http://www.w3.org/TR/css3-selectors</a>
+
+ <dt>Previous version:
+
+ <dd><a href="http://www.w3.org/TR/2001/CR-css3-selectors-20011113">
+ http://www.w3.org/TR/2001/CR-css3-selectors-20011113</a>
+
+ <dt><a name=editors-list></a>Editors:
+
+ <dd class="vcard"><span class="fn">Daniel Glazman</span> (Invited
+ Expert)
+ </dd>
+
+ <dd class="vcard"><a lang="tr" class="url fn"
+ href="http://www.tantek.com/">Tantek Çelik</a>
+ (Invited Expert)
+
+ <dd class="vcard"><a href="mailto:ian@hixie.ch" class="url fn">Ian
+ Hickson</a> (<span
+ class="company"><a
+ href="http://www.google.com/">Google</a></span>)
+
+ <dd class="vcard"><span class="fn">Peter Linss</span> (former
+ editor, <span class="company"><a
+ href="http://www.netscape.com/">Netscape/AOL</a></span>)
+
+ <dd class="vcard"><span class="fn">John Williams</span> (former editor, <span
+ class="company"><a
+ href="http://www.quark.com/">Quark, Inc.</a></span>)
+
+ </dl>
+
+ <p class="copyright"><a
+ href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">
+ Copyright</a> © 2005 <a href="http://www.w3.org/"><abbr
+ title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup>
+ (<a href="http://www.csail.mit.edu/"><abbr title="Massachusetts
+ Institute of Technology">MIT</abbr></a>, <a
+ href="http://www.ercim.org/"><acronym title="European Research
+ Consortium for Informatics and Mathematics">ERCIM</acronym></a>, <a
+ href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved.
+ W3C
+ <a
+ href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
+ <a
+ href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>,
+ <a
+ href="http://www.w3.org/Consortium/Legal/copyright-documents">document
+ use</a> rules apply.
+
+ <hr title="Separator for header">
+
+</div>
+
+<h2><a name=abstract></a>Abstract</h2>
+
+<p><em>Selectors</em> are patterns that match against elements in a
+ tree. Selectors have been optimized for use with HTML and XML, and
+ are designed to be usable in performance-critical code.</p>
+
+<p><acronym title="Cascading Style Sheets">CSS</acronym> (Cascading
+ Style Sheets) is a language for describing the rendering of <acronym
+ title="Hypertext Markup Language">HTML</acronym> and <acronym
+ title="Extensible Markup Language">XML</acronym> documents on
+ screen, on paper, in speech, etc. CSS uses Selectors for binding
+ style properties to elements in the document. This document
+ describes extensions to the selectors defined in CSS level 2. These
+ extended selectors will be used by CSS level 3.
+
+<p>Selectors define the following function:</p>
+
+<pre>expression ∗ element → boolean</pre>
+
+<p>That is, given an element and a selector, this specification
+ defines whether that element matches the selector.</p>
+
+<p>These expressions can also be used, for instance, to select a set
+ of elements, or a single element from a set of elements, by
+ evaluating the expression across all the elements in a
+ subtree. <acronym title="Simple Tree Transformation
+ Sheets">STTS</acronym> (Simple Tree Transformation Sheets), a
+ language for transforming XML trees, uses this mechanism. <a
+ href="#refsSTTS">[STTS]</a></p>
+
+<h2><a name=status></a>Status of this document</h2>
+
+<p><em>This section describes the status of this document at the
+ time of its publication. Other documents may supersede this
+ document. A list of current W3C publications and the latest revision
+ of this technical report can be found in the <a
+ href="http://www.w3.org/TR/">W3C technical reports index at
+ http://www.w3.org/TR/.</a></em></p>
+
+<p>This document describes the selectors that already exist in <a
+ href="#refsCSS1"><abbr title="CSS level 1">CSS1</abbr></a> and <a
+ href="#refsCSS21"><abbr title="CSS level 2">CSS2</abbr></a>, and
+ also proposes new selectors for <abbr title="CSS level
+ 3">CSS3</abbr> and other languages that may need them.</p>
+
+<p>The CSS Working Group doesn't expect that all implementations of
+ CSS3 will have to implement all selectors. Instead, there will
+ probably be a small number of variants of CSS3, called profiles. For
+ example, it may be that only a profile for interactive user agents
+ will include all of the selectors.</p>
+
+<p>This specification is a last call working draft for the the <a
+ href="http://www.w3.org/Style/CSS/members">CSS Working Group</a>
+ (<a href="/Style/">Style Activity</a>). This
+ document is a revision of the <a
+ href="http://www.w3.org/TR/2001/CR-css3-selectors-20011113/">Candidate
+ Recommendation dated 2001 November 13</a>, and has incorporated
+ implementation feedback received in the past few years. It is
+ expected that this last call will proceed straight to Proposed
+ Recommendation stage since it is believed that interoperability will
+ be demonstrable.</p>
+
+<p>All persons are encouraged to review and implement this
+ specification and return comments to the (<a
+ href="http://lists.w3.org/Archives/Public/www-style/">archived</a>)
+ public mailing list <a
+ href="http://www.w3.org/Mail/Lists.html#www-style">www-style</a>
+ (see <a href="http://www.w3.org/Mail/Request">instructions</a>). W3C
+ Members can also send comments directly to the CSS Working
+ Group.
+ The deadline for comments is 14 January 2006.</p>
+
+<p>This is still a draft document and may be updated, replaced, or
+ obsoleted by other documents at any time. It is inappropriate to
+ cite a W3C Working Draft as other than "work in progress".
+
+<p>This document may be available in <a
+ href="http://www.w3.org/Style/css3-selectors-updates/translations">translation</a>.
+ The English version of this specification is the only normative
+ version.
+
+<div class="subtoc">
+
+ <h2><a name=contents>Table of contents</a></h2>
+
+ <ul class="toc">
+ <li class="tocline2"><a href="#context">1. Introduction</a>
+ <ul>
+ <li><a href="#dependencies">1.1. Dependencies</a></li>
+ <li><a href="#terminology">1.2. Terminology</a></li>
+ <li><a href="#changesFromCSS2">1.3. Changes from CSS2</a></li>
+ </ul>
+ <li class="tocline2"><a href="#selectors">2. Selectors</a>
+ <li class="tocline2"><a href="#casesens">3. Case sensitivity</a>
+ <li class="tocline2"><a href="#selector-syntax">4. Selector syntax</a>
+ <li class="tocline2"><a href="#grouping">5. Groups of selectors</a>
+ <li class="tocline2"><a href="#simple-selectors">6. Simple selectors</a>
+ <ul class="toc">
+ <li class="tocline3"><a href="#type-selectors">6.1. Type
+ selectors</a>
+ <ul class="toc">
+ <li class="tocline4"><a href="#typenmsp">6.1.1. Type
+ selectors and namespaces</a></li>
+ </ul>
+ <li class="tocline3"><a href="#universal-selector">6.2.
+ Universal selector</a>
+ <ul>
+ <li><a href="#univnmsp">6.2.1. Universal selector and
+ namespaces</a></li>
+ </ul>
+ <li class="tocline3"><a href="#attribute-selectors">6.3.
+ Attribute selectors</a>
+ <ul class="toc">
+ <li class="tocline4"><a
+ href="#attribute-representation">6.3.1.
+ Representation of attributes and attributes
+ values</a>
+ <li><a href="#attribute-substrings">6.3.2. Substring
+ matching attribute selectors</a>
+ <li class="tocline4"><a href="#attrnmsp">6.3.3.
+ Attribute selectors and namespaces</a>
+ <li class="tocline4"><a href="#def-values">6.3.4.
+ Default attribute values in DTDs</a></li>
+ </ul>
+ <li class="tocline3"><a href="#class-html">6.4. Class
+ selectors</a>
+ <li class="tocline3"><a href="#id-selectors">6.5. ID
+ selectors</a>
+ <li class="tocline3"><a href="#pseudo-classes">6.6.
+ Pseudo-classes</a>
+ <ul class="toc">
+ <li class="tocline4"><a href="#dynamic-pseudos">6.6.1.
+ Dynamic pseudo-classes</a>
+ <li class="tocline4"><a href="#target-pseudo">6.6.2. The
+ :target pseudo-class</a>
+ <li class="tocline4"><a href="#lang-pseudo">6.6.3. The
+ :lang() pseudo-class</a>
+ <li class="tocline4"><a href="#UIstates">6.6.4. UI
+ element states pseudo-classes</a>
+ <li class="tocline4"><a href="#structural-pseudos">6.6.5.
+ Structural pseudo-classes</a>
+ <ul>
+ <li><a href="#root-pseudo">:root
+ pseudo-class</a>
+ <li><a href="#nth-child-pseudo">:nth-child()
+ pseudo-class</a>
+ <li><a href="#nth-last-child-pseudo">:nth-last-child()</a>
+ <li><a href="#nth-of-type-pseudo">:nth-of-type()
+ pseudo-class</a>
+ <li><a href="#nth-last-of-type-pseudo">:nth-last-of-type()</a>
+ <li><a href="#first-child-pseudo">:first-child
+ pseudo-class</a>
+ <li><a href="#last-child-pseudo">:last-child
+ pseudo-class</a>
+ <li><a href="#first-of-type-pseudo">:first-of-type
+ pseudo-class</a>
+ <li><a href="#last-of-type-pseudo">:last-of-type
+ pseudo-class</a>
+ <li><a href="#only-child-pseudo">:only-child
+ pseudo-class</a>
+ <li><a href="#only-of-type-pseudo">:only-of-type
+ pseudo-class</a>
+ <li><a href="#empty-pseudo">:empty
+ pseudo-class</a></li>
+ </ul>
+ <li class="tocline4"><a href="#negation">6.6.7. The
+ negation pseudo-class</a></li>
+ </ul>
+ </li>
+ </ul>
+ <li><a href="#pseudo-elements">7. Pseudo-elements</a>
+ <ul>
+ <li><a href="#first-line">7.1. The ::first-line
+ pseudo-element</a>
+ <li><a href="#first-letter">7.2. The ::first-letter
+ pseudo-element</a>
+ <li><a href="#UIfragments">7.3. The ::selection
+ pseudo-element</a>
+ <li><a href="#gen-content">7.4. The ::before and ::after
+ pseudo-elements</a></li>
+ </ul>
+ <li class="tocline2"><a href="#combinators">8. Combinators</a>
+ <ul class="toc">
+ <li class="tocline3"><a href="#descendant-combinators">8.1.
+ Descendant combinators</a>
+ <li class="tocline3"><a href="#child-combinators">8.2. Child
+ combinators</a>
+ <li class="tocline3"><a href="#sibling-combinators">8.3. Sibling
+ combinators</a>
+ <ul class="toc">
+ <li class="tocline4"><a
+ href="#adjacent-sibling-combinators">8.3.1.
+ Adjacent sibling combinator</a>
+ <li class="tocline4"><a
+ href="#general-sibling-combinators">8.3.2.
+ General sibling combinator</a></li>
+ </ul>
+ </li>
+ </ul>
+ <li class="tocline2"><a href="#specificity">9. Calculating a selector's
+ specificity</a>
+ <li class="tocline2"><a href="#w3cselgrammar">10. The grammar of
+ Selectors</a>
+ <ul class="toc">
+ <li class="tocline3"><a href="#grammar">10.1. Grammar</a>
+ <li class="tocline3"><a href="#lex">10.2. Lexical scanner</a>
+ </li>
+ </ul>
+ <li class="tocline2"><a href="#downlevel">11. Namespaces and down-level
+ clients</a>
+ <li class="tocline2"><a href="#profiling">12. Profiles</a>
+ <li><a href="#Conformance">13. Conformance and requirements</a>
+ <li><a href="#Tests">14. Tests</a>
+ <li><a href="#ACKS">15. Acknowledgements</a>
+ <li class="tocline2"><a href="#references">16. References</a>
+ </ul>
+
+</div>
+
+<h2><a name=context>1. Introduction</a></h2>
+
+<h3><a name=dependencies></a>1.1. Dependencies</h3>
+
+<p>Some features of this specification are specific to CSS, or have
+ particular limitations or rules specific to CSS. In this
+ specification, these have been described in terms of CSS2.1. <a
+ href="#refsCSS21">[CSS21]</a></p>
+
+<h3><a name=terminology></a>1.2. Terminology</h3>
+
+<p>All of the text of this specification is normative except
+ examples, notes, and sections explicitly marked as
+ non-normative.</p>
+
+<h3><a name=changesFromCSS2></a>1.3. Changes from CSS2</h3>
+
+<p><em>This section is non-normative.</em></p>
+
+<p>The main differences between the selectors in CSS2 and those in
+ Selectors are:
+
+<ul>
+
+ <li>the list of basic definitions (selector, group of selectors,
+ simple selector, etc.) has been changed; in particular, what was
+ referred to in CSS2 as a simple selector is now called a sequence
+ of simple selectors, and the term "simple selector" is now used for
+ the components of this sequence
+ </li>
+
+ <li>an optional namespace component is now allowed in type element
+ selectors, the universal selector and attribute selectors
+ </li>
+
+ <li>a <a href="#general-sibling-combinators">new combinator</a> has been
+ introduced
+ </li>
+
+ <li>new simple selectors including substring matching attribute
+ selectors, and new pseudo-classes
+ </li>
+
+ <li>new pseudo-elements, and introduction of the "::" convention
+ for pseudo-elements
+ </li>
+
+ <li>the grammar has been rewritten</li>
+
+ <li>profiles to be added to specifications integrating Selectors
+ and defining the set of selectors which is actually supported by
+ each specification
+ </li>
+
+ <li>Selectors are now a CSS3 Module and an independent
+ specification; other specifications can now refer to this document
+ independently of CSS
+ </li>
+
+ <li>the specification now has its own test suite</li>
+
+</ul>
+
+<h2><a name=selectors></a>2. Selectors</h2>
+
+<p><em>This section is non-normative, as it merely summarizes the
+ following sections.</em></p>
+
+<p>A Selector represents a structure. This structure can be used as a
+ condition (e.g. in a CSS rule) that determines which elements a
+ selector matches in the document tree, or as a flat description of the
+ HTML or XML fragment corresponding to that structure.</p>
+
+<p>Selectors may range from simple element names to rich contextual
+ representations.</p>
+
+<p>The following table summarizes the Selector syntax:</p>
+
+<table class="selectorsReview">
+<thead>
+<tr>
+ <th class="pattern">Pattern</th>
+ <th class="meaning">Meaning</th>
+ <th class="described">Described in section</th>
+ <th class="origin">First defined in CSS level</th>
+</tr>
+<tbody>
+<tr>
+ <td class="pattern">*</td>
+ <td class="meaning">any element</td>
+ <td class="described"><a
+ href="#universal-selector">Universal
+ selector</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
+ <td class="pattern">E</td>
+ <td class="meaning">an element of type E</td>
+ <td class="described"><a
+ href="#type-selectors">Type selector</a></td>
+ <td class="origin">1</td>
+</tr>
+<tr>
+ <td class="pattern">E[foo]</td>
+ <td class="meaning">an E element with a "foo" attribute</td>
+ <td class="described"><a
+ href="#attribute-selectors">Attribute
+ selectors</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
+ <td class="pattern">E[foo="bar"]</td>
+ <td class="meaning">an E element whose "foo" attribute value is exactly
+ equal to "bar"
+ </td>
+ <td class="described"><a
+ href="#attribute-selectors">Attribute
+ selectors</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
+ <td class="pattern">E[foo~="bar"]</td>
+ <td class="meaning">an E element whose "foo" attribute value is a list of
+ space-separated values, one of which is exactly equal to "bar"
+ </td>
+ <td class="described"><a
+ href="#attribute-selectors">Attribute
+ selectors</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
+ <td class="pattern">E[foo^="bar"]</td>
+ <td class="meaning">an E element whose "foo" attribute value begins exactly
+ with the string "bar"
+ </td>
+ <td class="described"><a
+ href="#attribute-selectors">Attribute
+ selectors</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E[foo$="bar"]</td>
+ <td class="meaning">an E element whose "foo" attribute value ends exactly
+ with the string "bar"
+ </td>
+ <td class="described"><a
+ href="#attribute-selectors">Attribute
+ selectors</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E[foo*="bar"]</td>
+ <td class="meaning">an E element whose "foo" attribute value contains the
+ substring "bar"
+ </td>
+ <td class="described"><a
+ href="#attribute-selectors">Attribute
+ selectors</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E[hreflang|="en"]</td>
+ <td class="meaning">an E element whose "hreflang" attribute has a
+ hyphen-separated
+ list of values beginning (from the left) with "en"
+ </td>
+ <td class="described"><a
+ href="#attribute-selectors">Attribute
+ selectors</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
+ <td class="pattern">E:root</td>
+ <td class="meaning">an E element, root of the document</td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:nth-child(n)</td>
+ <td class="meaning">an E element, the n-th child of its parent</td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:nth-last-child(n)</td>
+ <td class="meaning">an E element, the n-th child of its parent, counting
+ from the last one
+ </td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:nth-of-type(n)</td>
+ <td class="meaning">an E element, the n-th sibling of its type</td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:nth-last-of-type(n)</td>
+ <td class="meaning">an E element, the n-th sibling of its type, counting
+ from the last one
+ </td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:first-child</td>
+ <td class="meaning">an E element, first child of its parent</td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
+ <td class="pattern">E:last-child</td>
+ <td class="meaning">an E element, last child of its parent</td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:first-of-type</td>
+ <td class="meaning">an E element, first sibling of its type</td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:last-of-type</td>
+ <td class="meaning">an E element, last sibling of its type</td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:only-child</td>
+ <td class="meaning">an E element, only child of its parent</td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:only-of-type</td>
+ <td class="meaning">an E element, only sibling of its type</td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:empty</td>
+ <td class="meaning">an E element that has no children (including text
+ nodes)
+ </td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:link<br>E:visited</td>
+ <td class="meaning">an E element being the source anchor of a hyperlink of
+ which the target is not yet visited (:link) or already visited
+ (:visited)
+ </td>
+ <td class="described"><a
+ href="#link">The link
+ pseudo-classes</a></td>
+ <td class="origin">1</td>
+</tr>
+<tr>
+ <td class="pattern">E:active<br>E:hover<br>E:focus</td>
+ <td class="meaning">an E element during certain user actions</td>
+ <td class="described"><a
+ href="#useraction-pseudos">The user
+ action pseudo-classes</a></td>
+ <td class="origin">1 and 2</td>
+</tr>
+<tr>
+ <td class="pattern">E:target</td>
+ <td class="meaning">an E element being the target of the referring URI</td>
+ <td class="described"><a
+ href="#target-pseudo">The target
+ pseudo-class</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:lang(fr)</td>
+ <td class="meaning">an element of type E in language "fr" (the document
+ language specifies how language is determined)
+ </td>
+ <td class="described"><a
+ href="#lang-pseudo">The :lang()
+ pseudo-class</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
+ <td class="pattern">E:enabled<br>E:disabled</td>
+ <td class="meaning">a user interface element E which is enabled or
+ disabled
+ </td>
+ <td class="described"><a
+ href="#UIstates">The UI element states
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:checked<!--<br>E:indeterminate--></td>
+ <td class="meaning">a user interface element E which is checked<!-- or in an
+ indeterminate state--> (for instance a radio-button or checkbox)
+ </td>
+ <td class="described"><a
+ href="#UIstates">The UI element states
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E::first-line</td>
+ <td class="meaning">the first formatted line of an E element</td>
+ <td class="described"><a
+ href="#first-line">The ::first-line
+ pseudo-element</a></td>
+ <td class="origin">1</td>
+</tr>
+<tr>
+ <td class="pattern">E::first-letter</td>
+ <td class="meaning">the first formatted letter of an E element</td>
+ <td class="described"><a
+ href="#first-letter">The ::first-letter
+ pseudo-element</a></td>
+ <td class="origin">1</td>
+</tr>
+<tr>
+ <td class="pattern">E::selection</td>
+ <td class="meaning">the portion of an E element that is currently
+ selected/highlighted by the user
+ </td>
+ <td class="described"><a
+ href="#UIfragments">The UI element
+ fragments pseudo-elements</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E::before</td>
+ <td class="meaning">generated content before an E element</td>
+ <td class="described"><a
+ href="#gen-content">The ::before
+ pseudo-element</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
+ <td class="pattern">E::after</td>
+ <td class="meaning">generated content after an E element</td>
+ <td class="described"><a
+ href="#gen-content">The ::after
+ pseudo-element</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
+ <td class="pattern">E.warning</td>
+ <td class="meaning">an E element whose class is
+ "warning" (the document language specifies how class is determined).
+ </td>
+ <td class="described"><a
+ href="#class-html">Class
+ selectors</a></td>
+ <td class="origin">1</td>
+</tr>
+<tr>
+ <td class="pattern">E#myid</td>
+ <td class="meaning">an E element with ID equal to "myid".</td>
+ <td class="described"><a
+ href="#id-selectors">ID
+ selectors</a></td>
+ <td class="origin">1</td>
+</tr>
+<tr>
+ <td class="pattern">E:not(s)</td>
+ <td class="meaning">an E element that does not match simple selector s</td>
+ <td class="described"><a
+ href="#negation">Negation
+ pseudo-class</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E F</td>
+ <td class="meaning">an F element descendant of an E element</td>
+ <td class="described"><a
+ href="#descendant-combinators">Descendant
+ combinator</a></td>
+ <td class="origin">1</td>
+</tr>
+<tr>
+ <td class="pattern">E > F</td>
+ <td class="meaning">an F element child of an E element</td>
+ <td class="described"><a
+ href="#child-combinators">Child
+ combinator</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
+ <td class="pattern">E + F</td>
+ <td class="meaning">an F element immediately preceded by an E element</td>
+ <td class="described"><a
+ href="#adjacent-sibling-combinators">Adjacent sibling combinator</a>
+ </td>
+ <td class="origin">2</td>
+</tr>
+<tr>
+ <td class="pattern">E ~ F</td>
+ <td class="meaning">an F element preceded by an E element</td>
+ <td class="described"><a
+ href="#general-sibling-combinators">General sibling combinator</a>
+ </td>
+ <td class="origin">3</td>
+</tr>
+</tbody>
+</table>
+
+<p>The meaning of each selector is derived from the table above by
+ prepending "matches" to the contents of each cell in the "Meaning"
+ column.</p>
+
+<h2><a name=casesens>3. Case sensitivity</a></h2>
+
+<p>The case sensitivity of document language element names, attribute
+ names, and attribute values in selectors depends on the document
+ language. For example, in HTML, element names are case-insensitive,
+ but in XML, they are case-sensitive.</p>
+
+<h2><a name=selector-syntax>4. Selector syntax</a></h2>
+
+<p>A <dfn><a name=selector>selector</a></dfn> is a chain of one
+ or more <a href="#sequence">sequences of simple selectors</a>
+ separated by <a href="#combinators">combinators</a>.</p>
+
+<p>A <dfn><a name=sequence>sequence of simple selectors</a></dfn>
+ is a chain of <a href="#simple-selectors-dfn">simple selectors</a>
+ that are not separated by a <a href="#combinators">combinator</a>. It
+ always begins with a <a href="#type-selectors">type selector</a> or a
+ <a href="#universal-selector">universal selector</a>. No other type
+ selector or universal selector is allowed in the sequence.</p>
+
+<p>A <dfn><a name=simple-selectors-dfn></a><a
+ href="#simple-selectors">simple selector</a></dfn> is either a <a
+ href="#type-selectors">type selector</a>, <a
+ href="#universal-selector">universal selector</a>, <a
+ href="#attribute-selectors">attribute selector</a>, <a
+ href="#class-html">class selector</a>, <a
+ href="#id-selectors">ID selector</a>, <a
+ href="#content-selectors">content selector</a>, or <a
+ href="#pseudo-classes">pseudo-class</a>. One <a
+ href="#pseudo-elements">pseudo-element</a> may be appended to the last
+ sequence of simple selectors.</p>
+
+<p><dfn>Combinators</dfn> are: white space, "greater-than
+ sign" (U+003E, <code>></code>), "plus sign" (U+002B,
+ <code>+</code>) and "tilde" (U+007E, <code>~</code>). White
+ space may appear between a combinator and the simple selectors around
+ it. <a name=whitespace></a>Only the characters "space" (U+0020), "tab"
+ (U+0009), "line feed" (U+000A), "carriage return" (U+000D), and "form
+ feed" (U+000C) can occur in white space. Other space-like characters,
+ such as "em-space" (U+2003) and "ideographic space" (U+3000), are
+ never part of white space.</p>
+
+<p>The elements of a document tree that are represented by a selector
+ are the <dfn><a name=subject></a>subjects of the selector</dfn>. A
+ selector consisting of a single sequence of simple selectors
+ represents any element satisfying its requirements. Prepending another
+ sequence of simple selectors and a combinator to a sequence imposes
+ additional matching constraints, so the subjects of a selector are
+ always a subset of the elements represented by the last sequence of
+ simple selectors.</p>
+
+<p>An empty selector, containing no sequence of simple selectors and
+ no pseudo-element, is an <a href="#Conformance">invalid
+ selector</a>.</p>
+
+<h2><a name=grouping>5. Groups of selectors</a></h2>
+
+<p>When several selectors share the same declarations, they may be
+ grouped into a comma-separated list. (A comma is U+002C.)</p>
+
+<div class="example">
+ <p>CSS examples:</p>
+
+ <p>In this example, we condense three rules with identical
+ declarations into one. Thus,</p>
+<pre>h1 { font-family: sans-serif }
+h2 { font-family: sans-serif }
+h3 { font-family: sans-serif }</pre>
+ <p>is equivalent to:</p>
+ <pre>h1, h2, h3 { font-family: sans-serif }</pre>
+</div>
+
+<p><strong>Warning</strong>: the equivalence is true in this example
+ because all the selectors are valid selectors. If just one of these
+ selectors were invalid, the entire group of selectors would be
+ invalid. This would invalidate the rule for all three heading
+ elements, whereas in the former case only one of the three individual
+ heading rules would be invalidated.</p>
+
+
+<h2><a name=simple-selectors>6. Simple selectors</a></h2>
+
+<h3><a name=type-selectors>6.1. Type selector</a></h3>
+
+<p>A <dfn>type selector</dfn> is the name of a document language
+ element type. A type selector represents an instance of the element
+ type in the document tree.</p>
+
+<div class="example">
+ <p>Example:</p>
+
+ <p>The following selector represents an <code>h1</code> element in the
+ document tree:</p>
+ <pre>h1</pre>
+</div>
+
+
+<h4><a name=typenmsp>6.1.1. Type selectors and namespaces</a></h4>
+
+<p>Type selectors allow an optional namespace (<a
+ href="#refsXMLNAMES">[XMLNAMES]</a>) component. A namespace prefix
+ that has been previously declared may be prepended to the element name
+ separated by the namespace separator "vertical bar"
+ (U+007C, <code>|</code>).</p>
+
+<p>The namespace component may be left empty to indicate that the
+ selector is only to represent elements with no declared namespace.</p>
+
+<p>An asterisk may be used for the namespace prefix, indicating that
+ the selector represents elements in any namespace (including elements
+ with no namespace).</p>
+
+<p>Element type selectors that have no namespace component (no
+ namespace separator), represent elements without regard to the
+ element's namespace (equivalent to "<code>*|</code>") unless a default
+ namespace has been declared. If a default namespace has been declared,
+ the selector will represent only elements in the default
+ namespace.</p>
+
+<p>A type selector containing a namespace prefix that has not been
+ previously declared is an <a href="#Conformance">invalid</a> selector.
+ The mechanism for declaring a namespace prefix is left up to the
+ language implementing Selectors. In CSS, such a mechanism is defined
+ in the General Syntax module.</p>
+
+<p>In a namespace-aware client, element type selectors will only match
+ against the <a
+ href="http://www.w3.org/TR/REC-xml-names/#NT-LocalPart">local
+ part</a>
+ of the element's <a
+ href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">qualified
+ name</a>. See <a href="#downlevel">below</a> for notes about matching
+ behaviors in down-level clients.</p>
+
+<p>In summary:</p>
+
+<dl>
+ <dt><code>ns|E</code></dt>
+ <dd>elements with name E in namespace ns</dd>
+ <dt><code>*|E</code></dt>
+ <dd>elements with name E in any namespace, including those without any
+ declared namespace
+ </dd>
+ <dt><code>|E</code></dt>
+ <dd>elements with name E without any declared namespace</dd>
+ <dt><code>E</code></dt>
+ <dd>if no default namespace has been specified, this is equivalent to *|E.
+ Otherwise it is equivalent to ns|E where ns is the default namespace.
+ </dd>
+</dl>
+
+<div class="example">
+ <p>CSS examples:</p>
+
+ <pre>@namespace foo url(http://www.example.com);
+ foo|h1 { color: blue }
+ foo|* { color: yellow }
+ |h1 { color: red }
+ *|h1 { color: green }
+ h1 { color: green }</pre>
+
+ <p>The first rule will match only <code>h1</code> elements in the
+ "http://www.example.com" namespace.</p>
+
+ <p>The second rule will match all elements in the
+ "http://www.example.com" namespace.</p>
+
+ <p>The third rule will match only <code>h1</code> elements without
+ any declared namespace.</p>
+
+ <p>The fourth rule will match <code>h1</code> elements in any
+ namespace (including those without any declared namespace).</p>
+
+ <p>The last rule is equivalent to the fourth rule because no default
+ namespace has been defined.</p>
+
+</div>
+
+<h3><a name=universal-selector>6.2. Universal selector</a></h3>
+
+<p>The <dfn>universal selector</dfn>, written "asterisk"
+ (<code>*</code>), represents the qualified name of any element
+ type. It represents any single element in the document tree in any
+ namespace (including those without any declared namespace) if no
+ default namespace has been specified. If a default namespace has been
+ specified, see <a href="#univnmsp">Universal selector and
+ Namespaces</a> below.</p>
+
+<p>If the universal selector is not the only component of a sequence
+ of simple selectors, the <code>*</code> may be omitted.</p>
+
+<div class="example">
+ <p>Examples:</p>
+ <ul>
+ <li><code>*[hreflang|=en]</code> and <code>[hreflang|=en]</code> are
+ equivalent,
+ </li>
+ <li><code>*.warning</code> and <code>.warning</code> are equivalent,
+ </li>
+ <li><code>*#myid</code> and <code>#myid</code> are equivalent.</li>
+ </ul>
+</div>
+
+<p class="note"><strong>Note:</strong> it is recommended that the
+ <code>*</code>, representing the universal selector, not be
+ omitted.</p>
+
+<h4><a name=univnmsp>6.2.1. Universal selector and namespaces</a></h4>
+
+<p>The universal selector allows an optional namespace component. It
+ is used as follows:</p>
+
+<dl>
+ <dt><code>ns|*</code></dt>
+ <dd>all elements in namespace ns</dd>
+ <dt><code>*|*</code></dt>
+ <dd>all elements</dd>
+ <dt><code>|*</code></dt>
+ <dd>all elements without any declared namespace</dd>
+ <dt><code>*</code></dt>
+ <dd>if no default namespace has been specified, this is equivalent to *|*.
+ Otherwise it is equivalent to ns|* where ns is the default namespace.
+ </dd>
+</dl>
+
+<p>A universal selector containing a namespace prefix that has not
+ been previously declared is an <a href="#Conformance">invalid</a>
+ selector. The mechanism for declaring a namespace prefix is left up
+ to the language implementing Selectors. In CSS, such a mechanism is
+ defined in the General Syntax module.</p>
+
+
+<h3><a name=attribute-selectors>6.3. Attribute selectors</a></h3>
+
+<p>Selectors allow the representation of an element's attributes. When
+ a selector is used as an expression to match against an element,
+ attribute selectors must be considered to match an element if that
+ element has an attribute that matches the attribute represented by the
+ attribute selector.</p>
+
+<h4><a name=attribute-representation>6.3.1. Attribute presence and values
+ selectors</a></h4>
+
+<p>CSS2 introduced four attribute selectors:</p>
+
+<dl>
+ <dt><code>[att]</code>
+ <dd>Represents an element with the <code>att</code> attribute, whatever the
+ value of
+ the attribute.
+ </dd>
+ <dt><code>[att=val]</code></dt>
+ <dd>Represents an element with the <code>att</code> attribute whose value is
+ exactly
+ "val".
+ </dd>
+ <dt><code>[att~=val]</code></dt>
+ <dd>Represents an element with the <code>att</code> attribute whose value is
+ a <a
+ href="#whitespace">whitespace</a>-separated list of words, one
+ of
+ which is exactly "val". If "val" contains whitespace, it will never
+ represent anything (since the words are <em>separated</em> by
+ spaces).
+ </dd>
+ <dt><code>[att|=val]</code>
+ <dd>Represents an element with the <code>att</code> attribute, its value
+ either
+ being exactly "val" or beginning with "val" immediately followed by
+ "-" (U+002D). This is primarily intended to allow language subcode
+ matches (e.g., the <code>hreflang</code> attribute on the
+ <code>link</code> element in HTML) as described in RFC 3066 (<a
+ href="#refsRFC3066">[RFC3066]</a>). For <code>lang</code> (or
+ <code>xml:lang</code>) language subcode matching, please see <a
+ href="#lang-pseudo">the <code>:lang</code> pseudo-class</a>.
+ </dd>
+</dl>
+
+<p>Attribute values must be identifiers or strings. The
+ case-sensitivity of attribute names and values in selectors depends on
+ the document language.</p>
+
+<div class="example">
+
+ <p>Examples:</p>
+
+ <p>The following attribute selector represents an <code>h1</code>
+ element that carries the <code>title</code> attribute, whatever its
+ value:</p>
+
+ <pre>h1[title]</pre>
+
+ <p>In the following example, the selector represents a
+ <code>span</code> element whose <code>class</code> attribute has
+ exactly the value "example":</p>
+
+ <pre>span[class="example"]</pre>
+
+ <p>Multiple attribute selectors can be used to represent several
+ attributes of an element, or several conditions on the same
+ attribute. Here, the selector represents a <code>span</code> element
+ whose <code>hello</code> attribute has exactly the value "Cleveland"
+ and whose <code>goodbye</code> attribute has exactly the value
+ "Columbus":</p>
+
+ <pre>span[hello="Cleveland"][goodbye="Columbus"]</pre>
+
+ <p>The following selectors illustrate the differences between "="
+ and "~=". The first selector will represent, for example, the value
+ "copyright copyleft copyeditor" on a <code>rel</code> attribute. The
+ second selector will only represent an <code>a</code> element with
+ an <code>href</code> attribute having the exact value
+ "http://www.w3.org/".</p>
+
+ <pre>a[rel~="copyright"]
+a[href="http://www.w3.org/"]</pre>
+
+ <p>The following selector represents a <code>link</code> element
+ whose <code>hreflang</code> attribute is exactly "fr".</p>
+
+ <pre>link[hreflang=fr]</pre>
+
+ <p>The following selector represents a <code>link</code> element for
+ which the values of the <code>hreflang</code> attribute begins with
+ "en", including "en", "en-US", and "en-cockney":</p>
+
+ <pre>link[hreflang|="en"]</pre>
+
+ <p>Similarly, the following selectors represents a
+ <code>DIALOGUE</code> element whenever it has one of two different
+ values for an attribute <code>character</code>:</p>
+
+ <pre>DIALOGUE[character=romeo]
+DIALOGUE[character=juliet]</pre>
+
+</div>
+
+<h4><a name=attribute-substrings></a>6.3.2. Substring matching attribute
+ selectors</h4>
+
+<p>Three additional attribute selectors are provided for matching
+ substrings in the value of an attribute:</p>
+
+<dl>
+ <dt><code>[att^=val]</code></dt>
+ <dd>Represents an element with the <code>att</code> attribute whose value
+ begins
+ with the prefix "val".
+ </dd>
+ <dt><code>[att$=val]</code>
+ <dd>Represents an element with the <code>att</code> attribute whose value
+ ends with
+ the suffix "val".
+ </dd>
+ <dt><code>[att*=val]</code>
+ <dd>Represents an element with the <code>att</code> attribute whose value
+ contains
+ at least one instance of the substring "val".
+ </dd>
+</dl>
+
+<p>Attribute values must be identifiers or strings. The
+ case-sensitivity of attribute names in selectors depends on the
+ document language.</p>
+
+<div class="example">
+ <p>Examples:</p>
+
+ <p>The following selector represents an HTML <code>object</code>,
+ referencing an
+ image:</p>
+ <pre>object[type^="image/"]</pre>
+ <p>The following selector represents an HTML anchor <code>a</code> with an
+ <code>href</code> attribute whose value ends with ".html".</p>
+ <pre>a[href$=".html"]</pre>
+ <p>The following selector represents an HTML paragraph with a
+ <code>title</code>
+ attribute whose value contains the substring "hello"</p>
+ <pre>p[title*="hello"]</pre>
+</div>
+
+<h4><a name=attrnmsp>6.3.3. Attribute selectors and namespaces</a></h4>
+
+<p>Attribute selectors allow an optional namespace component to the
+ attribute name. A namespace prefix that has been previously declared
+ may be prepended to the attribute name separated by the namespace
+ separator "vertical bar" (<code>|</code>). In keeping with
+ the Namespaces in the XML recommendation, default namespaces do not
+ apply to attributes, therefore attribute selectors without a namespace
+ component apply only to attributes that have no declared namespace
+ (equivalent to "<code>|attr</code>"). An asterisk may be used for the
+ namespace prefix indicating that the selector is to match all
+ attribute names without regard to the attribute's namespace.
+
+<p>An attribute selector with an attribute name containing a namespace
+ prefix that has not been previously declared is an <a
+ href="#Conformance">invalid</a> selector. The mechanism for
+ declaring
+ a namespace prefix is left up to the language implementing Selectors.
+ In CSS, such a mechanism is defined in the General Syntax module.
+
+<div class="example">
+ <p>CSS examples:</p>
+ <pre>@namespace foo "http://www.example.com";
+[foo|att=val] { color: blue }
+[*|att] { color: yellow }
+[|att] { color: green }
+[att] { color: green }</pre>
+
+ <p>The first rule will match only elements with the attribute
+ <code>att</code> in the "http://www.example.com" namespace with the
+ value "val".</p>
+
+ <p>The second rule will match only elements with the attribute
+ <code>att</code> regardless of the namespace of the attribute
+ (including no declared namespace).</p>
+
+ <p>The last two rules are equivalent and will match only elements
+ with the attribute <code>att</code> where the attribute is not
+ declared to be in a namespace.</p>
+
+</div>
+
+<h4><a name=def-values>6.3.4. Default attribute values in DTDs</a></h4>
+
+<p>Attribute selectors represent explicitly set attribute values in
+ the document tree. Default attribute values may be defined in a DTD or
+ elsewhere, but cannot always be selected by attribute
+ selectors. Selectors should be designed so that they work even if the
+ default values are not included in the document tree.</p>
+
+<p>More precisely, a UA is <em>not</em> required to read an "external
+ subset" of the DTD but <em>is</em> required to look for default
+ attribute values in the document's "internal subset." (See <a
+ href="#refsXML10">[XML10]</a> for definitions of these subsets.)</p>
+
+<p>A UA that recognizes an XML namespace <a
+ href="#refsXMLNAMES">[XMLNAMES]</a> is not required to use its
+ knowledge of that namespace to treat default attribute values as if
+ they were present in the document. (For example, an XHTML UA is not
+ required to use its built-in knowledge of the XHTML DTD.)</p>
+
+<p class="note"><strong>Note:</strong> Typically, implementations
+ choose to ignore external subsets.</p>
+
+<div class="example">
+ <p>Example:</p>
+
+ <p>Consider an element EXAMPLE with an attribute "notation" that has a
+ default value of "decimal". The DTD fragment might be</p>
+
+ <pre class="dtd-example"><!ATTLIST EXAMPLE notation (decimal,octal) "decimal"></pre>
+
+ <p>If the style sheet contains the rules</p>
+
+<pre>EXAMPLE[notation=decimal] { /*... default property settings ...*/ }
+EXAMPLE[notation=octal] { /*... other settings...*/ }</pre>
+
+ <p>the first rule will not match elements whose "notation" attribute
+ is set by default, i.e. not set explicitly. To catch all cases, the
+ attribute selector for the default value must be dropped:</p>
+
+<pre>EXAMPLE { /*... default property settings ...*/ }
+EXAMPLE[notation=octal] { /*... other settings...*/ }</pre>
+
+ <p>Here, because the selector <code>EXAMPLE[notation=octal]</code> is
+ more specific than the tag
+ selector alone, the style declarations in the second rule will override
+ those in the first for elements that have a "notation" attribute value
+ of "octal". Care has to be taken that all property declarations that
+ are to apply only to the default case are overridden in the non-default
+ cases' style rules.</p>
+
+</div>
+
+<h3><a name=class-html>6.4. Class selectors</a></h3>
+
+<p>Working with HTML, authors may use the period (U+002E,
+ <code>.</code>) notation as an alternative to the <code>~=</code>
+ notation when representing the <code>class</code> attribute. Thus, for
+ HTML, <code>div.value</code> and <code>div[class~=value]</code> have
+ the same meaning. The attribute value must immediately follow the
+ "period" (<code>.</code>).</p>
+
+<p>UAs may apply selectors using the period (.) notation in XML
+ documents if the UA has namespace-specific knowledge that allows it to
+ determine which attribute is the "class" attribute for the
+ respective namespace. One such example of namespace-specific knowledge
+ is the prose in the specification for a particular namespace (e.g. SVG
+ 1.0 <a href="#refsSVG">[SVG]</a> describes the <a
+ href="http://www.w3.org/TR/2001/PR-SVG-20010719/styling.html#ClassAttribute">SVG
+ "class" attribute</a> and how a UA should interpret it, and
+ similarly MathML 1.01 <a href="#refsMATH">[MATH]</a> describes the <a
+ href="http://www.w3.org/1999/07/REC-MathML-19990707/chapter2.html#sec2.3.4">MathML
+ "class" attribute</a>.)</p>
+
+<div class="example">
+ <p>CSS examples:</p>
+
+ <p>We can assign style information to all elements with
+ <code>class~="pastoral"</code> as follows:</p>
+
+ <pre>*.pastoral { color: green } /* all elements with class~=pastoral */</pre>
+
+ <p>or just</p>
+
+ <pre>.pastoral { color: green } /* all elements with class~=pastoral */</pre>
+
+ <p>The following assigns style only to H1 elements with
+ <code>class~="pastoral"</code>:</p>
+
+ <pre>H1.pastoral { color: green } /* H1 elements with class~=pastoral */</pre>
+
+ <p>Given these rules, the first H1 instance below would not have
+ green text, while the second would:</p>
+
+ <pre><H1>Not green</H1>
+<H1 class="pastoral">Very green</H1></pre>
+
+</div>
+
+<p>To represent a subset of "class" values, each value must be preceded
+ by a ".", in any order.</P>
+
+<div class="example">
+
+ <p>CSS example:</p>
+
+ <p>The following rule matches any P element whose "class" attribute
+ has been assigned a list of <a
+ href="#whitespace">whitespace</a>-separated values that includes
+ "pastoral" and "marine":</p>
+
+ <pre>p.pastoral.marine { color: green }</pre>
+
+ <p>This rule matches when <code>class="pastoral blue aqua
+ marine"</code> but does not match for <code>class="pastoral
+ blue"</code>.</p>
+
+</div>
+
+<p class="note"><strong>Note:</strong> Because CSS gives considerable
+ power to the "class" attribute, authors could conceivably design their
+ own "document language" based on elements with almost no associated
+ presentation (such as DIV and SPAN in HTML) and assigning style
+ information through the "class" attribute. Authors should avoid this
+ practice since the structural elements of a document language often
+ have recognized and accepted meanings and author-defined classes may
+ not.</p>
+
+<p class="note"><strong>Note:</strong> If an element has multiple
+ class attributes, their values must be concatenated with spaces
+ between the values before searching for the class. As of this time the
+ working group is not aware of any manner in which this situation can
+ be reached, however, so this behavior is explicitly non-normative in
+ this specification.</p>
+
+<h3><a name=id-selectors>6.5. ID selectors</a></h3>
+
+<p>Document languages may contain attributes that are declared to be
+ of type ID. What makes attributes of type ID special is that no two
+ such attributes can have the same value in a document, regardless of
+ the type of the elements that carry them; whatever the document
+ language, an ID typed attribute can be used to uniquely identify its
+ element. In HTML all ID attributes are named "id"; XML applications
+ may name ID attributes differently, but the same restriction
+ applies.</p>
+
+<p>An ID-typed attribute of a document language allows authors to
+ assign an identifier to one element instance in the document tree. W3C
+ ID selectors represent an element instance based on its identifier. An
+ ID selector contains a "number sign" (U+0023,
+ <code>#</code>) immediately followed by the ID value, which must be an
+ identifier.</p>
+
+<p>Selectors does not specify how a UA knows the ID-typed attribute of
+ an element. The UA may, e.g., read a document's DTD, have the
+ information hard-coded or ask the user.
+
+<div class="example">
+ <p>Examples:</p>
+
+ <p>The following ID selector represents an <code>h1</code> element
+ whose ID-typed attribute has the value "chapter1":</p>
+ <pre>h1#chapter1</pre>
+ <p>The following ID selector represents any element whose ID-typed
+ attribute has the value "chapter1":</p>
+ <pre>#chapter1</pre>
+ <p>The following selector represents any element whose ID-typed
+ attribute has the value "z98y".</p>
+ <pre>*#z98y</pre>
+</div>
+
+<p class="note"><strong>Note.</strong> In XML 1.0 <a
+ href="#refsXML10">[XML10]</a>, the information about which attribute
+ contains an element's IDs is contained in a DTD or a schema. When
+ parsing XML, UAs do not always read the DTD, and thus may not know
+ what the ID of an element is (though a UA may have namespace-specific
+ knowledge that allows it to determine which attribute is the ID
+ attribute for that namespace). If a style sheet designer knows or
+ suspects that a UA may not know what the ID of an element is, he
+ should use normal attribute selectors instead:
+ <code>[name=p371]</code> instead of <code>#p371</code>. Elements in
+ XML 1.0 documents without a DTD do not have IDs at all.</p>
+
+<p>If an element has multiple ID attributes, all of them must be
+ treated as IDs for that element for the purposes of the ID
+ selector. Such a situation could be reached using mixtures of xml:id,
+ DOM3 Core, XML DTDs, and namespace-specific knowledge.</p>
+
+<h3><a name=pseudo-classes>6.6. Pseudo-classes</a></h3>
+
+<p>The pseudo-class concept is introduced to permit selection based on
+ information that lies outside of the document tree or that cannot be
+ expressed using the other simple selectors.</p>
+
+<p>A pseudo-class always consists of a "colon"
+ (<code>:</code>) followed by the name of the pseudo-class and
+ optionally by a value between parentheses.</p>
+
+<p>Pseudo-classes are allowed in all sequences of simple selectors
+ contained in a selector. Pseudo-classes are allowed anywhere in
+ sequences of simple selectors, after the leading type selector or
+ universal selector (possibly omitted). Pseudo-class names are
+ case-insensitive. Some pseudo-classes are mutually exclusive, while
+ others can be applied simultaneously to the same
+ element. Pseudo-classes may be dynamic, in the sense that an element
+ may acquire or lose a pseudo-class while a user interacts with the
+ document.</p>
+
+
+<h4><a name=dynamic-pseudos>6.6.1. Dynamic pseudo-classes</a></h4>
+
+<p>Dynamic pseudo-classes classify elements on characteristics other
+ than their name, attributes, or content, in principle characteristics
+ that cannot be deduced from the document tree.</p>
+
+<p>Dynamic pseudo-classes do not appear in the document source or
+ document tree.</p>
+
+
+<h5>The <a name=link>link pseudo-classes: :link and :visited</a></h5>
+
+<p>User agents commonly display unvisited links differently from
+ previously visited ones. Selectors
+ provides the pseudo-classes <code>:link</code> and
+ <code>:visited</code> to distinguish them:</p>
+
+<ul>
+ <li>The <code>:link</code> pseudo-class applies to links that have
+ not yet been visited.
+ </li>
+ <li>The <code>:visited</code> pseudo-class applies once the link has
+ been visited by the user.
+ </li>
+</ul>
+
+<p>After some amount of time, user agents may choose to return a
+ visited link to the (unvisited) ':link' state.</p>
+
+<p>The two states are mutually exclusive.</p>
+
+<div class="example">
+
+ <p>Example:</p>
+
+ <p>The following selector represents links carrying class
+ <code>external</code> and already visited:</p>
+
+ <pre>a.external:visited</pre>
+
+</div>
+
+<p class="note"><strong>Note:</strong> It is possible for style sheet
+ authors to abuse the :link and :visited pseudo-classes to determine
+ which sites a user has visited without the user's consent.
+
+<p>UAs may therefore treat all links as unvisited links, or implement
+ other measures to preserve the user's privacy while rendering visited
+ and unvisited links differently.</p>
+
+<h5>The <a name=useraction-pseudos>user action pseudo-classes
+ :hover, :active, and :focus</a></h5>
+
+<p>Interactive user agents sometimes change the rendering in response
+ to user actions. Selectors provides
+ three pseudo-classes for the selection of an element the user is
+ acting on.</p>
+
+<ul>
+
+ <li>The <code>:hover</code> pseudo-class applies while the user
+ designates an element with a pointing device, but does not activate
+ it. For example, a visual user agent could apply this pseudo-class
+ when the cursor (mouse pointer) hovers over a box generated by the
+ element. User agents not that do not support <a
+ href="http://www.w3.org/TR/REC-CSS2/media.html#interactive-media-group">interactive
+ media</a> do not have to support this pseudo-class. Some conforming
+ user agents that support <a
+ href="http://www.w3.org/TR/REC-CSS2/media.html#interactive-media-group">interactive
+ media</a> may not be able to support this pseudo-class (e.g., a pen
+ device that does not detect hovering).
+ </li>
+
+ <li>The <code>:active</code> pseudo-class applies while an element
+ is being activated by the user. For example, between the times the
+ user presses the mouse button and releases it.
+ </li>
+
+ <li>The <code>:focus</code> pseudo-class applies while an element
+ has the focus (accepts keyboard or mouse events, or other forms of
+ input).
+ </li>
+
+</ul>
+
+<p>There may be document language or implementation specific limits on
+ which elements can become <code>:active</code> or acquire
+ <code>:focus</code>.</p>
+
+<p>These pseudo-classes are not mutually exclusive. An element may
+ match several pseudo-classes at the same time.</p>
+
+<p>Selectors doesn't define if the parent of an element that is
+ ':active' or ':hover' is also in that state.</p>
+
+<div class="example">
+ <p>Examples:</p>
+ <pre>a:link /* unvisited links */
+a:visited /* visited links */
+a:hover /* user hovers */
+a:active /* active links */</pre>
+ <p>An example of combining dynamic pseudo-classes:</p>
+ <pre>a:focus
+a:focus:hover</pre>
+ <p>The last selector matches <code>a</code> elements that are in
+ the pseudo-class :focus and in the pseudo-class :hover.</p>
+</div>
+
+<p class="note"><strong>Note:</strong> An element can be both ':visited'
+ and ':active' (or ':link' and ':active').</p>
+
+<h4><a name=target-pseudo>6.6.2. The target pseudo-class :target</a></h4>
+
+<p>Some URIs refer to a location within a resource. This kind of URI
+ ends with a "number sign" (#) followed by an anchor
+ identifier (called the fragment identifier).</p>
+
+<p>URIs with fragment identifiers link to a certain element within the
+ document, known as the target element. For instance, here is a URI
+ pointing to an anchor named <code>section_2</code> in an HTML
+ document:</p>
+
+<pre>http://example.com/html/top.html#section_2</pre>
+
+<p>A target element can be represented by the <code>:target</code>
+ pseudo-class. If the document's URI has no fragment identifier, then
+ the document has no target element.</p>
+
+<div class="example">
+ <p>Example:</p>
+ <pre>p.note:target</pre>
+ <p>This selector represents a <code>p</code> element of class
+ <code>note</code> that is the target element of the referring
+ URI.</p>
+</div>
+
+<div class="example">
+ <p>CSS example:</p>
+
+ <p>Here, the <code>:target</code> pseudo-class is used to make the
+ target element red and place an image before it, if there is one:</p>
+ <pre>*:target { color : red }
+*:target::before { content : url(target.png) }</pre>
+</div>
+
+<h4><a name=lang-pseudo>6.6.3. The language pseudo-class :lang</a></h4>
+
+<p>If the document language specifies how the human language of an
+ element is determined, it is possible to write selectors that
+ represent an element based on its language. For example, in HTML <a
+ href="#refsHTML4">[HTML4]</a>, the language is determined by a
+ combination of the <code>lang</code> attribute, the <code>meta</code>
+ element, and possibly by information from the protocol (such as HTTP
+ headers). XML uses an attribute called <code>xml:lang</code>, and
+ there may be other document language-specific methods for determining
+ the language.</p>
+
+<p>The pseudo-class <code>:lang(C)</code> represents an element that
+ is in language C. Whether an element is represented by a
+ <code>:lang()</code> selector is based solely on the identifier C
+ being either equal to, or a hyphen-separated substring of, the
+ element's language value, in the same way as if performed by the <a
+ href="#attribute-representation">'|='</a> operator in attribute
+ selectors. The identifier C does not have to be a valid language
+ name.</p>
+
+<p>C must not be empty. (If it is, the selector is invalid.)</p>
+
+<p class="note"><strong>Note:</strong> It is recommended that
+ documents and protocols indicate language using codes from RFC 3066 <a
+ href="#refsRFC3066">[RFC3066]</a> or its successor, and by means of
+ "xml:lang" attributes in the case of XML-based documents <a
+ href="#refsXML10">[XML10]</a>. See <a
+ href="http://www.w3.org/International/questions/qa-lang-2or3.html">
+ "FAQ: Two-letter or three-letter language codes."</a></p>
+
+<div class="example">
+ <p>Examples:</p>
+
+ <p>The two following selectors represent an HTML document that is in
+ Belgian, French, or German. The two next selectors represent
+ <code>q</code> quotations in an arbitrary element in Belgian, French,
+ or German.</p>
+ <pre>html:lang(fr-be)
+html:lang(de)
+:lang(fr-be) > q
+:lang(de) > q</pre>
+</div>
+
+<h4><a name=UIstates>6.6.4. The UI element states pseudo-classes</a></h4>
+
+<h5><a name=enableddisabled>The :enabled and :disabled pseudo-classes</a></h5>
+
+<p>The <code>:enabled</code> pseudo-class allows authors to customize
+ the look of user interface elements that are enabled — which the
+ user can select or activate in some fashion (e.g. clicking on a button
+ with a mouse). There is a need for such a pseudo-class because there
+ is no way to programmatically specify the default appearance of say,
+ an enabled <code>input</code> element without also specifying what it
+ would look like when it was disabled.</p>
+
+<p>Similar to <code>:enabled</code>, <code>:disabled</code> allows the
+ author to specify precisely how a disabled or inactive user interface
+ element should look.</p>
+
+<p>Most elements will be neither enabled nor disabled. An element is
+ enabled if the user can either activate it or transfer the focus to
+ it. An element is disabled if it could be enabled, but the user cannot
+ presently activate it or transfer focus to it.</p>
+
+
+<h5><a name=checked>The :checked pseudo-class</a></h5>
+
+<p>Radio and checkbox elements can be toggled by the user. Some menu
+ items are "checked" when the user selects them. When such elements are
+ toggled "on" the <code>:checked</code> pseudo-class applies. The
+ <code>:checked</code> pseudo-class initially applies to such elements
+ that have the HTML4 <code>selected</code> and <code>checked</code>
+ attributes as described in <a
+ href="http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.2.1">Section
+ 17.2.1 of HTML4</a>, but of course the user can toggle "off" such
+ elements in which case the <code>:checked</code> pseudo-class would no
+ longer apply. While the <code>:checked</code> pseudo-class is dynamic
+ in nature, and is altered by user action, since it can also be based
+ on the presence of the semantic HTML4 <code>selected</code> and
+ <code>checked</code> attributes, it applies to all media.
+
+
+<h5><a name=indeterminate>The :indeterminate pseudo-class</a></h5>
+
+<div class="note">
+
+ <p>Radio and checkbox elements can be toggled by the user, but are
+ sometimes in an indeterminate state, neither checked nor unchecked.
+ This can be due to an element attribute, or DOM manipulation.</p>
+
+ <p>A future version of this specification may introduce an
+ <code>:indeterminate</code> pseudo-class that applies to such elements.
+ <!--While the <code>:indeterminate</code> pseudo-class is dynamic in
+ nature, and is altered by user action, since it can also be based on
+ the presence of an element attribute, it applies to all media.</p>
+
+ <p>Components of a radio-group initialized with no pre-selected choice
+ are an example of :indeterminate state.--></p>
+
+</div>
+
+
+<h4><a name=structural-pseudos>6.6.5. Structural pseudo-classes</a></h4>
+
+<p>Selectors introduces the concept of <dfn>structural
+ pseudo-classes</dfn> to permit selection based on extra information that
+ lies in
+ the document tree but cannot be represented by other simple selectors or
+ combinators.
+
+<p>Note that standalone pieces of PCDATA (text nodes in the DOM) are
+ not counted when calculating the position of an element in the list of
+ children of its parent. When calculating the position of an element in
+ the list of children of its parent, the index numbering starts at 1.
+
+
+<h5><a name=root-pseudo>:root pseudo-class</a></h5>
+
+<p>The <code>:root</code> pseudo-class represents an element that is
+ the root of the document. In HTML 4, this is always the
+ <code>HTML</code> element.
+
+
+<h5><a name=nth-child-pseudo>:nth-child() pseudo-class</a></h5>
+
+<p>The
+ <code>:nth-child(<var>a</var><code>n</code>+<var>b</var>)</code>
+ pseudo-class notation represents an element that has
+ <var>a</var><code>n</code>+<var>b</var>-1 siblings
+ <strong>before</strong> it in the document tree, for a given positive
+ integer or zero value of <code>n</code>, and has a parent element. In
+ other words, this matches the <var>b</var>th child of an element after
+ all the children have been split into groups of <var>a</var> elements
+ each. For example, this allows the selectors to address every other
+ row in a table, and could be used to alternate the color
+ of paragraph text in a cycle of four. The <var>a</var> and
+ <var>b</var> values must be zero, negative integers or positive
+ integers. The index of the first child of an element is 1.
+
+<p>In addition to this, <code>:nth-child()</code> can take
+ '<code>odd</code>' and '<code>even</code>' as arguments instead.
+ '<code>odd</code>' has the same signification as <code>2n+1</code>,
+ and '<code>even</code>' has the same signification as <code>2n</code>.
+
+
+<div class="example">
+ <p>Examples:</p>
+<pre>tr:nth-child(2n+1) /* represents every odd row of an HTML table */
+tr:nth-child(odd) /* same */
+tr:nth-child(2n) /* represents every even row of an HTML table */
+tr:nth-child(even) /* same */
+
+/* Alternate paragraph colours in CSS */
+p:nth-child(4n+1) { color: navy; }
+p:nth-child(4n+2) { color: green; }
+p:nth-child(4n+3) { color: maroon; }
+p:nth-child(4n+4) { color: purple; }</pre>
+</div>
+
+<p>When <var>a</var>=0, no repeating is used, so for example
+ <code>:nth-child(0n+5)</code> matches only the fifth child. When
+ <var>a</var>=0, the <var>a</var><code>n</code> part need not be
+ included, so the syntax simplifies to
+ <code>:nth-child(<var>b</var>)</code> and the last example simplifies
+ to <code>:nth-child(5)</code>.
+
+<div class="example">
+ <p>Examples:</p>
+<pre>foo:nth-child(0n+1) /* represents an element foo, first child of its parent element */
+foo:nth-child(1) /* same */</pre>
+</div>
+
+<p>When <var>a</var>=1, the number may be omitted from the rule.
+
+<div class="example">
+ <p>Examples:</p>
+
+ <p>The following selectors are therefore equivalent:</p>
+<pre>bar:nth-child(1n+0) /* represents all bar elements, specificity (0,1,1) */
+bar:nth-child(n+0) /* same */
+bar:nth-child(n) /* same */
+bar /* same but lower specificity (0,0,1) */</pre>
+</div>
+
+<p>If <var>b</var>=0, then every <var>a</var>th element is picked. In
+ such a case, the <var>b</var> part may be omitted.
+
+<div class="example">
+ <p>Examples:</p>
+<pre>tr:nth-child(2n+0) /* represents every even row of an HTML table */
+tr:nth-child(2n) /* same */</pre>
+</div>
+
+<p>If both <var>a</var> and <var>b</var> are equal to zero, the
+ pseudo-class represents no element in the document tree.</p>
+
+<p>The value <var>a</var> can be negative, but only the positive
+ values of <var>a</var><code>n</code>+<var>b</var>, for
+ <code>n</code>≥0, may represent an element in the document
+ tree.</p>
+
+<div class="example">
+ <p>Example:</p>
+ <pre>html|tr:nth-child(-n+6) /* represents the 6 first rows of XHTML tables */</pre>
+</div>
+
+<p>When the value <var>b</var> is negative, the "+" character in the
+ expression must be removed (it is effectively replaced by the "-"
+ character indicating the negative value of <var>b</var>).</p>
+
+<div class="example">
+ <p>Examples:</p>
+<pre>:nth-child(10n-1) /* represents the 9th, 19th, 29th, etc, element */
+:nth-child(10n+9) /* Same */
+:nth-child(10n+-1) /* Syntactically invalid, and would be ignored */</pre>
+</div>
+
+
+<h5><a name=nth-last-child-pseudo>:nth-last-child() pseudo-class</a></h5>
+
+<p>The <code>:nth-last-child(<var>a</var>n+<var>b</var>)</code>
+ pseudo-class notation represents an element that has
+ <var>a</var><code>n</code>+<var>b</var>-1 siblings
+ <strong>after</strong> it in the document tree, for a given positive
+ integer or zero value of <code>n</code>, and has a parent element. See
+ <code>:nth-child()</code> pseudo-class for the syntax of its argument.
+ It also accepts the '<code>even</code>' and '<code>odd</code>' values
+ as arguments.
+
+
+<div class="example">
+ <p>Examples:</p>
+<pre>tr:nth-last-child(-n+2) /* represents the two last rows of an HTML table */
+
+foo:nth-last-child(odd) /* represents all odd foo elements in their parent element,
+ counting from the last one */</pre>
+</div>
+
+
+<h5><a name=nth-of-type-pseudo>:nth-of-type() pseudo-class</a></h5>
+
+<p>The <code>:nth-of-type(<var>a</var>n+<var>b</var>)</code>
+ pseudo-class notation represents an element that has
+ <var>a</var><code>n</code>+<var>b</var>-1 siblings with the same
+ element name <strong>before</strong> it in the document tree, for a
+ given zero or positive integer value of <code>n</code>, and has a
+ parent element. In other words, this matches the <var>b</var>th child
+ of that type after all the children of that type have been split into
+ groups of a elements each. See <code>:nth-child()</code> pseudo-class
+ for the syntax of its argument. It also accepts the
+ '<code>even</code>' and '<code>odd</code>' values.
+
+
+<div class="example">
+ <p>CSS example:</p>
+
+ <p>This allows an author to alternate the position of floated images:</p>
+<pre>img:nth-of-type(2n+1) { float: right; }
+img:nth-of-type(2n) { float: left; }</pre>
+</div>
+
+
+<h5><a name=nth-last-of-type-pseudo>:nth-last-of-type() pseudo-class</a></h5>
+
+<p>The <code>:nth-last-of-type(<var>a</var>n+<var>b</var>)</code>
+ pseudo-class notation represents an element that has
+ <var>a</var><code>n</code>+<var>b</var>-1 siblings with the same
+ element name <strong>after</strong> it in the document tree, for a
+ given zero or positive integer value of <code>n</code>, and has a
+ parent element. See <code>:nth-child()</code> pseudo-class for the
+ syntax of its argument. It also accepts the '<code>even</code>' and '<code>odd</code>'
+ values.
+
+
+<div class="example">
+ <p>Example:</p>
+
+ <p>To represent all <code>h2</code> children of an XHTML
+ <code>body</code> except the first and last, one could use the
+ following selector:</p>
+ <pre>body > h2:nth-of-type(n+2):nth-last-of-type(n+2)</pre>
+ <p>In this case, one could also use <code>:not()</code>, although the
+ selector ends up being just as long:</p>
+ <pre>body > h2:not(:first-of-type):not(:last-of-type)</pre>
+</div>
+
+
+<h5><a name=first-child-pseudo>:first-child pseudo-class</a></h5>
+
+<p>Same as <code>:nth-child(1)</code>. The <code>:first-child</code>
+ pseudo-class
+ represents an element that is the first child of some other element.
+
+
+<div class="example">
+ <p>Examples:</p>
+
+ <p>The following selector represents a <code>p</code> element that is
+ the first child of a <code>div</code> element:</p>
+ <pre>div > p:first-child</pre>
+ <p>This selector can represent the <code>p</code> inside the
+ <code>div</code> of the following fragment:</p>
+ <pre><p> The last P before the note.</p>
+<div class="note">
+ <p> The first P inside the note.</p>
+</div></pre>
+ but cannot represent the second <code>p</code> in the following
+ fragment:
+ <pre><p> The last P before the note.</p>
+<div class="note">
+ <h2> Note </h2>
+ <p> The first P inside the note.</p>
+</div></pre>
+ <p>The following two selectors are usually equivalent:</p>
+ <pre>* > a:first-child /* a is first child of any element */
+a:first-child /* Same (assuming a is not the root element) */</pre>
+</div>
+
+<h5><a name=last-child-pseudo>:last-child pseudo-class</a></h5>
+
+<p>Same as <code>:nth-last-child(1)</code>. The <code>:last-child</code>
+ pseudo-class
+ represents an element that is the last child of some other element.
+
+<div class="example">
+ <p>Example:</p>
+
+ <p>The following selector represents a list item <code>li</code> that
+ is the last child of an ordered list <code>ol</code>.
+ <pre>ol > li:last-child</pre>
+</div>
+
+<h5><a name=first-of-type-pseudo>:first-of-type pseudo-class</a></h5>
+
+<p>Same as <code>:nth-of-type(1)</code>. The <code>:first-of-type</code>
+ pseudo-class
+ represents an element that is the first sibling of its type in the list of
+ children of its parent element.
+
+<div class="example">
+ <p>Example:</p>
+
+ <p>The following selector represents a definition title
+ <code>dt</code> inside a definition list <code>dl</code>, this
+ <code>dt</code> being the first of its type in the list of children of
+ its parent element.</p>
+ <pre>dl dt:first-of-type</pre>
+ <p>It is a valid description for the first two <code>dt</code>
+ elements in the following example but not for the third one:</p>
+<pre><dl>
+ <dt>gigogne</dt>
+ <dd>
+ <dl>
+ <dt>fusée</dt>
+ <dd>multistage rocket</dd>
+ <dt>table</dt>
+ <dd>nest of tables</dd>
+ </dl>
+ </dd>
+</dl></pre>
+</div>
+
+<h5><a name=last-of-type-pseudo>:last-of-type pseudo-class</a></h5>
+
+<p>Same as <code>:nth-last-of-type(1)</code>. The
+ <code>:last-of-type</code> pseudo-class represents an element that is
+ the last sibling of its type in the list of children of its parent
+ element.</p>
+
+<div class="example">
+ <p>Example:</p>
+
+ <p>The following selector represents the last data cell
+ <code>td</code> of a table row.</p>
+ <pre>tr > td:last-of-type</pre>
+</div>
+
+<h5><a name=only-child-pseudo>:only-child pseudo-class</a></h5>
+
+<p>Represents an element that has a parent element and whose parent
+ element has no other element children. Same as
+ <code>:first-child:last-child</code> or
+ <code>:nth-child(1):nth-last-child(1)</code>, but with a lower
+ specificity.</p>
+
+<h5><a name=only-of-type-pseudo>:only-of-type pseudo-class</a></h5>
+
+<p>Represents an element that has a parent element and whose parent
+ element has no other element children with the same element name. Same
+ as <code>:first-of-type:last-of-type</code> or
+ <code>:nth-of-type(1):nth-last-of-type(1)</code>, but with a lower
+ specificity.</p>
+
+
+<h5><a name=empty-pseudo></a>:empty pseudo-class</h5>
+
+<p>The <code>:empty</code> pseudo-class represents an element that has
+ no children at all. In terms of the DOM, only element nodes and text
+ nodes (including CDATA nodes and entity references) whose data has a
+ non-zero length must be considered as affecting emptiness; comments,
+ PIs, and other nodes must not affect whether an element is considered
+ empty or not.</p>
+
+<div class="example">
+ <p>Examples:</p>
+
+ <p><code>p:empty</code> is a valid representation of the following fragment:
+ </p>
+ <pre><p></p></pre>
+ <p><code>foo:empty</code> is not a valid representation for the
+ following fragments:</p>
+ <pre><foo>bar</foo></pre>
+ <pre><foo><bar>bla</bar></foo></pre>
+ <pre><foo>this is not <bar>:empty</bar></foo></pre>
+</div>
+
+<h4><a name=content-selectors>6.6.6. Blank</a></h4>
+<!-- It's the Return of Appendix H!!! Run away! -->
+
+<p>This section intentionally left blank.</p>
+<!-- (used to be :contains()) -->
+
+<h4><a name=negation></a>6.6.7. The negation pseudo-class</h4>
+
+<p>The negation pseudo-class, <code>:not(<var>X</var>)</code>, is a
+ functional notation taking a <a href="#simple-selectors-dfn">simple
+ selector</a> (excluding the negation pseudo-class itself and
+ pseudo-elements) as an argument. It represents an element that is not
+ represented by the argument.
+
+ <!-- pseudo-elements are not simple selectors, so the above paragraph
+may be a bit confusing -->
+
+<div class="example">
+ <p>Examples:</p>
+
+ <p>The following CSS selector matches all <code>button</code>
+ elements in an HTML document that are not disabled.</p>
+ <pre>button:not([DISABLED])</pre>
+ <p>The following selector represents all but <code>FOO</code>
+ elements.</p>
+ <pre>*:not(FOO)</pre>
+ <p>The following group of selectors represents all HTML elements
+ except links.</p>
+ <pre>html|*:not(:link):not(:visited)</pre>
+</div>
+
+<p>Default namespace declarations do not affect the argument of the
+ negation pseudo-class unless the argument is a universal selector or a
+ type selector.</p>
+
+<div class="example">
+ <p>Examples:</p>
+
+ <p>Assuming that the default namespace is bound to
+ "http://example.com/", the following selector represents all
+ elements that are not in that namespace:</p>
+ <pre>*|*:not(*)</pre>
+ <p>The following CSS selector matches any element being hovered,
+ regardless of its namespace. In particular, it is not limited to
+ only matching elements in the default namespace that are not being
+ hovered, and elements not in the default namespace don't match the
+ rule when they <em>are</em> being hovered.</p>
+ <pre>*|*:not(:hover)</pre>
+</div>
+
+<p class="note"><strong>Note</strong>: the :not() pseudo allows
+ useless selectors to be written. For instance <code>:not(*|*)</code>,
+ which represents no element at all, or <code>foo:not(bar)</code>,
+ which is equivalent to <code>foo</code> but with a higher
+ specificity.</p>
+
+<h3><a name=pseudo-elements>7. Pseudo-elements</a></h3>
+
+<p>Pseudo-elements create abstractions about the document tree beyond
+ those specified by the document language. For instance, document
+ languages do not offer mechanisms to access the first letter or first
+ line of an element's content. Pseudo-elements allow designers to refer
+ to this otherwise inaccessible information. Pseudo-elements may also
+ provide designers a way to refer to content that does not exist in the
+ source document (e.g., the <code>::before</code> and
+ <code>::after</code> pseudo-elements give access to generated
+ content).</p>
+
+<p>A pseudo-element is made of two colons (<code>::</code>) followed
+ by the name of the pseudo-element.</p>
+
+<p>This <code>::</code> notation is introduced by the current document
+ in order to establish a discrimination between pseudo-classes and
+ pseudo-elements. For compatibility with existing style sheets, user
+ agents must also accept the previous one-colon notation for
+ pseudo-elements introduced in CSS levels 1 and 2 (namely,
+ <code>:first-line</code>, <code>:first-letter</code>,
+ <code>:before</code> and <code>:after</code>). This compatibility is
+ not allowed for the new pseudo-elements introduced in CSS level 3.</p>
+
+<p>Only one pseudo-element may appear per selector, and if present it
+ must appear after the sequence of simple selectors that represents the
+ <a href="#subject">subjects</a> of the selector. <span class="note">A
+future version of this specification may allow multiple
+pesudo-elements per selector.</span></p>
+
+<h4><a name=first-line>7.1. The ::first-line pseudo-element</a></h4>
+
+<p>The <code>::first-line</code> pseudo-element describes the contents
+ of the first formatted line of an element.
+
+<div class="example">
+ <p>CSS example:</p>
+ <pre>p::first-line { text-transform: uppercase }</pre>
+ <p>The above rule means "change the letters of the first line of every
+ paragraph to uppercase".</p>
+</div>
+
+<p>The selector <code>p::first-line</code> does not match any real
+ HTML element. It does match a pseudo-element that conforming user
+ agents will insert at the beginning of every paragraph.</p>
+
+<p>Note that the length of the first line depends on a number of
+ factors, including the width of the page, the font size, etc. Thus,
+ an ordinary HTML paragraph such as:</p>
+
+<pre>
+<P>This is a somewhat long HTML
+paragraph that will be broken into several
+lines. The first line will be identified
+by a fictional tag sequence. The other lines
+will be treated as ordinary lines in the
+paragraph.</P>
+</pre>
+
+<p>the lines of which happen to be broken as follows:
+
+<pre>
+THIS IS A SOMEWHAT LONG HTML PARAGRAPH THAT
+will be broken into several lines. The first
+line will be identified by a fictional tag
+sequence. The other lines will be treated as
+ordinary lines in the paragraph.
+</pre>
+
+<p>This paragraph might be "rewritten" by user agents to include the
+ <em>fictional tag sequence</em> for <code>::first-line</code>. This
+ fictional tag sequence helps to show how properties are inherited.</p>
+
+<pre>
+<P><b><P::first-line></b> This is a somewhat long HTML
+paragraph that <b></P::first-line></b> will be broken into several
+lines. The first line will be identified
+by a fictional tag sequence. The other lines
+will be treated as ordinary lines in the
+paragraph.</P>
+</pre>
+
+<p>If a pseudo-element breaks up a real element, the desired effect
+ can often be described by a fictional tag sequence that closes and
+ then re-opens the element. Thus, if we mark up the previous paragraph
+ with a <code>span</code> element:</p>
+
+<pre>
+<P><b><SPAN class="test"></b> This is a somewhat long HTML
+paragraph that will be broken into several
+lines.<b></SPAN></b> The first line will be identified
+by a fictional tag sequence. The other lines
+will be treated as ordinary lines in the
+paragraph.</P>
+</pre>
+
+<p>the user agent could simulate start and end tags for
+ <code>span</code> when inserting the fictional tag sequence for
+ <code>::first-line</code>.
+
+<pre>
+<P><P::first-line><b><SPAN class="test"></b> This is a
+somewhat long HTML
+paragraph that will <b></SPAN></b></P::first-line><b><SPAN
+ class="test"></b> be
+broken into several
+lines.<b></SPAN></b> The first line will be identified
+by a fictional tag sequence. The other lines
+will be treated as ordinary lines in the
+paragraph.</P>
+</pre>
+
+<p>In CSS, the <code>::first-line</code> pseudo-element can only be
+ attached to a block-level element, an inline-block, a table-caption,
+ or a table-cell.</p>
+
+<p><a name="first-formatted-line"></a>The "first formatted line" of an
+ element may occur inside a
+ block-level descendant in the same flow (i.e., a block-level
+ descendant that is not positioned and not a float). E.g., the first
+ line of the <code>div</code> in <code><DIV><P>This
+ line...</P></DIV></code> is the first line of the <code>p</code>
+ (assuming
+ that both <code>p</code> and <code>div</code> are block-level).
+
+<p>The first line of a table-cell or inline-block cannot be the first
+ formatted line of an ancestor element. Thus, in <code><DIV><P
+ STYLE="display: inline-block">Hello<BR>Goodbye</P>
+ etcetera</DIV></code> the first formatted line of the
+ <code>div</code> is not the line "Hello".
+
+<p class="note">Note that the first line of the <code>p</code> in this
+ fragment: <code><p><br>First...</code> doesn't contain any
+ letters (assuming the default style for <code>br</code> in HTML
+ 4). The word "First" is not on the first formatted line.
+
+<p>A UA should act as if the fictional start tags of the
+ <code>::first-line</code> pseudo-elements were nested just inside the
+ innermost enclosing block-level element. (Since CSS1 and CSS2 were
+ silent on this case, authors should not rely on this behavior.) Here
+ is an example. The fictional tag sequence for</p>
+
+<pre>
+<DIV>
+ <P>First paragraph</P>
+ <P>Second paragraph</P>
+</DIV>
+</pre>
+
+<p>is</p>
+
+<pre>
+<DIV>
+ <P><DIV::first-line><P::first-line>First paragraph</P::first-line></DIV::first-line></P>
+ <P><P::first-line>Second paragraph</P::first-line></P>
+</DIV>
+</pre>
+
+<p>The <code>::first-line</code> pseudo-element is similar to an
+ inline-level element, but with certain restrictions. In CSS, the
+ following properties apply to a <code>::first-line</code>
+ pseudo-element: font properties, color property, background
+ properties, 'word-spacing', 'letter-spacing', 'text-decoration',
+ 'vertical-align', 'text-transform', 'line-height'. UAs may apply other
+ properties as well.</p>
+
+
+<h4><a name=first-letter>7.2. The ::first-letter pseudo-element</a></h4>
+
+<p>The <code>::first-letter</code> pseudo-element represents the first
+ letter of the first line of a block, if it is not preceded by any
+ other content (such as images or inline tables) on its line. The
+ ::first-letter pseudo-element may be used for "initial caps" and "drop
+ caps", which are common typographical effects. This type of initial
+ letter is similar to an inline-level element if its 'float' property
+ is 'none'; otherwise, it is similar to a floated element.</p>
+
+<p>In CSS, these are the properties that apply to <code>::first-letter</code>
+ pseudo-elements: font properties, 'text-decoration', 'text-transform',
+ 'letter-spacing', 'word-spacing' (when appropriate), 'line-height',
+ 'float', 'vertical-align' (only if 'float' is 'none'), margin
+ properties, padding properties, border properties, color property,
+ background properties. UAs may apply other properties as well. To
+ allow UAs to render a typographically correct drop cap or initial cap,
+ the UA may choose a line-height, width and height based on the shape
+ of the letter, unlike for normal elements.</p>
+
+<div class="example">
+ <p>Example:</p>
+
+ <p>This example shows a possible rendering of an initial cap. Note
+ that the 'line-height' that is inherited by the
+ <code>::first-letter</code>
+ pseudo-element is 1.1, but the UA in this example has computed the
+ height of the first letter differently, so that it doesn't cause any
+ unnecessary space between the first two lines. Also note that the
+ fictional start tag of the first letter is inside the <span>span</span>,
+ and thus
+ the font weight of the first letter is normal, not bold as the <span>span</span>:
+<pre>
+p { line-height: 1.1 }
+p::first-letter { font-size: 3em; font-weight: normal }
+span { font-weight: bold }
+...
+<p><span>Het hemelsche</span> gerecht heeft zich ten lange lesten<br>
+Erbarremt over my en mijn benaeuwde vesten<br>
+En arme burgery, en op mijn volcx gebed<br>
+En dagelix geschrey de bange stad ontzet.
+</pre>
+ <div class="figure">
+ <p><img src="initial-cap.png"
+ alt="Image illustrating the ::first-letter pseudo-element">
+ </div>
+</div>
+
+<div class="example">
+ <p>The following CSS will make a drop cap initial letter span about two
+ lines:</p>
+
+<pre>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
+<HTML>
+ <HEAD>
+ <TITLE>Drop cap initial letter</TITLE>
+ <STYLE type="text/css">
+ P { font-size: 12pt; line-height: 1.2 }
+ P::first-letter { font-size: 200%; font-weight: bold; float: left }
+ SPAN { text-transform: uppercase }
+ </STYLE>
+ </HEAD>
+ <BODY>
+ <P><SPAN>The first</SPAN> few words of an article
+ in The Economist.</P>
+ </BODY>
+</HTML>
+</pre>
+
+ <p>This example might be formatted as follows:</p>
+
+ <div class="figure">
+ <P><img src="first-letter.gif"
+ alt="Image illustrating the combined effect of the ::first-letter and ::first-line pseudo-elements">
+ </p>
+ </div>
+
+ <p>The <span class="index-inst" title="fictional tag
+sequence">fictional tag sequence</span> is:</p>
+
+<pre>
+<P>
+<SPAN>
+<P::first-letter>
+T
+</P::first-letter>he first
+</SPAN>
+few words of an article in the Economist.
+</P>
+</pre>
+
+ <p>Note that the <code>::first-letter</code> pseudo-element tags abut
+ the content (i.e., the initial character), while the ::first-line
+ pseudo-element start tag is inserted right after the start tag of the
+ block element.</p></div>
+
+<p>In order to achieve traditional drop caps formatting, user agents
+ may approximate font sizes, for example to align baselines. Also, the
+ glyph outline may be taken into account when formatting.</p>
+
+<p>Punctuation (i.e, characters defined in Unicode in the "open" (Ps),
+ "close" (Pe), "initial" (Pi). "final" (Pf) and "other" (Po)
+ punctuation classes), that precedes or follows the first letter should
+ be included. <a href="#refsUNICODE">[UNICODE]</a></p>
+
+<div class="figure">
+ <P><img src="first-letter2.gif" alt="Quotes that precede the
+first letter should be included."></p>
+</div>
+
+<p>The <code>::first-letter</code> also applies if the first letter is
+ in fact a digit, e.g., the "6" in "67 million dollars is a lot of
+ money."</p>
+
+<p>In CSS, the <code>::first-letter</code> pseudo-element applies to
+ block, list-item, table-cell, table-caption, and inline-block
+ elements. <span class="note">A future version of this specification
+may allow this pesudo-element to apply to more element
+types.</span></p>
+
+<p>The <code>::first-letter</code> pseudo-element can be used with all
+ such elements that contain text, or that have a descendant in the same
+ flow that contains text. A UA should act as if the fictional start tag
+ of the ::first-letter pseudo-element is just before the first text of
+ the element, even if that first text is in a descendant.</p>
+
+<div class="example">
+ <p>Example:</p>
+
+ <p>The fictional tag sequence for this HTMLfragment:
+<pre><div>
+<p>The first text.</pre>
+ <p>is:
+<pre><div>
+<p><div::first-letter><p::first-letter>T</...></...>he first text.</pre>
+</div>
+
+<p>The first letter of a table-cell or inline-block cannot be the
+ first letter of an ancestor element. Thus, in <code><DIV><P
+ STYLE="display: inline-block">Hello<BR>Goodbye</P>
+ etcetera</DIV></code> the first letter of the <code>div</code> is
+ not the
+ letter "H". In fact, the <code>div</code> doesn't have a first letter.
+
+<p>The first letter must occur on the <a
+ href="#first-formatted-line">first formatted line.</a> For example, in
+ this fragment: <code><p><br>First...</code> the first line
+ doesn't contain any letters and <code>::first-letter</code> doesn't
+ match anything (assuming the default style for <code>br</code> in HTML
+ 4). In particular, it does not match the "F" of "First."
+
+<p>In CSS, if an element is a list item ('display: list-item'), the
+ <code>::first-letter</code> applies to the first letter in the
+ principal box after the marker. UAs may ignore
+ <code>::first-letter</code> on list items with 'list-style-position:
+ inside'. If an element has <code>::before</code> or
+ <code>::after</code> content, the <code>::first-letter</code> applies
+ to the first letter of the element <em>including</em> that content.
+
+<div class="example">
+ <p>Example:</p>
+
+ <p>After the rule 'p::before {content: "Note: "}', the selector
+ 'p::first-letter' matches the "N" of "Note".</p>
+</div>
+
+<p>Some languages may have specific rules about how to treat certain
+ letter combinations. In Dutch, for example, if the letter combination
+ "ij" appears at the beginning of a word, both letters should be
+ considered within the <code>::first-letter</code> pseudo-element.
+
+<p>If the letters that would form the ::first-letter are not in the
+ same element, such as "'T" in <code><p>'<em>T...</code>, the UA
+ may create a ::first-letter pseudo-element from one of the elements,
+ both elements, or simply not create a pseudo-element.</p>
+
+<p>Similarly, if the first letter(s) of the block are not at the start
+ of the line (for example due to bidirectional reordering), then the UA
+ need not create the pseudo-element(s).
+
+<div class="example">
+ <p>Example:</p>
+
+ <p><a name="overlapping-example">The following example</a> illustrates
+ how overlapping pseudo-elements may interact. The first letter of
+ each P element will be green with a font size of '24pt'. The rest of
+ the first formatted line will be 'blue' while the rest of the
+ paragraph will be 'red'.</p>
+
+<pre>p { color: red; font-size: 12pt }
+p::first-letter { color: green; font-size: 200% }
+p::first-line { color: blue }
+
+<P>Some text that ends up on two lines</P></pre>
+
+ <p>Assuming that a line break will occur before the word "ends", the
+<span class="index-inst" title="fictional tag sequence">fictional tag
+sequence</span> for this fragment might be:</p>
+
+<pre><P>
+<P::first-line>
+<P::first-letter>
+S
+</P::first-letter>ome text that
+</P::first-line>
+ends up on two lines
+</P></pre>
+
+ <p>Note that the <code>::first-letter</code> element is inside the <code>::first-line</code>
+ element. Properties set on <code>::first-line</code> are inherited by
+ <code>::first-letter</code>, but are overridden if the same property is
+ set on
+ <code>::first-letter</code>.</p>
+</div>
+
+
+<h4><a name=UIfragments>7.3.</a> <a name=selection>The ::selection
+ pseudo-element</a></h4>
+
+<p>The <code>::selection</code> pseudo-element applies to the portion
+ of a document that has been highlighted by the user. This also
+ applies, for example, to selected text within an editable text
+ field. This pseudo-element should not be confused with the <code><a
+ href="#checked">:checked</a></code> pseudo-class (which used to be
+ named <code>:selected</code>)
+
+<p>Although the <code>::selection</code> pseudo-element is dynamic in
+ nature, and is altered by user action, it is reasonable to expect that
+ when a UA re-renders to a static medium (such as a printed page, see
+ <a href="#refsCSS21">[CSS21]</a>) which was originally rendered to a
+ dynamic medium (like screen), the UA may wish to transfer the current
+ <code>::selection</code> state to that other medium, and have all the
+ appropriate formatting and rendering take effect as well. This is not
+ required — UAs may omit the <code>::selection</code>
+ pseudo-element for static media.
+
+<p>These are the CSS properties that apply to <code>::selection</code>
+ pseudo-elements: color, background, cursor (optional), outline
+ (optional). The computed value of the 'background-image' property on
+ <code>::selection</code> may be ignored.
+
+
+<h4><a name=gen-content>7.4. The ::before and ::after pseudo-elements</a></h4>
+
+<p>The <code>::before</code> and <code>::after</code> pseudo-elements
+ can be used to describe generated content before or after an element's
+ content. They are explained in CSS 2.1 <a
+ href="#refsCSS21">[CSS21]</a>.</p>
+
+<p>When the <code>::first-letter</code> and <code>::first-line</code>
+ pseudo-elements are combined with <code>::before</code> and
+ <code>::after</code>, they apply to the first letter or line of the
+ element including the inserted text.</p>
+
+<h2><a name=combinators>8. Combinators</a></h2>
+
+<h3><a name=descendant-combinators>8.1. Descendant combinator</a></h3>
+
+<p>At times, authors may want selectors to describe an element that is
+ the descendant of another element in the document tree (e.g., "an
+ <code>EM</code> element that is contained within an <code>H1</code>
+ element"). Descendant combinators express such a relationship. A
+ descendant combinator is <a href="#whitespace">white space</a> that
+ separates two sequences of simple selectors. A selector of the form
+ "<code>A B</code>" represents an element <code>B</code> that is an
+ arbitrary descendant of some ancestor element <code>A</code>.
+
+<div class="example">
+ <p>Examples:</p>
+
+ <p>For example, consider the following selector:</p>
+ <pre>h1 em</pre>
+ <p>It represents an <code>em</code> element being the descendant of
+ an <code>h1</code> element. It is a correct and valid, but partial,
+ description of the following fragment:</p>
+ <pre><h1>This <span class="myclass">headline
+is <em>very</em> important</span></h1></pre>
+ <p>The following selector:</p>
+ <pre>div * p</pre>
+ <p>represents a <code>p</code> element that is a grandchild or later
+ descendant of a <code>div</code> element. Note the whitespace on
+ either side of the "*" is not part of the universal selector; the
+ whitespace is a combinator indicating that the DIV must be the
+ ancestor of some element, and that that element must be an ancestor
+ of the P.</p>
+
+ <p>The following selector, which combines descendant combinators and
+ <a href="#attribute-selectors">attribute selectors</a>, represents an
+ element that (1) has the <code>href</code> attribute set and (2) is
+ inside a <code>p</code> that is itself inside a <code>div</code>:</p>
+ <pre>div p *[href]</pre>
+</div>
+
+<h3><a name=child-combinators>8.2. Child combinators</a></h3>
+
+<p>A <dfn>child combinator</dfn> describes a childhood relationship
+ between two elements. A child combinator is made of the
+ "greater-than sign" (<code>></code>) character and
+ separates two sequences of simple selectors.
+
+
+<div class="example">
+ <p>Examples:</p>
+
+ <p>The following selector represents a <code>p</code> element that is
+ child of <code>body</code>:</p>
+ <pre>body > p</pre>
+ <p>The following example combines descendant combinators and child
+ combinators.</p>
+ <pre>div ol>li p</pre>
+ <!-- LEAVE THOSE SPACES OUT! see below -->
+ <p>It represents a <code>p</code> element that is a descendant of an
+ <code>li</code> element; the <code>li</code> element must be the
+ child of an <code>ol</code> element; the <code>ol</code> element must
+ be a descendant of a <code>div</code>. Notice that the optional white
+ space around the ">" combinator has been left out.</p>
+</div>
+
+<p>For information on selecting the first child of an element, please
+ see the section on the <code><a
+ href="#structural-pseudos">:first-child</a></code> pseudo-class
+ above.</p>
+
+<h3><a name=sibling-combinators>8.3. Sibling combinators</a></h3>
+
+<p>There are two different sibling combinators: the adjacent sibling
+ combinator and the general sibling combinator. In both cases,
+ non-element nodes (e.g. text between elements) are ignored when
+ considering adjacency of elements.</p>
+
+<h4><a name=adjacent-sibling-combinators>8.3.1. Adjacent sibling combinator</a>
+</h4>
+
+<p>The adjacent sibling combinator is made of the "plus
+ sign" (U+002B, <code>+</code>) character that separates two
+ sequences of simple selectors. The elements represented by the two
+ sequences share the same parent in the document tree and the element
+ represented by the first sequence immediately precedes the element
+ represented by the second one.</p>
+
+<div class="example">
+ <p>Examples:</p>
+
+ <p>The following selector represents a <code>p</code> element
+ immediately following a <code>math</code> element:</p>
+ <pre>math + p</pre>
+ <p>The following selector is conceptually similar to the one in the
+ previous example, except that it adds an attribute selector — it
+ adds a constraint to the <code>h1</code> element, that it must have
+ <code>class="opener"</code>:</p>
+ <pre>h1.opener + h2</pre>
+</div>
+
+
+<h4><a name=general-sibling-combinators>8.3.2. General sibling combinator</a>
+</h4>
+
+<p>The general sibling combinator is made of the "tilde"
+ (U+007E, <code>~</code>) character that separates two sequences of
+ simple selectors. The elements represented by the two sequences share
+ the same parent in the document tree and the element represented by
+ the first sequence precedes (not necessarily immediately) the element
+ represented by the second one.</p>
+
+<div class="example">
+ <p>Example:</p>
+ <pre>h1 ~ pre</pre>
+ <p>represents a <code>pre</code> element following an <code>h1</code>. It
+ is a correct and valid, but partial, description of:</p>
+ <pre><h1>Definition of the function a</h1>
+<p>Function a(x) has to be applied to all figures in the table.</p>
+<pre>function a(x) = 12x/13.5</pre></pre>
+</div>
+
+<h2><a name=specificity>9. Calculating a selector's specificity</a></h2>
+
+<p>A selector's specificity is calculated as follows:</p>
+
+<ul>
+ <li>count the number of ID selectors in the selector (= a)</li>
+ <li>count the number of class selectors, attributes selectors, and
+ pseudo-classes in the selector (= b)
+ </li>
+ <li>count the number of element names in the selector (= c)</li>
+ <li>ignore pseudo-elements</li>
+</ul>
+
+<p>Selectors inside <a href="#negation">the negation pseudo-class</a>
+ are counted like any other, but the negation itself does not count as
+ a pseudo-class.</p>
+
+<p>Concatenating the three numbers a-b-c (in a number system with a
+ large base) gives the specificity.</p>
+
+<div class="example">
+ <p>Examples:</p>
+<pre>* /* a=0 b=0 c=0 -> specificity = 0 */
+LI /* a=0 b=0 c=1 -> specificity = 1 */
+UL LI /* a=0 b=0 c=2 -> specificity = 2 */
+UL OL+LI /* a=0 b=0 c=3 -> specificity = 3 */
+H1 + *[REL=up] /* a=0 b=1 c=1 -> specificity = 11 */
+UL OL LI.red /* a=0 b=1 c=3 -> specificity = 13 */
+LI.red.level /* a=0 b=2 c=1 -> specificity = 21 */
+#x34y /* a=1 b=0 c=0 -> specificity = 100 */
+#s12:not(FOO) /* a=1 b=0 c=1 -> specificity = 101 */
+</pre>
+</div>
+
+<p class="note"><strong>Note:</strong> the specificity of the styles
+ specified in an HTML <code>style</code> attribute is described in CSS
+ 2.1. <a href="#refsCSS21">[CSS21]</a>.</p>
+
+<h2><a name=w3cselgrammar>10. The grammar of Selectors</a></h2>
+
+<h3><a name=grammar>10.1. Grammar</a></h3>
+
+<p>The grammar below defines the syntax of Selectors. It is globally
+ LL(1) and can be locally LL(2) (but note that most UA's should not use
+ it directly, since it doesn't express the parsing conventions). The
+ format of the productions is optimized for human consumption and some
+ shorthand notations beyond Yacc (see <a href="#refsYACC">[YACC]</a>)
+ are used:</p>
+
+<ul>
+ <li><b>*</b>: 0 or more
+ <li><b>+</b>: 1 or more
+ <li><b>?</b>: 0 or 1
+ <li><b>|</b>: separates alternatives
+ <li><b>[ ]</b>: grouping</li>
+</ul>
+
+<p>The productions are:</p>
+
+<pre>selectors_group
+ : selector [ COMMA S* selector ]*
+ ;
+
+selector
+ : simple_selector_sequence [ combinator simple_selector_sequence ]*
+ ;
+
+combinator
+ /* combinators can be surrounded by white space */
+ : PLUS S* | GREATER S* | TILDE S* | S+
+ ;
+
+simple_selector_sequence
+ : [ type_selector | universal ]
+ [ HASH | class | attrib | pseudo | negation ]*
+ | [ HASH | class | attrib | pseudo | negation ]+
+ ;
+
+type_selector
+ : [ namespace_prefix ]? element_name
+ ;
+
+namespace_prefix
+ : [ IDENT | '*' ]? '|'
+ ;
+
+element_name
+ : IDENT
+ ;
+
+universal
+ : [ namespace_prefix ]? '*'
+ ;
+
+class
+ : '.' IDENT
+ ;
+
+attrib
+ : '[' S* [ namespace_prefix ]? IDENT S*
+ [ [ PREFIXMATCH |
+ SUFFIXMATCH |
+ SUBSTRINGMATCH |
+ '=' |
+ INCLUDES |
+ DASHMATCH ] S* [ IDENT | STRING ] S*
+ ]? ']'
+ ;
+
+pseudo
+ /* '::' starts a pseudo-element, ':' a pseudo-class */
+ /* Exceptions: :first-line, :first-letter, :before and :after. */
+ /* Note that pseudo-elements are restricted to one per selector and */
+ /* occur only in the last simple_selector_sequence. */
+ : ':' ':'? [ IDENT | functional_pseudo ]
+ ;
+
+functional_pseudo
+ : FUNCTION S* expression ')'
+ ;
+
+expression
+ /* In CSS3, the expressions are identifiers, strings, */
+ /* or of the form "an+b" */
+ : [ [ PLUS | '-' | DIMENSION | NUMBER | STRING | IDENT ] S* ]+
+ ;
+
+negation
+ : NOT S* negation_arg S* ')'
+ ;
+
+negation_arg
+ : type_selector | universal | HASH | class | attrib | pseudo
+ ;</pre>
+
+
+<h3><a name=lex>10.2. Lexical scanner</a></h3>
+
+<p>The following is the <a name=x3>tokenizer</a>, written in Flex (see
+ <a href="#refsFLEX">[FLEX]</a>) notation. The tokenizer is
+ case-insensitive.</p>
+
+<p>The two occurrences of "\377" represent the highest character
+ number that current versions of Flex can deal with (decimal 255). They
+ should be read as "\4177777" (decimal 1114111), which is the highest
+ possible code point in Unicode/ISO-10646. <a
+ href="#refsUNICODE">[UNICODE]</a></p>
+
+<pre>%option case-insensitive
+
+ident [-]?{nmstart}{nmchar}*
+name {nmchar}+
+nmstart [_a-z]|{nonascii}|{escape}
+nonascii [^\0-\177]
+unicode \\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?
+escape {unicode}|\\[^\n\r\f0-9a-f]
+nmchar [_a-z0-9-]|{nonascii}|{escape}
+num [0-9]+|[0-9]*\.[0-9]+
+string {string1}|{string2}
+string1 \"([^\n\r\f\\"]|\\{nl}|{nonascii}|{escape})*\"
+string2 \'([^\n\r\f\\']|\\{nl}|{nonascii}|{escape})*\'
+invalid {invalid1}|{invalid2}
+invalid1 \"([^\n\r\f\\"]|\\{nl}|{nonascii}|{escape})*
+invalid2 \'([^\n\r\f\\']|\\{nl}|{nonascii}|{escape})*
+nl \n|\r\n|\r|\f
+w [ \t\r\n\f]*
+
+%%
+
+[ \t\r\n\f]+ return S;
+
+"~=" return INCLUDES;
+"|=" return DASHMATCH;
+"^=" return PREFIXMATCH;
+"$=" return SUFFIXMATCH;
+"*=" return SUBSTRINGMATCH;
+{ident} return IDENT;
+{string} return STRING;
+{ident}"(" return FUNCTION;
+{num} return NUMBER;
+"#"{name} return HASH;
+{w}"+" return PLUS;
+{w}">" return GREATER;
+{w}"," return COMMA;
+{w}"~" return TILDE;
+":not(" return NOT;
+@{ident} return ATKEYWORD;
+{invalid} return INVALID;
+{num}% return PERCENTAGE;
+{num}{ident} return DIMENSION;
+"<!--" return CDO;
+"-->" return CDC;
+
+"url("{w}{string}{w}")" return URI;
+"url("{w}([!#$%&*-~]|{nonascii}|{escape})*{w}")" return URI;
+U\+[0-9a-f?]{1,6}(-[0-9a-f]{1,6})? return UNICODE_RANGE;
+
+\/\*[^*]*\*+([^/*][^*]*\*+)*\/ /* ignore comments */
+
+. return *yytext;</pre>
+
+
+<h2><a name=downlevel>11. Namespaces and down-level clients</a></h2>
+
+<p>An important issue is the interaction of CSS selectors with XML
+ documents in web clients that were produced prior to this
+ document. Unfortunately, due to the fact that namespaces must be
+ matched based on the URI which identifies the namespace, not the
+ namespace prefix, some mechanism is required to identify namespaces in
+ CSS by their URI as well. Without such a mechanism, it is impossible
+ to construct a CSS style sheet which will properly match selectors in
+ all cases against a random set of XML documents. However, given
+ complete knowledge of the XML document to which a style sheet is to be
+ applied, and a limited use of namespaces within the XML document, it
+ is possible to construct a style sheet in which selectors would match
+ elements and attributes correctly.</p>
+
+<p>It should be noted that a down-level CSS client will (if it
+ properly conforms to CSS forward compatible parsing rules) ignore all
+ <code>@namespace</code> at-rules, as well as all style rules that make
+ use of namespace qualified element type or attribute selectors. The
+ syntax of delimiting namespace prefixes in CSS was deliberately chosen
+ so that down-level CSS clients would ignore the style rules rather
+ than possibly match them incorrectly.</p>
+
+<p>The use of default namespaces in CSS makes it possible to write
+ element type selectors that will function in both namespace aware CSS
+ clients as well as down-level clients. It should be noted that
+ down-level clients may incorrectly match selectors against XML
+ elements in other namespaces.</p>
+
+<p>The following are scenarios and examples in which it is possible to
+ construct style sheets which would function properly in web clients
+ that do not implement this proposal.</p>
+
+<ol>
+ <li>
+
+ <p>The XML document does not use namespaces.</p>
+
+ <ul>
+
+ <li>In this case, it is obviously not necessary to declare or use
+ namespaces in the style sheet. Standard CSS element type and
+ attribute selectors will function adequately in a down-level
+ client.
+ </li>
+
+ <li>In a CSS namespace aware client, the default behavior of
+ element selectors matching without regard to namespace will
+ function properly against all elements, since no namespaces are
+ present. However, the use of specific element type selectors
+ that
+ match only elements that have no namespace ("<code>|name</code>")
+ will guarantee that selectors will match only XML elements that
+ do
+ not have a declared namespace.
+ </li>
+
+ </ul>
+
+ </li>
+
+ <li>
+
+ <p>The XML document defines a single, default namespace used
+ throughout the document. No namespace prefixes are used in element
+ names.</p>
+
+ <ul>
+
+ <li>In this case, a down-level client will function as if
+ namespaces were not used in the XML document at all. Standard
+ CSS
+ element type and attribute selectors will match against all
+ elements.
+ </li>
+
+ </ul>
+
+ </li>
+
+ <li>
+
+ <p>The XML document does <b>not</b> use a default namespace, all
+ namespace prefixes used are known to the style sheet author, and
+ there is a direct mapping between namespace prefixes and namespace
+ URIs. (A given prefix may only be mapped to one namespace URI
+ throughout the XML document; there may be multiple prefixes mapped
+ to the same URI).</p>
+
+ <ul>
+
+ <li>In this case, the down-level client will view and match
+ element type and attribute selectors based on their fully
+ qualified name, not the local part as outlined in the <a
+ href="#typenmsp">Type selectors and Namespaces</a>
+ section. CSS
+ selectors may be declared using an escaped colon
+ "<code>\:</code>"
+ to describe the fully qualified names, e.g.
+ "<code>html\:h1</code>" will match
+ <code><html:h1></code>. Selectors using the qualified name
+ will only match XML elements that use the same prefix. Other
+ namespace prefixes used in the XML that are mapped to the same
+ URI
+ will not match as expected unless additional CSS style rules are
+ declared for them.
+ </li>
+
+ <li>Note that selectors declared in this fashion will
+ <em>only</em> match in down-level clients. A CSS namespace aware
+ client will match element type and attribute selectors based on
+ the name's local part. Selectors declared with the fully
+ qualified name will not match (unless there is no namespace
+ prefix
+ in the fully qualified name).
+ </li>
+
+ </ul>
+
+ </li>
+
+</ol>
+
+<p>In other scenarios: when the namespace prefixes used in the XML are
+ not known in advance by the style sheet author; or a combination of
+ elements with no namespace are used in conjunction with elements using
+ a default namespace; or the same namespace prefix is mapped to
+ <em>different</em> namespace URIs within the same document, or in
+ different documents; it is impossible to construct a CSS style sheet
+ that will function properly against all elements in those documents,
+ unless, the style sheet is written using a namespace URI syntax (as
+ outlined in this document or similar) and the document is processed by
+ a CSS and XML namespace aware client.</p>
+
+<h2><a name=profiling>12. Profiles</a></h2>
+
+<p>Each specification using Selectors must define the subset of W3C
+ Selectors it allows and excludes, and describe the local meaning of
+ all the components of that subset.</p>
+
+<p>Non normative examples:
+
+<div class="profile">
+ <table class="tprofile">
+ <tbody>
+ <tr>
+ <th class="title" colspan=2>Selectors profile</th>
+ </tr>
+ <tr>
+ <th>Specification</th>
+ <td>CSS level 1</td>
+ </tr>
+ <tr>
+ <th>Accepts</th>
+ <td>type selectors<br>class selectors<br>ID selectors<br>:link,
+ :visited and :active pseudo-classes<br>descendant combinator
+ <br>::first-line and ::first-letter pseudo-elements
+ </td>
+ </tr>
+ <tr>
+ <th>Excludes</th>
+ <td>
+
+ <p>universal selector<br>attribute selectors<br>:hover and
+ :focus
+ pseudo-classes<br>:target pseudo-class<br>:lang()
+ pseudo-class<br>all UI
+ element states pseudo-classes<br>all structural
+ pseudo-classes<br>negation pseudo-class<br>all
+ UI element fragments pseudo-elements<br>::before and ::after
+ pseudo-elements<br>child combinators<br>sibling combinators
+
+ <p>namespaces</td>
+ </tr>
+ <tr>
+ <th>Extra constraints</th>
+ <td>only one class selector allowed per sequence of simple
+ selectors
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ <br><br>
+ <table class="tprofile">
+ <tbody>
+ <tr>
+ <th class="title" colspan=2>Selectors profile</th>
+ </tr>
+ <tr>
+ <th>Specification</th>
+ <td>CSS level 2</td>
+ </tr>
+ <tr>
+ <th>Accepts</th>
+ <td>type selectors<br>universal selector<br>attribute presence and
+ values selectors<br>class selectors<br>ID selectors<br>:link,
+ :visited,
+ :active, :hover, :focus, :lang() and :first-child pseudo-classes
+ <br>descendant combinator<br>child combinator<br>adjacent
+ sibling
+ combinator<br>::first-line and ::first-letter
+ pseudo-elements<br>::before
+ and ::after pseudo-elements
+ </td>
+ </tr>
+ <tr>
+ <th>Excludes</th>
+ <td>
+
+ <p>content selectors<br>substring matching attribute
+ selectors<br>:target pseudo-classes<br>all UI element
+ states pseudo-classes<br>all structural pseudo-classes other
+ than :first-child<br>negation pseudo-class<br>all UI element
+ fragments pseudo-elements<br>general sibling combinators
+
+ <p>namespaces</td>
+ </tr>
+ <tr>
+ <th>Extra constraints</th>
+ <td>more than one class selector per sequence of simple selectors
+ (CSS1
+ constraint) allowed
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+ <p>In CSS, selectors express pattern matching rules that determine which
+ style
+ rules apply to elements in the document tree.
+
+ <p>The following selector (CSS level 2) will <b>match</b> all anchors <code>a</code>
+ with attribute <code>name</code> set inside a section 1 header
+ <code>h1</code>:
+ <pre>h1 a[name]</pre>
+
+ <p>All CSS declarations attached to such a selector are applied to elements
+ matching it.</div>
+
+<div class="profile">
+ <table class="tprofile">
+ <tbody>
+ <tr>
+ <th class="title" colspan=2>Selectors profile</th>
+ </tr>
+ <tr>
+ <th>Specification</th>
+ <td>STTS 3</td>
+ </tr>
+ <tr>
+ <th>Accepts</th>
+ <td>
+
+ <p>type selectors<br>universal selectors<br>attribute
+ selectors<br>class
+ selectors<br>ID selectors<br>all structural
+ pseudo-classes<br>
+ all combinators
+
+ <p>namespaces</td>
+ </tr>
+ <tr>
+ <th>Excludes</th>
+ <td>non-accepted pseudo-classes<br>pseudo-elements<br></td>
+ </tr>
+ <tr>
+ <th>Extra constraints</th>
+ <td>some selectors and combinators are not allowed in fragment
+ descriptions on the right side of STTS declarations.
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+ <p>Selectors can be used in STTS 3 in two different
+ manners:
+ <ol>
+ <li>a selection mechanism equivalent to CSS selection mechanism:
+ declarations
+ attached to a given selector are applied to elements matching that
+ selector,
+ <li>fragment descriptions that appear on the right side of declarations.
+ </li>
+ </ol>
+</div>
+
+<h2><a name=Conformance></a>13. Conformance and requirements</h2>
+
+<p>This section defines conformance with the present specification only.
+
+<p>The inability of a user agent to implement part of this specification due to
+ the limitations of a particular device (e.g., non interactive user agents
+ will
+ probably not implement dynamic pseudo-classes because they make no sense
+ without
+ interactivity) does not imply non-conformance.
+
+<p>All specifications reusing Selectors must contain a <a
+ href="#profiling">Profile</a> listing the
+ subset of Selectors it accepts or excludes, and describing the constraints
+ it adds to the current specification.
+
+<p>Invalidity is caused by a parsing error, e.g. an unrecognized token or a
+ token
+ which is not allowed at the current parsing point.
+
+<p>User agents must observe the rules for handling parsing errors:
+<ul>
+ <li>a simple selector containing an undeclared namespace prefix is invalid
+ </li>
+ <li>a selector containing an invalid simple selector, an invalid combinator
+ or an invalid token is invalid.
+ </li>
+ <li>a group of selectors containing an invalid selector is invalid.</li>
+</ul>
+
+<p>Specifications reusing Selectors must define how to handle parsing
+ errors. (In the case of CSS, the entire rule in which the selector is
+ used is dropped.)</p>
+
+<!-- Apparently all these references are out of date:
+<p>Implementations of this specification must behave as
+"recipients of text data" as defined by <a href="#refsCWWW">[CWWW]</a>
+when parsing selectors and attempting matches. (In particular,
+implementations must assume the data is normalized and must not
+normalize it.) Normative rules for matching strings are defined in
+<a href="#refsCWWW">[CWWW]</a> and <a
+href="#refsUNICODE">[UNICODE]</a> and apply to implementations of this
+specification.</p>-->
+
+<h2><a name=Tests></a>14. Tests</h2>
+
+<p>This specification has <a
+ href="http://www.w3.org/Style/CSS/Test/CSS3/Selectors/current/">a test
+ suite</a> allowing user agents to verify their basic conformance to
+ the specification. This test suite does not pretend to be exhaustive
+ and does not cover all possible combined cases of Selectors.</p>
+
+<h2><a name=ACKS></a>15. Acknowledgements</h2>
+
+<p>The CSS working group would like to thank everyone who has sent
+ comments on this specification over the years.</p>
+
+<p>The working group would like to extend special thanks to Donna
+ McManus, Justin Baker, Joel Sklar, and Molly Ives Brower who perfermed
+ the final editorial review.</p>
+
+<h2><a name=references>16. References</a></h2>
+
+<dl class="refs">
+
+ <dt>[CSS1]
+ <dd><a name=refsCSS1></a> Bert Bos, Håkon Wium Lie; "<cite>Cascading
+ Style Sheets, level 1</cite>", W3C Recommendation, 17 Dec 1996, revised
+ 11 Jan 1999
+ <dd>(<code><a href="http://www.w3.org/TR/REC-CSS1">http://www.w3.org/TR/REC-CSS1</a></code>)
+
+ <dt>[CSS21]
+ <dd><a name=refsCSS21></a> Bert Bos, Tantek Çelik, Ian Hickson, Håkon
+ Wium Lie, editors; "<cite>Cascading Style Sheets, level 2 revision
+ 1</cite>", W3C Working Draft, 13 June 2005
+ <dd>(<code><a
+ href="http://www.w3.org/TR/CSS21">http://www.w3.org/TR/CSS21</a></code>)
+
+ <dt>[CWWW]
+ <dd><a name=refsCWWW></a> Martin J. Dürst, François Yergeau,
+ Misha Wolf, Asmus Freytag, Tex Texin, editors; "<cite>Character Model
+ for the World Wide Web</cite>", W3C Recommendation, 15 February 2005
+ <dd>(<code><a href="http://www.w3.org/TR/charmod/">http://www.w3.org/TR/charmod/</a></code>)
+
+ <dt>[FLEX]
+ <dd><a name="refsFLEX"></a> "<cite>Flex: The Lexical Scanner
+ Generator</cite>", Version 2.3.7, ISBN 1882114213
+
+ <dt>[HTML4]
+ <dd><a name="refsHTML4"></a> Dave Ragget, Arnaud Le Hors, Ian Jacobs,
+ editors; "<cite>HTML 4.01 Specification</cite>", W3C Recommendation, 24
+ December 1999
+ <dd>
+ (<a href="http://www.w3.org/TR/html4/"><code>http://www.w3.org/TR/html4/</code></a>)
+
+ <dt>[MATH]
+ <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
+ <dd>(<code><a href="http://www.w3.org/TR/REC-MathML/">http://www.w3.org/TR/REC-MathML/</a></code>)
+
+ <dt>[RFC3066]
+ <dd><a name="refsRFC3066"></a> H. Alvestrand; "<cite>Tags for the
+ Identification of Languages</cite>", Request for Comments 3066, January
+ 2001
+ <dd>(<a href="http://www.ietf.org/rfc/rfc3066.txt"><code>http://www.ietf.org/rfc/rfc3066.txt</code></a>)
+
+ <dt>[STTS]
+ <dd><a name=refsSTTS></a> Daniel Glazman; "<cite>Simple Tree Transformation
+ Sheets 3</cite>", Electricité de France, submission to the W3C,
+ 11 November 1998
+ <dd>(<code><a href="http://www.w3.org/TR/NOTE-STTS3">http://www.w3.org/TR/NOTE-STTS3</a></code>)
+
+ <dt>[SVG]
+ <dd><a name="refsSVG"></a> Jon Ferraiolo, 藤沢 淳, Dean
+ Jackson, editors; "<cite>Scalable Vector Graphics (SVG) 1.1
+ Specification</cite>", W3C Recommendation, 14 January 2003
+ <dd>(<code><a href="http://www.w3.org/TR/SVG/">http://www.w3.org/TR/SVG/</a></code>)
+
+ <dt>[UNICODE]</dt>
+ <dd><a name="refsUNICODE"></a> <cite><a
+ 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>.
+ <dd>(<code><a href="http://www.unicode.org/versions/">http://www.unicode.org/versions/</a></code>)
+ </dd>
+
+ <dt>[XML10]
+ <dd><a name="refsXML10"></a> Tim Bray, Jean Paoli, C. M. Sperberg-McQueen,
+ Eve Maler, François Yergeau, editors; "<cite>Extensible Markup
+ Language (XML) 1.0 (Third Edition)</cite>", W3C Recommendation, 4
+ February 2004
+ <dd>(<a href="http://www.w3.org/TR/REC-xml/"><code>http://www.w3.org/TR/REC-xml/</code></a>)
+
+ <dt>[XMLNAMES]
+ <dd><a name="refsXMLNAMES"></a> Tim Bray, Dave Hollander, Andrew Layman,
+ editors; "<cite>Namespaces in XML</cite>", W3C Recommendation, 14
+ January 1999
+ <dd>(<a href="http://www.w3.org/TR/REC-xml-names/"><code>http://www.w3.org/TR/REC-xml-names/</code></a>)
+
+ <dt>[YACC]
+ <dd><a name="refsYACC"></a> S. C. Johnson; "<cite>YACC — Yet another
+ compiler compiler</cite>", Technical Report, Murray Hill, 1975
+
+</dl>
+</div>
+</body>
+</html>
diff --git a/samples/src/main/java/gwtquery/samples/public/grass-texture.jpg b/samples/src/main/java/gwtquery/samples/public/grass-texture.jpg Binary files differnew file mode 100644 index 00000000..d4cc586a --- /dev/null +++ b/samples/src/main/java/gwtquery/samples/public/grass-texture.jpg diff --git a/samples/src/main/java/gwtquery/samples/public/horse.png b/samples/src/main/java/gwtquery/samples/public/horse.png Binary files differnew file mode 100644 index 00000000..fb185a18 --- /dev/null +++ b/samples/src/main/java/gwtquery/samples/public/horse.png diff --git a/samples/src/main/java/gwtquery/samples/public/jquery-1.3.1.js b/samples/src/main/java/gwtquery/samples/public/jquery-1.3.1.js new file mode 100644 index 00000000..1337b21d --- /dev/null +++ b/samples/src/main/java/gwtquery/samples/public/jquery-1.3.1.js @@ -0,0 +1,4242 @@ +/*! + * jQuery JavaScript Library v1.3.1 + * http://jquery.com/ + * + * Copyright (c) 2009 John Resig + * Dual licensed under the MIT and GPL licenses. + * http://docs.jquery.com/License + * + * Date: 2009-01-21 20:42:16 -0500 (Wed, 21 Jan 2009) + * Revision: 6158 + */ +(function(){ + +var + // Will speed up references to window, and allows munging its name. + window = this, + // Will speed up references to undefined, and allows munging its name. + undefined, + // Map over jQuery in case of overwrite + _jQuery = window.jQuery, + // Map over the $ in case of overwrite + _$ = window.$, + + jQuery = window.jQuery = window.$ = function( selector, context ) { + // The jQuery object is actually just the init constructor 'enhanced' + return new jQuery.fn.init( selector, context ); + }, + + // A simple way to check for HTML strings or ID strings + // (both of which we optimize for) + quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/, + // Is it a simple selector + isSimple = /^.[^:#\[\.,]*$/; + +jQuery.fn = jQuery.prototype = { + init: function( selector, context ) { + // Make sure that a selection was provided + selector = selector || document; + + // Handle $(DOMElement) + if ( selector.nodeType ) { + this[0] = selector; + this.length = 1; + this.context = selector; + return this; + } + // Handle HTML strings + if ( typeof selector === "string" ) { + // Are we dealing with HTML string or an ID? + var match = quickExpr.exec( selector ); + + // Verify a match, and that no context was specified for #id + if ( match && (match[1] || !context) ) { + + // HANDLE: $(html) -> $(array) + if ( match[1] ) + selector = jQuery.clean( [ match[1] ], context ); + + // HANDLE: $("#id") + else { + var elem = document.getElementById( match[3] ); + + // Handle the case where IE and Opera return items + // by name instead of ID + if ( elem && elem.id != match[3] ) + return jQuery().find( selector ); + + // Otherwise, we inject the element directly into the jQuery object + var ret = jQuery( elem || [] ); + ret.context = document; + ret.selector = selector; + return ret; + } + + // HANDLE: $(expr, [context]) + // (which is just equivalent to: $(content).find(expr) + } else + return jQuery( context ).find( selector ); + + // HANDLE: $(function) + // Shortcut for document ready + } else if ( jQuery.isFunction( selector ) ) + return jQuery( document ).ready( selector ); + + // Make sure that old selector state is passed along + if ( selector.selector && selector.context ) { + this.selector = selector.selector; + this.context = selector.context; + } + + return this.setArray(jQuery.makeArray(selector)); + }, + + // Start with an empty selector + selector: "", + + // The current version of jQuery being used + jquery: "1.3.1", + + // The number of elements contained in the matched element set + size: function() { + return this.length; + }, + + // Get the Nth element in the matched element set OR + // Get the whole matched element set as a clean array + get: function( num ) { + return num === undefined ? + + // Return a 'clean' array + jQuery.makeArray( this ) : + + // Return just the object + this[ num ]; + }, + + // Take an array of elements and push it onto the stack + // (returning the new matched element set) + pushStack: function( elems, name, selector ) { + // Build a new jQuery matched element set + var ret = jQuery( elems ); + + // Add the old object onto the stack (as a reference) + ret.prevObject = this; + + ret.context = this.context; + + if ( name === "find" ) + ret.selector = this.selector + (this.selector ? " " : "") + selector; + else if ( name ) + ret.selector = this.selector + "." + name + "(" + selector + ")"; + + // Return the newly-formed element set + return ret; + }, + + // Force the current matched set of elements to become + // the specified array of elements (destroying the stack in the process) + // You should use pushStack() in order to do this, but maintain the stack + setArray: function( elems ) { + // Resetting the length to 0, then using the native Array push + // is a super-fast way to populate an object with array-like properties + this.length = 0; + Array.prototype.push.apply( this, elems ); + + return this; + }, + + // Execute a callback for every element in the matched set. + // (You can seed the arguments with an array of args, but this is + // only used internally.) + each: function( callback, args ) { + return jQuery.each( this, callback, args ); + }, + + // Determine the position of an element within + // the matched set of elements + index: function( elem ) { + // Locate the position of the desired element + return jQuery.inArray( + // If it receives a jQuery object, the first element is used + elem && elem.jquery ? elem[0] : elem + , this ); + }, + + attr: function( name, value, type ) { + var options = name; + + // Look for the case where we're accessing a style value + if ( typeof name === "string" ) + if ( value === undefined ) + return this[0] && jQuery[ type || "attr" ]( this[0], name ); + + else { + options = {}; + options[ name ] = value; + } + + // Check to see if we're setting style values + return this.each(function(i){ + // Set all the styles + for ( name in options ) + jQuery.attr( + type ? + this.style : + this, + name, jQuery.prop( this, options[ name ], type, i, name ) + ); + }); + }, + + css: function( key, value ) { + // ignore negative width and height values + if ( (key == 'width' || key == 'height') && parseFloat(value) < 0 ) + value = undefined; + return this.attr( key, value, "curCSS" ); + }, + + text: function( text ) { + if ( typeof text !== "object" && text != null ) + return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) ); + + var ret = ""; + + jQuery.each( text || this, function(){ + jQuery.each( this.childNodes, function(){ + if ( this.nodeType != 8 ) + ret += this.nodeType != 1 ? + this.nodeValue : + jQuery.fn.text( [ this ] ); + }); + }); + + return ret; + }, + + wrapAll: function( html ) { + if ( this[0] ) { + // The elements to wrap the target around + var wrap = jQuery( html, this[0].ownerDocument ).clone(); + + if ( this[0].parentNode ) + wrap.insertBefore( this[0] ); + + wrap.map(function(){ + var elem = this; + + while ( elem.firstChild ) + elem = elem.firstChild; + + return elem; + }).append(this); + } + + return this; + }, + + wrapInner: function( html ) { + return this.each(function(){ + jQuery( this ).contents().wrapAll( html ); + }); + }, + + wrap: function( html ) { + return this.each(function(){ + jQuery( this ).wrapAll( html ); + }); + }, + + append: function() { + return this.domManip(arguments, true, function(elem){ + if (this.nodeType == 1) + this.appendChild( elem ); + }); + }, + + prepend: function() { + return this.domManip(arguments, true, function(elem){ + if (this.nodeType == 1) + this.insertBefore( elem, this.firstChild ); + }); + }, + + before: function() { + return this.domManip(arguments, false, function(elem){ + this.parentNode.insertBefore( elem, this ); + }); + }, + + after: function() { + return this.domManip(arguments, false, function(elem){ + this.parentNode.insertBefore( elem, this.nextSibling ); + }); + }, + + end: function() { + return this.prevObject || jQuery( [] ); + }, + + // For internal use only. + // Behaves like an Array's .push method, not like a jQuery method. + push: [].push, + + find: function( selector ) { + if ( this.length === 1 && !/,/.test(selector) ) { + var ret = this.pushStack( [], "find", selector ); + ret.length = 0; + jQuery.find( selector, this[0], ret ); + return ret; + } else { + var elems = jQuery.map(this, function(elem){ + return jQuery.find( selector, elem ); + }); + + return this.pushStack( /[^+>] [^+>]/.test( selector ) ? + jQuery.unique( elems ) : + elems, "find", selector ); + } + }, + + clone: function( events ) { + // Do the clone + var ret = this.map(function(){ + if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) { + // IE copies events bound via attachEvent when + // using cloneNode. Calling detachEvent on the + // clone will also remove the events from the orignal + // In order to get around this, we use innerHTML. + // Unfortunately, this means some modifications to + // attributes in IE that are actually only stored + // as properties will not be copied (such as the + // the name attribute on an input). + var clone = this.cloneNode(true), + container = document.createElement("div"); + container.appendChild(clone); + return jQuery.clean([container.innerHTML])[0]; + } else + return this.cloneNode(true); + }); + + // Need to set the expando to null on the cloned set if it exists + // removeData doesn't work here, IE removes it from the original as well + // this is primarily for IE but the data expando shouldn't be copied over in any browser + var clone = ret.find("*").andSelf().each(function(){ + if ( this[ expando ] !== undefined ) + this[ expando ] = null; + }); + + // Copy the events from the original to the clone + if ( events === true ) + this.find("*").andSelf().each(function(i){ + if (this.nodeType == 3) + return; + var events = jQuery.data( this, "events" ); + + for ( var type in events ) + for ( var handler in events[ type ] ) + jQuery.event.add( clone[ i ], type, events[ type ][ handler ], events[ type ][ handler ].data ); + }); + + // Return the cloned set + return ret; + }, + + filter: function( selector ) { + return this.pushStack( + jQuery.isFunction( selector ) && + jQuery.grep(this, function(elem, i){ + return selector.call( elem, i ); + }) || + + jQuery.multiFilter( selector, jQuery.grep(this, function(elem){ + return elem.nodeType === 1; + }) ), "filter", selector ); + }, + + closest: function( selector ) { + var pos = jQuery.expr.match.POS.test( selector ) ? jQuery(selector) : null; + + return this.map(function(){ + var cur = this; + while ( cur && cur.ownerDocument ) { + if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selector) ) + return cur; + cur = cur.parentNode; + } + }); + }, + + not: function( selector ) { + if ( typeof selector === "string" ) + // test special case where just one selector is passed in + if ( isSimple.test( selector ) ) + return this.pushStack( jQuery.multiFilter( selector, this, true ), "not", selector ); + else + selector = jQuery.multiFilter( selector, this ); + + var isArrayLike = selector.length && selector[selector.length - 1] !== undefined && !selector.nodeType; + return this.filter(function() { + return isArrayLike ? jQuery.inArray( this, selector ) < 0 : this != selector; + }); + }, + + add: function( selector ) { + return this.pushStack( jQuery.unique( jQuery.merge( + this.get(), + typeof selector === "string" ? + jQuery( selector ) : + jQuery.makeArray( selector ) + ))); + }, + + is: function( selector ) { + return !!selector && jQuery.multiFilter( selector, this ).length > 0; + }, + + hasClass: function( selector ) { + return !!selector && this.is( "." + selector ); + }, + + val: function( value ) { + if ( value === undefined ) { + var elem = this[0]; + + if ( elem ) { + if( jQuery.nodeName( elem, 'option' ) ) + return (elem.attributes.value || {}).specified ? elem.value : elem.text; + + // We need to handle select boxes special + if ( jQuery.nodeName( elem, "select" ) ) { + var index = elem.selectedIndex, + values = [], + options = elem.options, + one = elem.type == "select-one"; + + // Nothing was selected + if ( index < 0 ) + return null; + + // Loop through all the selected options + for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { + var option = options[ i ]; + + if ( option.selected ) { + // Get the specifc value for the option + value = jQuery(option).val(); + + // We don't need an array for one selects + if ( one ) + return value; + + // Multi-Selects return an array + values.push( value ); + } + } + + return values; + } + + // Everything else, we just grab the value + return (elem.value || "").replace(/\r/g, ""); + + } + + return undefined; + } + + if ( typeof value === "number" ) + value += ''; + + return this.each(function(){ + if ( this.nodeType != 1 ) + return; + + if ( jQuery.isArray(value) && /radio|checkbox/.test( this.type ) ) + this.checked = (jQuery.inArray(this.value, value) >= 0 || + jQuery.inArray(this.name, value) >= 0); + + else if ( jQuery.nodeName( this, "select" ) ) { + var values = jQuery.makeArray(value); + + jQuery( "option", this ).each(function(){ + this.selected = (jQuery.inArray( this.value, values ) >= 0 || + jQuery.inArray( this.text, values ) >= 0); + }); + + if ( !values.length ) + this.selectedIndex = -1; + + } else + this.value = value; + }); + }, + + html: function( value ) { + return value === undefined ? + (this[0] ? + this[0].innerHTML : + null) : + this.empty().append( value ); + }, + + replaceWith: function( value ) { + return this.after( value ).remove(); + }, + + eq: function( i ) { + return this.slice( i, +i + 1 ); + }, + + slice: function() { + return this.pushStack( Array.prototype.slice.apply( this, arguments ), + "slice", Array.prototype.slice.call(arguments).join(",") ); + }, + + map: function( callback ) { + return this.pushStack( jQuery.map(this, function(elem, i){ + return callback.call( elem, i, elem ); + })); + }, + + andSelf: function() { + return this.add( this.prevObject ); + }, + + + domManip: function( args, table, callback ) { + if ( this[0] ) { + var fragment = (this[0].ownerDocument || this[0]).createDocumentFragment(), + scripts = jQuery.clean( args, (this[0].ownerDocument || this[0]), fragment ), + first = fragment.firstChild, + extra = this.length > 1 ? fragment.cloneNode(true) : fragment; + + if ( first ) + for ( var i = 0, l = this.length; i < l; i++ ) + callback.call( root(this[i], first), i > 0 ? extra.cloneNode(true) : fragment ); + + if ( scripts ) + jQuery.each( scripts, evalScript ); + } + + return this; + + function root( elem, cur ) { + return table && jQuery.nodeName(elem, "table") && jQuery.nodeName(cur, "tr") ? + (elem.getElementsByTagName("tbody")[0] || + elem.appendChild(elem.ownerDocument.createElement("tbody"))) : + elem; + } + } +}; + +// Give the init function the jQuery prototype for later instantiation +jQuery.fn.init.prototype = jQuery.fn; + +function evalScript( i, elem ) { + if ( elem.src ) + jQuery.ajax({ + url: elem.src, + async: false, + dataType: "script" + }); + + else + jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" ); + + if ( elem.parentNode ) + elem.parentNode.removeChild( elem ); +} + +function now(){ + return +new Date; +} + +jQuery.extend = jQuery.fn.extend = function() { + // copy reference to target object + var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options; + + // Handle a deep copy situation + if ( typeof target === "boolean" ) { + deep = target; + target = arguments[1] || {}; + // skip the boolean and the target + i = 2; + } + + // Handle case when target is a string or something (possible in deep copy) + if ( typeof target !== "object" && !jQuery.isFunction(target) ) + target = {}; + + // extend jQuery itself if only one argument is passed + if ( length == i ) { + target = this; + --i; + } + + for ( ; i < length; i++ ) + // Only deal with non-null/undefined values + if ( (options = arguments[ i ]) != null ) + // Extend the base object + for ( var name in options ) { + var src = target[ name ], copy = options[ name ]; + + // Prevent never-ending loop + if ( target === copy ) + continue; + + // Recurse if we're merging object values + if ( deep && copy && typeof copy === "object" && !copy.nodeType ) + target[ name ] = jQuery.extend( deep, + // Never move original objects, clone them + src || ( copy.length != null ? [ ] : { } ) + , copy ); + + // Don't bring in undefined values + else if ( copy !== undefined ) + target[ name ] = copy; + + } + + // Return the modified object + return target; +}; + +// exclude the following css properties to add px +var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i, + // cache defaultView + defaultView = document.defaultView || {}, + toString = Object.prototype.toString; + +jQuery.extend({ + noConflict: function( deep ) { + window.$ = _$; + + if ( deep ) + window.jQuery = _jQuery; + + return jQuery; + }, + + // See test/unit/core.js for details concerning isFunction. + // Since version 1.3, DOM methods and functions like alert + // aren't supported. They return false on IE (#2968). + isFunction: function( obj ) { + return toString.call(obj) === "[object Function]"; + }, + + isArray: function( obj ) { + return toString.call(obj) === "[object Array]"; + }, + + // check if an element is in a (or is an) XML document + isXMLDoc: function( elem ) { + return elem.nodeType === 9 && elem.documentElement.nodeName !== "HTML" || + !!elem.ownerDocument && jQuery.isXMLDoc( elem.ownerDocument ); + }, + + // Evalulates a script in a global context + globalEval: function( data ) { + data = jQuery.trim( data ); + + if ( data ) { + // Inspired by code by Andrea Giammarchi + // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html + var head = document.getElementsByTagName("head")[0] || document.documentElement, + script = document.createElement("script"); + + script.type = "text/javascript"; + if ( jQuery.support.scriptEval ) + script.appendChild( document.createTextNode( data ) ); + else + script.text = data; + + // Use insertBefore instead of appendChild to circumvent an IE6 bug. + // This arises when a base node is used (#2709). + head.insertBefore( script, head.firstChild ); + head.removeChild( script ); + } + }, + + nodeName: function( elem, name ) { + return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase(); + }, + + // args is for internal usage only + each: function( object, callback, args ) { + var name, i = 0, length = object.length; + + if ( args ) { + if ( length === undefined ) { + for ( name in object ) + if ( callback.apply( object[ name ], args ) === false ) + break; + } else + for ( ; i < length; ) + if ( callback.apply( object[ i++ ], args ) === false ) + break; + + // A special, fast, case for the most common use of each + } else { + if ( length === undefined ) { + for ( name in object ) + if ( callback.call( object[ name ], name, object[ name ] ) === false ) + break; + } else + for ( var value = object[0]; + i < length && callback.call( value, i, value ) !== false; value = object[++i] ){} + } + + return object; + }, + + prop: function( elem, value, type, i, name ) { + // Handle executable functions + if ( jQuery.isFunction( value ) ) + value = value.call( elem, i ); + + // Handle passing in a number to a CSS property + return typeof value === "number" && type == "curCSS" && !exclude.test( name ) ? + value + "px" : + value; + }, + + className: { + // internal only, use addClass("class") + add: function( elem, classNames ) { + jQuery.each((classNames || "").split(/\s+/), function(i, className){ + if ( elem.nodeType == 1 && !jQuery.className.has( elem.className, className ) ) + elem.className += (elem.className ? " " : "") + className; + }); + }, + + // internal only, use removeClass("class") + remove: function( elem, classNames ) { + if (elem.nodeType == 1) + elem.className = classNames !== undefined ? + jQuery.grep(elem.className.split(/\s+/), function(className){ + return !jQuery.className.has( classNames, className ); + }).join(" ") : + ""; + }, + + // internal only, use hasClass("class") + has: function( elem, className ) { + return elem && jQuery.inArray( className, (elem.className || elem).toString().split(/\s+/) ) > -1; + } + }, + + // A method for quickly swapping in/out CSS properties to get correct calculations + swap: function( elem, options, callback ) { + var old = {}; + // Remember the old values, and insert the new ones + for ( var name in options ) { + old[ name ] = elem.style[ name ]; + elem.style[ name ] = options[ name ]; + } + + callback.call( elem ); + + // Revert the old values + for ( var name in options ) + elem.style[ name ] = old[ name ]; + }, + + css: function( elem, name, force ) { + if ( name == "width" || name == "height" ) { + var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ]; + + function getWH() { + val = name == "width" ? elem.offsetWidth : elem.offsetHeight; + var padding = 0, border = 0; + jQuery.each( which, function() { + padding += parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0; + border += parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0; + }); + val -= Math.round(padding + border); + } + + if ( jQuery(elem).is(":visible") ) + getWH(); + else + jQuery.swap( elem, props, getWH ); + + return Math.max(0, val); + } + + return jQuery.curCSS( elem, name, force ); + }, + + curCSS: function( elem, name, force ) { + var ret, style = elem.style; + + // We need to handle opacity special in IE + if ( name == "opacity" && !jQuery.support.opacity ) { + ret = jQuery.attr( style, "opacity" ); + + return ret == "" ? + "1" : + ret; + } + + // Make sure we're using the right name for getting the float value + if ( name.match( /float/i ) ) + name = styleFloat; + + if ( !force && style && style[ name ] ) + ret = style[ name ]; + + else if ( defaultView.getComputedStyle ) { + + // Only "float" is needed here + if ( name.match( /float/i ) ) + name = "float"; + + name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase(); + + var computedStyle = defaultView.getComputedStyle( elem, null ); + + if ( computedStyle ) + ret = computedStyle.getPropertyValue( name ); + + // We should always get a number back from opacity + if ( name == "opacity" && ret == "" ) + ret = "1"; + + } else if ( elem.currentStyle ) { + var camelCase = name.replace(/\-(\w)/g, function(all, letter){ + return letter.toUpperCase(); + }); + + ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ]; + + // From the awesome hack by Dean Edwards + // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 + + // If we're not dealing with a regular pixel number + // but a number that has a weird ending, we need to convert it to pixels + if ( !/^\d+(px)?$/i.test( ret ) && /^\d/.test( ret ) ) { + // Remember the original values + var left = style.left, rsLeft = elem.runtimeStyle.left; + + // Put in the new values to get a computed value out + elem.runtimeStyle.left = elem.currentStyle.left; + style.left = ret || 0; + ret = style.pixelLeft + "px"; + + // Revert the changed values + style.left = left; + elem.runtimeStyle.left = rsLeft; + } + } + + return ret; + }, + + clean: function( elems, context, fragment ) { + context = context || document; + + // !context.createElement fails in IE with an error but returns typeof 'object' + if ( typeof context.createElement === "undefined" ) + context = context.ownerDocument || context[0] && context[0].ownerDocument || document; + + // If a single string is passed in and it's a single tag + // just do a createElement and skip the rest + if ( !fragment && elems.length === 1 && typeof elems[0] === "string" ) { + var match = /^<(\w+)\s*\/?>$/.exec(elems[0]); + if ( match ) + return [ context.createElement( match[1] ) ]; + } + + var ret = [], scripts = [], div = context.createElement("div"); + + jQuery.each(elems, function(i, elem){ + if ( typeof elem === "number" ) + elem += ''; + + if ( !elem ) + return; + + // Convert html string into DOM nodes + if ( typeof elem === "string" ) { + // Fix "XHTML"-style tags in all browsers + elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){ + return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i) ? + all : + front + "></" + tag + ">"; + }); + + // Trim whitespace, otherwise indexOf won't work as expected + var tags = jQuery.trim( elem ).toLowerCase(); + + var wrap = + // option or optgroup + !tags.indexOf("<opt") && + [ 1, "<select multiple='multiple'>", "</select>" ] || + + !tags.indexOf("<leg") && + [ 1, "<fieldset>", "</fieldset>" ] || + + tags.match(/^<(thead|tbody|tfoot|colg|cap)/) && + [ 1, "<table>", "</table>" ] || + + !tags.indexOf("<tr") && + [ 2, "<table><tbody>", "</tbody></table>" ] || + + // <thead> matched above + (!tags.indexOf("<td") || !tags.indexOf("<th")) && + [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ] || + + !tags.indexOf("<col") && + [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ] || + + // IE can't serialize <link> and <script> tags normally + !jQuery.support.htmlSerialize && + [ 1, "div<div>", "</div>" ] || + + [ 0, "", "" ]; + + // Go to html and back, then peel off extra wrappers + div.innerHTML = wrap[1] + elem + wrap[2]; + + // Move to the right depth + while ( wrap[0]-- ) + div = div.lastChild; + + // Remove IE's autoinserted <tbody> from table fragments + if ( !jQuery.support.tbody ) { + + // String was a <table>, *may* have spurious <tbody> + var tbody = !tags.indexOf("<table") && tags.indexOf("<tbody") < 0 ? + div.firstChild && div.firstChild.childNodes : + + // String was a bare <thead> or <tfoot> + wrap[1] == "<table>" && tags.indexOf("<tbody") < 0 ? + div.childNodes : + []; + + for ( var j = tbody.length - 1; j >= 0 ; --j ) + if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) + tbody[ j ].parentNode.removeChild( tbody[ j ] ); + + } + + // IE completely kills leading whitespace when innerHTML is used + if ( !jQuery.support.leadingWhitespace && /^\s/.test( elem ) ) + div.insertBefore( context.createTextNode( elem.match(/^\s*/)[0] ), div.firstChild ); + + elem = jQuery.makeArray( div.childNodes ); + } + + if ( elem.nodeType ) + ret.push( elem ); + else + ret = jQuery.merge( ret, elem ); + + }); + + if ( fragment ) { + for ( var i = 0; ret[i]; i++ ) { + if ( jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) { + scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] ); + } else { + if ( ret[i].nodeType === 1 ) + ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) ); + fragment.appendChild( ret[i] ); + } + } + + return scripts; + } + + return ret; + }, + + attr: function( elem, name, value ) { + // don't set attributes on text and comment nodes + if (!elem || elem.nodeType == 3 || elem.nodeType == 8) + return undefined; + + var notxml = !jQuery.isXMLDoc( elem ), + // Whether we are setting (or getting) + set = value !== undefined; + + // Try to normalize/fix the name + name = notxml && jQuery.props[ name ] || name; + + // Only do all the following if this is a node (faster for style) + // IE elem.getAttribute passes even for style + if ( elem.tagName ) { + + // These attributes require special treatment + var special = /href|src|style/.test( name ); + + // Safari mis-reports the default selected property of a hidden option + // Accessing the parent's selectedIndex property fixes it + if ( name == "selected" && elem.parentNode ) + elem.parentNode.selectedIndex; + + // If applicable, access the attribute via the DOM 0 way + if ( name in elem && notxml && !special ) { + if ( set ){ + // We can't allow the type property to be changed (since it causes problems in IE) + if ( name == "type" && jQuery.nodeName( elem, "input" ) && elem.parentNode ) + throw "type property can't be changed"; + + elem[ name ] = value; + } + + // browsers index elements by id/name on forms, give priority to attributes. + if( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) + return elem.getAttributeNode( name ).nodeValue; + + // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set + // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ + if ( name == "tabIndex" ) { + var attributeNode = elem.getAttributeNode( "tabIndex" ); + return attributeNode && attributeNode.specified + ? attributeNode.value + : elem.nodeName.match(/(button|input|object|select|textarea)/i) + ? 0 + : elem.nodeName.match(/^(a|area)$/i) && elem.href + ? 0 + : undefined; + } + + return elem[ name ]; + } + + if ( !jQuery.support.style && notxml && name == "style" ) + return jQuery.attr( elem.style, "cssText", value ); + + if ( set ) + // convert the value to a string (all browsers do this but IE) see #1070 + elem.setAttribute( name, "" + value ); + + var attr = !jQuery.support.hrefNormalized && notxml && special + // Some attributes require a special call on IE + ? elem.getAttribute( name, 2 ) + : elem.getAttribute( name ); + + // Non-existent attributes return null, we normalize to undefined + return attr === null ? undefined : attr; + } + + // elem is actually elem.style ... set the style + + // IE uses filters for opacity + if ( !jQuery.support.opacity && name == "opacity" ) { + if ( set ) { + // IE has trouble with opacity if it does not have layout + // Force it by setting the zoom level + elem.zoom = 1; + + // Set the alpha filter to set the opacity + elem.filter = (elem.filter || "").replace( /alpha\([^)]*\)/, "" ) + + (parseInt( value ) + '' == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")"); + } + + return elem.filter && elem.filter.indexOf("opacity=") >= 0 ? + (parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100) + '': + ""; + } + + name = name.replace(/-([a-z])/ig, function(all, letter){ + return letter.toUpperCase(); + }); + + if ( set ) + elem[ name ] = value; + + return elem[ name ]; + }, + + trim: function( text ) { + return (text || "").replace( /^\s+|\s+$/g, "" ); + }, + + makeArray: function( array ) { + var ret = []; + + if( array != null ){ + var i = array.length; + // The window, strings (and functions) also have 'length' + if( i == null || typeof array === "string" || jQuery.isFunction(array) || array.setInterval ) + ret[0] = array; + else + while( i ) + ret[--i] = array[i]; + } + + return ret; + }, + + inArray: function( elem, array ) { + for ( var i = 0, length = array.length; i < length; i++ ) + // Use === because on IE, window == document + if ( array[ i ] === elem ) + return i; + + return -1; + }, + + merge: function( first, second ) { + // We have to loop this way because IE & Opera overwrite the length + // expando of getElementsByTagName + var i = 0, elem, pos = first.length; + // Also, we need to make sure that the correct elements are being returned + // (IE returns comment nodes in a '*' query) + if ( !jQuery.support.getAll ) { + while ( (elem = second[ i++ ]) != null ) + if ( elem.nodeType != 8 ) + first[ pos++ ] = elem; + + } else + while ( (elem = second[ i++ ]) != null ) + first[ pos++ ] = elem; + + return first; + }, + + unique: function( array ) { + var ret = [], done = {}; + + try { + + for ( var i = 0, length = array.length; i < length; i++ ) { + var id = jQuery.data( array[ i ] ); + + if ( !done[ id ] ) { + done[ id ] = true; + ret.push( array[ i ] ); + } + } + + } catch( e ) { + ret = array; + } + + return ret; + }, + + grep: function( elems, callback, inv ) { + var ret = []; + + // Go through the array, only saving the items + // that pass the validator function + for ( var i = 0, length = elems.length; i < length; i++ ) + if ( !inv != !callback( elems[ i ], i ) ) + ret.push( elems[ i ] ); + + return ret; + }, + + map: function( elems, callback ) { + var ret = []; + + // Go through the array, translating each of the items to their + // new value (or values). + for ( var i = 0, length = elems.length; i < length; i++ ) { + var value = callback( elems[ i ], i ); + + if ( value != null ) + ret[ ret.length ] = value; + } + + return ret.concat.apply( [], ret ); + } +}); + +// Use of jQuery.browser is deprecated. +// It's included for backwards compatibility and plugins, +// although they should work to migrate away. + +var userAgent = navigator.userAgent.toLowerCase(); + +// Figure out what browser is being used +jQuery.browser = { + version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1], + safari: /webkit/.test( userAgent ), + opera: /opera/.test( userAgent ), + msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ), + mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent ) +}; + +jQuery.each({ + parent: function(elem){return elem.parentNode;}, + parents: function(elem){return jQuery.dir(elem,"parentNode");}, + next: function(elem){return jQuery.nth(elem,2,"nextSibling");}, + prev: function(elem){return jQuery.nth(elem,2,"previousSibling");}, + nextAll: function(elem){return jQuery.dir(elem,"nextSibling");}, + prevAll: function(elem){return jQuery.dir(elem,"previousSibling");}, + siblings: function(elem){return jQuery.sibling(elem.parentNode.firstChild,elem);}, + children: function(elem){return jQuery.sibling(elem.firstChild);}, + contents: function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes);} +}, function(name, fn){ + jQuery.fn[ name ] = function( selector ) { + var ret = jQuery.map( this, fn ); + + if ( selector && typeof selector == "string" ) + ret = jQuery.multiFilter( selector, ret ); + + return this.pushStack( jQuery.unique( ret ), name, selector ); + }; +}); + +jQuery.each({ + appendTo: "append", + prependTo: "prepend", + insertBefore: "before", + insertAfter: "after", + replaceAll: "replaceWith" +}, function(name, original){ + jQuery.fn[ name ] = function() { + var args = arguments; + + return this.each(function(){ + for ( var i = 0, length = args.length; i < length; i++ ) + jQuery( args[ i ] )[ original ]( this ); + }); + }; +}); + +jQuery.each({ + removeAttr: function( name ) { + jQuery.attr( this, name, "" ); + if (this.nodeType == 1) + this.removeAttribute( name ); + }, + + addClass: function( classNames ) { + jQuery.className.add( this, classNames ); + }, + + removeClass: function( classNames ) { + jQuery.className.remove( this, classNames ); + }, + + toggleClass: function( classNames, state ) { + if( typeof state !== "boolean" ) + state = !jQuery.className.has( this, classNames ); + jQuery.className[ state ? "add" : "remove" ]( this, classNames ); + }, + + remove: function( selector ) { + if ( !selector || jQuery.filter( selector, [ this ] ).length ) { + // Prevent memory leaks + jQuery( "*", this ).add([this]).each(function(){ + jQuery.event.remove(this); + jQuery.removeData(this); + }); + if (this.parentNode) + this.parentNode.removeChild( this ); + } + }, + + empty: function() { + // Remove element nodes and prevent memory leaks + jQuery( ">*", this ).remove(); + + // Remove any remaining nodes + while ( this.firstChild ) + this.removeChild( this.firstChild ); + } +}, function(name, fn){ + jQuery.fn[ name ] = function(){ + return this.each( fn, arguments ); + }; +}); + +// Helper function used by the dimensions and offset modules +function num(elem, prop) { + return elem[0] && parseInt( jQuery.curCSS(elem[0], prop, true), 10 ) || 0; +} +var expando = "jQuery" + now(), uuid = 0, windowData = {}; + +jQuery.extend({ + cache: {}, + + data: function( elem, name, data ) { + elem = elem == window ? + windowData : + elem; + + var id = elem[ expando ]; + + // Compute a unique ID for the element + if ( !id ) + id = elem[ expando ] = ++uuid; + + // Only generate the data cache if we're + // trying to access or manipulate it + if ( name && !jQuery.cache[ id ] ) + jQuery.cache[ id ] = {}; + + // Prevent overriding the named cache with undefined values + if ( data !== undefined ) + jQuery.cache[ id ][ name ] = data; + + // Return the named cache data, or the ID for the element + return name ? + jQuery.cache[ id ][ name ] : + id; + }, + + removeData: function( elem, name ) { + elem = elem == window ? + windowData : + elem; + + var id = elem[ expando ]; + + // If we want to remove a specific section of the element's data + if ( name ) { + if ( jQuery.cache[ id ] ) { + // Remove the section of cache data + delete jQuery.cache[ id ][ name ]; + + // If we've removed all the data, remove the element's cache + name = ""; + + for ( name in jQuery.cache[ id ] ) + break; + + if ( !name ) + jQuery.removeData( elem ); + } + + // Otherwise, we want to remove all of the element's data + } else { + // Clean up the element expando + try { + delete elem[ expando ]; + } catch(e){ + // IE has trouble directly removing the expando + // but it's ok with using removeAttribute + if ( elem.removeAttribute ) + elem.removeAttribute( expando ); + } + + // Completely remove the data cache + delete jQuery.cache[ id ]; + } + }, + queue: function( elem, type, data ) { + if ( elem ){ + + type = (type || "fx") + "queue"; + + var q = jQuery.data( elem, type ); + + if ( !q || jQuery.isArray(data) ) + q = jQuery.data( elem, type, jQuery.makeArray(data) ); + else if( data ) + q.push( data ); + + } + return q; + }, + + dequeue: function( elem, type ){ + var queue = jQuery.queue( elem, type ), + fn = queue.shift(); + + if( !type || type === "fx" ) + fn = queue[0]; + + if( fn !== undefined ) + fn.call(elem); + } +}); + +jQuery.fn.extend({ + data: function( key, value ){ + var parts = key.split("."); + parts[1] = parts[1] ? "." + parts[1] : ""; + + if ( value === undefined ) { + var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]); + + if ( data === undefined && this.length ) + data = jQuery.data( this[0], key ); + + return data === undefined && parts[1] ? + this.data( parts[0] ) : + data; + } else + return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function(){ + jQuery.data( this, key, value ); + }); + }, + + removeData: function( key ){ + return this.each(function(){ + jQuery.removeData( this, key ); + }); + }, + queue: function(type, data){ + if ( typeof type !== "string" ) { + data = type; + type = "fx"; + } + + if ( data === undefined ) + return jQuery.queue( this[0], type ); + + return this.each(function(){ + var queue = jQuery.queue( this, type, data ); + + if( type == "fx" && queue.length == 1 ) + queue[0].call(this); + }); + }, + dequeue: function(type){ + return this.each(function(){ + jQuery.dequeue( this, type ); + }); + } +});/*! + * Sizzle CSS Selector Engine - v0.9.3 + * Copyright 2009, The Dojo Foundation + * Released under the MIT, BSD, and GPL Licenses. + * More information: http://sizzlejs.com/ + */ +(function(){ + +var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]+['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[]+)+|[>+~])(\s*,\s*)?/g, + done = 0, + toString = Object.prototype.toString; + +var Sizzle = function(selector, context, results, seed) { + results = results || []; + context = context || document; + + if ( context.nodeType !== 1 && context.nodeType !== 9 ) + return []; + + if ( !selector || typeof selector !== "string" ) { + return results; + } + + var parts = [], m, set, checkSet, check, mode, extra, prune = true; + + // Reset the position of the chunker regexp (start from head) + chunker.lastIndex = 0; + + while ( (m = chunker.exec(selector)) !== null ) { + parts.push( m[1] ); + + if ( m[2] ) { + extra = RegExp.rightContext; + break; + } + } + + if ( parts.length > 1 && origPOS.exec( selector ) ) { + if ( parts.length === 2 && Expr.relative[ parts[0] ] ) { + set = posProcess( parts[0] + parts[1], context ); + } else { + set = Expr.relative[ parts[0] ] ? + [ context ] : + Sizzle( parts.shift(), context ); + + while ( parts.length ) { + selector = parts.shift(); + + if ( Expr.relative[ selector ] ) + selector += parts.shift(); + + set = posProcess( selector, set ); + } + } + } else { + var ret = seed ? + { expr: parts.pop(), set: makeArray(seed) } : + Sizzle.find( parts.pop(), parts.length === 1 && context.parentNode ? context.parentNode : context, isXML(context) ); + set = Sizzle.filter( ret.expr, ret.set ); + + if ( parts.length > 0 ) { + checkSet = makeArray(set); + } else { + prune = false; + } + + while ( parts.length ) { + var cur = parts.pop(), pop = cur; + + if ( !Expr.relative[ cur ] ) { + cur = ""; + } else { + pop = parts.pop(); + } + + if ( pop == null ) { + pop = context; + } + + Expr.relative[ cur ]( checkSet, pop, isXML(context) ); + } + } + + if ( !checkSet ) { + checkSet = set; + } + + if ( !checkSet ) { + throw "Syntax error, unrecognized expression: " + (cur || selector); + } + + if ( toString.call(checkSet) === "[object Array]" ) { + if ( !prune ) { + results.push.apply( results, checkSet ); + } else if ( context.nodeType === 1 ) { + for ( var i = 0; checkSet[i] != null; i++ ) { + if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) { + results.push( set[i] ); + } + } + } else { + for ( var i = 0; checkSet[i] != null; i++ ) { + if ( checkSet[i] && checkSet[i].nodeType === 1 ) { + results.push( set[i] ); + } + } + } + } else { + makeArray( checkSet, results ); + } + + if ( extra ) { + Sizzle( extra, context, results, seed ); + } + + return results; +}; + +Sizzle.matches = function(expr, set){ + return Sizzle(expr, null, null, set); +}; + +Sizzle.find = function(expr, context, isXML){ + var set, match; + + if ( !expr ) { + return []; + } + + for ( var i = 0, l = Expr.order.length; i < l; i++ ) { + var type = Expr.order[i], match; + + if ( (match = Expr.match[ type ].exec( expr )) ) { + var left = RegExp.leftContext; + + if ( left.substr( left.length - 1 ) !== "\\" ) { + match[1] = (match[1] || "").replace(/\\/g, ""); + set = Expr.find[ type ]( match, context, isXML ); + if ( set != null ) { + expr = expr.replace( Expr.match[ type ], "" ); + break; + } + } + } + } + + if ( !set ) { + set = context.getElementsByTagName("*"); + } + + return {set: set, expr: expr}; +}; + +Sizzle.filter = function(expr, set, inplace, not){ + var old = expr, result = [], curLoop = set, match, anyFound; + + while ( expr && set.length ) { + for ( var type in Expr.filter ) { + if ( (match = Expr.match[ type ].exec( expr )) != null ) { + var filter = Expr.filter[ type ], found, item; + anyFound = false; + + if ( curLoop == result ) { + result = []; + } + + if ( Expr.preFilter[ type ] ) { + match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not ); + + if ( !match ) { + anyFound = found = true; + } else if ( match === true ) { + continue; + } + } + + if ( match ) { + for ( var i = 0; (item = curLoop[i]) != null; i++ ) { + if ( item ) { + found = filter( item, match, i, curLoop ); + var pass = not ^ !!found; + + if ( inplace && found != null ) { + if ( pass ) { + anyFound = true; + } else { + curLoop[i] = false; + } + } else if ( pass ) { + result.push( item ); + anyFound = true; + } + } + } + } + + if ( found !== undefined ) { + if ( !inplace ) { + curLoop = result; + } + + expr = expr.replace( Expr.match[ type ], "" ); + + if ( !anyFound ) { + return []; + } + + break; + } + } + } + + expr = expr.replace(/\s*,\s*/, ""); + + // Improper expression + if ( expr == old ) { + if ( anyFound == null ) { + throw "Syntax error, unrecognized expression: " + expr; + } else { + break; + } + } + + old = expr; + } + + return curLoop; +}; + +var Expr = Sizzle.selectors = { + order: [ "ID", "NAME", "TAG" ], + match: { + ID: /#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/, + CLASS: /\.((?:[\w\u00c0-\uFFFF_-]|\\.)+)/, + NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF_-]|\\.)+)['"]*\]/, + ATTR: /\[\s*((?:[\w\u00c0-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/, + TAG: /^((?:[\w\u00c0-\uFFFF\*_-]|\\.)+)/, + CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/, + POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/, + PSEUDO: /:((?:[\w\u00c0-\uFFFF_-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/ + }, + attrMap: { + "class": "className", + "for": "htmlFor" + }, + attrHandle: { + href: function(elem){ + return elem.getAttribute("href"); + } + }, + relative: { + "+": function(checkSet, part){ + for ( var i = 0, l = checkSet.length; i < l; i++ ) { + var elem = checkSet[i]; + if ( elem ) { + var cur = elem.previousSibling; + while ( cur && cur.nodeType !== 1 ) { + cur = cur.previousSibling; + } + checkSet[i] = typeof part === "string" ? + cur || false : + cur === part; + } + } + + if ( typeof part === "string" ) { + Sizzle.filter( part, checkSet, true ); + } + }, + ">": function(checkSet, part, isXML){ + if ( typeof part === "string" && !/\W/.test(part) ) { + part = isXML ? part : part.toUpperCase(); + + for ( var i = 0, l = checkSet.length; i < l; i++ ) { + var elem = checkSet[i]; + if ( elem ) { + var parent = elem.parentNode; + checkSet[i] = parent.nodeName === part ? parent : false; + } + } + } else { + for ( var i = 0, l = checkSet.length; i < l; i++ ) { + var elem = checkSet[i]; + if ( elem ) { + checkSet[i] = typeof part === "string" ? + elem.parentNode : + elem.parentNode === part; + } + } + + if ( typeof part === "string" ) { + Sizzle.filter( part, checkSet, true ); + } + } + }, + "": function(checkSet, part, isXML){ + var doneName = "done" + (done++), checkFn = dirCheck; + + if ( !part.match(/\W/) ) { + var nodeCheck = part = isXML ? part : part.toUpperCase(); + checkFn = dirNodeCheck; + } + + checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML); + }, + "~": function(checkSet, part, isXML){ + var doneName = "done" + (done++), checkFn = dirCheck; + + if ( typeof part === "string" && !part.match(/\W/) ) { + var nodeCheck = part = isXML ? part : part.toUpperCase(); + checkFn = dirNodeCheck; + } + + checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML); + } + }, + find: { + ID: function(match, context, isXML){ + if ( typeof context.getElementById !== "undefined" && !isXML ) { + var m = context.getElementById(match[1]); + return m ? [m] : []; + } + }, + NAME: function(match, context, isXML){ + if ( typeof context.getElementsByName !== "undefined" && !isXML ) { + return context.getElementsByName(match[1]); + } + }, + TAG: function(match, context){ + return context.getElementsByTagName(match[1]); + } + }, + preFilter: { + CLASS: function(match, curLoop, inplace, result, not){ + match = " " + match[1].replace(/\\/g, "") + " "; + + var elem; + for ( var i = 0; (elem = curLoop[i]) != null; i++ ) { + if ( elem ) { + if ( not ^ (" " + elem.className + " ").indexOf(match) >= 0 ) { + if ( !inplace ) + result.push( elem ); + } else if ( inplace ) { + curLoop[i] = false; + } + } + } + + return false; + }, + ID: function(match){ + return match[1].replace(/\\/g, ""); + }, + TAG: function(match, curLoop){ + for ( var i = 0; curLoop[i] === false; i++ ){} + return curLoop[i] && isXML(curLoop[i]) ? match[1] : match[1].toUpperCase(); + }, + CHILD: function(match){ + if ( match[1] == "nth" ) { + // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6' + var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec( + match[2] == "even" && "2n" || match[2] == "odd" && "2n+1" || + !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]); + + // calculate the numbers (first)n+(last) including if they are negative + match[2] = (test[1] + (test[2] || 1)) - 0; + match[3] = test[3] - 0; + } + + // TODO: Move to normal caching system + match[0] = "done" + (done++); + + return match; + }, + ATTR: function(match){ + var name = match[1].replace(/\\/g, ""); + + if ( Expr.attrMap[name] ) { + match[1] = Expr.attrMap[name]; + } + + if ( match[2] === "~=" ) { + match[4] = " " + match[4] + " "; + } + + return match; + }, + PSEUDO: function(match, curLoop, inplace, result, not){ + if ( match[1] === "not" ) { + // If we're dealing with a complex expression, or a simple one + if ( match[3].match(chunker).length > 1 ) { + match[3] = Sizzle(match[3], null, null, curLoop); + } else { + var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); + if ( !inplace ) { + result.push.apply( result, ret ); + } + return false; + } + } else if ( Expr.match.POS.test( match[0] ) ) { + return true; + } + + return match; + }, + POS: function(match){ + match.unshift( true ); + return match; + } + }, + filters: { + enabled: function(elem){ + return elem.disabled === false && elem.type !== "hidden"; + }, + disabled: function(elem){ + return elem.disabled === true; + }, + checked: function(elem){ + return elem.checked === true; + }, + selected: function(elem){ + // Accessing this property makes selected-by-default + // options in Safari work properly + elem.parentNode.selectedIndex; + return elem.selected === true; + }, + parent: function(elem){ + return !!elem.firstChild; + }, + empty: function(elem){ + return !elem.firstChild; + }, + has: function(elem, i, match){ + return !!Sizzle( match[3], elem ).length; + }, + header: function(elem){ + return /h\d/i.test( elem.nodeName ); + }, + text: function(elem){ + return "text" === elem.type; + }, + radio: function(elem){ + return "radio" === elem.type; + }, + checkbox: function(elem){ + return "checkbox" === elem.type; + }, + file: function(elem){ + return "file" === elem.type; + }, + password: function(elem){ + return "password" === elem.type; + }, + submit: function(elem){ + return "submit" === elem.type; + }, + image: function(elem){ + return "image" === elem.type; + }, + reset: function(elem){ + return "reset" === elem.type; + }, + button: function(elem){ + return "button" === elem.type || elem.nodeName.toUpperCase() === "BUTTON"; + }, + input: function(elem){ + return /input|select|textarea|button/i.test(elem.nodeName); + } + }, + setFilters: { + first: function(elem, i){ + return i === 0; + }, + last: function(elem, i, match, array){ + return i === array.length - 1; + }, + even: function(elem, i){ + return i % 2 === 0; + }, + odd: function(elem, i){ + return i % 2 === 1; + }, + lt: function(elem, i, match){ + return i < match[3] - 0; + }, + gt: function(elem, i, match){ + return i > match[3] - 0; + }, + nth: function(elem, i, match){ + return match[3] - 0 == i; + }, + eq: function(elem, i, match){ + return match[3] - 0 == i; + } + }, + filter: { + CHILD: function(elem, match){ + var type = match[1], parent = elem.parentNode; + + var doneName = match[0]; + + if ( parent && (!parent[ doneName ] || !elem.nodeIndex) ) { + var count = 1; + + for ( var node = parent.firstChild; node; node = node.nextSibling ) { + if ( node.nodeType == 1 ) { + node.nodeIndex = count++; + } + } + + parent[ doneName ] = count - 1; + } + + if ( type == "first" ) { + return elem.nodeIndex == 1; + } else if ( type == "last" ) { + return elem.nodeIndex == parent[ doneName ]; + } else if ( type == "only" ) { + return parent[ doneName ] == 1; + } else if ( type == "nth" ) { + var add = false, first = match[2], last = match[3]; + + if ( first == 1 && last == 0 ) { + return true; + } + + if ( first == 0 ) { + if ( elem.nodeIndex == last ) { + add = true; + } + } else if ( (elem.nodeIndex - last) % first == 0 && (elem.nodeIndex - last) / first >= 0 ) { + add = true; + } + + return add; + } + }, + PSEUDO: function(elem, match, i, array){ + var name = match[1], filter = Expr.filters[ name ]; + + if ( filter ) { + return filter( elem, i, match, array ); + } else if ( name === "contains" ) { + return (elem.textContent || elem.innerText || "").indexOf(match[3]) >= 0; + } else if ( name === "not" ) { + var not = match[3]; + + for ( var i = 0, l = not.length; i < l; i++ ) { + if ( not[i] === elem ) { + return false; + } + } + + return true; + } + }, + ID: function(elem, match){ + return elem.nodeType === 1 && elem.getAttribute("id") === match; + }, + TAG: function(elem, match){ + return (match === "*" && elem.nodeType === 1) || elem.nodeName === match; + }, + CLASS: function(elem, match){ + return match.test( elem.className ); + }, + ATTR: function(elem, match){ + var result = Expr.attrHandle[ match[1] ] ? Expr.attrHandle[ match[1] ]( elem ) : elem[ match[1] ] || elem.getAttribute( match[1] ), value = result + "", type = match[2], check = match[4]; + return result == null ? + type === "!=" : + type === "=" ? + value === check : + type === "*=" ? + value.indexOf(check) >= 0 : + type === "~=" ? + (" " + value + " ").indexOf(check) >= 0 : + !match[4] ? + result : + type === "!=" ? + value != check : + type === "^=" ? + value.indexOf(check) === 0 : + type === "$=" ? + value.substr(value.length - check.length) === check : + type === "|=" ? + value === check || value.substr(0, check.length + 1) === check + "-" : + false; + }, + POS: function(elem, match, i, array){ + var name = match[2], filter = Expr.setFilters[ name ]; + + if ( filter ) { + return filter( elem, i, match, array ); + } + } + } +}; + +var origPOS = Expr.match.POS; + +for ( var type in Expr.match ) { + Expr.match[ type ] = RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source ); +} + +var makeArray = function(array, results) { + array = Array.prototype.slice.call( array ); + + if ( results ) { + results.push.apply( results, array ); + return results; + } + + return array; +}; + +// Perform a simple check to determine if the browser is capable of +// converting a NodeList to an array using builtin methods. +try { + Array.prototype.slice.call( document.documentElement.childNodes ); + +// Provide a fallback method if it does not work +} catch(e){ + makeArray = function(array, results) { + var ret = results || []; + + if ( toString.call(array) === "[object Array]" ) { + Array.prototype.push.apply( ret, array ); + } else { + if ( typeof array.length === "number" ) { + for ( var i = 0, l = array.length; i < l; i++ ) { + ret.push( array[i] ); + } + } else { + for ( var i = 0; array[i]; i++ ) { + ret.push( array[i] ); + } + } + } + + return ret; + }; +} + +// Check to see if the browser returns elements by name when +// querying by getElementById (and provide a workaround) +(function(){ + // We're going to inject a fake input element with a specified name + var form = document.createElement("form"), + id = "script" + (new Date).getTime(); + form.innerHTML = "<input name='" + id + "'/>"; + + // Inject it into the root element, check its status, and remove it quickly + var root = document.documentElement; + root.insertBefore( form, root.firstChild ); + + // The workaround has to do additional checks after a getElementById + // Which slows things down for other browsers (hence the branching) + if ( !!document.getElementById( id ) ) { + Expr.find.ID = function(match, context, isXML){ + if ( typeof context.getElementById !== "undefined" && !isXML ) { + var m = context.getElementById(match[1]); + return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : []; + } + }; + + Expr.filter.ID = function(elem, match){ + var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); + return elem.nodeType === 1 && node && node.nodeValue === match; + }; + } + + root.removeChild( form ); +})(); + +(function(){ + // Check to see if the browser returns only elements + // when doing getElementsByTagName("*") + + // Create a fake element + var div = document.createElement("div"); + div.appendChild( document.createComment("") ); + + // Make sure no comments are found + if ( div.getElementsByTagName("*").length > 0 ) { + Expr.find.TAG = function(match, context){ + var results = context.getElementsByTagName(match[1]); + + // Filter out possible comments + if ( match[1] === "*" ) { + var tmp = []; + + for ( var i = 0; results[i]; i++ ) { + if ( results[i].nodeType === 1 ) { + tmp.push( results[i] ); + } + } + + results = tmp; + } + + return results; + }; + } + + // Check to see if an attribute returns normalized href attributes + div.innerHTML = "<a href='#'></a>"; + if ( div.firstChild && div.firstChild.getAttribute("href") !== "#" ) { + Expr.attrHandle.href = function(elem){ + return elem.getAttribute("href", 2); + }; + } +})(); + +if ( document.querySelectorAll ) (function(){ + var oldSizzle = Sizzle, div = document.createElement("div"); + div.innerHTML = "<p class='TEST'></p>"; + + // Safari can't handle uppercase or unicode characters when + // in quirks mode. + if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { + return; + } + + Sizzle = function(query, context, extra, seed){ + context = context || document; + + // Only use querySelectorAll on non-XML documents + // (ID selectors don't work in non-HTML documents) + if ( !seed && context.nodeType === 9 && !isXML(context) ) { + try { + return makeArray( context.querySelectorAll(query), extra ); + } catch(e){} + } + + return oldSizzle(query, context, extra, seed); + }; + + Sizzle.find = oldSizzle.find; + Sizzle.filter = oldSizzle.filter; + Sizzle.selectors = oldSizzle.selectors; + Sizzle.matches = oldSizzle.matches; +})(); + +if ( document.getElementsByClassName && document.documentElement.getElementsByClassName ) { + Expr.order.splice(1, 0, "CLASS"); + Expr.find.CLASS = function(match, context) { + return context.getElementsByClassName(match[1]); + }; +} + +function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { + for ( var i = 0, l = checkSet.length; i < l; i++ ) { + var elem = checkSet[i]; + if ( elem ) { + elem = elem[dir]; + var match = false; + + while ( elem && elem.nodeType ) { + var done = elem[doneName]; + if ( done ) { + match = checkSet[ done ]; + break; + } + + if ( elem.nodeType === 1 && !isXML ) + elem[doneName] = i; + + if ( elem.nodeName === cur ) { + match = elem; + break; + } + + elem = elem[dir]; + } + + checkSet[i] = match; + } + } +} + +function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { + for ( var i = 0, l = checkSet.length; i < l; i++ ) { + var elem = checkSet[i]; + if ( elem ) { + elem = elem[dir]; + var match = false; + + while ( elem && elem.nodeType ) { + if ( elem[doneName] ) { + match = checkSet[ elem[doneName] ]; + break; + } + + if ( elem.nodeType === 1 ) { + if ( !isXML ) + elem[doneName] = i; + + if ( typeof cur !== "string" ) { + if ( elem === cur ) { + match = true; + break; + } + + } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) { + match = elem; + break; + } + } + + elem = elem[dir]; + } + + checkSet[i] = match; + } + } +} + +var contains = document.compareDocumentPosition ? function(a, b){ + return a.compareDocumentPosition(b) & 16; +} : function(a, b){ + return a !== b && (a.contains ? a.contains(b) : true); +}; + +var isXML = function(elem){ + return elem.nodeType === 9 && elem.documentElement.nodeName !== "HTML" || + !!elem.ownerDocument && isXML( elem.ownerDocument ); +}; + +var posProcess = function(selector, context){ + var tmpSet = [], later = "", match, + root = context.nodeType ? [context] : context; + + // Position selectors must be done after the filter + // And so must :not(positional) so we move all PSEUDOs to the end + while ( (match = Expr.match.PSEUDO.exec( selector )) ) { + later += match[0]; + selector = selector.replace( Expr.match.PSEUDO, "" ); + } + + selector = Expr.relative[selector] ? selector + "*" : selector; + + for ( var i = 0, l = root.length; i < l; i++ ) { + Sizzle( selector, root[i], tmpSet ); + } + + return Sizzle.filter( later, tmpSet ); +}; + +// EXPOSE +jQuery.find = Sizzle; +jQuery.filter = Sizzle.filter; +jQuery.expr = Sizzle.selectors; +jQuery.expr[":"] = jQuery.expr.filters; + +Sizzle.selectors.filters.hidden = function(elem){ + return "hidden" === elem.type || + jQuery.css(elem, "display") === "none" || + jQuery.css(elem, "visibility") === "hidden"; +}; + +Sizzle.selectors.filters.visible = function(elem){ + return "hidden" !== elem.type && + jQuery.css(elem, "display") !== "none" && + jQuery.css(elem, "visibility") !== "hidden"; +}; + +Sizzle.selectors.filters.animated = function(elem){ + return jQuery.grep(jQuery.timers, function(fn){ + return elem === fn.elem; + }).length; +}; + +jQuery.multiFilter = function( expr, elems, not ) { + if ( not ) { + expr = ":not(" + expr + ")"; + } + + return Sizzle.matches(expr, elems); +}; + +jQuery.dir = function( elem, dir ){ + var matched = [], cur = elem[dir]; + while ( cur && cur != document ) { + if ( cur.nodeType == 1 ) + matched.push( cur ); + cur = cur[dir]; + } + return matched; +}; + +jQuery.nth = function(cur, result, dir, elem){ + result = result || 1; + var num = 0; + + for ( ; cur; cur = cur[dir] ) + if ( cur.nodeType == 1 && ++num == result ) + break; + + return cur; +}; + +jQuery.sibling = function(n, elem){ + var r = []; + + for ( ; n; n = n.nextSibling ) { + if ( n.nodeType == 1 && n != elem ) + r.push( n ); + } + + return r; +}; + +return; + +window.Sizzle = Sizzle; + +})(); +/* + * A number of helper functions used for managing events. + * Many of the ideas behind this code originated from + * Dean Edwards' addEvent library. + */ +jQuery.event = { + + // Bind an event to an element + // Original by Dean Edwards + add: function(elem, types, handler, data) { + if ( elem.nodeType == 3 || elem.nodeType == 8 ) + return; + + // For whatever reason, IE has trouble passing the window object + // around, causing it to be cloned in the process + if ( elem.setInterval && elem != window ) + elem = window; + + // Make sure that the function being executed has a unique ID + if ( !handler.guid ) + handler.guid = this.guid++; + + // if data is passed, bind to handler + if ( data !== undefined ) { + // Create temporary function pointer to original handler + var fn = handler; + + // Create unique handler function, wrapped around original handler + handler = this.proxy( fn ); + + // Store data in unique handler + handler.data = data; + } + + // Init the element's event structure + var events = jQuery.data(elem, "events") || jQuery.data(elem, "events", {}), + handle = jQuery.data(elem, "handle") || jQuery.data(elem, "handle", function(){ + // Handle the second event of a trigger and when + // an event is called after a page has unloaded + return typeof jQuery !== "undefined" && !jQuery.event.triggered ? + jQuery.event.handle.apply(arguments.callee.elem, arguments) : + undefined; + }); + // Add elem as a property of the handle function + // This is to prevent a memory leak with non-native + // event in IE. + handle.elem = elem; + + // Handle multiple events separated by a space + // jQuery(...).bind("mouseover mouseout", fn); + jQuery.each(types.split(/\s+/), function(index, type) { + // Namespaced event handlers + var namespaces = type.split("."); + type = namespaces.shift(); + handler.type = namespaces.slice().sort().join("."); + + // Get the current list of functions bound to this event + var handlers = events[type]; + + if ( jQuery.event.specialAll[type] ) + jQuery.event.specialAll[type].setup.call(elem, data, namespaces); + + // Init the event handler queue + if (!handlers) { + handlers = events[type] = {}; + + // Check for a special event handler + // Only use addEventListener/attachEvent if the special + // events handler returns false + if ( !jQuery.event.special[type] || jQuery.event.special[type].setup.call(elem, data, namespaces) === false ) { + // Bind the global event handler to the element + if (elem.addEventListener) + elem.addEventListener(type, handle, false); + else if (elem.attachEvent) + elem.attachEvent("on" + type, handle); + } + } + + // Add the function to the element's handler list + handlers[handler.guid] = handler; + + // Keep track of which events have been used, for global triggering + jQuery.event.global[type] = true; + }); + + // Nullify elem to prevent memory leaks in IE + elem = null; + }, + + guid: 1, + global: {}, + + // Detach an event or set of events from an element + remove: function(elem, types, handler) { + // don't do events on text and comment nodes + if ( elem.nodeType == 3 || elem.nodeType == 8 ) + return; + + var events = jQuery.data(elem, "events"), ret, index; + + if ( events ) { + // Unbind all events for the element + if ( types === undefined || (typeof types === "string" && types.charAt(0) == ".") ) + for ( var type in events ) + this.remove( elem, type + (types || "") ); + else { + // types is actually an event object here + if ( types.type ) { + handler = types.handler; + types = types.type; + } + + // Handle multiple events seperated by a space + // jQuery(...).unbind("mouseover mouseout", fn); + jQuery.each(types.split(/\s+/), function(index, type){ + // Namespaced event handlers + var namespaces = type.split("."); + type = namespaces.shift(); + var namespace = RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)"); + + if ( events[type] ) { + // remove the given handler for the given type + if ( handler ) + delete events[type][handler.guid]; + + // remove all handlers for the given type + else + for ( var handle in events[type] ) + // Handle the removal of namespaced events + if ( namespace.test(events[type][handle].type) ) + delete events[type][handle]; + + if ( jQuery.event.specialAll[type] ) + jQuery.event.specialAll[type].teardown.call(elem, namespaces); + + // remove generic event handler if no more handlers exist + for ( ret in events[type] ) break; + if ( !ret ) { + if ( !jQuery.event.special[type] || jQuery.event.special[type].teardown.call(elem, namespaces) === false ) { + if (elem.removeEventListener) + elem.removeEventListener(type, jQuery.data(elem, "handle"), false); + else if (elem.detachEvent) + elem.detachEvent("on" + type, jQuery.data(elem, "handle")); + } + ret = null; + delete events[type]; + } + } + }); + } + + // Remove the expando if it's no longer used + for ( ret in events ) break; + if ( !ret ) { + var handle = jQuery.data( elem, "handle" ); + if ( handle ) handle.elem = null; + jQuery.removeData( elem, "events" ); + jQuery.removeData( elem, "handle" ); + } + } + }, + + // bubbling is internal + trigger: function( event, data, elem, bubbling ) { + // Event object or event type + var type = event.type || event; + + if( !bubbling ){ + event = typeof event === "object" ? + // jQuery.Event object + event[expando] ? event : + // Object literal + jQuery.extend( jQuery.Event(type), event ) : + // Just the event type (string) + jQuery.Event(type); + + if ( type.indexOf("!") >= 0 ) { + event.type = type = type.slice(0, -1); + event.exclusive = true; + } + + // Handle a global trigger + if ( !elem ) { + // Don't bubble custom events when global (to avoid too much overhead) + event.stopPropagation(); + // Only trigger if we've ever bound an event for it + if ( this.global[type] ) + jQuery.each( jQuery.cache, function(){ + if ( this.events && this.events[type] ) + jQuery.event.trigger( event, data, this.handle.elem ); + }); + } + + // Handle triggering a single element + + // don't do events on text and comment nodes + if ( !elem || elem.nodeType == 3 || elem.nodeType == 8 ) + return undefined; + + // Clean up in case it is reused + event.result = undefined; + event.target = elem; + + // Clone the incoming data, if any + data = jQuery.makeArray(data); + data.unshift( event ); + } + + event.currentTarget = elem; + + // Trigger the event, it is assumed that "handle" is a function + var handle = jQuery.data(elem, "handle"); + if ( handle ) + handle.apply( elem, data ); + + // Handle triggering native .onfoo handlers (and on links since we don't call .click() for links) + if ( (!elem[type] || (jQuery.nodeName(elem, 'a') && type == "click")) && elem["on"+type] && elem["on"+type].apply( elem, data ) === false ) + event.result = false; + + // Trigger the native events (except for clicks on links) + if ( !bubbling && elem[type] && !event.isDefaultPrevented() && !(jQuery.nodeName(elem, 'a') && type == "click") ) { + this.triggered = true; + try { + elem[ type ](); + // prevent IE from throwing an error for some hidden elements + } catch (e) {} + } + + this.triggered = false; + + if ( !event.isPropagationStopped() ) { + var parent = elem.parentNode || elem.ownerDocument; + if ( parent ) + jQuery.event.trigger(event, data, parent, true); + } + }, + + handle: function(event) { + // returned undefined or false + var all, handlers; + + event = arguments[0] = jQuery.event.fix( event || window.event ); + + // Namespaced event handlers + var namespaces = event.type.split("."); + event.type = namespaces.shift(); + + // Cache this now, all = true means, any handler + all = !namespaces.length && !event.exclusive; + + var namespace = RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)"); + + handlers = ( jQuery.data(this, "events") || {} )[event.type]; + + for ( var j in handlers ) { + var handler = handlers[j]; + + // Filter the functions by class + if ( all || namespace.test(handler.type) ) { + // Pass in a reference to the handler function itself + // So that we can later remove it + event.handler = handler; + event.data = handler.data; + + var ret = handler.apply(this, arguments); + + if( ret !== undefined ){ + event.result = ret; + if ( ret === false ) { + event.preventDefault(); + event.stopPropagation(); + } + } + + if( event.isImmediatePropagationStopped() ) + break; + + } + } + }, + + props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "), + + fix: function(event) { + if ( event[expando] ) + return event; + + // store a copy of the original event object + // and "clone" to set read-only properties + var originalEvent = event; + event = jQuery.Event( originalEvent ); + + for ( var i = this.props.length, prop; i; ){ + prop = this.props[ --i ]; + event[ prop ] = originalEvent[ prop ]; + } + + // Fix target property, if necessary + if ( !event.target ) + event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either + + // check if target is a textnode (safari) + if ( event.target.nodeType == 3 ) + event.target = event.target.parentNode; + + // Add relatedTarget, if necessary + if ( !event.relatedTarget && event.fromElement ) + event.relatedTarget = event.fromElement == event.target ? event.toElement : event.fromElement; + + // Calculate pageX/Y if missing and clientX/Y available + if ( event.pageX == null && event.clientX != null ) { + var doc = document.documentElement, body = document.body; + event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc.clientLeft || 0); + event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc.clientTop || 0); + } + + // Add which for key events + if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) ) + event.which = event.charCode || event.keyCode; + + // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs) + if ( !event.metaKey && event.ctrlKey ) + event.metaKey = event.ctrlKey; + + // Add which for click: 1 == left; 2 == middle; 3 == right + // Note: button is not normalized, so don't use it + if ( !event.which && event.button ) + event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) )); + + return event; + }, + + proxy: function( fn, proxy ){ + proxy = proxy || function(){ return fn.apply(this, arguments); }; + // Set the guid of unique handler to the same of original handler, so it can be removed + proxy.guid = fn.guid = fn.guid || proxy.guid || this.guid++; + // So proxy can be declared as an argument + return proxy; + }, + + special: { + ready: { + // Make sure the ready event is setup + setup: bindReady, + teardown: function() {} + } + }, + + specialAll: { + live: { + setup: function( selector, namespaces ){ + jQuery.event.add( this, namespaces[0], liveHandler ); + }, + teardown: function( namespaces ){ + if ( namespaces.length ) { + var remove = 0, name = RegExp("(^|\\.)" + namespaces[0] + "(\\.|$)"); + + jQuery.each( (jQuery.data(this, "events").live || {}), function(){ + if ( name.test(this.type) ) + remove++; + }); + + if ( remove < 1 ) + jQuery.event.remove( this, namespaces[0], liveHandler ); + } + } + } + } +}; + +jQuery.Event = function( src ){ + // Allow instantiation without the 'new' keyword + if( !this.preventDefault ) + return new jQuery.Event(src); + + // Event object + if( src && src.type ){ + this.originalEvent = src; + this.type = src.type; + // Event type + }else + this.type = src; + + // timeStamp is buggy for some events on Firefox(#3843) + // So we won't rely on the native value + this.timeStamp = now(); + + // Mark it as fixed + this[expando] = true; +}; + +function returnFalse(){ + return false; +} +function returnTrue(){ + return true; +} + +// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding +// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html +jQuery.Event.prototype = { + preventDefault: function() { + this.isDefaultPrevented = returnTrue; + + var e = this.originalEvent; + if( !e ) + return; + // if preventDefault exists run it on the original event + if (e.preventDefault) + e.preventDefault(); + // otherwise set the returnValue property of the original event to false (IE) + e.returnValue = false; + }, + stopPropagation: function() { + this.isPropagationStopped = returnTrue; + + var e = this.originalEvent; + if( !e ) + return; + // if stopPropagation exists run it on the original event + if (e.stopPropagation) + e.stopPropagation(); + // otherwise set the cancelBubble property of the original event to true (IE) + e.cancelBubble = true; + }, + stopImmediatePropagation:function(){ + this.isImmediatePropagationStopped = returnTrue; + this.stopPropagation(); + }, + isDefaultPrevented: returnFalse, + isPropagationStopped: returnFalse, + isImmediatePropagationStopped: returnFalse +}; +// Checks if an event happened on an element within another element +// Used in jQuery.event.special.mouseenter and mouseleave handlers +var withinElement = function(event) { + // Check if mouse(over|out) are still within the same parent element + var parent = event.relatedTarget; + // Traverse up the tree + while ( parent && parent != this ) + try { parent = parent.parentNode; } + catch(e) { parent = this; } + + if( parent != this ){ + // set the correct event type + event.type = event.data; + // handle event if we actually just moused on to a non sub-element + jQuery.event.handle.apply( this, arguments ); + } +}; + +jQuery.each({ + mouseover: 'mouseenter', + mouseout: 'mouseleave' +}, function( orig, fix ){ + jQuery.event.special[ fix ] = { + setup: function(){ + jQuery.event.add( this, orig, withinElement, fix ); + }, + teardown: function(){ + jQuery.event.remove( this, orig, withinElement ); + } + }; +}); + +jQuery.fn.extend({ + bind: function( type, data, fn ) { + return type == "unload" ? this.one(type, data, fn) : this.each(function(){ + jQuery.event.add( this, type, fn || data, fn && data ); + }); + }, + + one: function( type, data, fn ) { + var one = jQuery.event.proxy( fn || data, function(event) { + jQuery(this).unbind(event, one); + return (fn || data).apply( this, arguments ); + }); + return this.each(function(){ + jQuery.event.add( this, type, one, fn && data); + }); + }, + + unbind: function( type, fn ) { + return this.each(function(){ + jQuery.event.remove( this, type, fn ); + }); + }, + + trigger: function( type, data ) { + return this.each(function(){ + jQuery.event.trigger( type, data, this ); + }); + }, + + triggerHandler: function( type, data ) { + if( this[0] ){ + var event = jQuery.Event(type); + event.preventDefault(); + event.stopPropagation(); + jQuery.event.trigger( event, data, this[0] ); + return event.result; + } + }, + + toggle: function( fn ) { + // Save reference to arguments for access in closure + var args = arguments, i = 1; + + // link all the functions, so any of them can unbind this click handler + while( i < args.length ) + jQuery.event.proxy( fn, args[i++] ); + + return this.click( jQuery.event.proxy( fn, function(event) { + // Figure out which function to execute + this.lastToggle = ( this.lastToggle || 0 ) % i; + + // Make sure that clicks stop + event.preventDefault(); + + // and execute the function + return args[ this.lastToggle++ ].apply( this, arguments ) || false; + })); + }, + + hover: function(fnOver, fnOut) { + return this.mouseenter(fnOver).mouseleave(fnOut); + }, + + ready: function(fn) { + // Attach the listeners + bindReady(); + + // If the DOM is already ready + if ( jQuery.isReady ) + // Execute the function immediately + fn.call( document, jQuery ); + + // Otherwise, remember the function for later + else + // Add the function to the wait list + jQuery.readyList.push( fn ); + + return this; + }, + + live: function( type, fn ){ + var proxy = jQuery.event.proxy( fn ); + proxy.guid += this.selector + type; + + jQuery(document).bind( liveConvert(type, this.selector), this.selector, proxy ); + + return this; + }, + + die: function( type, fn ){ + jQuery(document).unbind( liveConvert(type, this.selector), fn ? { guid: fn.guid + this.selector + type } : null ); + return this; + } +}); + +function liveHandler( event ){ + var check = RegExp("(^|\\.)" + event.type + "(\\.|$)"), + stop = true, + elems = []; + + jQuery.each(jQuery.data(this, "events").live || [], function(i, fn){ + if ( check.test(fn.type) ) { + var elem = jQuery(event.target).closest(fn.data)[0]; + if ( elem ) + elems.push({ elem: elem, fn: fn }); + } + }); + + jQuery.each(elems, function(){ + if ( this.fn.call(this.elem, event, this.fn.data) === false ) + stop = false; + }); + + return stop; +} + +function liveConvert(type, selector){ + return ["live", type, selector.replace(/\./g, "`").replace(/ /g, "|")].join("."); +} + +jQuery.extend({ + isReady: false, + readyList: [], + // Handle when the DOM is ready + ready: function() { + // Make sure that the DOM is not already loaded + if ( !jQuery.isReady ) { + // Remember that the DOM is ready + jQuery.isReady = true; + + // If there are functions bound, to execute + if ( jQuery.readyList ) { + // Execute all of them + jQuery.each( jQuery.readyList, function(){ + this.call( document, jQuery ); + }); + + // Reset the list of functions + jQuery.readyList = null; + } + + // Trigger any bound ready events + jQuery(document).triggerHandler("ready"); + } + } +}); + +var readyBound = false; + +function bindReady(){ + if ( readyBound ) return; + readyBound = true; + + // Mozilla, Opera and webkit nightlies currently support this event + if ( document.addEventListener ) { + // Use the handy event callback + document.addEventListener( "DOMContentLoaded", function(){ + document.removeEventListener( "DOMContentLoaded", arguments.callee, false ); + jQuery.ready(); + }, false ); + + // If IE event model is used + } else if ( document.attachEvent ) { + // ensure firing before onload, + // maybe late but safe also for iframes + document.attachEvent("onreadystatechange", function(){ + if ( document.readyState === "complete" ) { + document.detachEvent( "onreadystatechange", arguments.callee ); + jQuery.ready(); + } + }); + + // If IE and not an iframe + // continually check to see if the document is ready + if ( document.documentElement.doScroll && typeof window.frameElement === "undefined" ) (function(){ + if ( jQuery.isReady ) return; + + try { + // If IE is used, use the trick by Diego Perini + // http://javascript.nwbox.com/IEContentLoaded/ + document.documentElement.doScroll("left"); + } catch( error ) { + setTimeout( arguments.callee, 0 ); + return; + } + + // and execute any waiting functions + jQuery.ready(); + })(); + } + + // A fallback to window.onload, that will always work + jQuery.event.add( window, "load", jQuery.ready ); +} + +jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," + + "mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave," + + "change,select,submit,keydown,keypress,keyup,error").split(","), function(i, name){ + + // Handle event binding + jQuery.fn[name] = function(fn){ + return fn ? this.bind(name, fn) : this.trigger(name); + }; +}); + +// Prevent memory leaks in IE +// And prevent errors on refresh with events like mouseover in other browsers +// Window isn't included so as not to unbind existing unload events +jQuery( window ).bind( 'unload', function(){ + for ( var id in jQuery.cache ) + // Skip the window + if ( id != 1 && jQuery.cache[ id ].handle ) + jQuery.event.remove( jQuery.cache[ id ].handle.elem ); +}); +(function(){ + + jQuery.support = {}; + + var root = document.documentElement, + script = document.createElement("script"), + div = document.createElement("div"), + id = "script" + (new Date).getTime(); + + div.style.display = "none"; + div.innerHTML = ' <link/><table></table><a href="/a" style="color:red;float:left;opacity:.5;">a</a><select><option>text</option></select><object><param/></object>'; + + var all = div.getElementsByTagName("*"), + a = div.getElementsByTagName("a")[0]; + + // Can't get basic test support + if ( !all || !all.length || !a ) { + return; + } + + jQuery.support = { + // IE strips leading whitespace when .innerHTML is used + leadingWhitespace: div.firstChild.nodeType == 3, + + // Make sure that tbody elements aren't automatically inserted + // IE will insert them into empty tables + tbody: !div.getElementsByTagName("tbody").length, + + // Make sure that you can get all elements in an <object> element + // IE 7 always returns no results + objectAll: !!div.getElementsByTagName("object")[0] + .getElementsByTagName("*").length, + + // Make sure that link elements get serialized correctly by innerHTML + // This requires a wrapper element in IE + htmlSerialize: !!div.getElementsByTagName("link").length, + + // Get the style information from getAttribute + // (IE uses .cssText insted) + style: /red/.test( a.getAttribute("style") ), + + // Make sure that URLs aren't manipulated + // (IE normalizes it by default) + hrefNormalized: a.getAttribute("href") === "/a", + + // Make sure that element opacity exists + // (IE uses filter instead) + opacity: a.style.opacity === "0.5", + + // Verify style float existence + // (IE uses styleFloat instead of cssFloat) + cssFloat: !!a.style.cssFloat, + + // Will be defined later + scriptEval: false, + noCloneEvent: true, + boxModel: null + }; + + script.type = "text/javascript"; + try { + script.appendChild( document.createTextNode( "window." + id + "=1;" ) ); + } catch(e){} + + root.insertBefore( script, root.firstChild ); + + // Make sure that the execution of code works by injecting a script + // tag with appendChild/createTextNode + // (IE doesn't support this, fails, and uses .text instead) + if ( window[ id ] ) { + jQuery.support.scriptEval = true; + delete window[ id ]; + } + + root.removeChild( script ); + + if ( div.attachEvent && div.fireEvent ) { + div.attachEvent("onclick", function(){ + // Cloning a node shouldn't copy over any + // bound event handlers (IE does this) + jQuery.support.noCloneEvent = false; + div.detachEvent("onclick", arguments.callee); + }); + div.cloneNode(true).fireEvent("onclick"); + } + + // Figure out if the W3C box model works as expected + // document.body must exist before we can do this + jQuery(function(){ + var div = document.createElement("div"); + div.style.width = "1px"; + div.style.paddingLeft = "1px"; + + document.body.appendChild( div ); + jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2; + document.body.removeChild( div ); + }); +})(); + +var styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat"; + +jQuery.props = { + "for": "htmlFor", + "class": "className", + "float": styleFloat, + cssFloat: styleFloat, + styleFloat: styleFloat, + readonly: "readOnly", + maxlength: "maxLength", + cellspacing: "cellSpacing", + rowspan: "rowSpan", + tabindex: "tabIndex" +}; +jQuery.fn.extend({ + // Keep a copy of the old load + _load: jQuery.fn.load, + + load: function( url, params, callback ) { + if ( typeof url !== "string" ) + return this._load( url ); + + var off = url.indexOf(" "); + if ( off >= 0 ) { + var selector = url.slice(off, url.length); + url = url.slice(0, off); + } + + // Default to a GET request + var type = "GET"; + + // If the second parameter was provided + if ( params ) + // If it's a function + if ( jQuery.isFunction( params ) ) { + // We assume that it's the callback + callback = params; + params = null; + + // Otherwise, build a param string + } else if( typeof params === "object" ) { + params = jQuery.param( params ); + type = "POST"; + } + + var self = this; + + // Request the remote document + jQuery.ajax({ + url: url, + type: type, + dataType: "html", + data: params, + complete: function(res, status){ + // If successful, inject the HTML into all the matched elements + if ( status == "success" || status == "notmodified" ) + // See if a selector was specified + self.html( selector ? + // Create a dummy div to hold the results + jQuery("<div/>") + // inject the contents of the document in, removing the scripts + // to avoid any 'Permission Denied' errors in IE + .append(res.responseText.replace(/<script(.|\s)*?\/script>/g, "")) + + // Locate the specified elements + .find(selector) : + + // If not, just inject the full result + res.responseText ); + + if( callback ) + self.each( callback, [res.responseText, status, res] ); + } + }); + return this; + }, + + serialize: function() { + return jQuery.param(this.serializeArray()); + }, + serializeArray: function() { + return this.map(function(){ + return this.elements ? jQuery.makeArray(this.elements) : this; + }) + .filter(function(){ + return this.name && !this.disabled && + (this.checked || /select|textarea/i.test(this.nodeName) || + /text|hidden|password/i.test(this.type)); + }) + .map(function(i, elem){ + var val = jQuery(this).val(); + return val == null ? null : + jQuery.isArray(val) ? + jQuery.map( val, function(val, i){ + return {name: elem.name, value: val}; + }) : + {name: elem.name, value: val}; + }).get(); + } +}); + +// Attach a bunch of functions for handling common AJAX events +jQuery.each( "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","), function(i,o){ + jQuery.fn[o] = function(f){ + return this.bind(o, f); + }; +}); + +var jsc = now(); + +jQuery.extend({ + + get: function( url, data, callback, type ) { + // shift arguments if data argument was ommited + if ( jQuery.isFunction( data ) ) { + callback = data; + data = null; + } + + return jQuery.ajax({ + type: "GET", + url: url, + data: data, + success: callback, + dataType: type + }); + }, + + getScript: function( url, callback ) { + return jQuery.get(url, null, callback, "script"); + }, + + getJSON: function( url, data, callback ) { + return jQuery.get(url, data, callback, "json"); + }, + + post: function( url, data, callback, type ) { + if ( jQuery.isFunction( data ) ) { + callback = data; + data = {}; + } + + return jQuery.ajax({ + type: "POST", + url: url, + data: data, + success: callback, + dataType: type + }); + }, + + ajaxSetup: function( settings ) { + jQuery.extend( jQuery.ajaxSettings, settings ); + }, + + ajaxSettings: { + url: location.href, + global: true, + type: "GET", + contentType: "application/x-www-form-urlencoded", + processData: true, + async: true, + /* + timeout: 0, + data: null, + username: null, + password: null, + */ + // Create the request object; Microsoft failed to properly + // implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available + // This function can be overriden by calling jQuery.ajaxSetup + xhr:function(){ + return window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); + }, + accepts: { + xml: "application/xml, text/xml", + html: "text/html", + script: "text/javascript, application/javascript", + json: "application/json, text/javascript", + text: "text/plain", + _default: "*/*" + } + }, + + // Last-Modified header cache for next request + lastModified: {}, + + ajax: function( s ) { + // Extend the settings, but re-extend 's' so that it can be + // checked again later (in the test suite, specifically) + s = jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings, s)); + + var jsonp, jsre = /=\?(&|$)/g, status, data, + type = s.type.toUpperCase(); + + // convert data if not already a string + if ( s.data && s.processData && typeof s.data !== "string" ) + s.data = jQuery.param(s.data); + + // Handle JSONP Parameter Callbacks + if ( s.dataType == "jsonp" ) { + if ( type == "GET" ) { + if ( !s.url.match(jsre) ) + s.url += (s.url.match(/\?/) ? "&" : "?") + (s.jsonp || "callback") + "=?"; + } else if ( !s.data || !s.data.match(jsre) ) + s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?"; + s.dataType = "json"; + } + + // Build temporary JSONP function + if ( s.dataType == "json" && (s.data && s.data.match(jsre) || s.url.match(jsre)) ) { + jsonp = "jsonp" + jsc++; + + // Replace the =? sequence both in the query string and the data + if ( s.data ) + s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1"); + s.url = s.url.replace(jsre, "=" + jsonp + "$1"); + + // We need to make sure + // that a JSONP style response is executed properly + s.dataType = "script"; + + // Handle JSONP-style loading + window[ jsonp ] = function(tmp){ + data = tmp; + success(); + complete(); + // Garbage collect + window[ jsonp ] = undefined; + try{ delete window[ jsonp ]; } catch(e){} + if ( head ) + head.removeChild( script ); + }; + } + + if ( s.dataType == "script" && s.cache == null ) + s.cache = false; + + if ( s.cache === false && type == "GET" ) { + var ts = now(); + // try replacing _= if it is there + var ret = s.url.replace(/(\?|&)_=.*?(&|$)/, "$1_=" + ts + "$2"); + // if nothing was replaced, add timestamp to the end + s.url = ret + ((ret == s.url) ? (s.url.match(/\?/) ? "&" : "?") + "_=" + ts : ""); + } + + // If data is available, append data to url for get requests + if ( s.data && type == "GET" ) { + s.url += (s.url.match(/\?/) ? "&" : "?") + s.data; + + // IE likes to send both get and post data, prevent this + s.data = null; + } + + // Watch for a new set of requests + if ( s.global && ! jQuery.active++ ) + jQuery.event.trigger( "ajaxStart" ); + + // Matches an absolute URL, and saves the domain + var parts = /^(\w+:)?\/\/([^\/?#]+)/.exec( s.url ); + + // If we're requesting a remote document + // and trying to load JSON or Script with a GET + if ( s.dataType == "script" && type == "GET" && parts + && ( parts[1] && parts[1] != location.protocol || parts[2] != location.host )){ + + var head = document.getElementsByTagName("head")[0]; + var script = document.createElement("script"); + script.src = s.url; + if (s.scriptCharset) + script.charset = s.scriptCharset; + + // Handle Script loading + if ( !jsonp ) { + var done = false; + + // Attach handlers for all browsers + script.onload = script.onreadystatechange = function(){ + if ( !done && (!this.readyState || + this.readyState == "loaded" || this.readyState == "complete") ) { + done = true; + success(); + complete(); + head.removeChild( script ); + } + }; + } + + head.appendChild(script); + + // We handle everything using the script element injection + return undefined; + } + + var requestDone = false; + + // Create the request object + var xhr = s.xhr(); + + // Open the socket + // Passing null username, generates a login popup on Opera (#2865) + if( s.username ) + xhr.open(type, s.url, s.async, s.username, s.password); + else + xhr.open(type, s.url, s.async); + + // Need an extra try/catch for cross domain requests in Firefox 3 + try { + // Set the correct header, if data is being sent + if ( s.data ) + xhr.setRequestHeader("Content-Type", s.contentType); + + // Set the If-Modified-Since header, if ifModified mode. + if ( s.ifModified ) + xhr.setRequestHeader("If-Modified-Since", + jQuery.lastModified[s.url] || "Thu, 01 Jan 1970 00:00:00 GMT" ); + + // Set header so the called script knows that it's an XMLHttpRequest + xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); + + // Set the Accepts header for the server, depending on the dataType + xhr.setRequestHeader("Accept", s.dataType && s.accepts[ s.dataType ] ? + s.accepts[ s.dataType ] + ", */*" : + s.accepts._default ); + } catch(e){} + + // Allow custom headers/mimetypes and early abort + if ( s.beforeSend && s.beforeSend(xhr, s) === false ) { + // Handle the global AJAX counter + if ( s.global && ! --jQuery.active ) + jQuery.event.trigger( "ajaxStop" ); + // close opended socket + xhr.abort(); + return false; + } + + if ( s.global ) + jQuery.event.trigger("ajaxSend", [xhr, s]); + + // Wait for a response to come back + var onreadystatechange = function(isTimeout){ + // The request was aborted, clear the interval and decrement jQuery.active + if (xhr.readyState == 0) { + if (ival) { + // clear poll interval + clearInterval(ival); + ival = null; + // Handle the global AJAX counter + if ( s.global && ! --jQuery.active ) + jQuery.event.trigger( "ajaxStop" ); + } + // The transfer is complete and the data is available, or the request timed out + } else if ( !requestDone && xhr && (xhr.readyState == 4 || isTimeout == "timeout") ) { + requestDone = true; + + // clear poll interval + if (ival) { + clearInterval(ival); + ival = null; + } + + status = isTimeout == "timeout" ? "timeout" : + !jQuery.httpSuccess( xhr ) ? "error" : + s.ifModified && jQuery.httpNotModified( xhr, s.url ) ? "notmodified" : + "success"; + + if ( status == "success" ) { + // Watch for, and catch, XML document parse errors + try { + // process the data (runs the xml through httpData regardless of callback) + data = jQuery.httpData( xhr, s.dataType, s ); + } catch(e) { + status = "parsererror"; + } + } + + // Make sure that the request was successful or notmodified + if ( status == "success" ) { + // Cache Last-Modified header, if ifModified mode. + var modRes; + try { + modRes = xhr.getResponseHeader("Last-Modified"); + } catch(e) {} // swallow exception thrown by FF if header is not available + + if ( s.ifModified && modRes ) + jQuery.lastModified[s.url] = modRes; + + // JSONP handles its own success callback + if ( !jsonp ) + success(); + } else + jQuery.handleError(s, xhr, status); + + // Fire the complete handlers + complete(); + + if ( isTimeout ) + xhr.abort(); + + // Stop memory leaks + if ( s.async ) + xhr = null; + } + }; + + if ( s.async ) { + // don't attach the handler to the request, just poll it instead + var ival = setInterval(onreadystatechange, 13); + + // Timeout checker + if ( s.timeout > 0 ) + setTimeout(function(){ + // Check to see if the request is still happening + if ( xhr && !requestDone ) + onreadystatechange( "timeout" ); + }, s.timeout); + } + + // Send the data + try { + xhr.send(s.data); + } catch(e) { + jQuery.handleError(s, xhr, null, e); + } + + // firefox 1.5 doesn't fire statechange for sync requests + if ( !s.async ) + onreadystatechange(); + + function success(){ + // If a local callback was specified, fire it and pass it the data + if ( s.success ) + s.success( data, status ); + + // Fire the global callback + if ( s.global ) + jQuery.event.trigger( "ajaxSuccess", [xhr, s] ); + } + + function complete(){ + // Process result + if ( s.complete ) + s.complete(xhr, status); + + // The request was completed + if ( s.global ) + jQuery.event.trigger( "ajaxComplete", [xhr, s] ); + + // Handle the global AJAX counter + if ( s.global && ! --jQuery.active ) + jQuery.event.trigger( "ajaxStop" ); + } + + // return XMLHttpRequest to allow aborting the request etc. + return xhr; + }, + + handleError: function( s, xhr, status, e ) { + // If a local callback was specified, fire it + if ( s.error ) s.error( xhr, status, e ); + + // Fire the global callback + if ( s.global ) + jQuery.event.trigger( "ajaxError", [xhr, s, e] ); + }, + + // Counter for holding the number of active queries + active: 0, + + // Determines if an XMLHttpRequest was successful or not + httpSuccess: function( xhr ) { + try { + // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450 + return !xhr.status && location.protocol == "file:" || + ( xhr.status >= 200 && xhr.status < 300 ) || xhr.status == 304 || xhr.status == 1223; + } catch(e){} + return false; + }, + + // Determines if an XMLHttpRequest returns NotModified + httpNotModified: function( xhr, url ) { + try { + var xhrRes = xhr.getResponseHeader("Last-Modified"); + + // Firefox always returns 200. check Last-Modified date + return xhr.status == 304 || xhrRes == jQuery.lastModified[url]; + } catch(e){} + return false; + }, + + httpData: function( xhr, type, s ) { + var ct = xhr.getResponseHeader("content-type"), + xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0, + data = xml ? xhr.responseXML : xhr.responseText; + + if ( xml && data.documentElement.tagName == "parsererror" ) + throw "parsererror"; + + // Allow a pre-filtering function to sanitize the response + // s != null is checked to keep backwards compatibility + if( s && s.dataFilter ) + data = s.dataFilter( data, type ); + + // The filter can actually parse the response + if( typeof data === "string" ){ + + // If the type is "script", eval it in global context + if ( type == "script" ) + jQuery.globalEval( data ); + + // Get the JavaScript object, if JSON is used. + if ( type == "json" ) + data = window["eval"]("(" + data + ")"); + } + + return data; + }, + + // Serialize an array of form elements or a set of + // key/values into a query string + param: function( a ) { + var s = [ ]; + + function add( key, value ){ + s[ s.length ] = encodeURIComponent(key) + '=' + encodeURIComponent(value); + }; + + // If an array was passed in, assume that it is an array + // of form elements + if ( jQuery.isArray(a) || a.jquery ) + // Serialize the form elements + jQuery.each( a, function(){ + add( this.name, this.value ); + }); + + // Otherwise, assume that it's an object of key/value pairs + else + // Serialize the key/values + for ( var j in a ) + // If the value is an array then the key names need to be repeated + if ( jQuery.isArray(a[j]) ) + jQuery.each( a[j], function(){ + add( j, this ); + }); + else + add( j, jQuery.isFunction(a[j]) ? a[j]() : a[j] ); + + // Return the resulting serialization + return s.join("&").replace(/%20/g, "+"); + } + +}); +var elemdisplay = {}, + timerId, + fxAttrs = [ + // height animations + [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ], + // width animations + [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ], + // opacity animations + [ "opacity" ] + ]; + +function genFx( type, num ){ + var obj = {}; + jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function(){ + obj[ this ] = type; + }); + return obj; +} + +jQuery.fn.extend({ + show: function(speed,callback){ + if ( speed ) { + return this.animate( genFx("show", 3), speed, callback); + } else { + for ( var i = 0, l = this.length; i < l; i++ ){ + var old = jQuery.data(this[i], "olddisplay"); + + this[i].style.display = old || ""; + + if ( jQuery.css(this[i], "display") === "none" ) { + var tagName = this[i].tagName, display; + + if ( elemdisplay[ tagName ] ) { + display = elemdisplay[ tagName ]; + } else { + var elem = jQuery("<" + tagName + " />").appendTo("body"); + + display = elem.css("display"); + if ( display === "none" ) + display = "block"; + + elem.remove(); + + elemdisplay[ tagName ] = display; + } + + this[i].style.display = jQuery.data(this[i], "olddisplay", display); + } + } + + return this; + } + }, + + hide: function(speed,callback){ + if ( speed ) { + return this.animate( genFx("hide", 3), speed, callback); + } else { + for ( var i = 0, l = this.length; i < l; i++ ){ + var old = jQuery.data(this[i], "olddisplay"); + if ( !old && old !== "none" ) + jQuery.data(this[i], "olddisplay", jQuery.css(this[i], "display")); + this[i].style.display = "none"; + } + return this; + } + }, + + // Save the old toggle function + _toggle: jQuery.fn.toggle, + + toggle: function( fn, fn2 ){ + var bool = typeof fn === "boolean"; + + return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ? + this._toggle.apply( this, arguments ) : + fn == null || bool ? + this.each(function(){ + var state = bool ? fn : jQuery(this).is(":hidden"); + jQuery(this)[ state ? "show" : "hide" ](); + }) : + this.animate(genFx("toggle", 3), fn, fn2); + }, + + fadeTo: function(speed,to,callback){ + return this.animate({opacity: to}, speed, callback); + }, + + animate: function( prop, speed, easing, callback ) { + var optall = jQuery.speed(speed, easing, callback); + + return this[ optall.queue === false ? "each" : "queue" ](function(){ + + var opt = jQuery.extend({}, optall), p, + hidden = this.nodeType == 1 && jQuery(this).is(":hidden"), + self = this; + + for ( p in prop ) { + if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden ) + return opt.complete.call(this); + + if ( ( p == "height" || p == "width" ) && this.style ) { + // Store display property + opt.display = jQuery.css(this, "display"); + + // Make sure that nothing sneaks out + opt.overflow = this.style.overflow; + } + } + + if ( opt.overflow != null ) + this.style.overflow = "hidden"; + + opt.curAnim = jQuery.extend({}, prop); + + jQuery.each( prop, function(name, val){ + var e = new jQuery.fx( self, opt, name ); + + if ( /toggle|show|hide/.test(val) ) + e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop ); + else { + var parts = val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/), + start = e.cur(true) || 0; + + if ( parts ) { + var end = parseFloat(parts[2]), + unit = parts[3] || "px"; + + // We need to compute starting value + if ( unit != "px" ) { + self.style[ name ] = (end || 1) + unit; + start = ((end || 1) / e.cur(true)) * start; + self.style[ name ] = start + unit; + } + + // If a +=/-= token was provided, we're doing a relative animation + if ( parts[1] ) + end = ((parts[1] == "-=" ? -1 : 1) * end) + start; + + e.custom( start, end, unit ); + } else + e.custom( start, val, "" ); + } + }); + + // For JS strict compliance + return true; + }); + }, + + stop: function(clearQueue, gotoEnd){ + var timers = jQuery.timers; + + if (clearQueue) + this.queue([]); + + this.each(function(){ + // go in reverse order so anything added to the queue during the loop is ignored + for ( var i = timers.length - 1; i >= 0; i-- ) + if ( timers[i].elem == this ) { + if (gotoEnd) + // force the next step to be the last + timers[i](true); + timers.splice(i, 1); + } + }); + + // start the next in the queue if the last step wasn't forced + if (!gotoEnd) + this.dequeue(); + + return this; + } + +}); + +// Generate shortcuts for custom animations +jQuery.each({ + slideDown: genFx("show", 1), + slideUp: genFx("hide", 1), + slideToggle: genFx("toggle", 1), + fadeIn: { opacity: "show" }, + fadeOut: { opacity: "hide" } +}, function( name, props ){ + jQuery.fn[ name ] = function( speed, callback ){ + return this.animate( props, speed, callback ); + }; +}); + +jQuery.extend({ + + speed: function(speed, easing, fn) { + var opt = typeof speed === "object" ? speed : { + complete: fn || !fn && easing || + jQuery.isFunction( speed ) && speed, + duration: speed, + easing: fn && easing || easing && !jQuery.isFunction(easing) && easing + }; + + opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration : + jQuery.fx.speeds[opt.duration] || jQuery.fx.speeds._default; + + // Queueing + opt.old = opt.complete; + opt.complete = function(){ + if ( opt.queue !== false ) + jQuery(this).dequeue(); + if ( jQuery.isFunction( opt.old ) ) + opt.old.call( this ); + }; + + return opt; + }, + + easing: { + linear: function( p, n, firstNum, diff ) { + return firstNum + diff * p; + }, + swing: function( p, n, firstNum, diff ) { + return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum; + } + }, + + timers: [], + + fx: function( elem, options, prop ){ + this.options = options; + this.elem = elem; + this.prop = prop; + + if ( !options.orig ) + options.orig = {}; + } + +}); + +jQuery.fx.prototype = { + + // Simple function for setting a style value + update: function(){ + if ( this.options.step ) + this.options.step.call( this.elem, this.now, this ); + + (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this ); + + // Set display property to block for height/width animations + if ( ( this.prop == "height" || this.prop == "width" ) && this.elem.style ) + this.elem.style.display = "block"; + }, + + // Get the current size + cur: function(force){ + if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) + return this.elem[ this.prop ]; + + var r = parseFloat(jQuery.css(this.elem, this.prop, force)); + return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0; + }, + + // Start an animation from one number to another + custom: function(from, to, unit){ + this.startTime = now(); + this.start = from; + this.end = to; + this.unit = unit || this.unit || "px"; + this.now = this.start; + this.pos = this.state = 0; + + var self = this; + function t(gotoEnd){ + return self.step(gotoEnd); + } + + t.elem = this.elem; + + if ( t() && jQuery.timers.push(t) == 1 ) { + timerId = setInterval(function(){ + var timers = jQuery.timers; + + for ( var i = 0; i < timers.length; i++ ) + if ( !timers[i]() ) + timers.splice(i--, 1); + + if ( !timers.length ) { + clearInterval( timerId ); + } + }, 13); + } + }, + + // Simple 'show' function + show: function(){ + // Remember where we started, so that we can go back to it later + this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop ); + this.options.show = true; + + // Begin the animation + // Make sure that we start at a small width/height to avoid any + // flash of content + this.custom(this.prop == "width" || this.prop == "height" ? 1 : 0, this.cur()); + + // Start by showing the element + jQuery(this.elem).show(); + }, + + // Simple 'hide' function + hide: function(){ + // Remember where we started, so that we can go back to it later + this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop ); + this.options.hide = true; + + // Begin the animation + this.custom(this.cur(), 0); + }, + + // Each step of an animation + step: function(gotoEnd){ + var t = now(); + + if ( gotoEnd || t >= this.options.duration + this.startTime ) { + this.now = this.end; + this.pos = this.state = 1; + this.update(); + + this.options.curAnim[ this.prop ] = true; + + var done = true; + for ( var i in this.options.curAnim ) + if ( this.options.curAnim[i] !== true ) + done = false; + + if ( done ) { + if ( this.options.display != null ) { + // Reset the overflow + this.elem.style.overflow = this.options.overflow; + + // Reset the display + this.elem.style.display = this.options.display; + if ( jQuery.css(this.elem, "display") == "none" ) + this.elem.style.display = "block"; + } + + // Hide the element if the "hide" operation was done + if ( this.options.hide ) + jQuery(this.elem).hide(); + + // Reset the properties, if the item has been hidden or shown + if ( this.options.hide || this.options.show ) + for ( var p in this.options.curAnim ) + jQuery.attr(this.elem.style, p, this.options.orig[p]); + + // Execute the complete function + this.options.complete.call( this.elem ); + } + + return false; + } else { + var n = t - this.startTime; + this.state = n / this.options.duration; + + // Perform the easing function, defaults to swing + this.pos = jQuery.easing[this.options.easing || (jQuery.easing.swing ? "swing" : "linear")](this.state, n, 0, 1, this.options.duration); + this.now = this.start + ((this.end - this.start) * this.pos); + + // Perform the next step of the animation + this.update(); + } + + return true; + } + +}; + +jQuery.extend( jQuery.fx, { + speeds:{ + slow: 600, + fast: 200, + // Default speed + _default: 400 + }, + step: { + + opacity: function(fx){ + jQuery.attr(fx.elem.style, "opacity", fx.now); + }, + + _default: function(fx){ + if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) + fx.elem.style[ fx.prop ] = fx.now + fx.unit; + else + fx.elem[ fx.prop ] = fx.now; + } + } +}); +if ( document.documentElement["getBoundingClientRect"] ) + jQuery.fn.offset = function() { + if ( !this[0] ) return { top: 0, left: 0 }; + if ( this[0] === this[0].ownerDocument.body ) return jQuery.offset.bodyOffset( this[0] ); + var box = this[0].getBoundingClientRect(), doc = this[0].ownerDocument, body = doc.body, docElem = doc.documentElement, + clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0, + top = box.top + (self.pageYOffset || jQuery.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop, + left = box.left + (self.pageXOffset || jQuery.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft; + return { top: top, left: left }; + }; +else + jQuery.fn.offset = function() { + if ( !this[0] ) return { top: 0, left: 0 }; + if ( this[0] === this[0].ownerDocument.body ) return jQuery.offset.bodyOffset( this[0] ); + jQuery.offset.initialized || jQuery.offset.initialize(); + + var elem = this[0], offsetParent = elem.offsetParent, prevOffsetParent = elem, + doc = elem.ownerDocument, computedStyle, docElem = doc.documentElement, + body = doc.body, defaultView = doc.defaultView, + prevComputedStyle = defaultView.getComputedStyle(elem, null), + top = elem.offsetTop, left = elem.offsetLeft; + + while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) { + computedStyle = defaultView.getComputedStyle(elem, null); + top -= elem.scrollTop, left -= elem.scrollLeft; + if ( elem === offsetParent ) { + top += elem.offsetTop, left += elem.offsetLeft; + if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && /^t(able|d|h)$/i.test(elem.tagName)) ) + top += parseInt( computedStyle.borderTopWidth, 10) || 0, + left += parseInt( computedStyle.borderLeftWidth, 10) || 0; + prevOffsetParent = offsetParent, offsetParent = elem.offsetParent; + } + if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) + top += parseInt( computedStyle.borderTopWidth, 10) || 0, + left += parseInt( computedStyle.borderLeftWidth, 10) || 0; + prevComputedStyle = computedStyle; + } + + if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) + top += body.offsetTop, + left += body.offsetLeft; + + if ( prevComputedStyle.position === "fixed" ) + top += Math.max(docElem.scrollTop, body.scrollTop), + left += Math.max(docElem.scrollLeft, body.scrollLeft); + + return { top: top, left: left }; + }; + +jQuery.offset = { + initialize: function() { + if ( this.initialized ) return; + var body = document.body, container = document.createElement('div'), innerDiv, checkDiv, table, td, rules, prop, bodyMarginTop = body.style.marginTop, + html = '<div style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;"><div></div></div><table style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;" cellpadding="0" cellspacing="0"><tr><td></td></tr></table>'; + + rules = { position: 'absolute', top: 0, left: 0, margin: 0, border: 0, width: '1px', height: '1px', visibility: 'hidden' }; + for ( prop in rules ) container.style[prop] = rules[prop]; + + container.innerHTML = html; + body.insertBefore(container, body.firstChild); + innerDiv = container.firstChild, checkDiv = innerDiv.firstChild, td = innerDiv.nextSibling.firstChild.firstChild; + + this.doesNotAddBorder = (checkDiv.offsetTop !== 5); + this.doesAddBorderForTableAndCells = (td.offsetTop === 5); + + innerDiv.style.overflow = 'hidden', innerDiv.style.position = 'relative'; + this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5); + + body.style.marginTop = '1px'; + this.doesNotIncludeMarginInBodyOffset = (body.offsetTop === 0); + body.style.marginTop = bodyMarginTop; + + body.removeChild(container); + this.initialized = true; + }, + + bodyOffset: function(body) { + jQuery.offset.initialized || jQuery.offset.initialize(); + var top = body.offsetTop, left = body.offsetLeft; + if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) + top += parseInt( jQuery.curCSS(body, 'marginTop', true), 10 ) || 0, + left += parseInt( jQuery.curCSS(body, 'marginLeft', true), 10 ) || 0; + return { top: top, left: left }; + } +}; + + +jQuery.fn.extend({ + position: function() { + var left = 0, top = 0, results; + + if ( this[0] ) { + // Get *real* offsetParent + var offsetParent = this.offsetParent(), + + // Get correct offsets + offset = this.offset(), + parentOffset = /^body|html$/i.test(offsetParent[0].tagName) ? { top: 0, left: 0 } : offsetParent.offset(); + + // Subtract element margins + // note: when an element has margin: auto the offsetLeft and marginLeft + // are the same in Safari causing offset.left to incorrectly be 0 + offset.top -= num( this, 'marginTop' ); + offset.left -= num( this, 'marginLeft' ); + + // Add offsetParent borders + parentOffset.top += num( offsetParent, 'borderTopWidth' ); + parentOffset.left += num( offsetParent, 'borderLeftWidth' ); + + // Subtract the two offsets + results = { + top: offset.top - parentOffset.top, + left: offset.left - parentOffset.left + }; + } + + return results; + }, + + offsetParent: function() { + var offsetParent = this[0].offsetParent || document.body; + while ( offsetParent && (!/^body|html$/i.test(offsetParent.tagName) && jQuery.css(offsetParent, 'position') == 'static') ) + offsetParent = offsetParent.offsetParent; + return jQuery(offsetParent); + } +}); + + +// Create scrollLeft and scrollTop methods +jQuery.each( ['Left', 'Top'], function(i, name) { + var method = 'scroll' + name; + + jQuery.fn[ method ] = function(val) { + if (!this[0]) return null; + + return val !== undefined ? + + // Set the scroll offset + this.each(function() { + this == window || this == document ? + window.scrollTo( + !i ? val : jQuery(window).scrollLeft(), + i ? val : jQuery(window).scrollTop() + ) : + this[ method ] = val; + }) : + + // Return the scroll offset + this[0] == window || this[0] == document ? + self[ i ? 'pageYOffset' : 'pageXOffset' ] || + jQuery.boxModel && document.documentElement[ method ] || + document.body[ method ] : + this[0][ method ]; + }; +}); +// Create innerHeight, innerWidth, outerHeight and outerWidth methods +jQuery.each([ "Height", "Width" ], function(i, name){ + + var tl = i ? "Left" : "Top", // top or left + br = i ? "Right" : "Bottom"; // bottom or right + + // innerHeight and innerWidth + jQuery.fn["inner" + name] = function(){ + return this[ name.toLowerCase() ]() + + num(this, "padding" + tl) + + num(this, "padding" + br); + }; + + // outerHeight and outerWidth + jQuery.fn["outer" + name] = function(margin) { + return this["inner" + name]() + + num(this, "border" + tl + "Width") + + num(this, "border" + br + "Width") + + (margin ? + num(this, "margin" + tl) + num(this, "margin" + br) : 0); + }; + + var type = name.toLowerCase(); + + jQuery.fn[ type ] = function( size ) { + // Get window width or height + return this[0] == window ? + // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode + document.compatMode == "CSS1Compat" && document.documentElement[ "client" + name ] || + document.body[ "client" + name ] : + + // Get document width or height + this[0] == document ? + // Either scroll[Width/Height] or offset[Width/Height], whichever is greater + Math.max( + document.documentElement["client" + name], + document.body["scroll" + name], document.documentElement["scroll" + name], + document.body["offset" + name], document.documentElement["offset" + name] + ) : + + // Get or set width or height on the element + size === undefined ? + // Get width or height on the element + (this.length ? jQuery.css( this[0], type ) : null) : + + // Set the width or height on the element (default to pixels if value is unitless) + this.css( type, typeof size === "string" ? size : size + "px" ); + }; + +});})(); diff --git a/samples/src/main/java/gwtquery/samples/public/jquerybench.html b/samples/src/main/java/gwtquery/samples/public/jquerybench.html new file mode 100644 index 00000000..b50ce668 --- /dev/null +++ b/samples/src/main/java/gwtquery/samples/public/jquerybench.html @@ -0,0 +1,3172 @@ +<html>
+<head>
+ <title>JQuery</title>
+ <script language="javascript" src="jquery-1.3.1.js"></script>
+ <script type="text/javascript">
+ window.parent.jquerybenchmark = function(sel) {
+ return $(sel).length;
+ }
+ </script>
+</head>
+<body>
+<div style="display: none">
+<div style="display: none" class="head">
+ <p><a href="http://www.w3.org/"><img height=48 alt=W3C
+ src="http://www.w3.org/Icons/w3c_home"
+ width=72></a>
+
+ <h1 id="title">Selectors</h1>
+
+ <h2>W3C Working Draft 15 December 2005</h2>
+
+ <dl>
+
+ <dt>This version:
+
+ <dd><a href="http://www.w3.org/TR/2005/WD-css3-selectors-20051215">
+ http://www.w3.org/TR/2005/WD-css3-selectors-20051215</a>
+
+ <dt>Latest version:
+
+ <dd><a href="http://www.w3.org/TR/css3-selectors">
+ http://www.w3.org/TR/css3-selectors</a>
+
+ <dt>Previous version:
+
+ <dd><a href="http://www.w3.org/TR/2001/CR-css3-selectors-20011113">
+ http://www.w3.org/TR/2001/CR-css3-selectors-20011113</a>
+
+ <dt><a name=editors-list></a>Editors:
+
+ <dd class="vcard"><span class="fn">Daniel Glazman</span> (Invited
+ Expert)
+ </dd>
+
+ <dd class="vcard"><a lang="tr" class="url fn"
+ href="http://www.tantek.com/">Tantek Çelik</a>
+ (Invited Expert)
+
+ <dd class="vcard"><a href="mailto:ian@hixie.ch" class="url fn">Ian
+ Hickson</a> (<span
+ class="company"><a
+ href="http://www.google.com/">Google</a></span>)
+
+ <dd class="vcard"><span class="fn">Peter Linss</span> (former
+ editor, <span class="company"><a
+ href="http://www.netscape.com/">Netscape/AOL</a></span>)
+
+ <dd class="vcard"><span class="fn">John Williams</span> (former editor, <span
+ class="company"><a
+ href="http://www.quark.com/">Quark, Inc.</a></span>)
+
+ </dl>
+
+ <p class="copyright"><a
+ href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">
+ Copyright</a> © 2005 <a href="http://www.w3.org/"><abbr
+ title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup>
+ (<a href="http://www.csail.mit.edu/"><abbr title="Massachusetts
+ Institute of Technology">MIT</abbr></a>, <a
+ href="http://www.ercim.org/"><acronym title="European Research
+ Consortium for Informatics and Mathematics">ERCIM</acronym></a>, <a
+ href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved.
+ W3C
+ <a
+ href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
+ <a
+ href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>,
+ <a
+ href="http://www.w3.org/Consortium/Legal/copyright-documents">document
+ use</a> rules apply.
+
+ <hr title="Separator for header">
+
+</div>
+
+<h2><a name=abstract></a>Abstract</h2>
+
+<p><em>Selectors</em> are patterns that match against elements in a
+ tree. Selectors have been optimized for use with HTML and XML, and
+ are designed to be usable in performance-critical code.</p>
+
+<p><acronym title="Cascading Style Sheets">CSS</acronym> (Cascading
+ Style Sheets) is a language for describing the rendering of <acronym
+ title="Hypertext Markup Language">HTML</acronym> and <acronym
+ title="Extensible Markup Language">XML</acronym> documents on
+ screen, on paper, in speech, etc. CSS uses Selectors for binding
+ style properties to elements in the document. This document
+ describes extensions to the selectors defined in CSS level 2. These
+ extended selectors will be used by CSS level 3.
+
+<p>Selectors define the following function:</p>
+
+<pre>expression ∗ element → boolean</pre>
+
+<p>That is, given an element and a selector, this specification
+ defines whether that element matches the selector.</p>
+
+<p>These expressions can also be used, for instance, to select a set
+ of elements, or a single element from a set of elements, by
+ evaluating the expression across all the elements in a
+ subtree. <acronym title="Simple Tree Transformation
+ Sheets">STTS</acronym> (Simple Tree Transformation Sheets), a
+ language for transforming XML trees, uses this mechanism. <a
+ href="#refsSTTS">[STTS]</a></p>
+
+<h2><a name=status></a>Status of this document</h2>
+
+<p><em>This section describes the status of this document at the
+ time of its publication. Other documents may supersede this
+ document. A list of current W3C publications and the latest revision
+ of this technical report can be found in the <a
+ href="http://www.w3.org/TR/">W3C technical reports index at
+ http://www.w3.org/TR/.</a></em></p>
+
+<p>This document describes the selectors that already exist in <a
+ href="#refsCSS1"><abbr title="CSS level 1">CSS1</abbr></a> and <a
+ href="#refsCSS21"><abbr title="CSS level 2">CSS2</abbr></a>, and
+ also proposes new selectors for <abbr title="CSS level
+ 3">CSS3</abbr> and other languages that may need them.</p>
+
+<p>The CSS Working Group doesn't expect that all implementations of
+ CSS3 will have to implement all selectors. Instead, there will
+ probably be a small number of variants of CSS3, called profiles. For
+ example, it may be that only a profile for interactive user agents
+ will include all of the selectors.</p>
+
+<p>This specification is a last call working draft for the the <a
+ href="http://www.w3.org/Style/CSS/members">CSS Working Group</a>
+ (<a href="/Style/">Style Activity</a>). This
+ document is a revision of the <a
+ href="http://www.w3.org/TR/2001/CR-css3-selectors-20011113/">Candidate
+ Recommendation dated 2001 November 13</a>, and has incorporated
+ implementation feedback received in the past few years. It is
+ expected that this last call will proceed straight to Proposed
+ Recommendation stage since it is believed that interoperability will
+ be demonstrable.</p>
+
+<p>All persons are encouraged to review and implement this
+ specification and return comments to the (<a
+ href="http://lists.w3.org/Archives/Public/www-style/">archived</a>)
+ public mailing list <a
+ href="http://www.w3.org/Mail/Lists.html#www-style">www-style</a>
+ (see <a href="http://www.w3.org/Mail/Request">instructions</a>). W3C
+ Members can also send comments directly to the CSS Working
+ Group.
+ The deadline for comments is 14 January 2006.</p>
+
+<p>This is still a draft document and may be updated, replaced, or
+ obsoleted by other documents at any time. It is inappropriate to
+ cite a W3C Working Draft as other than "work in progress".
+
+<p>This document may be available in <a
+ href="http://www.w3.org/Style/css3-selectors-updates/translations">translation</a>.
+ The English version of this specification is the only normative
+ version.
+
+<div class="subtoc">
+
+ <h2><a name=contents>Table of contents</a></h2>
+
+ <ul class="toc">
+ <li class="tocline2"><a href="#context">1. Introduction</a>
+ <ul>
+ <li><a href="#dependencies">1.1. Dependencies</a></li>
+ <li><a href="#terminology">1.2. Terminology</a></li>
+ <li><a href="#changesFromCSS2">1.3. Changes from CSS2</a></li>
+ </ul>
+ <li class="tocline2"><a href="#selectors">2. Selectors</a>
+ <li class="tocline2"><a href="#casesens">3. Case sensitivity</a>
+ <li class="tocline2"><a href="#selector-syntax">4. Selector syntax</a>
+ <li class="tocline2"><a href="#grouping">5. Groups of selectors</a>
+ <li class="tocline2"><a href="#simple-selectors">6. Simple selectors</a>
+ <ul class="toc">
+ <li class="tocline3"><a href="#type-selectors">6.1. Type
+ selectors</a>
+ <ul class="toc">
+ <li class="tocline4"><a href="#typenmsp">6.1.1. Type
+ selectors and namespaces</a></li>
+ </ul>
+ <li class="tocline3"><a href="#universal-selector">6.2.
+ Universal selector</a>
+ <ul>
+ <li><a href="#univnmsp">6.2.1. Universal selector and
+ namespaces</a></li>
+ </ul>
+ <li class="tocline3"><a href="#attribute-selectors">6.3.
+ Attribute selectors</a>
+ <ul class="toc">
+ <li class="tocline4"><a
+ href="#attribute-representation">6.3.1.
+ Representation of attributes and attributes
+ values</a>
+ <li><a href="#attribute-substrings">6.3.2. Substring
+ matching attribute selectors</a>
+ <li class="tocline4"><a href="#attrnmsp">6.3.3.
+ Attribute selectors and namespaces</a>
+ <li class="tocline4"><a href="#def-values">6.3.4.
+ Default attribute values in DTDs</a></li>
+ </ul>
+ <li class="tocline3"><a href="#class-html">6.4. Class
+ selectors</a>
+ <li class="tocline3"><a href="#id-selectors">6.5. ID
+ selectors</a>
+ <li class="tocline3"><a href="#pseudo-classes">6.6.
+ Pseudo-classes</a>
+ <ul class="toc">
+ <li class="tocline4"><a href="#dynamic-pseudos">6.6.1.
+ Dynamic pseudo-classes</a>
+ <li class="tocline4"><a href="#target-pseudo">6.6.2. The
+ :target pseudo-class</a>
+ <li class="tocline4"><a href="#lang-pseudo">6.6.3. The
+ :lang() pseudo-class</a>
+ <li class="tocline4"><a href="#UIstates">6.6.4. UI
+ element states pseudo-classes</a>
+ <li class="tocline4"><a href="#structural-pseudos">6.6.5.
+ Structural pseudo-classes</a>
+ <ul>
+ <li><a href="#root-pseudo">:root
+ pseudo-class</a>
+ <li><a href="#nth-child-pseudo">:nth-child()
+ pseudo-class</a>
+ <li><a href="#nth-last-child-pseudo">:nth-last-child()</a>
+ <li><a href="#nth-of-type-pseudo">:nth-of-type()
+ pseudo-class</a>
+ <li><a href="#nth-last-of-type-pseudo">:nth-last-of-type()</a>
+ <li><a href="#first-child-pseudo">:first-child
+ pseudo-class</a>
+ <li><a href="#last-child-pseudo">:last-child
+ pseudo-class</a>
+ <li><a href="#first-of-type-pseudo">:first-of-type
+ pseudo-class</a>
+ <li><a href="#last-of-type-pseudo">:last-of-type
+ pseudo-class</a>
+ <li><a href="#only-child-pseudo">:only-child
+ pseudo-class</a>
+ <li><a href="#only-of-type-pseudo">:only-of-type
+ pseudo-class</a>
+ <li><a href="#empty-pseudo">:empty
+ pseudo-class</a></li>
+ </ul>
+ <li class="tocline4"><a href="#negation">6.6.7. The
+ negation pseudo-class</a></li>
+ </ul>
+ </li>
+ </ul>
+ <li><a href="#pseudo-elements">7. Pseudo-elements</a>
+ <ul>
+ <li><a href="#first-line">7.1. The ::first-line
+ pseudo-element</a>
+ <li><a href="#first-letter">7.2. The ::first-letter
+ pseudo-element</a>
+ <li><a href="#UIfragments">7.3. The ::selection
+ pseudo-element</a>
+ <li><a href="#gen-content">7.4. The ::before and ::after
+ pseudo-elements</a></li>
+ </ul>
+ <li class="tocline2"><a href="#combinators">8. Combinators</a>
+ <ul class="toc">
+ <li class="tocline3"><a href="#descendant-combinators">8.1.
+ Descendant combinators</a>
+ <li class="tocline3"><a href="#child-combinators">8.2. Child
+ combinators</a>
+ <li class="tocline3"><a href="#sibling-combinators">8.3. Sibling
+ combinators</a>
+ <ul class="toc">
+ <li class="tocline4"><a
+ href="#adjacent-sibling-combinators">8.3.1.
+ Adjacent sibling combinator</a>
+ <li class="tocline4"><a
+ href="#general-sibling-combinators">8.3.2.
+ General sibling combinator</a></li>
+ </ul>
+ </li>
+ </ul>
+ <li class="tocline2"><a href="#specificity">9. Calculating a selector's
+ specificity</a>
+ <li class="tocline2"><a href="#w3cselgrammar">10. The grammar of
+ Selectors</a>
+ <ul class="toc">
+ <li class="tocline3"><a href="#grammar">10.1. Grammar</a>
+ <li class="tocline3"><a href="#lex">10.2. Lexical scanner</a>
+ </li>
+ </ul>
+ <li class="tocline2"><a href="#downlevel">11. Namespaces and down-level
+ clients</a>
+ <li class="tocline2"><a href="#profiling">12. Profiles</a>
+ <li><a href="#Conformance">13. Conformance and requirements</a>
+ <li><a href="#Tests">14. Tests</a>
+ <li><a href="#ACKS">15. Acknowledgements</a>
+ <li class="tocline2"><a href="#references">16. References</a>
+ </ul>
+
+</div>
+
+<h2><a name=context>1. Introduction</a></h2>
+
+<h3><a name=dependencies></a>1.1. Dependencies</h3>
+
+<p>Some features of this specification are specific to CSS, or have
+ particular limitations or rules specific to CSS. In this
+ specification, these have been described in terms of CSS2.1. <a
+ href="#refsCSS21">[CSS21]</a></p>
+
+<h3><a name=terminology></a>1.2. Terminology</h3>
+
+<p>All of the text of this specification is normative except
+ examples, notes, and sections explicitly marked as
+ non-normative.</p>
+
+<h3><a name=changesFromCSS2></a>1.3. Changes from CSS2</h3>
+
+<p><em>This section is non-normative.</em></p>
+
+<p>The main differences between the selectors in CSS2 and those in
+ Selectors are:
+
+<ul>
+
+ <li>the list of basic definitions (selector, group of selectors,
+ simple selector, etc.) has been changed; in particular, what was
+ referred to in CSS2 as a simple selector is now called a sequence
+ of simple selectors, and the term "simple selector" is now used for
+ the components of this sequence
+ </li>
+
+ <li>an optional namespace component is now allowed in type element
+ selectors, the universal selector and attribute selectors
+ </li>
+
+ <li>a <a href="#general-sibling-combinators">new combinator</a> has been
+ introduced
+ </li>
+
+ <li>new simple selectors including substring matching attribute
+ selectors, and new pseudo-classes
+ </li>
+
+ <li>new pseudo-elements, and introduction of the "::" convention
+ for pseudo-elements
+ </li>
+
+ <li>the grammar has been rewritten</li>
+
+ <li>profiles to be added to specifications integrating Selectors
+ and defining the set of selectors which is actually supported by
+ each specification
+ </li>
+
+ <li>Selectors are now a CSS3 Module and an independent
+ specification; other specifications can now refer to this document
+ independently of CSS
+ </li>
+
+ <li>the specification now has its own test suite</li>
+
+</ul>
+
+<h2><a name=selectors></a>2. Selectors</h2>
+
+<p><em>This section is non-normative, as it merely summarizes the
+ following sections.</em></p>
+
+<p>A Selector represents a structure. This structure can be used as a
+ condition (e.g. in a CSS rule) that determines which elements a
+ selector matches in the document tree, or as a flat description of the
+ HTML or XML fragment corresponding to that structure.</p>
+
+<p>Selectors may range from simple element names to rich contextual
+ representations.</p>
+
+<p>The following table summarizes the Selector syntax:</p>
+
+<table class="selectorsReview">
+<thead>
+<tr>
+ <th class="pattern">Pattern</th>
+ <th class="meaning">Meaning</th>
+ <th class="described">Described in section</th>
+ <th class="origin">First defined in CSS level</th>
+</tr>
+<tbody>
+<tr>
+ <td class="pattern">*</td>
+ <td class="meaning">any element</td>
+ <td class="described"><a
+ href="#universal-selector">Universal
+ selector</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
+ <td class="pattern">E</td>
+ <td class="meaning">an element of type E</td>
+ <td class="described"><a
+ href="#type-selectors">Type selector</a></td>
+ <td class="origin">1</td>
+</tr>
+<tr>
+ <td class="pattern">E[foo]</td>
+ <td class="meaning">an E element with a "foo" attribute</td>
+ <td class="described"><a
+ href="#attribute-selectors">Attribute
+ selectors</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
+ <td class="pattern">E[foo="bar"]</td>
+ <td class="meaning">an E element whose "foo" attribute value is exactly
+ equal to "bar"
+ </td>
+ <td class="described"><a
+ href="#attribute-selectors">Attribute
+ selectors</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
+ <td class="pattern">E[foo~="bar"]</td>
+ <td class="meaning">an E element whose "foo" attribute value is a list of
+ space-separated values, one of which is exactly equal to "bar"
+ </td>
+ <td class="described"><a
+ href="#attribute-selectors">Attribute
+ selectors</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
+ <td class="pattern">E[foo^="bar"]</td>
+ <td class="meaning">an E element whose "foo" attribute value begins exactly
+ with the string "bar"
+ </td>
+ <td class="described"><a
+ href="#attribute-selectors">Attribute
+ selectors</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E[foo$="bar"]</td>
+ <td class="meaning">an E element whose "foo" attribute value ends exactly
+ with the string "bar"
+ </td>
+ <td class="described"><a
+ href="#attribute-selectors">Attribute
+ selectors</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E[foo*="bar"]</td>
+ <td class="meaning">an E element whose "foo" attribute value contains the
+ substring "bar"
+ </td>
+ <td class="described"><a
+ href="#attribute-selectors">Attribute
+ selectors</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E[hreflang|="en"]</td>
+ <td class="meaning">an E element whose "hreflang" attribute has a
+ hyphen-separated
+ list of values beginning (from the left) with "en"
+ </td>
+ <td class="described"><a
+ href="#attribute-selectors">Attribute
+ selectors</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
+ <td class="pattern">E:root</td>
+ <td class="meaning">an E element, root of the document</td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:nth-child(n)</td>
+ <td class="meaning">an E element, the n-th child of its parent</td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:nth-last-child(n)</td>
+ <td class="meaning">an E element, the n-th child of its parent, counting
+ from the last one
+ </td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:nth-of-type(n)</td>
+ <td class="meaning">an E element, the n-th sibling of its type</td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:nth-last-of-type(n)</td>
+ <td class="meaning">an E element, the n-th sibling of its type, counting
+ from the last one
+ </td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:first-child</td>
+ <td class="meaning">an E element, first child of its parent</td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
+ <td class="pattern">E:last-child</td>
+ <td class="meaning">an E element, last child of its parent</td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:first-of-type</td>
+ <td class="meaning">an E element, first sibling of its type</td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:last-of-type</td>
+ <td class="meaning">an E element, last sibling of its type</td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:only-child</td>
+ <td class="meaning">an E element, only child of its parent</td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:only-of-type</td>
+ <td class="meaning">an E element, only sibling of its type</td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:empty</td>
+ <td class="meaning">an E element that has no children (including text
+ nodes)
+ </td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:link<br>E:visited</td>
+ <td class="meaning">an E element being the source anchor of a hyperlink of
+ which the target is not yet visited (:link) or already visited
+ (:visited)
+ </td>
+ <td class="described"><a
+ href="#link">The link
+ pseudo-classes</a></td>
+ <td class="origin">1</td>
+</tr>
+<tr>
+ <td class="pattern">E:active<br>E:hover<br>E:focus</td>
+ <td class="meaning">an E element during certain user actions</td>
+ <td class="described"><a
+ href="#useraction-pseudos">The user
+ action pseudo-classes</a></td>
+ <td class="origin">1 and 2</td>
+</tr>
+<tr>
+ <td class="pattern">E:target</td>
+ <td class="meaning">an E element being the target of the referring URI</td>
+ <td class="described"><a
+ href="#target-pseudo">The target
+ pseudo-class</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:lang(fr)</td>
+ <td class="meaning">an element of type E in language "fr" (the document
+ language specifies how language is determined)
+ </td>
+ <td class="described"><a
+ href="#lang-pseudo">The :lang()
+ pseudo-class</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
+ <td class="pattern">E:enabled<br>E:disabled</td>
+ <td class="meaning">a user interface element E which is enabled or
+ disabled
+ </td>
+ <td class="described"><a
+ href="#UIstates">The UI element states
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:checked<!--<br>E:indeterminate--></td>
+ <td class="meaning">a user interface element E which is checked<!-- or in an
+ indeterminate state--> (for instance a radio-button or checkbox)
+ </td>
+ <td class="described"><a
+ href="#UIstates">The UI element states
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E::first-line</td>
+ <td class="meaning">the first formatted line of an E element</td>
+ <td class="described"><a
+ href="#first-line">The ::first-line
+ pseudo-element</a></td>
+ <td class="origin">1</td>
+</tr>
+<tr>
+ <td class="pattern">E::first-letter</td>
+ <td class="meaning">the first formatted letter of an E element</td>
+ <td class="described"><a
+ href="#first-letter">The ::first-letter
+ pseudo-element</a></td>
+ <td class="origin">1</td>
+</tr>
+<tr>
+ <td class="pattern">E::selection</td>
+ <td class="meaning">the portion of an E element that is currently
+ selected/highlighted by the user
+ </td>
+ <td class="described"><a
+ href="#UIfragments">The UI element
+ fragments pseudo-elements</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E::before</td>
+ <td class="meaning">generated content before an E element</td>
+ <td class="described"><a
+ href="#gen-content">The ::before
+ pseudo-element</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
+ <td class="pattern">E::after</td>
+ <td class="meaning">generated content after an E element</td>
+ <td class="described"><a
+ href="#gen-content">The ::after
+ pseudo-element</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
+ <td class="pattern">E.warning</td>
+ <td class="meaning">an E element whose class is
+ "warning" (the document language specifies how class is determined).
+ </td>
+ <td class="described"><a
+ href="#class-html">Class
+ selectors</a></td>
+ <td class="origin">1</td>
+</tr>
+<tr>
+ <td class="pattern">E#myid</td>
+ <td class="meaning">an E element with ID equal to "myid".</td>
+ <td class="described"><a
+ href="#id-selectors">ID
+ selectors</a></td>
+ <td class="origin">1</td>
+</tr>
+<tr>
+ <td class="pattern">E:not(s)</td>
+ <td class="meaning">an E element that does not match simple selector s</td>
+ <td class="described"><a
+ href="#negation">Negation
+ pseudo-class</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E F</td>
+ <td class="meaning">an F element descendant of an E element</td>
+ <td class="described"><a
+ href="#descendant-combinators">Descendant
+ combinator</a></td>
+ <td class="origin">1</td>
+</tr>
+<tr>
+ <td class="pattern">E > F</td>
+ <td class="meaning">an F element child of an E element</td>
+ <td class="described"><a
+ href="#child-combinators">Child
+ combinator</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
+ <td class="pattern">E + F</td>
+ <td class="meaning">an F element immediately preceded by an E element</td>
+ <td class="described"><a
+ href="#adjacent-sibling-combinators">Adjacent sibling combinator</a>
+ </td>
+ <td class="origin">2</td>
+</tr>
+<tr>
+ <td class="pattern">E ~ F</td>
+ <td class="meaning">an F element preceded by an E element</td>
+ <td class="described"><a
+ href="#general-sibling-combinators">General sibling combinator</a>
+ </td>
+ <td class="origin">3</td>
+</tr>
+</tbody>
+</table>
+
+<p>The meaning of each selector is derived from the table above by
+ prepending "matches" to the contents of each cell in the "Meaning"
+ column.</p>
+
+<h2><a name=casesens>3. Case sensitivity</a></h2>
+
+<p>The case sensitivity of document language element names, attribute
+ names, and attribute values in selectors depends on the document
+ language. For example, in HTML, element names are case-insensitive,
+ but in XML, they are case-sensitive.</p>
+
+<h2><a name=selector-syntax>4. Selector syntax</a></h2>
+
+<p>A <dfn><a name=selector>selector</a></dfn> is a chain of one
+ or more <a href="#sequence">sequences of simple selectors</a>
+ separated by <a href="#combinators">combinators</a>.</p>
+
+<p>A <dfn><a name=sequence>sequence of simple selectors</a></dfn>
+ is a chain of <a href="#simple-selectors-dfn">simple selectors</a>
+ that are not separated by a <a href="#combinators">combinator</a>. It
+ always begins with a <a href="#type-selectors">type selector</a> or a
+ <a href="#universal-selector">universal selector</a>. No other type
+ selector or universal selector is allowed in the sequence.</p>
+
+<p>A <dfn><a name=simple-selectors-dfn></a><a
+ href="#simple-selectors">simple selector</a></dfn> is either a <a
+ href="#type-selectors">type selector</a>, <a
+ href="#universal-selector">universal selector</a>, <a
+ href="#attribute-selectors">attribute selector</a>, <a
+ href="#class-html">class selector</a>, <a
+ href="#id-selectors">ID selector</a>, <a
+ href="#content-selectors">content selector</a>, or <a
+ href="#pseudo-classes">pseudo-class</a>. One <a
+ href="#pseudo-elements">pseudo-element</a> may be appended to the last
+ sequence of simple selectors.</p>
+
+<p><dfn>Combinators</dfn> are: white space, "greater-than
+ sign" (U+003E, <code>></code>), "plus sign" (U+002B,
+ <code>+</code>) and "tilde" (U+007E, <code>~</code>). White
+ space may appear between a combinator and the simple selectors around
+ it. <a name=whitespace></a>Only the characters "space" (U+0020), "tab"
+ (U+0009), "line feed" (U+000A), "carriage return" (U+000D), and "form
+ feed" (U+000C) can occur in white space. Other space-like characters,
+ such as "em-space" (U+2003) and "ideographic space" (U+3000), are
+ never part of white space.</p>
+
+<p>The elements of a document tree that are represented by a selector
+ are the <dfn><a name=subject></a>subjects of the selector</dfn>. A
+ selector consisting of a single sequence of simple selectors
+ represents any element satisfying its requirements. Prepending another
+ sequence of simple selectors and a combinator to a sequence imposes
+ additional matching constraints, so the subjects of a selector are
+ always a subset of the elements represented by the last sequence of
+ simple selectors.</p>
+
+<p>An empty selector, containing no sequence of simple selectors and
+ no pseudo-element, is an <a href="#Conformance">invalid
+ selector</a>.</p>
+
+<h2><a name=grouping>5. Groups of selectors</a></h2>
+
+<p>When several selectors share the same declarations, they may be
+ grouped into a comma-separated list. (A comma is U+002C.)</p>
+
+<div class="example">
+ <p>CSS examples:</p>
+
+ <p>In this example, we condense three rules with identical
+ declarations into one. Thus,</p>
+<pre>h1 { font-family: sans-serif }
+h2 { font-family: sans-serif }
+h3 { font-family: sans-serif }</pre>
+ <p>is equivalent to:</p>
+ <pre>h1, h2, h3 { font-family: sans-serif }</pre>
+</div>
+
+<p><strong>Warning</strong>: the equivalence is true in this example
+ because all the selectors are valid selectors. If just one of these
+ selectors were invalid, the entire group of selectors would be
+ invalid. This would invalidate the rule for all three heading
+ elements, whereas in the former case only one of the three individual
+ heading rules would be invalidated.</p>
+
+
+<h2><a name=simple-selectors>6. Simple selectors</a></h2>
+
+<h3><a name=type-selectors>6.1. Type selector</a></h3>
+
+<p>A <dfn>type selector</dfn> is the name of a document language
+ element type. A type selector represents an instance of the element
+ type in the document tree.</p>
+
+<div class="example">
+ <p>Example:</p>
+
+ <p>The following selector represents an <code>h1</code> element in the
+ document tree:</p>
+ <pre>h1</pre>
+</div>
+
+
+<h4><a name=typenmsp>6.1.1. Type selectors and namespaces</a></h4>
+
+<p>Type selectors allow an optional namespace (<a
+ href="#refsXMLNAMES">[XMLNAMES]</a>) component. A namespace prefix
+ that has been previously declared may be prepended to the element name
+ separated by the namespace separator "vertical bar"
+ (U+007C, <code>|</code>).</p>
+
+<p>The namespace component may be left empty to indicate that the
+ selector is only to represent elements with no declared namespace.</p>
+
+<p>An asterisk may be used for the namespace prefix, indicating that
+ the selector represents elements in any namespace (including elements
+ with no namespace).</p>
+
+<p>Element type selectors that have no namespace component (no
+ namespace separator), represent elements without regard to the
+ element's namespace (equivalent to "<code>*|</code>") unless a default
+ namespace has been declared. If a default namespace has been declared,
+ the selector will represent only elements in the default
+ namespace.</p>
+
+<p>A type selector containing a namespace prefix that has not been
+ previously declared is an <a href="#Conformance">invalid</a> selector.
+ The mechanism for declaring a namespace prefix is left up to the
+ language implementing Selectors. In CSS, such a mechanism is defined
+ in the General Syntax module.</p>
+
+<p>In a namespace-aware client, element type selectors will only match
+ against the <a
+ href="http://www.w3.org/TR/REC-xml-names/#NT-LocalPart">local
+ part</a>
+ of the element's <a
+ href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">qualified
+ name</a>. See <a href="#downlevel">below</a> for notes about matching
+ behaviors in down-level clients.</p>
+
+<p>In summary:</p>
+
+<dl>
+ <dt><code>ns|E</code></dt>
+ <dd>elements with name E in namespace ns</dd>
+ <dt><code>*|E</code></dt>
+ <dd>elements with name E in any namespace, including those without any
+ declared namespace
+ </dd>
+ <dt><code>|E</code></dt>
+ <dd>elements with name E without any declared namespace</dd>
+ <dt><code>E</code></dt>
+ <dd>if no default namespace has been specified, this is equivalent to *|E.
+ Otherwise it is equivalent to ns|E where ns is the default namespace.
+ </dd>
+</dl>
+
+<div class="example">
+ <p>CSS examples:</p>
+
+ <pre>@namespace foo url(http://www.example.com);
+ foo|h1 { color: blue }
+ foo|* { color: yellow }
+ |h1 { color: red }
+ *|h1 { color: green }
+ h1 { color: green }</pre>
+
+ <p>The first rule will match only <code>h1</code> elements in the
+ "http://www.example.com" namespace.</p>
+
+ <p>The second rule will match all elements in the
+ "http://www.example.com" namespace.</p>
+
+ <p>The third rule will match only <code>h1</code> elements without
+ any declared namespace.</p>
+
+ <p>The fourth rule will match <code>h1</code> elements in any
+ namespace (including those without any declared namespace).</p>
+
+ <p>The last rule is equivalent to the fourth rule because no default
+ namespace has been defined.</p>
+
+</div>
+
+<h3><a name=universal-selector>6.2. Universal selector</a></h3>
+
+<p>The <dfn>universal selector</dfn>, written "asterisk"
+ (<code>*</code>), represents the qualified name of any element
+ type. It represents any single element in the document tree in any
+ namespace (including those without any declared namespace) if no
+ default namespace has been specified. If a default namespace has been
+ specified, see <a href="#univnmsp">Universal selector and
+ Namespaces</a> below.</p>
+
+<p>If the universal selector is not the only component of a sequence
+ of simple selectors, the <code>*</code> may be omitted.</p>
+
+<div class="example">
+ <p>Examples:</p>
+ <ul>
+ <li><code>*[hreflang|=en]</code> and <code>[hreflang|=en]</code> are
+ equivalent,
+ </li>
+ <li><code>*.warning</code> and <code>.warning</code> are equivalent,
+ </li>
+ <li><code>*#myid</code> and <code>#myid</code> are equivalent.</li>
+ </ul>
+</div>
+
+<p class="note"><strong>Note:</strong> it is recommended that the
+ <code>*</code>, representing the universal selector, not be
+ omitted.</p>
+
+<h4><a name=univnmsp>6.2.1. Universal selector and namespaces</a></h4>
+
+<p>The universal selector allows an optional namespace component. It
+ is used as follows:</p>
+
+<dl>
+ <dt><code>ns|*</code></dt>
+ <dd>all elements in namespace ns</dd>
+ <dt><code>*|*</code></dt>
+ <dd>all elements</dd>
+ <dt><code>|*</code></dt>
+ <dd>all elements without any declared namespace</dd>
+ <dt><code>*</code></dt>
+ <dd>if no default namespace has been specified, this is equivalent to *|*.
+ Otherwise it is equivalent to ns|* where ns is the default namespace.
+ </dd>
+</dl>
+
+<p>A universal selector containing a namespace prefix that has not
+ been previously declared is an <a href="#Conformance">invalid</a>
+ selector. The mechanism for declaring a namespace prefix is left up
+ to the language implementing Selectors. In CSS, such a mechanism is
+ defined in the General Syntax module.</p>
+
+
+<h3><a name=attribute-selectors>6.3. Attribute selectors</a></h3>
+
+<p>Selectors allow the representation of an element's attributes. When
+ a selector is used as an expression to match against an element,
+ attribute selectors must be considered to match an element if that
+ element has an attribute that matches the attribute represented by the
+ attribute selector.</p>
+
+<h4><a name=attribute-representation>6.3.1. Attribute presence and values
+ selectors</a></h4>
+
+<p>CSS2 introduced four attribute selectors:</p>
+
+<dl>
+ <dt><code>[att]</code>
+ <dd>Represents an element with the <code>att</code> attribute, whatever the
+ value of
+ the attribute.
+ </dd>
+ <dt><code>[att=val]</code></dt>
+ <dd>Represents an element with the <code>att</code> attribute whose value is
+ exactly
+ "val".
+ </dd>
+ <dt><code>[att~=val]</code></dt>
+ <dd>Represents an element with the <code>att</code> attribute whose value is
+ a <a
+ href="#whitespace">whitespace</a>-separated list of words, one
+ of
+ which is exactly "val". If "val" contains whitespace, it will never
+ represent anything (since the words are <em>separated</em> by
+ spaces).
+ </dd>
+ <dt><code>[att|=val]</code>
+ <dd>Represents an element with the <code>att</code> attribute, its value
+ either
+ being exactly "val" or beginning with "val" immediately followed by
+ "-" (U+002D). This is primarily intended to allow language subcode
+ matches (e.g., the <code>hreflang</code> attribute on the
+ <code>link</code> element in HTML) as described in RFC 3066 (<a
+ href="#refsRFC3066">[RFC3066]</a>). For <code>lang</code> (or
+ <code>xml:lang</code>) language subcode matching, please see <a
+ href="#lang-pseudo">the <code>:lang</code> pseudo-class</a>.
+ </dd>
+</dl>
+
+<p>Attribute values must be identifiers or strings. The
+ case-sensitivity of attribute names and values in selectors depends on
+ the document language.</p>
+
+<div class="example">
+
+ <p>Examples:</p>
+
+ <p>The following attribute selector represents an <code>h1</code>
+ element that carries the <code>title</code> attribute, whatever its
+ value:</p>
+
+ <pre>h1[title]</pre>
+
+ <p>In the following example, the selector represents a
+ <code>span</code> element whose <code>class</code> attribute has
+ exactly the value "example":</p>
+
+ <pre>span[class="example"]</pre>
+
+ <p>Multiple attribute selectors can be used to represent several
+ attributes of an element, or several conditions on the same
+ attribute. Here, the selector represents a <code>span</code> element
+ whose <code>hello</code> attribute has exactly the value "Cleveland"
+ and whose <code>goodbye</code> attribute has exactly the value
+ "Columbus":</p>
+
+ <pre>span[hello="Cleveland"][goodbye="Columbus"]</pre>
+
+ <p>The following selectors illustrate the differences between "="
+ and "~=". The first selector will represent, for example, the value
+ "copyright copyleft copyeditor" on a <code>rel</code> attribute. The
+ second selector will only represent an <code>a</code> element with
+ an <code>href</code> attribute having the exact value
+ "http://www.w3.org/".</p>
+
+ <pre>a[rel~="copyright"]
+a[href="http://www.w3.org/"]</pre>
+
+ <p>The following selector represents a <code>link</code> element
+ whose <code>hreflang</code> attribute is exactly "fr".</p>
+
+ <pre>link[hreflang=fr]</pre>
+
+ <p>The following selector represents a <code>link</code> element for
+ which the values of the <code>hreflang</code> attribute begins with
+ "en", including "en", "en-US", and "en-cockney":</p>
+
+ <pre>link[hreflang|="en"]</pre>
+
+ <p>Similarly, the following selectors represents a
+ <code>DIALOGUE</code> element whenever it has one of two different
+ values for an attribute <code>character</code>:</p>
+
+ <pre>DIALOGUE[character=romeo]
+DIALOGUE[character=juliet]</pre>
+
+</div>
+
+<h4><a name=attribute-substrings></a>6.3.2. Substring matching attribute
+ selectors</h4>
+
+<p>Three additional attribute selectors are provided for matching
+ substrings in the value of an attribute:</p>
+
+<dl>
+ <dt><code>[att^=val]</code></dt>
+ <dd>Represents an element with the <code>att</code> attribute whose value
+ begins
+ with the prefix "val".
+ </dd>
+ <dt><code>[att$=val]</code>
+ <dd>Represents an element with the <code>att</code> attribute whose value
+ ends with
+ the suffix "val".
+ </dd>
+ <dt><code>[att*=val]</code>
+ <dd>Represents an element with the <code>att</code> attribute whose value
+ contains
+ at least one instance of the substring "val".
+ </dd>
+</dl>
+
+<p>Attribute values must be identifiers or strings. The
+ case-sensitivity of attribute names in selectors depends on the
+ document language.</p>
+
+<div class="example">
+ <p>Examples:</p>
+
+ <p>The following selector represents an HTML <code>object</code>,
+ referencing an
+ image:</p>
+ <pre>object[type^="image/"]</pre>
+ <p>The following selector represents an HTML anchor <code>a</code> with an
+ <code>href</code> attribute whose value ends with ".html".</p>
+ <pre>a[href$=".html"]</pre>
+ <p>The following selector represents an HTML paragraph with a
+ <code>title</code>
+ attribute whose value contains the substring "hello"</p>
+ <pre>p[title*="hello"]</pre>
+</div>
+
+<h4><a name=attrnmsp>6.3.3. Attribute selectors and namespaces</a></h4>
+
+<p>Attribute selectors allow an optional namespace component to the
+ attribute name. A namespace prefix that has been previously declared
+ may be prepended to the attribute name separated by the namespace
+ separator "vertical bar" (<code>|</code>). In keeping with
+ the Namespaces in the XML recommendation, default namespaces do not
+ apply to attributes, therefore attribute selectors without a namespace
+ component apply only to attributes that have no declared namespace
+ (equivalent to "<code>|attr</code>"). An asterisk may be used for the
+ namespace prefix indicating that the selector is to match all
+ attribute names without regard to the attribute's namespace.
+
+<p>An attribute selector with an attribute name containing a namespace
+ prefix that has not been previously declared is an <a
+ href="#Conformance">invalid</a> selector. The mechanism for
+ declaring
+ a namespace prefix is left up to the language implementing Selectors.
+ In CSS, such a mechanism is defined in the General Syntax module.
+
+<div class="example">
+ <p>CSS examples:</p>
+ <pre>@namespace foo "http://www.example.com";
+[foo|att=val] { color: blue }
+[*|att] { color: yellow }
+[|att] { color: green }
+[att] { color: green }</pre>
+
+ <p>The first rule will match only elements with the attribute
+ <code>att</code> in the "http://www.example.com" namespace with the
+ value "val".</p>
+
+ <p>The second rule will match only elements with the attribute
+ <code>att</code> regardless of the namespace of the attribute
+ (including no declared namespace).</p>
+
+ <p>The last two rules are equivalent and will match only elements
+ with the attribute <code>att</code> where the attribute is not
+ declared to be in a namespace.</p>
+
+</div>
+
+<h4><a name=def-values>6.3.4. Default attribute values in DTDs</a></h4>
+
+<p>Attribute selectors represent explicitly set attribute values in
+ the document tree. Default attribute values may be defined in a DTD or
+ elsewhere, but cannot always be selected by attribute
+ selectors. Selectors should be designed so that they work even if the
+ default values are not included in the document tree.</p>
+
+<p>More precisely, a UA is <em>not</em> required to read an "external
+ subset" of the DTD but <em>is</em> required to look for default
+ attribute values in the document's "internal subset." (See <a
+ href="#refsXML10">[XML10]</a> for definitions of these subsets.)</p>
+
+<p>A UA that recognizes an XML namespace <a
+ href="#refsXMLNAMES">[XMLNAMES]</a> is not required to use its
+ knowledge of that namespace to treat default attribute values as if
+ they were present in the document. (For example, an XHTML UA is not
+ required to use its built-in knowledge of the XHTML DTD.)</p>
+
+<p class="note"><strong>Note:</strong> Typically, implementations
+ choose to ignore external subsets.</p>
+
+<div class="example">
+ <p>Example:</p>
+
+ <p>Consider an element EXAMPLE with an attribute "notation" that has a
+ default value of "decimal". The DTD fragment might be</p>
+
+ <pre class="dtd-example"><!ATTLIST EXAMPLE notation (decimal,octal) "decimal"></pre>
+
+ <p>If the style sheet contains the rules</p>
+
+<pre>EXAMPLE[notation=decimal] { /*... default property settings ...*/ }
+EXAMPLE[notation=octal] { /*... other settings...*/ }</pre>
+
+ <p>the first rule will not match elements whose "notation" attribute
+ is set by default, i.e. not set explicitly. To catch all cases, the
+ attribute selector for the default value must be dropped:</p>
+
+<pre>EXAMPLE { /*... default property settings ...*/ }
+EXAMPLE[notation=octal] { /*... other settings...*/ }</pre>
+
+ <p>Here, because the selector <code>EXAMPLE[notation=octal]</code> is
+ more specific than the tag
+ selector alone, the style declarations in the second rule will override
+ those in the first for elements that have a "notation" attribute value
+ of "octal". Care has to be taken that all property declarations that
+ are to apply only to the default case are overridden in the non-default
+ cases' style rules.</p>
+
+</div>
+
+<h3><a name=class-html>6.4. Class selectors</a></h3>
+
+<p>Working with HTML, authors may use the period (U+002E,
+ <code>.</code>) notation as an alternative to the <code>~=</code>
+ notation when representing the <code>class</code> attribute. Thus, for
+ HTML, <code>div.value</code> and <code>div[class~=value]</code> have
+ the same meaning. The attribute value must immediately follow the
+ "period" (<code>.</code>).</p>
+
+<p>UAs may apply selectors using the period (.) notation in XML
+ documents if the UA has namespace-specific knowledge that allows it to
+ determine which attribute is the "class" attribute for the
+ respective namespace. One such example of namespace-specific knowledge
+ is the prose in the specification for a particular namespace (e.g. SVG
+ 1.0 <a href="#refsSVG">[SVG]</a> describes the <a
+ href="http://www.w3.org/TR/2001/PR-SVG-20010719/styling.html#ClassAttribute">SVG
+ "class" attribute</a> and how a UA should interpret it, and
+ similarly MathML 1.01 <a href="#refsMATH">[MATH]</a> describes the <a
+ href="http://www.w3.org/1999/07/REC-MathML-19990707/chapter2.html#sec2.3.4">MathML
+ "class" attribute</a>.)</p>
+
+<div class="example">
+ <p>CSS examples:</p>
+
+ <p>We can assign style information to all elements with
+ <code>class~="pastoral"</code> as follows:</p>
+
+ <pre>*.pastoral { color: green } /* all elements with class~=pastoral */</pre>
+
+ <p>or just</p>
+
+ <pre>.pastoral { color: green } /* all elements with class~=pastoral */</pre>
+
+ <p>The following assigns style only to H1 elements with
+ <code>class~="pastoral"</code>:</p>
+
+ <pre>H1.pastoral { color: green } /* H1 elements with class~=pastoral */</pre>
+
+ <p>Given these rules, the first H1 instance below would not have
+ green text, while the second would:</p>
+
+ <pre><H1>Not green</H1>
+<H1 class="pastoral">Very green</H1></pre>
+
+</div>
+
+<p>To represent a subset of "class" values, each value must be preceded
+ by a ".", in any order.</P>
+
+<div class="example">
+
+ <p>CSS example:</p>
+
+ <p>The following rule matches any P element whose "class" attribute
+ has been assigned a list of <a
+ href="#whitespace">whitespace</a>-separated values that includes
+ "pastoral" and "marine":</p>
+
+ <pre>p.pastoral.marine { color: green }</pre>
+
+ <p>This rule matches when <code>class="pastoral blue aqua
+ marine"</code> but does not match for <code>class="pastoral
+ blue"</code>.</p>
+
+</div>
+
+<p class="note"><strong>Note:</strong> Because CSS gives considerable
+ power to the "class" attribute, authors could conceivably design their
+ own "document language" based on elements with almost no associated
+ presentation (such as DIV and SPAN in HTML) and assigning style
+ information through the "class" attribute. Authors should avoid this
+ practice since the structural elements of a document language often
+ have recognized and accepted meanings and author-defined classes may
+ not.</p>
+
+<p class="note"><strong>Note:</strong> If an element has multiple
+ class attributes, their values must be concatenated with spaces
+ between the values before searching for the class. As of this time the
+ working group is not aware of any manner in which this situation can
+ be reached, however, so this behavior is explicitly non-normative in
+ this specification.</p>
+
+<h3><a name=id-selectors>6.5. ID selectors</a></h3>
+
+<p>Document languages may contain attributes that are declared to be
+ of type ID. What makes attributes of type ID special is that no two
+ such attributes can have the same value in a document, regardless of
+ the type of the elements that carry them; whatever the document
+ language, an ID typed attribute can be used to uniquely identify its
+ element. In HTML all ID attributes are named "id"; XML applications
+ may name ID attributes differently, but the same restriction
+ applies.</p>
+
+<p>An ID-typed attribute of a document language allows authors to
+ assign an identifier to one element instance in the document tree. W3C
+ ID selectors represent an element instance based on its identifier. An
+ ID selector contains a "number sign" (U+0023,
+ <code>#</code>) immediately followed by the ID value, which must be an
+ identifier.</p>
+
+<p>Selectors does not specify how a UA knows the ID-typed attribute of
+ an element. The UA may, e.g., read a document's DTD, have the
+ information hard-coded or ask the user.
+
+<div class="example">
+ <p>Examples:</p>
+
+ <p>The following ID selector represents an <code>h1</code> element
+ whose ID-typed attribute has the value "chapter1":</p>
+ <pre>h1#chapter1</pre>
+ <p>The following ID selector represents any element whose ID-typed
+ attribute has the value "chapter1":</p>
+ <pre>#chapter1</pre>
+ <p>The following selector represents any element whose ID-typed
+ attribute has the value "z98y".</p>
+ <pre>*#z98y</pre>
+</div>
+
+<p class="note"><strong>Note.</strong> In XML 1.0 <a
+ href="#refsXML10">[XML10]</a>, the information about which attribute
+ contains an element's IDs is contained in a DTD or a schema. When
+ parsing XML, UAs do not always read the DTD, and thus may not know
+ what the ID of an element is (though a UA may have namespace-specific
+ knowledge that allows it to determine which attribute is the ID
+ attribute for that namespace). If a style sheet designer knows or
+ suspects that a UA may not know what the ID of an element is, he
+ should use normal attribute selectors instead:
+ <code>[name=p371]</code> instead of <code>#p371</code>. Elements in
+ XML 1.0 documents without a DTD do not have IDs at all.</p>
+
+<p>If an element has multiple ID attributes, all of them must be
+ treated as IDs for that element for the purposes of the ID
+ selector. Such a situation could be reached using mixtures of xml:id,
+ DOM3 Core, XML DTDs, and namespace-specific knowledge.</p>
+
+<h3><a name=pseudo-classes>6.6. Pseudo-classes</a></h3>
+
+<p>The pseudo-class concept is introduced to permit selection based on
+ information that lies outside of the document tree or that cannot be
+ expressed using the other simple selectors.</p>
+
+<p>A pseudo-class always consists of a "colon"
+ (<code>:</code>) followed by the name of the pseudo-class and
+ optionally by a value between parentheses.</p>
+
+<p>Pseudo-classes are allowed in all sequences of simple selectors
+ contained in a selector. Pseudo-classes are allowed anywhere in
+ sequences of simple selectors, after the leading type selector or
+ universal selector (possibly omitted). Pseudo-class names are
+ case-insensitive. Some pseudo-classes are mutually exclusive, while
+ others can be applied simultaneously to the same
+ element. Pseudo-classes may be dynamic, in the sense that an element
+ may acquire or lose a pseudo-class while a user interacts with the
+ document.</p>
+
+
+<h4><a name=dynamic-pseudos>6.6.1. Dynamic pseudo-classes</a></h4>
+
+<p>Dynamic pseudo-classes classify elements on characteristics other
+ than their name, attributes, or content, in principle characteristics
+ that cannot be deduced from the document tree.</p>
+
+<p>Dynamic pseudo-classes do not appear in the document source or
+ document tree.</p>
+
+
+<h5>The <a name=link>link pseudo-classes: :link and :visited</a></h5>
+
+<p>User agents commonly display unvisited links differently from
+ previously visited ones. Selectors
+ provides the pseudo-classes <code>:link</code> and
+ <code>:visited</code> to distinguish them:</p>
+
+<ul>
+ <li>The <code>:link</code> pseudo-class applies to links that have
+ not yet been visited.
+ </li>
+ <li>The <code>:visited</code> pseudo-class applies once the link has
+ been visited by the user.
+ </li>
+</ul>
+
+<p>After some amount of time, user agents may choose to return a
+ visited link to the (unvisited) ':link' state.</p>
+
+<p>The two states are mutually exclusive.</p>
+
+<div class="example">
+
+ <p>Example:</p>
+
+ <p>The following selector represents links carrying class
+ <code>external</code> and already visited:</p>
+
+ <pre>a.external:visited</pre>
+
+</div>
+
+<p class="note"><strong>Note:</strong> It is possible for style sheet
+ authors to abuse the :link and :visited pseudo-classes to determine
+ which sites a user has visited without the user's consent.
+
+<p>UAs may therefore treat all links as unvisited links, or implement
+ other measures to preserve the user's privacy while rendering visited
+ and unvisited links differently.</p>
+
+<h5>The <a name=useraction-pseudos>user action pseudo-classes
+ :hover, :active, and :focus</a></h5>
+
+<p>Interactive user agents sometimes change the rendering in response
+ to user actions. Selectors provides
+ three pseudo-classes for the selection of an element the user is
+ acting on.</p>
+
+<ul>
+
+ <li>The <code>:hover</code> pseudo-class applies while the user
+ designates an element with a pointing device, but does not activate
+ it. For example, a visual user agent could apply this pseudo-class
+ when the cursor (mouse pointer) hovers over a box generated by the
+ element. User agents not that do not support <a
+ href="http://www.w3.org/TR/REC-CSS2/media.html#interactive-media-group">interactive
+ media</a> do not have to support this pseudo-class. Some conforming
+ user agents that support <a
+ href="http://www.w3.org/TR/REC-CSS2/media.html#interactive-media-group">interactive
+ media</a> may not be able to support this pseudo-class (e.g., a pen
+ device that does not detect hovering).
+ </li>
+
+ <li>The <code>:active</code> pseudo-class applies while an element
+ is being activated by the user. For example, between the times the
+ user presses the mouse button and releases it.
+ </li>
+
+ <li>The <code>:focus</code> pseudo-class applies while an element
+ has the focus (accepts keyboard or mouse events, or other forms of
+ input).
+ </li>
+
+</ul>
+
+<p>There may be document language or implementation specific limits on
+ which elements can become <code>:active</code> or acquire
+ <code>:focus</code>.</p>
+
+<p>These pseudo-classes are not mutually exclusive. An element may
+ match several pseudo-classes at the same time.</p>
+
+<p>Selectors doesn't define if the parent of an element that is
+ ':active' or ':hover' is also in that state.</p>
+
+<div class="example">
+ <p>Examples:</p>
+ <pre>a:link /* unvisited links */
+a:visited /* visited links */
+a:hover /* user hovers */
+a:active /* active links */</pre>
+ <p>An example of combining dynamic pseudo-classes:</p>
+ <pre>a:focus
+a:focus:hover</pre>
+ <p>The last selector matches <code>a</code> elements that are in
+ the pseudo-class :focus and in the pseudo-class :hover.</p>
+</div>
+
+<p class="note"><strong>Note:</strong> An element can be both ':visited'
+ and ':active' (or ':link' and ':active').</p>
+
+<h4><a name=target-pseudo>6.6.2. The target pseudo-class :target</a></h4>
+
+<p>Some URIs refer to a location within a resource. This kind of URI
+ ends with a "number sign" (#) followed by an anchor
+ identifier (called the fragment identifier).</p>
+
+<p>URIs with fragment identifiers link to a certain element within the
+ document, known as the target element. For instance, here is a URI
+ pointing to an anchor named <code>section_2</code> in an HTML
+ document:</p>
+
+<pre>http://example.com/html/top.html#section_2</pre>
+
+<p>A target element can be represented by the <code>:target</code>
+ pseudo-class. If the document's URI has no fragment identifier, then
+ the document has no target element.</p>
+
+<div class="example">
+ <p>Example:</p>
+ <pre>p.note:target</pre>
+ <p>This selector represents a <code>p</code> element of class
+ <code>note</code> that is the target element of the referring
+ URI.</p>
+</div>
+
+<div class="example">
+ <p>CSS example:</p>
+
+ <p>Here, the <code>:target</code> pseudo-class is used to make the
+ target element red and place an image before it, if there is one:</p>
+ <pre>*:target { color : red }
+*:target::before { content : url(target.png) }</pre>
+</div>
+
+<h4><a name=lang-pseudo>6.6.3. The language pseudo-class :lang</a></h4>
+
+<p>If the document language specifies how the human language of an
+ element is determined, it is possible to write selectors that
+ represent an element based on its language. For example, in HTML <a
+ href="#refsHTML4">[HTML4]</a>, the language is determined by a
+ combination of the <code>lang</code> attribute, the <code>meta</code>
+ element, and possibly by information from the protocol (such as HTTP
+ headers). XML uses an attribute called <code>xml:lang</code>, and
+ there may be other document language-specific methods for determining
+ the language.</p>
+
+<p>The pseudo-class <code>:lang(C)</code> represents an element that
+ is in language C. Whether an element is represented by a
+ <code>:lang()</code> selector is based solely on the identifier C
+ being either equal to, or a hyphen-separated substring of, the
+ element's language value, in the same way as if performed by the <a
+ href="#attribute-representation">'|='</a> operator in attribute
+ selectors. The identifier C does not have to be a valid language
+ name.</p>
+
+<p>C must not be empty. (If it is, the selector is invalid.)</p>
+
+<p class="note"><strong>Note:</strong> It is recommended that
+ documents and protocols indicate language using codes from RFC 3066 <a
+ href="#refsRFC3066">[RFC3066]</a> or its successor, and by means of
+ "xml:lang" attributes in the case of XML-based documents <a
+ href="#refsXML10">[XML10]</a>. See <a
+ href="http://www.w3.org/International/questions/qa-lang-2or3.html">
+ "FAQ: Two-letter or three-letter language codes."</a></p>
+
+<div class="example">
+ <p>Examples:</p>
+
+ <p>The two following selectors represent an HTML document that is in
+ Belgian, French, or German. The two next selectors represent
+ <code>q</code> quotations in an arbitrary element in Belgian, French,
+ or German.</p>
+ <pre>html:lang(fr-be)
+html:lang(de)
+:lang(fr-be) > q
+:lang(de) > q</pre>
+</div>
+
+<h4><a name=UIstates>6.6.4. The UI element states pseudo-classes</a></h4>
+
+<h5><a name=enableddisabled>The :enabled and :disabled pseudo-classes</a></h5>
+
+<p>The <code>:enabled</code> pseudo-class allows authors to customize
+ the look of user interface elements that are enabled — which the
+ user can select or activate in some fashion (e.g. clicking on a button
+ with a mouse). There is a need for such a pseudo-class because there
+ is no way to programmatically specify the default appearance of say,
+ an enabled <code>input</code> element without also specifying what it
+ would look like when it was disabled.</p>
+
+<p>Similar to <code>:enabled</code>, <code>:disabled</code> allows the
+ author to specify precisely how a disabled or inactive user interface
+ element should look.</p>
+
+<p>Most elements will be neither enabled nor disabled. An element is
+ enabled if the user can either activate it or transfer the focus to
+ it. An element is disabled if it could be enabled, but the user cannot
+ presently activate it or transfer focus to it.</p>
+
+
+<h5><a name=checked>The :checked pseudo-class</a></h5>
+
+<p>Radio and checkbox elements can be toggled by the user. Some menu
+ items are "checked" when the user selects them. When such elements are
+ toggled "on" the <code>:checked</code> pseudo-class applies. The
+ <code>:checked</code> pseudo-class initially applies to such elements
+ that have the HTML4 <code>selected</code> and <code>checked</code>
+ attributes as described in <a
+ href="http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.2.1">Section
+ 17.2.1 of HTML4</a>, but of course the user can toggle "off" such
+ elements in which case the <code>:checked</code> pseudo-class would no
+ longer apply. While the <code>:checked</code> pseudo-class is dynamic
+ in nature, and is altered by user action, since it can also be based
+ on the presence of the semantic HTML4 <code>selected</code> and
+ <code>checked</code> attributes, it applies to all media.
+
+
+<h5><a name=indeterminate>The :indeterminate pseudo-class</a></h5>
+
+<div class="note">
+
+ <p>Radio and checkbox elements can be toggled by the user, but are
+ sometimes in an indeterminate state, neither checked nor unchecked.
+ This can be due to an element attribute, or DOM manipulation.</p>
+
+ <p>A future version of this specification may introduce an
+ <code>:indeterminate</code> pseudo-class that applies to such elements.
+ <!--While the <code>:indeterminate</code> pseudo-class is dynamic in
+ nature, and is altered by user action, since it can also be based on
+ the presence of an element attribute, it applies to all media.</p>
+
+ <p>Components of a radio-group initialized with no pre-selected choice
+ are an example of :indeterminate state.--></p>
+
+</div>
+
+
+<h4><a name=structural-pseudos>6.6.5. Structural pseudo-classes</a></h4>
+
+<p>Selectors introduces the concept of <dfn>structural
+ pseudo-classes</dfn> to permit selection based on extra information that
+ lies in
+ the document tree but cannot be represented by other simple selectors or
+ combinators.
+
+<p>Note that standalone pieces of PCDATA (text nodes in the DOM) are
+ not counted when calculating the position of an element in the list of
+ children of its parent. When calculating the position of an element in
+ the list of children of its parent, the index numbering starts at 1.
+
+
+<h5><a name=root-pseudo>:root pseudo-class</a></h5>
+
+<p>The <code>:root</code> pseudo-class represents an element that is
+ the root of the document. In HTML 4, this is always the
+ <code>HTML</code> element.
+
+
+<h5><a name=nth-child-pseudo>:nth-child() pseudo-class</a></h5>
+
+<p>The
+ <code>:nth-child(<var>a</var><code>n</code>+<var>b</var>)</code>
+ pseudo-class notation represents an element that has
+ <var>a</var><code>n</code>+<var>b</var>-1 siblings
+ <strong>before</strong> it in the document tree, for a given positive
+ integer or zero value of <code>n</code>, and has a parent element. In
+ other words, this matches the <var>b</var>th child of an element after
+ all the children have been split into groups of <var>a</var> elements
+ each. For example, this allows the selectors to address every other
+ row in a table, and could be used to alternate the color
+ of paragraph text in a cycle of four. The <var>a</var> and
+ <var>b</var> values must be zero, negative integers or positive
+ integers. The index of the first child of an element is 1.
+
+<p>In addition to this, <code>:nth-child()</code> can take
+ '<code>odd</code>' and '<code>even</code>' as arguments instead.
+ '<code>odd</code>' has the same signification as <code>2n+1</code>,
+ and '<code>even</code>' has the same signification as <code>2n</code>.
+
+
+<div class="example">
+ <p>Examples:</p>
+<pre>tr:nth-child(2n+1) /* represents every odd row of an HTML table */
+tr:nth-child(odd) /* same */
+tr:nth-child(2n) /* represents every even row of an HTML table */
+tr:nth-child(even) /* same */
+
+/* Alternate paragraph colours in CSS */
+p:nth-child(4n+1) { color: navy; }
+p:nth-child(4n+2) { color: green; }
+p:nth-child(4n+3) { color: maroon; }
+p:nth-child(4n+4) { color: purple; }</pre>
+</div>
+
+<p>When <var>a</var>=0, no repeating is used, so for example
+ <code>:nth-child(0n+5)</code> matches only the fifth child. When
+ <var>a</var>=0, the <var>a</var><code>n</code> part need not be
+ included, so the syntax simplifies to
+ <code>:nth-child(<var>b</var>)</code> and the last example simplifies
+ to <code>:nth-child(5)</code>.
+
+<div class="example">
+ <p>Examples:</p>
+<pre>foo:nth-child(0n+1) /* represents an element foo, first child of its parent element */
+foo:nth-child(1) /* same */</pre>
+</div>
+
+<p>When <var>a</var>=1, the number may be omitted from the rule.
+
+<div class="example">
+ <p>Examples:</p>
+
+ <p>The following selectors are therefore equivalent:</p>
+<pre>bar:nth-child(1n+0) /* represents all bar elements, specificity (0,1,1) */
+bar:nth-child(n+0) /* same */
+bar:nth-child(n) /* same */
+bar /* same but lower specificity (0,0,1) */</pre>
+</div>
+
+<p>If <var>b</var>=0, then every <var>a</var>th element is picked. In
+ such a case, the <var>b</var> part may be omitted.
+
+<div class="example">
+ <p>Examples:</p>
+<pre>tr:nth-child(2n+0) /* represents every even row of an HTML table */
+tr:nth-child(2n) /* same */</pre>
+</div>
+
+<p>If both <var>a</var> and <var>b</var> are equal to zero, the
+ pseudo-class represents no element in the document tree.</p>
+
+<p>The value <var>a</var> can be negative, but only the positive
+ values of <var>a</var><code>n</code>+<var>b</var>, for
+ <code>n</code>≥0, may represent an element in the document
+ tree.</p>
+
+<div class="example">
+ <p>Example:</p>
+ <pre>html|tr:nth-child(-n+6) /* represents the 6 first rows of XHTML tables */</pre>
+</div>
+
+<p>When the value <var>b</var> is negative, the "+" character in the
+ expression must be removed (it is effectively replaced by the "-"
+ character indicating the negative value of <var>b</var>).</p>
+
+<div class="example">
+ <p>Examples:</p>
+<pre>:nth-child(10n-1) /* represents the 9th, 19th, 29th, etc, element */
+:nth-child(10n+9) /* Same */
+:nth-child(10n+-1) /* Syntactically invalid, and would be ignored */</pre>
+</div>
+
+
+<h5><a name=nth-last-child-pseudo>:nth-last-child() pseudo-class</a></h5>
+
+<p>The <code>:nth-last-child(<var>a</var>n+<var>b</var>)</code>
+ pseudo-class notation represents an element that has
+ <var>a</var><code>n</code>+<var>b</var>-1 siblings
+ <strong>after</strong> it in the document tree, for a given positive
+ integer or zero value of <code>n</code>, and has a parent element. See
+ <code>:nth-child()</code> pseudo-class for the syntax of its argument.
+ It also accepts the '<code>even</code>' and '<code>odd</code>' values
+ as arguments.
+
+
+<div class="example">
+ <p>Examples:</p>
+<pre>tr:nth-last-child(-n+2) /* represents the two last rows of an HTML table */
+
+foo:nth-last-child(odd) /* represents all odd foo elements in their parent element,
+ counting from the last one */</pre>
+</div>
+
+
+<h5><a name=nth-of-type-pseudo>:nth-of-type() pseudo-class</a></h5>
+
+<p>The <code>:nth-of-type(<var>a</var>n+<var>b</var>)</code>
+ pseudo-class notation represents an element that has
+ <var>a</var><code>n</code>+<var>b</var>-1 siblings with the same
+ element name <strong>before</strong> it in the document tree, for a
+ given zero or positive integer value of <code>n</code>, and has a
+ parent element. In other words, this matches the <var>b</var>th child
+ of that type after all the children of that type have been split into
+ groups of a elements each. See <code>:nth-child()</code> pseudo-class
+ for the syntax of its argument. It also accepts the
+ '<code>even</code>' and '<code>odd</code>' values.
+
+
+<div class="example">
+ <p>CSS example:</p>
+
+ <p>This allows an author to alternate the position of floated images:</p>
+<pre>img:nth-of-type(2n+1) { float: right; }
+img:nth-of-type(2n) { float: left; }</pre>
+</div>
+
+
+<h5><a name=nth-last-of-type-pseudo>:nth-last-of-type() pseudo-class</a></h5>
+
+<p>The <code>:nth-last-of-type(<var>a</var>n+<var>b</var>)</code>
+ pseudo-class notation represents an element that has
+ <var>a</var><code>n</code>+<var>b</var>-1 siblings with the same
+ element name <strong>after</strong> it in the document tree, for a
+ given zero or positive integer value of <code>n</code>, and has a
+ parent element. See <code>:nth-child()</code> pseudo-class for the
+ syntax of its argument. It also accepts the '<code>even</code>' and '<code>odd</code>'
+ values.
+
+
+<div class="example">
+ <p>Example:</p>
+
+ <p>To represent all <code>h2</code> children of an XHTML
+ <code>body</code> except the first and last, one could use the
+ following selector:</p>
+ <pre>body > h2:nth-of-type(n+2):nth-last-of-type(n+2)</pre>
+ <p>In this case, one could also use <code>:not()</code>, although the
+ selector ends up being just as long:</p>
+ <pre>body > h2:not(:first-of-type):not(:last-of-type)</pre>
+</div>
+
+
+<h5><a name=first-child-pseudo>:first-child pseudo-class</a></h5>
+
+<p>Same as <code>:nth-child(1)</code>. The <code>:first-child</code>
+ pseudo-class
+ represents an element that is the first child of some other element.
+
+
+<div class="example">
+ <p>Examples:</p>
+
+ <p>The following selector represents a <code>p</code> element that is
+ the first child of a <code>div</code> element:</p>
+ <pre>div > p:first-child</pre>
+ <p>This selector can represent the <code>p</code> inside the
+ <code>div</code> of the following fragment:</p>
+ <pre><p> The last P before the note.</p>
+<div class="note">
+ <p> The first P inside the note.</p>
+</div></pre>
+ but cannot represent the second <code>p</code> in the following
+ fragment:
+ <pre><p> The last P before the note.</p>
+<div class="note">
+ <h2> Note </h2>
+ <p> The first P inside the note.</p>
+</div></pre>
+ <p>The following two selectors are usually equivalent:</p>
+ <pre>* > a:first-child /* a is first child of any element */
+a:first-child /* Same (assuming a is not the root element) */</pre>
+</div>
+
+<h5><a name=last-child-pseudo>:last-child pseudo-class</a></h5>
+
+<p>Same as <code>:nth-last-child(1)</code>. The <code>:last-child</code>
+ pseudo-class
+ represents an element that is the last child of some other element.
+
+<div class="example">
+ <p>Example:</p>
+
+ <p>The following selector represents a list item <code>li</code> that
+ is the last child of an ordered list <code>ol</code>.
+ <pre>ol > li:last-child</pre>
+</div>
+
+<h5><a name=first-of-type-pseudo>:first-of-type pseudo-class</a></h5>
+
+<p>Same as <code>:nth-of-type(1)</code>. The <code>:first-of-type</code>
+ pseudo-class
+ represents an element that is the first sibling of its type in the list of
+ children of its parent element.
+
+<div class="example">
+ <p>Example:</p>
+
+ <p>The following selector represents a definition title
+ <code>dt</code> inside a definition list <code>dl</code>, this
+ <code>dt</code> being the first of its type in the list of children of
+ its parent element.</p>
+ <pre>dl dt:first-of-type</pre>
+ <p>It is a valid description for the first two <code>dt</code>
+ elements in the following example but not for the third one:</p>
+<pre><dl>
+ <dt>gigogne</dt>
+ <dd>
+ <dl>
+ <dt>fusée</dt>
+ <dd>multistage rocket</dd>
+ <dt>table</dt>
+ <dd>nest of tables</dd>
+ </dl>
+ </dd>
+</dl></pre>
+</div>
+
+<h5><a name=last-of-type-pseudo>:last-of-type pseudo-class</a></h5>
+
+<p>Same as <code>:nth-last-of-type(1)</code>. The
+ <code>:last-of-type</code> pseudo-class represents an element that is
+ the last sibling of its type in the list of children of its parent
+ element.</p>
+
+<div class="example">
+ <p>Example:</p>
+
+ <p>The following selector represents the last data cell
+ <code>td</code> of a table row.</p>
+ <pre>tr > td:last-of-type</pre>
+</div>
+
+<h5><a name=only-child-pseudo>:only-child pseudo-class</a></h5>
+
+<p>Represents an element that has a parent element and whose parent
+ element has no other element children. Same as
+ <code>:first-child:last-child</code> or
+ <code>:nth-child(1):nth-last-child(1)</code>, but with a lower
+ specificity.</p>
+
+<h5><a name=only-of-type-pseudo>:only-of-type pseudo-class</a></h5>
+
+<p>Represents an element that has a parent element and whose parent
+ element has no other element children with the same element name. Same
+ as <code>:first-of-type:last-of-type</code> or
+ <code>:nth-of-type(1):nth-last-of-type(1)</code>, but with a lower
+ specificity.</p>
+
+
+<h5><a name=empty-pseudo></a>:empty pseudo-class</h5>
+
+<p>The <code>:empty</code> pseudo-class represents an element that has
+ no children at all. In terms of the DOM, only element nodes and text
+ nodes (including CDATA nodes and entity references) whose data has a
+ non-zero length must be considered as affecting emptiness; comments,
+ PIs, and other nodes must not affect whether an element is considered
+ empty or not.</p>
+
+<div class="example">
+ <p>Examples:</p>
+
+ <p><code>p:empty</code> is a valid representation of the following fragment:
+ </p>
+ <pre><p></p></pre>
+ <p><code>foo:empty</code> is not a valid representation for the
+ following fragments:</p>
+ <pre><foo>bar</foo></pre>
+ <pre><foo><bar>bla</bar></foo></pre>
+ <pre><foo>this is not <bar>:empty</bar></foo></pre>
+</div>
+
+<h4><a name=content-selectors>6.6.6. Blank</a></h4>
+<!-- It's the Return of Appendix H!!! Run away! -->
+
+<p>This section intentionally left blank.</p>
+<!-- (used to be :contains()) -->
+
+<h4><a name=negation></a>6.6.7. The negation pseudo-class</h4>
+
+<p>The negation pseudo-class, <code>:not(<var>X</var>)</code>, is a
+ functional notation taking a <a href="#simple-selectors-dfn">simple
+ selector</a> (excluding the negation pseudo-class itself and
+ pseudo-elements) as an argument. It represents an element that is not
+ represented by the argument.
+
+ <!-- pseudo-elements are not simple selectors, so the above paragraph
+may be a bit confusing -->
+
+<div class="example">
+ <p>Examples:</p>
+
+ <p>The following CSS selector matches all <code>button</code>
+ elements in an HTML document that are not disabled.</p>
+ <pre>button:not([DISABLED])</pre>
+ <p>The following selector represents all but <code>FOO</code>
+ elements.</p>
+ <pre>*:not(FOO)</pre>
+ <p>The following group of selectors represents all HTML elements
+ except links.</p>
+ <pre>html|*:not(:link):not(:visited)</pre>
+</div>
+
+<p>Default namespace declarations do not affect the argument of the
+ negation pseudo-class unless the argument is a universal selector or a
+ type selector.</p>
+
+<div class="example">
+ <p>Examples:</p>
+
+ <p>Assuming that the default namespace is bound to
+ "http://example.com/", the following selector represents all
+ elements that are not in that namespace:</p>
+ <pre>*|*:not(*)</pre>
+ <p>The following CSS selector matches any element being hovered,
+ regardless of its namespace. In particular, it is not limited to
+ only matching elements in the default namespace that are not being
+ hovered, and elements not in the default namespace don't match the
+ rule when they <em>are</em> being hovered.</p>
+ <pre>*|*:not(:hover)</pre>
+</div>
+
+<p class="note"><strong>Note</strong>: the :not() pseudo allows
+ useless selectors to be written. For instance <code>:not(*|*)</code>,
+ which represents no element at all, or <code>foo:not(bar)</code>,
+ which is equivalent to <code>foo</code> but with a higher
+ specificity.</p>
+
+<h3><a name=pseudo-elements>7. Pseudo-elements</a></h3>
+
+<p>Pseudo-elements create abstractions about the document tree beyond
+ those specified by the document language. For instance, document
+ languages do not offer mechanisms to access the first letter or first
+ line of an element's content. Pseudo-elements allow designers to refer
+ to this otherwise inaccessible information. Pseudo-elements may also
+ provide designers a way to refer to content that does not exist in the
+ source document (e.g., the <code>::before</code> and
+ <code>::after</code> pseudo-elements give access to generated
+ content).</p>
+
+<p>A pseudo-element is made of two colons (<code>::</code>) followed
+ by the name of the pseudo-element.</p>
+
+<p>This <code>::</code> notation is introduced by the current document
+ in order to establish a discrimination between pseudo-classes and
+ pseudo-elements. For compatibility with existing style sheets, user
+ agents must also accept the previous one-colon notation for
+ pseudo-elements introduced in CSS levels 1 and 2 (namely,
+ <code>:first-line</code>, <code>:first-letter</code>,
+ <code>:before</code> and <code>:after</code>). This compatibility is
+ not allowed for the new pseudo-elements introduced in CSS level 3.</p>
+
+<p>Only one pseudo-element may appear per selector, and if present it
+ must appear after the sequence of simple selectors that represents the
+ <a href="#subject">subjects</a> of the selector. <span class="note">A
+future version of this specification may allow multiple
+pesudo-elements per selector.</span></p>
+
+<h4><a name=first-line>7.1. The ::first-line pseudo-element</a></h4>
+
+<p>The <code>::first-line</code> pseudo-element describes the contents
+ of the first formatted line of an element.
+
+<div class="example">
+ <p>CSS example:</p>
+ <pre>p::first-line { text-transform: uppercase }</pre>
+ <p>The above rule means "change the letters of the first line of every
+ paragraph to uppercase".</p>
+</div>
+
+<p>The selector <code>p::first-line</code> does not match any real
+ HTML element. It does match a pseudo-element that conforming user
+ agents will insert at the beginning of every paragraph.</p>
+
+<p>Note that the length of the first line depends on a number of
+ factors, including the width of the page, the font size, etc. Thus,
+ an ordinary HTML paragraph such as:</p>
+
+<pre>
+<P>This is a somewhat long HTML
+paragraph that will be broken into several
+lines. The first line will be identified
+by a fictional tag sequence. The other lines
+will be treated as ordinary lines in the
+paragraph.</P>
+</pre>
+
+<p>the lines of which happen to be broken as follows:
+
+<pre>
+THIS IS A SOMEWHAT LONG HTML PARAGRAPH THAT
+will be broken into several lines. The first
+line will be identified by a fictional tag
+sequence. The other lines will be treated as
+ordinary lines in the paragraph.
+</pre>
+
+<p>This paragraph might be "rewritten" by user agents to include the
+ <em>fictional tag sequence</em> for <code>::first-line</code>. This
+ fictional tag sequence helps to show how properties are inherited.</p>
+
+<pre>
+<P><b><P::first-line></b> This is a somewhat long HTML
+paragraph that <b></P::first-line></b> will be broken into several
+lines. The first line will be identified
+by a fictional tag sequence. The other lines
+will be treated as ordinary lines in the
+paragraph.</P>
+</pre>
+
+<p>If a pseudo-element breaks up a real element, the desired effect
+ can often be described by a fictional tag sequence that closes and
+ then re-opens the element. Thus, if we mark up the previous paragraph
+ with a <code>span</code> element:</p>
+
+<pre>
+<P><b><SPAN class="test"></b> This is a somewhat long HTML
+paragraph that will be broken into several
+lines.<b></SPAN></b> The first line will be identified
+by a fictional tag sequence. The other lines
+will be treated as ordinary lines in the
+paragraph.</P>
+</pre>
+
+<p>the user agent could simulate start and end tags for
+ <code>span</code> when inserting the fictional tag sequence for
+ <code>::first-line</code>.
+
+<pre>
+<P><P::first-line><b><SPAN class="test"></b> This is a
+somewhat long HTML
+paragraph that will <b></SPAN></b></P::first-line><b><SPAN
+ class="test"></b> be
+broken into several
+lines.<b></SPAN></b> The first line will be identified
+by a fictional tag sequence. The other lines
+will be treated as ordinary lines in the
+paragraph.</P>
+</pre>
+
+<p>In CSS, the <code>::first-line</code> pseudo-element can only be
+ attached to a block-level element, an inline-block, a table-caption,
+ or a table-cell.</p>
+
+<p><a name="first-formatted-line"></a>The "first formatted line" of an
+ element may occur inside a
+ block-level descendant in the same flow (i.e., a block-level
+ descendant that is not positioned and not a float). E.g., the first
+ line of the <code>div</code> in <code><DIV><P>This
+ line...</P></DIV></code> is the first line of the <code>p</code>
+ (assuming
+ that both <code>p</code> and <code>div</code> are block-level).
+
+<p>The first line of a table-cell or inline-block cannot be the first
+ formatted line of an ancestor element. Thus, in <code><DIV><P
+ STYLE="display: inline-block">Hello<BR>Goodbye</P>
+ etcetera</DIV></code> the first formatted line of the
+ <code>div</code> is not the line "Hello".
+
+<p class="note">Note that the first line of the <code>p</code> in this
+ fragment: <code><p><br>First...</code> doesn't contain any
+ letters (assuming the default style for <code>br</code> in HTML
+ 4). The word "First" is not on the first formatted line.
+
+<p>A UA should act as if the fictional start tags of the
+ <code>::first-line</code> pseudo-elements were nested just inside the
+ innermost enclosing block-level element. (Since CSS1 and CSS2 were
+ silent on this case, authors should not rely on this behavior.) Here
+ is an example. The fictional tag sequence for</p>
+
+<pre>
+<DIV>
+ <P>First paragraph</P>
+ <P>Second paragraph</P>
+</DIV>
+</pre>
+
+<p>is</p>
+
+<pre>
+<DIV>
+ <P><DIV::first-line><P::first-line>First paragraph</P::first-line></DIV::first-line></P>
+ <P><P::first-line>Second paragraph</P::first-line></P>
+</DIV>
+</pre>
+
+<p>The <code>::first-line</code> pseudo-element is similar to an
+ inline-level element, but with certain restrictions. In CSS, the
+ following properties apply to a <code>::first-line</code>
+ pseudo-element: font properties, color property, background
+ properties, 'word-spacing', 'letter-spacing', 'text-decoration',
+ 'vertical-align', 'text-transform', 'line-height'. UAs may apply other
+ properties as well.</p>
+
+
+<h4><a name=first-letter>7.2. The ::first-letter pseudo-element</a></h4>
+
+<p>The <code>::first-letter</code> pseudo-element represents the first
+ letter of the first line of a block, if it is not preceded by any
+ other content (such as images or inline tables) on its line. The
+ ::first-letter pseudo-element may be used for "initial caps" and "drop
+ caps", which are common typographical effects. This type of initial
+ letter is similar to an inline-level element if its 'float' property
+ is 'none'; otherwise, it is similar to a floated element.</p>
+
+<p>In CSS, these are the properties that apply to <code>::first-letter</code>
+ pseudo-elements: font properties, 'text-decoration', 'text-transform',
+ 'letter-spacing', 'word-spacing' (when appropriate), 'line-height',
+ 'float', 'vertical-align' (only if 'float' is 'none'), margin
+ properties, padding properties, border properties, color property,
+ background properties. UAs may apply other properties as well. To
+ allow UAs to render a typographically correct drop cap or initial cap,
+ the UA may choose a line-height, width and height based on the shape
+ of the letter, unlike for normal elements.</p>
+
+<div class="example">
+ <p>Example:</p>
+
+ <p>This example shows a possible rendering of an initial cap. Note
+ that the 'line-height' that is inherited by the
+ <code>::first-letter</code>
+ pseudo-element is 1.1, but the UA in this example has computed the
+ height of the first letter differently, so that it doesn't cause any
+ unnecessary space between the first two lines. Also note that the
+ fictional start tag of the first letter is inside the <span>span</span>,
+ and thus
+ the font weight of the first letter is normal, not bold as the <span>span</span>:
+<pre>
+p { line-height: 1.1 }
+p::first-letter { font-size: 3em; font-weight: normal }
+span { font-weight: bold }
+...
+<p><span>Het hemelsche</span> gerecht heeft zich ten lange lesten<br>
+Erbarremt over my en mijn benaeuwde vesten<br>
+En arme burgery, en op mijn volcx gebed<br>
+En dagelix geschrey de bange stad ontzet.
+</pre>
+ <div class="figure">
+ <p><img src="initial-cap.png"
+ alt="Image illustrating the ::first-letter pseudo-element">
+ </div>
+</div>
+
+<div class="example">
+ <p>The following CSS will make a drop cap initial letter span about two
+ lines:</p>
+
+<pre>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
+<HTML>
+ <HEAD>
+ <TITLE>Drop cap initial letter</TITLE>
+ <STYLE type="text/css">
+ P { font-size: 12pt; line-height: 1.2 }
+ P::first-letter { font-size: 200%; font-weight: bold; float: left }
+ SPAN { text-transform: uppercase }
+ </STYLE>
+ </HEAD>
+ <BODY>
+ <P><SPAN>The first</SPAN> few words of an article
+ in The Economist.</P>
+ </BODY>
+</HTML>
+</pre>
+
+ <p>This example might be formatted as follows:</p>
+
+ <div class="figure">
+ <P><img src="first-letter.gif"
+ alt="Image illustrating the combined effect of the ::first-letter and ::first-line pseudo-elements">
+ </p>
+ </div>
+
+ <p>The <span class="index-inst" title="fictional tag
+sequence">fictional tag sequence</span> is:</p>
+
+<pre>
+<P>
+<SPAN>
+<P::first-letter>
+T
+</P::first-letter>he first
+</SPAN>
+few words of an article in the Economist.
+</P>
+</pre>
+
+ <p>Note that the <code>::first-letter</code> pseudo-element tags abut
+ the content (i.e., the initial character), while the ::first-line
+ pseudo-element start tag is inserted right after the start tag of the
+ block element.</p></div>
+
+<p>In order to achieve traditional drop caps formatting, user agents
+ may approximate font sizes, for example to align baselines. Also, the
+ glyph outline may be taken into account when formatting.</p>
+
+<p>Punctuation (i.e, characters defined in Unicode in the "open" (Ps),
+ "close" (Pe), "initial" (Pi). "final" (Pf) and "other" (Po)
+ punctuation classes), that precedes or follows the first letter should
+ be included. <a href="#refsUNICODE">[UNICODE]</a></p>
+
+<div class="figure">
+ <P><img src="first-letter2.gif" alt="Quotes that precede the
+first letter should be included."></p>
+</div>
+
+<p>The <code>::first-letter</code> also applies if the first letter is
+ in fact a digit, e.g., the "6" in "67 million dollars is a lot of
+ money."</p>
+
+<p>In CSS, the <code>::first-letter</code> pseudo-element applies to
+ block, list-item, table-cell, table-caption, and inline-block
+ elements. <span class="note">A future version of this specification
+may allow this pesudo-element to apply to more element
+types.</span></p>
+
+<p>The <code>::first-letter</code> pseudo-element can be used with all
+ such elements that contain text, or that have a descendant in the same
+ flow that contains text. A UA should act as if the fictional start tag
+ of the ::first-letter pseudo-element is just before the first text of
+ the element, even if that first text is in a descendant.</p>
+
+<div class="example">
+ <p>Example:</p>
+
+ <p>The fictional tag sequence for this HTMLfragment:
+<pre><div>
+<p>The first text.</pre>
+ <p>is:
+<pre><div>
+<p><div::first-letter><p::first-letter>T</...></...>he first text.</pre>
+</div>
+
+<p>The first letter of a table-cell or inline-block cannot be the
+ first letter of an ancestor element. Thus, in <code><DIV><P
+ STYLE="display: inline-block">Hello<BR>Goodbye</P>
+ etcetera</DIV></code> the first letter of the <code>div</code> is
+ not the
+ letter "H". In fact, the <code>div</code> doesn't have a first letter.
+
+<p>The first letter must occur on the <a
+ href="#first-formatted-line">first formatted line.</a> For example, in
+ this fragment: <code><p><br>First...</code> the first line
+ doesn't contain any letters and <code>::first-letter</code> doesn't
+ match anything (assuming the default style for <code>br</code> in HTML
+ 4). In particular, it does not match the "F" of "First."
+
+<p>In CSS, if an element is a list item ('display: list-item'), the
+ <code>::first-letter</code> applies to the first letter in the
+ principal box after the marker. UAs may ignore
+ <code>::first-letter</code> on list items with 'list-style-position:
+ inside'. If an element has <code>::before</code> or
+ <code>::after</code> content, the <code>::first-letter</code> applies
+ to the first letter of the element <em>including</em> that content.
+
+<div class="example">
+ <p>Example:</p>
+
+ <p>After the rule 'p::before {content: "Note: "}', the selector
+ 'p::first-letter' matches the "N" of "Note".</p>
+</div>
+
+<p>Some languages may have specific rules about how to treat certain
+ letter combinations. In Dutch, for example, if the letter combination
+ "ij" appears at the beginning of a word, both letters should be
+ considered within the <code>::first-letter</code> pseudo-element.
+
+<p>If the letters that would form the ::first-letter are not in the
+ same element, such as "'T" in <code><p>'<em>T...</code>, the UA
+ may create a ::first-letter pseudo-element from one of the elements,
+ both elements, or simply not create a pseudo-element.</p>
+
+<p>Similarly, if the first letter(s) of the block are not at the start
+ of the line (for example due to bidirectional reordering), then the UA
+ need not create the pseudo-element(s).
+
+<div class="example">
+ <p>Example:</p>
+
+ <p><a name="overlapping-example">The following example</a> illustrates
+ how overlapping pseudo-elements may interact. The first letter of
+ each P element will be green with a font size of '24pt'. The rest of
+ the first formatted line will be 'blue' while the rest of the
+ paragraph will be 'red'.</p>
+
+<pre>p { color: red; font-size: 12pt }
+p::first-letter { color: green; font-size: 200% }
+p::first-line { color: blue }
+
+<P>Some text that ends up on two lines</P></pre>
+
+ <p>Assuming that a line break will occur before the word "ends", the
+<span class="index-inst" title="fictional tag sequence">fictional tag
+sequence</span> for this fragment might be:</p>
+
+<pre><P>
+<P::first-line>
+<P::first-letter>
+S
+</P::first-letter>ome text that
+</P::first-line>
+ends up on two lines
+</P></pre>
+
+ <p>Note that the <code>::first-letter</code> element is inside the <code>::first-line</code>
+ element. Properties set on <code>::first-line</code> are inherited by
+ <code>::first-letter</code>, but are overridden if the same property is
+ set on
+ <code>::first-letter</code>.</p>
+</div>
+
+
+<h4><a name=UIfragments>7.3.</a> <a name=selection>The ::selection
+ pseudo-element</a></h4>
+
+<p>The <code>::selection</code> pseudo-element applies to the portion
+ of a document that has been highlighted by the user. This also
+ applies, for example, to selected text within an editable text
+ field. This pseudo-element should not be confused with the <code><a
+ href="#checked">:checked</a></code> pseudo-class (which used to be
+ named <code>:selected</code>)
+
+<p>Although the <code>::selection</code> pseudo-element is dynamic in
+ nature, and is altered by user action, it is reasonable to expect that
+ when a UA re-renders to a static medium (such as a printed page, see
+ <a href="#refsCSS21">[CSS21]</a>) which was originally rendered to a
+ dynamic medium (like screen), the UA may wish to transfer the current
+ <code>::selection</code> state to that other medium, and have all the
+ appropriate formatting and rendering take effect as well. This is not
+ required — UAs may omit the <code>::selection</code>
+ pseudo-element for static media.
+
+<p>These are the CSS properties that apply to <code>::selection</code>
+ pseudo-elements: color, background, cursor (optional), outline
+ (optional). The computed value of the 'background-image' property on
+ <code>::selection</code> may be ignored.
+
+
+<h4><a name=gen-content>7.4. The ::before and ::after pseudo-elements</a></h4>
+
+<p>The <code>::before</code> and <code>::after</code> pseudo-elements
+ can be used to describe generated content before or after an element's
+ content. They are explained in CSS 2.1 <a
+ href="#refsCSS21">[CSS21]</a>.</p>
+
+<p>When the <code>::first-letter</code> and <code>::first-line</code>
+ pseudo-elements are combined with <code>::before</code> and
+ <code>::after</code>, they apply to the first letter or line of the
+ element including the inserted text.</p>
+
+<h2><a name=combinators>8. Combinators</a></h2>
+
+<h3><a name=descendant-combinators>8.1. Descendant combinator</a></h3>
+
+<p>At times, authors may want selectors to describe an element that is
+ the descendant of another element in the document tree (e.g., "an
+ <code>EM</code> element that is contained within an <code>H1</code>
+ element"). Descendant combinators express such a relationship. A
+ descendant combinator is <a href="#whitespace">white space</a> that
+ separates two sequences of simple selectors. A selector of the form
+ "<code>A B</code>" represents an element <code>B</code> that is an
+ arbitrary descendant of some ancestor element <code>A</code>.
+
+<div class="example">
+ <p>Examples:</p>
+
+ <p>For example, consider the following selector:</p>
+ <pre>h1 em</pre>
+ <p>It represents an <code>em</code> element being the descendant of
+ an <code>h1</code> element. It is a correct and valid, but partial,
+ description of the following fragment:</p>
+ <pre><h1>This <span class="myclass">headline
+is <em>very</em> important</span></h1></pre>
+ <p>The following selector:</p>
+ <pre>div * p</pre>
+ <p>represents a <code>p</code> element that is a grandchild or later
+ descendant of a <code>div</code> element. Note the whitespace on
+ either side of the "*" is not part of the universal selector; the
+ whitespace is a combinator indicating that the DIV must be the
+ ancestor of some element, and that that element must be an ancestor
+ of the P.</p>
+
+ <p>The following selector, which combines descendant combinators and
+ <a href="#attribute-selectors">attribute selectors</a>, represents an
+ element that (1) has the <code>href</code> attribute set and (2) is
+ inside a <code>p</code> that is itself inside a <code>div</code>:</p>
+ <pre>div p *[href]</pre>
+</div>
+
+<h3><a name=child-combinators>8.2. Child combinators</a></h3>
+
+<p>A <dfn>child combinator</dfn> describes a childhood relationship
+ between two elements. A child combinator is made of the
+ "greater-than sign" (<code>></code>) character and
+ separates two sequences of simple selectors.
+
+
+<div class="example">
+ <p>Examples:</p>
+
+ <p>The following selector represents a <code>p</code> element that is
+ child of <code>body</code>:</p>
+ <pre>body > p</pre>
+ <p>The following example combines descendant combinators and child
+ combinators.</p>
+ <pre>div ol>li p</pre>
+ <!-- LEAVE THOSE SPACES OUT! see below -->
+ <p>It represents a <code>p</code> element that is a descendant of an
+ <code>li</code> element; the <code>li</code> element must be the
+ child of an <code>ol</code> element; the <code>ol</code> element must
+ be a descendant of a <code>div</code>. Notice that the optional white
+ space around the ">" combinator has been left out.</p>
+</div>
+
+<p>For information on selecting the first child of an element, please
+ see the section on the <code><a
+ href="#structural-pseudos">:first-child</a></code> pseudo-class
+ above.</p>
+
+<h3><a name=sibling-combinators>8.3. Sibling combinators</a></h3>
+
+<p>There are two different sibling combinators: the adjacent sibling
+ combinator and the general sibling combinator. In both cases,
+ non-element nodes (e.g. text between elements) are ignored when
+ considering adjacency of elements.</p>
+
+<h4><a name=adjacent-sibling-combinators>8.3.1. Adjacent sibling combinator</a>
+</h4>
+
+<p>The adjacent sibling combinator is made of the "plus
+ sign" (U+002B, <code>+</code>) character that separates two
+ sequences of simple selectors. The elements represented by the two
+ sequences share the same parent in the document tree and the element
+ represented by the first sequence immediately precedes the element
+ represented by the second one.</p>
+
+<div class="example">
+ <p>Examples:</p>
+
+ <p>The following selector represents a <code>p</code> element
+ immediately following a <code>math</code> element:</p>
+ <pre>math + p</pre>
+ <p>The following selector is conceptually similar to the one in the
+ previous example, except that it adds an attribute selector — it
+ adds a constraint to the <code>h1</code> element, that it must have
+ <code>class="opener"</code>:</p>
+ <pre>h1.opener + h2</pre>
+</div>
+
+
+<h4><a name=general-sibling-combinators>8.3.2. General sibling combinator</a>
+</h4>
+
+<p>The general sibling combinator is made of the "tilde"
+ (U+007E, <code>~</code>) character that separates two sequences of
+ simple selectors. The elements represented by the two sequences share
+ the same parent in the document tree and the element represented by
+ the first sequence precedes (not necessarily immediately) the element
+ represented by the second one.</p>
+
+<div class="example">
+ <p>Example:</p>
+ <pre>h1 ~ pre</pre>
+ <p>represents a <code>pre</code> element following an <code>h1</code>. It
+ is a correct and valid, but partial, description of:</p>
+ <pre><h1>Definition of the function a</h1>
+<p>Function a(x) has to be applied to all figures in the table.</p>
+<pre>function a(x) = 12x/13.5</pre></pre>
+</div>
+
+<h2><a name=specificity>9. Calculating a selector's specificity</a></h2>
+
+<p>A selector's specificity is calculated as follows:</p>
+
+<ul>
+ <li>count the number of ID selectors in the selector (= a)</li>
+ <li>count the number of class selectors, attributes selectors, and
+ pseudo-classes in the selector (= b)
+ </li>
+ <li>count the number of element names in the selector (= c)</li>
+ <li>ignore pseudo-elements</li>
+</ul>
+
+<p>Selectors inside <a href="#negation">the negation pseudo-class</a>
+ are counted like any other, but the negation itself does not count as
+ a pseudo-class.</p>
+
+<p>Concatenating the three numbers a-b-c (in a number system with a
+ large base) gives the specificity.</p>
+
+<div class="example">
+ <p>Examples:</p>
+<pre>* /* a=0 b=0 c=0 -> specificity = 0 */
+LI /* a=0 b=0 c=1 -> specificity = 1 */
+UL LI /* a=0 b=0 c=2 -> specificity = 2 */
+UL OL+LI /* a=0 b=0 c=3 -> specificity = 3 */
+H1 + *[REL=up] /* a=0 b=1 c=1 -> specificity = 11 */
+UL OL LI.red /* a=0 b=1 c=3 -> specificity = 13 */
+LI.red.level /* a=0 b=2 c=1 -> specificity = 21 */
+#x34y /* a=1 b=0 c=0 -> specificity = 100 */
+#s12:not(FOO) /* a=1 b=0 c=1 -> specificity = 101 */
+</pre>
+</div>
+
+<p class="note"><strong>Note:</strong> the specificity of the styles
+ specified in an HTML <code>style</code> attribute is described in CSS
+ 2.1. <a href="#refsCSS21">[CSS21]</a>.</p>
+
+<h2><a name=w3cselgrammar>10. The grammar of Selectors</a></h2>
+
+<h3><a name=grammar>10.1. Grammar</a></h3>
+
+<p>The grammar below defines the syntax of Selectors. It is globally
+ LL(1) and can be locally LL(2) (but note that most UA's should not use
+ it directly, since it doesn't express the parsing conventions). The
+ format of the productions is optimized for human consumption and some
+ shorthand notations beyond Yacc (see <a href="#refsYACC">[YACC]</a>)
+ are used:</p>
+
+<ul>
+ <li><b>*</b>: 0 or more
+ <li><b>+</b>: 1 or more
+ <li><b>?</b>: 0 or 1
+ <li><b>|</b>: separates alternatives
+ <li><b>[ ]</b>: grouping</li>
+</ul>
+
+<p>The productions are:</p>
+
+<pre>selectors_group
+ : selector [ COMMA S* selector ]*
+ ;
+
+selector
+ : simple_selector_sequence [ combinator simple_selector_sequence ]*
+ ;
+
+combinator
+ /* combinators can be surrounded by white space */
+ : PLUS S* | GREATER S* | TILDE S* | S+
+ ;
+
+simple_selector_sequence
+ : [ type_selector | universal ]
+ [ HASH | class | attrib | pseudo | negation ]*
+ | [ HASH | class | attrib | pseudo | negation ]+
+ ;
+
+type_selector
+ : [ namespace_prefix ]? element_name
+ ;
+
+namespace_prefix
+ : [ IDENT | '*' ]? '|'
+ ;
+
+element_name
+ : IDENT
+ ;
+
+universal
+ : [ namespace_prefix ]? '*'
+ ;
+
+class
+ : '.' IDENT
+ ;
+
+attrib
+ : '[' S* [ namespace_prefix ]? IDENT S*
+ [ [ PREFIXMATCH |
+ SUFFIXMATCH |
+ SUBSTRINGMATCH |
+ '=' |
+ INCLUDES |
+ DASHMATCH ] S* [ IDENT | STRING ] S*
+ ]? ']'
+ ;
+
+pseudo
+ /* '::' starts a pseudo-element, ':' a pseudo-class */
+ /* Exceptions: :first-line, :first-letter, :before and :after. */
+ /* Note that pseudo-elements are restricted to one per selector and */
+ /* occur only in the last simple_selector_sequence. */
+ : ':' ':'? [ IDENT | functional_pseudo ]
+ ;
+
+functional_pseudo
+ : FUNCTION S* expression ')'
+ ;
+
+expression
+ /* In CSS3, the expressions are identifiers, strings, */
+ /* or of the form "an+b" */
+ : [ [ PLUS | '-' | DIMENSION | NUMBER | STRING | IDENT ] S* ]+
+ ;
+
+negation
+ : NOT S* negation_arg S* ')'
+ ;
+
+negation_arg
+ : type_selector | universal | HASH | class | attrib | pseudo
+ ;</pre>
+
+
+<h3><a name=lex>10.2. Lexical scanner</a></h3>
+
+<p>The following is the <a name=x3>tokenizer</a>, written in Flex (see
+ <a href="#refsFLEX">[FLEX]</a>) notation. The tokenizer is
+ case-insensitive.</p>
+
+<p>The two occurrences of "\377" represent the highest character
+ number that current versions of Flex can deal with (decimal 255). They
+ should be read as "\4177777" (decimal 1114111), which is the highest
+ possible code point in Unicode/ISO-10646. <a
+ href="#refsUNICODE">[UNICODE]</a></p>
+
+<pre>%option case-insensitive
+
+ident [-]?{nmstart}{nmchar}*
+name {nmchar}+
+nmstart [_a-z]|{nonascii}|{escape}
+nonascii [^\0-\177]
+unicode \\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?
+escape {unicode}|\\[^\n\r\f0-9a-f]
+nmchar [_a-z0-9-]|{nonascii}|{escape}
+num [0-9]+|[0-9]*\.[0-9]+
+string {string1}|{string2}
+string1 \"([^\n\r\f\\"]|\\{nl}|{nonascii}|{escape})*\"
+string2 \'([^\n\r\f\\']|\\{nl}|{nonascii}|{escape})*\'
+invalid {invalid1}|{invalid2}
+invalid1 \"([^\n\r\f\\"]|\\{nl}|{nonascii}|{escape})*
+invalid2 \'([^\n\r\f\\']|\\{nl}|{nonascii}|{escape})*
+nl \n|\r\n|\r|\f
+w [ \t\r\n\f]*
+
+%%
+
+[ \t\r\n\f]+ return S;
+
+"~=" return INCLUDES;
+"|=" return DASHMATCH;
+"^=" return PREFIXMATCH;
+"$=" return SUFFIXMATCH;
+"*=" return SUBSTRINGMATCH;
+{ident} return IDENT;
+{string} return STRING;
+{ident}"(" return FUNCTION;
+{num} return NUMBER;
+"#"{name} return HASH;
+{w}"+" return PLUS;
+{w}">" return GREATER;
+{w}"," return COMMA;
+{w}"~" return TILDE;
+":not(" return NOT;
+@{ident} return ATKEYWORD;
+{invalid} return INVALID;
+{num}% return PERCENTAGE;
+{num}{ident} return DIMENSION;
+"<!--" return CDO;
+"-->" return CDC;
+
+"url("{w}{string}{w}")" return URI;
+"url("{w}([!#$%&*-~]|{nonascii}|{escape})*{w}")" return URI;
+U\+[0-9a-f?]{1,6}(-[0-9a-f]{1,6})? return UNICODE_RANGE;
+
+\/\*[^*]*\*+([^/*][^*]*\*+)*\/ /* ignore comments */
+
+. return *yytext;</pre>
+
+
+<h2><a name=downlevel>11. Namespaces and down-level clients</a></h2>
+
+<p>An important issue is the interaction of CSS selectors with XML
+ documents in web clients that were produced prior to this
+ document. Unfortunately, due to the fact that namespaces must be
+ matched based on the URI which identifies the namespace, not the
+ namespace prefix, some mechanism is required to identify namespaces in
+ CSS by their URI as well. Without such a mechanism, it is impossible
+ to construct a CSS style sheet which will properly match selectors in
+ all cases against a random set of XML documents. However, given
+ complete knowledge of the XML document to which a style sheet is to be
+ applied, and a limited use of namespaces within the XML document, it
+ is possible to construct a style sheet in which selectors would match
+ elements and attributes correctly.</p>
+
+<p>It should be noted that a down-level CSS client will (if it
+ properly conforms to CSS forward compatible parsing rules) ignore all
+ <code>@namespace</code> at-rules, as well as all style rules that make
+ use of namespace qualified element type or attribute selectors. The
+ syntax of delimiting namespace prefixes in CSS was deliberately chosen
+ so that down-level CSS clients would ignore the style rules rather
+ than possibly match them incorrectly.</p>
+
+<p>The use of default namespaces in CSS makes it possible to write
+ element type selectors that will function in both namespace aware CSS
+ clients as well as down-level clients. It should be noted that
+ down-level clients may incorrectly match selectors against XML
+ elements in other namespaces.</p>
+
+<p>The following are scenarios and examples in which it is possible to
+ construct style sheets which would function properly in web clients
+ that do not implement this proposal.</p>
+
+<ol>
+ <li>
+
+ <p>The XML document does not use namespaces.</p>
+
+ <ul>
+
+ <li>In this case, it is obviously not necessary to declare or use
+ namespaces in the style sheet. Standard CSS element type and
+ attribute selectors will function adequately in a down-level
+ client.
+ </li>
+
+ <li>In a CSS namespace aware client, the default behavior of
+ element selectors matching without regard to namespace will
+ function properly against all elements, since no namespaces are
+ present. However, the use of specific element type selectors
+ that
+ match only elements that have no namespace ("<code>|name</code>")
+ will guarantee that selectors will match only XML elements that
+ do
+ not have a declared namespace.
+ </li>
+
+ </ul>
+
+ </li>
+
+ <li>
+
+ <p>The XML document defines a single, default namespace used
+ throughout the document. No namespace prefixes are used in element
+ names.</p>
+
+ <ul>
+
+ <li>In this case, a down-level client will function as if
+ namespaces were not used in the XML document at all. Standard
+ CSS
+ element type and attribute selectors will match against all
+ elements.
+ </li>
+
+ </ul>
+
+ </li>
+
+ <li>
+
+ <p>The XML document does <b>not</b> use a default namespace, all
+ namespace prefixes used are known to the style sheet author, and
+ there is a direct mapping between namespace prefixes and namespace
+ URIs. (A given prefix may only be mapped to one namespace URI
+ throughout the XML document; there may be multiple prefixes mapped
+ to the same URI).</p>
+
+ <ul>
+
+ <li>In this case, the down-level client will view and match
+ element type and attribute selectors based on their fully
+ qualified name, not the local part as outlined in the <a
+ href="#typenmsp">Type selectors and Namespaces</a>
+ section. CSS
+ selectors may be declared using an escaped colon
+ "<code>\:</code>"
+ to describe the fully qualified names, e.g.
+ "<code>html\:h1</code>" will match
+ <code><html:h1></code>. Selectors using the qualified name
+ will only match XML elements that use the same prefix. Other
+ namespace prefixes used in the XML that are mapped to the same
+ URI
+ will not match as expected unless additional CSS style rules are
+ declared for them.
+ </li>
+
+ <li>Note that selectors declared in this fashion will
+ <em>only</em> match in down-level clients. A CSS namespace aware
+ client will match element type and attribute selectors based on
+ the name's local part. Selectors declared with the fully
+ qualified name will not match (unless there is no namespace
+ prefix
+ in the fully qualified name).
+ </li>
+
+ </ul>
+
+ </li>
+
+</ol>
+
+<p>In other scenarios: when the namespace prefixes used in the XML are
+ not known in advance by the style sheet author; or a combination of
+ elements with no namespace are used in conjunction with elements using
+ a default namespace; or the same namespace prefix is mapped to
+ <em>different</em> namespace URIs within the same document, or in
+ different documents; it is impossible to construct a CSS style sheet
+ that will function properly against all elements in those documents,
+ unless, the style sheet is written using a namespace URI syntax (as
+ outlined in this document or similar) and the document is processed by
+ a CSS and XML namespace aware client.</p>
+
+<h2><a name=profiling>12. Profiles</a></h2>
+
+<p>Each specification using Selectors must define the subset of W3C
+ Selectors it allows and excludes, and describe the local meaning of
+ all the components of that subset.</p>
+
+<p>Non normative examples:
+
+<div class="profile">
+ <table class="tprofile">
+ <tbody>
+ <tr>
+ <th class="title" colspan=2>Selectors profile</th>
+ </tr>
+ <tr>
+ <th>Specification</th>
+ <td>CSS level 1</td>
+ </tr>
+ <tr>
+ <th>Accepts</th>
+ <td>type selectors<br>class selectors<br>ID selectors<br>:link,
+ :visited and :active pseudo-classes<br>descendant combinator
+ <br>::first-line and ::first-letter pseudo-elements
+ </td>
+ </tr>
+ <tr>
+ <th>Excludes</th>
+ <td>
+
+ <p>universal selector<br>attribute selectors<br>:hover and
+ :focus
+ pseudo-classes<br>:target pseudo-class<br>:lang()
+ pseudo-class<br>all UI
+ element states pseudo-classes<br>all structural
+ pseudo-classes<br>negation pseudo-class<br>all
+ UI element fragments pseudo-elements<br>::before and ::after
+ pseudo-elements<br>child combinators<br>sibling combinators
+
+ <p>namespaces</td>
+ </tr>
+ <tr>
+ <th>Extra constraints</th>
+ <td>only one class selector allowed per sequence of simple
+ selectors
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ <br><br>
+ <table class="tprofile">
+ <tbody>
+ <tr>
+ <th class="title" colspan=2>Selectors profile</th>
+ </tr>
+ <tr>
+ <th>Specification</th>
+ <td>CSS level 2</td>
+ </tr>
+ <tr>
+ <th>Accepts</th>
+ <td>type selectors<br>universal selector<br>attribute presence and
+ values selectors<br>class selectors<br>ID selectors<br>:link,
+ :visited,
+ :active, :hover, :focus, :lang() and :first-child pseudo-classes
+ <br>descendant combinator<br>child combinator<br>adjacent
+ sibling
+ combinator<br>::first-line and ::first-letter
+ pseudo-elements<br>::before
+ and ::after pseudo-elements
+ </td>
+ </tr>
+ <tr>
+ <th>Excludes</th>
+ <td>
+
+ <p>content selectors<br>substring matching attribute
+ selectors<br>:target pseudo-classes<br>all UI element
+ states pseudo-classes<br>all structural pseudo-classes other
+ than :first-child<br>negation pseudo-class<br>all UI element
+ fragments pseudo-elements<br>general sibling combinators
+
+ <p>namespaces</td>
+ </tr>
+ <tr>
+ <th>Extra constraints</th>
+ <td>more than one class selector per sequence of simple selectors
+ (CSS1
+ constraint) allowed
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+ <p>In CSS, selectors express pattern matching rules that determine which
+ style
+ rules apply to elements in the document tree.
+
+ <p>The following selector (CSS level 2) will <b>match</b> all anchors <code>a</code>
+ with attribute <code>name</code> set inside a section 1 header
+ <code>h1</code>:
+ <pre>h1 a[name]</pre>
+
+ <p>All CSS declarations attached to such a selector are applied to elements
+ matching it.</div>
+
+<div class="profile">
+ <table class="tprofile">
+ <tbody>
+ <tr>
+ <th class="title" colspan=2>Selectors profile</th>
+ </tr>
+ <tr>
+ <th>Specification</th>
+ <td>STTS 3</td>
+ </tr>
+ <tr>
+ <th>Accepts</th>
+ <td>
+
+ <p>type selectors<br>universal selectors<br>attribute
+ selectors<br>class
+ selectors<br>ID selectors<br>all structural
+ pseudo-classes<br>
+ all combinators
+
+ <p>namespaces</td>
+ </tr>
+ <tr>
+ <th>Excludes</th>
+ <td>non-accepted pseudo-classes<br>pseudo-elements<br></td>
+ </tr>
+ <tr>
+ <th>Extra constraints</th>
+ <td>some selectors and combinators are not allowed in fragment
+ descriptions on the right side of STTS declarations.
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+ <p>Selectors can be used in STTS 3 in two different
+ manners:
+ <ol>
+ <li>a selection mechanism equivalent to CSS selection mechanism:
+ declarations
+ attached to a given selector are applied to elements matching that
+ selector,
+ <li>fragment descriptions that appear on the right side of declarations.
+ </li>
+ </ol>
+</div>
+
+<h2><a name=Conformance></a>13. Conformance and requirements</h2>
+
+<p>This section defines conformance with the present specification only.
+
+<p>The inability of a user agent to implement part of this specification due to
+ the limitations of a particular device (e.g., non interactive user agents
+ will
+ probably not implement dynamic pseudo-classes because they make no sense
+ without
+ interactivity) does not imply non-conformance.
+
+<p>All specifications reusing Selectors must contain a <a
+ href="#profiling">Profile</a> listing the
+ subset of Selectors it accepts or excludes, and describing the constraints
+ it adds to the current specification.
+
+<p>Invalidity is caused by a parsing error, e.g. an unrecognized token or a
+ token
+ which is not allowed at the current parsing point.
+
+<p>User agents must observe the rules for handling parsing errors:
+<ul>
+ <li>a simple selector containing an undeclared namespace prefix is invalid
+ </li>
+ <li>a selector containing an invalid simple selector, an invalid combinator
+ or an invalid token is invalid.
+ </li>
+ <li>a group of selectors containing an invalid selector is invalid.</li>
+</ul>
+
+<p>Specifications reusing Selectors must define how to handle parsing
+ errors. (In the case of CSS, the entire rule in which the selector is
+ used is dropped.)</p>
+
+<!-- Apparently all these references are out of date:
+<p>Implementations of this specification must behave as
+"recipients of text data" as defined by <a href="#refsCWWW">[CWWW]</a>
+when parsing selectors and attempting matches. (In particular,
+implementations must assume the data is normalized and must not
+normalize it.) Normative rules for matching strings are defined in
+<a href="#refsCWWW">[CWWW]</a> and <a
+href="#refsUNICODE">[UNICODE]</a> and apply to implementations of this
+specification.</p>-->
+
+<h2><a name=Tests></a>14. Tests</h2>
+
+<p>This specification has <a
+ href="http://www.w3.org/Style/CSS/Test/CSS3/Selectors/current/">a test
+ suite</a> allowing user agents to verify their basic conformance to
+ the specification. This test suite does not pretend to be exhaustive
+ and does not cover all possible combined cases of Selectors.</p>
+
+<h2><a name=ACKS></a>15. Acknowledgements</h2>
+
+<p>The CSS working group would like to thank everyone who has sent
+ comments on this specification over the years.</p>
+
+<p>The working group would like to extend special thanks to Donna
+ McManus, Justin Baker, Joel Sklar, and Molly Ives Brower who perfermed
+ the final editorial review.</p>
+
+<h2><a name=references>16. References</a></h2>
+
+<dl class="refs">
+
+ <dt>[CSS1]
+ <dd><a name=refsCSS1></a> Bert Bos, Håkon Wium Lie; "<cite>Cascading
+ Style Sheets, level 1</cite>", W3C Recommendation, 17 Dec 1996, revised
+ 11 Jan 1999
+ <dd>(<code><a href="http://www.w3.org/TR/REC-CSS1">http://www.w3.org/TR/REC-CSS1</a></code>)
+
+ <dt>[CSS21]
+ <dd><a name=refsCSS21></a> Bert Bos, Tantek Çelik, Ian Hickson, Håkon
+ Wium Lie, editors; "<cite>Cascading Style Sheets, level 2 revision
+ 1</cite>", W3C Working Draft, 13 June 2005
+ <dd>(<code><a
+ href="http://www.w3.org/TR/CSS21">http://www.w3.org/TR/CSS21</a></code>)
+
+ <dt>[CWWW]
+ <dd><a name=refsCWWW></a> Martin J. Dürst, François Yergeau,
+ Misha Wolf, Asmus Freytag, Tex Texin, editors; "<cite>Character Model
+ for the World Wide Web</cite>", W3C Recommendation, 15 February 2005
+ <dd>(<code><a href="http://www.w3.org/TR/charmod/">http://www.w3.org/TR/charmod/</a></code>)
+
+ <dt>[FLEX]
+ <dd><a name="refsFLEX"></a> "<cite>Flex: The Lexical Scanner
+ Generator</cite>", Version 2.3.7, ISBN 1882114213
+
+ <dt>[HTML4]
+ <dd><a name="refsHTML4"></a> Dave Ragget, Arnaud Le Hors, Ian Jacobs,
+ editors; "<cite>HTML 4.01 Specification</cite>", W3C Recommendation, 24
+ December 1999
+ <dd>
+ (<a href="http://www.w3.org/TR/html4/"><code>http://www.w3.org/TR/html4/</code></a>)
+
+ <dt>[MATH]
+ <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
+ <dd>(<code><a href="http://www.w3.org/TR/REC-MathML/">http://www.w3.org/TR/REC-MathML/</a></code>)
+
+ <dt>[RFC3066]
+ <dd><a name="refsRFC3066"></a> H. Alvestrand; "<cite>Tags for the
+ Identification of Languages</cite>", Request for Comments 3066, January
+ 2001
+ <dd>(<a href="http://www.ietf.org/rfc/rfc3066.txt"><code>http://www.ietf.org/rfc/rfc3066.txt</code></a>)
+
+ <dt>[STTS]
+ <dd><a name=refsSTTS></a> Daniel Glazman; "<cite>Simple Tree Transformation
+ Sheets 3</cite>", Electricité de France, submission to the W3C,
+ 11 November 1998
+ <dd>(<code><a href="http://www.w3.org/TR/NOTE-STTS3">http://www.w3.org/TR/NOTE-STTS3</a></code>)
+
+ <dt>[SVG]
+ <dd><a name="refsSVG"></a> Jon Ferraiolo, 藤沢 淳, Dean
+ Jackson, editors; "<cite>Scalable Vector Graphics (SVG) 1.1
+ Specification</cite>", W3C Recommendation, 14 January 2003
+ <dd>(<code><a href="http://www.w3.org/TR/SVG/">http://www.w3.org/TR/SVG/</a></code>)
+
+ <dt>[UNICODE]</dt>
+ <dd><a name="refsUNICODE"></a> <cite><a
+ 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>.
+ <dd>(<code><a href="http://www.unicode.org/versions/">http://www.unicode.org/versions/</a></code>)
+ </dd>
+
+ <dt>[XML10]
+ <dd><a name="refsXML10"></a> Tim Bray, Jean Paoli, C. M. Sperberg-McQueen,
+ Eve Maler, François Yergeau, editors; "<cite>Extensible Markup
+ Language (XML) 1.0 (Third Edition)</cite>", W3C Recommendation, 4
+ February 2004
+ <dd>(<a href="http://www.w3.org/TR/REC-xml/"><code>http://www.w3.org/TR/REC-xml/</code></a>)
+
+ <dt>[XMLNAMES]
+ <dd><a name="refsXMLNAMES"></a> Tim Bray, Dave Hollander, Andrew Layman,
+ editors; "<cite>Namespaces in XML</cite>", W3C Recommendation, 14
+ January 1999
+ <dd>(<a href="http://www.w3.org/TR/REC-xml-names/"><code>http://www.w3.org/TR/REC-xml-names/</code></a>)
+
+ <dt>[YACC]
+ <dd><a name="refsYACC"></a> S. C. Johnson; "<cite>YACC — Yet another
+ compiler compiler</cite>", Technical Report, Murray Hill, 1975
+
+</dl>
+</div>
+</body>
+</html>
diff --git a/samples/src/main/java/gwtquery/samples/public/prototype-1.6.0.3.js b/samples/src/main/java/gwtquery/samples/public/prototype-1.6.0.3.js new file mode 100644 index 00000000..dfe8ab4e --- /dev/null +++ b/samples/src/main/java/gwtquery/samples/public/prototype-1.6.0.3.js @@ -0,0 +1,4320 @@ +/* Prototype JavaScript framework, version 1.6.0.3 + * (c) 2005-2008 Sam Stephenson + * + * Prototype is freely distributable under the terms of an MIT-style license. + * For details, see the Prototype web site: http://www.prototypejs.org/ + * + *--------------------------------------------------------------------------*/ + +var Prototype = { + Version: '1.6.0.3', + + Browser: { + IE: !!(window.attachEvent && + navigator.userAgent.indexOf('Opera') === -1), + Opera: navigator.userAgent.indexOf('Opera') > -1, + WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1, + Gecko: navigator.userAgent.indexOf('Gecko') > -1 && + navigator.userAgent.indexOf('KHTML') === -1, + MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/) + }, + + BrowserFeatures: { + XPath: !!document.evaluate, + SelectorsAPI: !!document.querySelector, + ElementExtensions: !!window.HTMLElement, + SpecificElementExtensions: + document.createElement('div')['__proto__'] && + document.createElement('div')['__proto__'] !== + document.createElement('form')['__proto__'] + }, + + ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>', + JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/, + + emptyFunction: function() { }, + K: function(x) { return x } +}; + +if (Prototype.Browser.MobileSafari) + Prototype.BrowserFeatures.SpecificElementExtensions = false; + + +/* Based on Alex Arnell's inheritance implementation. */ +var Class = { + create: function() { + var parent = null, properties = $A(arguments); + if (Object.isFunction(properties[0])) + parent = properties.shift(); + + function klass() { + this.initialize.apply(this, arguments); + } + + Object.extend(klass, Class.Methods); + klass.superclass = parent; + klass.subclasses = []; + + if (parent) { + var subclass = function() { }; + subclass.prototype = parent.prototype; + klass.prototype = new subclass; + parent.subclasses.push(klass); + } + + for (var i = 0; i < properties.length; i++) + klass.addMethods(properties[i]); + + if (!klass.prototype.initialize) + klass.prototype.initialize = Prototype.emptyFunction; + + klass.prototype.constructor = klass; + + return klass; + } +}; + +Class.Methods = { + addMethods: function(source) { + var ancestor = this.superclass && this.superclass.prototype; + var properties = Object.keys(source); + + if (!Object.keys({ toString: true }).length) + properties.push("toString", "valueOf"); + + for (var i = 0, length = properties.length; i < length; i++) { + var property = properties[i], value = source[property]; + if (ancestor && Object.isFunction(value) && + value.argumentNames().first() == "$super") { + var method = value; + value = (function(m) { + return function() { return ancestor[m].apply(this, arguments) }; + })(property).wrap(method); + + value.valueOf = method.valueOf.bind(method); + value.toString = method.toString.bind(method); + } + this.prototype[property] = value; + } + + return this; + } +}; + +var Abstract = { }; + +Object.extend = function(destination, source) { + for (var property in source) + destination[property] = source[property]; + return destination; +}; + +Object.extend(Object, { + inspect: function(object) { + try { + if (Object.isUndefined(object)) return 'undefined'; + if (object === null) return 'null'; + return object.inspect ? object.inspect() : String(object); + } catch (e) { + if (e instanceof RangeError) return '...'; + throw e; + } + }, + + toJSON: function(object) { + var type = typeof object; + switch (type) { + case 'undefined': + case 'function': + case 'unknown': return; + case 'boolean': return object.toString(); + } + + if (object === null) return 'null'; + if (object.toJSON) return object.toJSON(); + if (Object.isElement(object)) return; + + var results = []; + for (var property in object) { + var value = Object.toJSON(object[property]); + if (!Object.isUndefined(value)) + results.push(property.toJSON() + ': ' + value); + } + + return '{' + results.join(', ') + '}'; + }, + + toQueryString: function(object) { + return $H(object).toQueryString(); + }, + + toHTML: function(object) { + return object && object.toHTML ? object.toHTML() : String.interpret(object); + }, + + keys: function(object) { + var keys = []; + for (var property in object) + keys.push(property); + return keys; + }, + + values: function(object) { + var values = []; + for (var property in object) + values.push(object[property]); + return values; + }, + + clone: function(object) { + return Object.extend({ }, object); + }, + + isElement: function(object) { + return !!(object && object.nodeType == 1); + }, + + isArray: function(object) { + return object != null && typeof object == "object" && + 'splice' in object && 'join' in object; + }, + + isHash: function(object) { + return object instanceof Hash; + }, + + isFunction: function(object) { + return typeof object == "function"; + }, + + isString: function(object) { + return typeof object == "string"; + }, + + isNumber: function(object) { + return typeof object == "number"; + }, + + isUndefined: function(object) { + return typeof object == "undefined"; + } +}); + +Object.extend(Function.prototype, { + argumentNames: function() { + var names = this.toString().match(/^[\s\(]*function[^(]*\(([^\)]*)\)/)[1] + .replace(/\s+/g, '').split(','); + return names.length == 1 && !names[0] ? [] : names; + }, + + bind: function() { + if (arguments.length < 2 && Object.isUndefined(arguments[0])) return this; + var __method = this, args = $A(arguments), object = args.shift(); + return function() { + return __method.apply(object, args.concat($A(arguments))); + } + }, + + bindAsEventListener: function() { + var __method = this, args = $A(arguments), object = args.shift(); + return function(event) { + return __method.apply(object, [event || window.event].concat(args)); + } + }, + + curry: function() { + if (!arguments.length) return this; + var __method = this, args = $A(arguments); + return function() { + return __method.apply(this, args.concat($A(arguments))); + } + }, + + delay: function() { + var __method = this, args = $A(arguments), timeout = args.shift() * 1000; + return window.setTimeout(function() { + return __method.apply(__method, args); + }, timeout); + }, + + defer: function() { + var args = [0.01].concat($A(arguments)); + return this.delay.apply(this, args); + }, + + wrap: function(wrapper) { + var __method = this; + return function() { + return wrapper.apply(this, [__method.bind(this)].concat($A(arguments))); + } + }, + + methodize: function() { + if (this._methodized) return this._methodized; + var __method = this; + return this._methodized = function() { + return __method.apply(null, [this].concat($A(arguments))); + }; + } +}); + +Date.prototype.toJSON = function() { + return '"' + this.getUTCFullYear() + '-' + + (this.getUTCMonth() + 1).toPaddedString(2) + '-' + + this.getUTCDate().toPaddedString(2) + 'T' + + this.getUTCHours().toPaddedString(2) + ':' + + this.getUTCMinutes().toPaddedString(2) + ':' + + this.getUTCSeconds().toPaddedString(2) + 'Z"'; +}; + +var Try = { + these: function() { + var returnValue; + + for (var i = 0, length = arguments.length; i < length; i++) { + var lambda = arguments[i]; + try { + returnValue = lambda(); + break; + } catch (e) { } + } + + return returnValue; + } +}; + +RegExp.prototype.match = RegExp.prototype.test; + +RegExp.escape = function(str) { + return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1'); +}; + +/*--------------------------------------------------------------------------*/ + +var PeriodicalExecuter = Class.create({ + initialize: function(callback, frequency) { + this.callback = callback; + this.frequency = frequency; + this.currentlyExecuting = false; + + this.registerCallback(); + }, + + registerCallback: function() { + this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); + }, + + execute: function() { + this.callback(this); + }, + + stop: function() { + if (!this.timer) return; + clearInterval(this.timer); + this.timer = null; + }, + + onTimerEvent: function() { + if (!this.currentlyExecuting) { + try { + this.currentlyExecuting = true; + this.execute(); + } finally { + this.currentlyExecuting = false; + } + } + } +}); +Object.extend(String, { + interpret: function(value) { + return value == null ? '' : String(value); + }, + specialChar: { + '\b': '\\b', + '\t': '\\t', + '\n': '\\n', + '\f': '\\f', + '\r': '\\r', + '\\': '\\\\' + } +}); + +Object.extend(String.prototype, { + gsub: function(pattern, replacement) { + var result = '', source = this, match; + replacement = arguments.callee.prepareReplacement(replacement); + + while (source.length > 0) { + if (match = source.match(pattern)) { + result += source.slice(0, match.index); + result += String.interpret(replacement(match)); + source = source.slice(match.index + match[0].length); + } else { + result += source, source = ''; + } + } + return result; + }, + + sub: function(pattern, replacement, count) { + replacement = this.gsub.prepareReplacement(replacement); + count = Object.isUndefined(count) ? 1 : count; + + return this.gsub(pattern, function(match) { + if (--count < 0) return match[0]; + return replacement(match); + }); + }, + + scan: function(pattern, iterator) { + this.gsub(pattern, iterator); + return String(this); + }, + + truncate: function(length, truncation) { + length = length || 30; + truncation = Object.isUndefined(truncation) ? '...' : truncation; + return this.length > length ? + this.slice(0, length - truncation.length) + truncation : String(this); + }, + + strip: function() { + return this.replace(/^\s+/, '').replace(/\s+$/, ''); + }, + + stripTags: function() { + return this.replace(/<\/?[^>]+>/gi, ''); + }, + + stripScripts: function() { + return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), ''); + }, + + extractScripts: function() { + var matchAll = new RegExp(Prototype.ScriptFragment, 'img'); + var matchOne = new RegExp(Prototype.ScriptFragment, 'im'); + return (this.match(matchAll) || []).map(function(scriptTag) { + return (scriptTag.match(matchOne) || ['', ''])[1]; + }); + }, + + evalScripts: function() { + return this.extractScripts().map(function(script) { return eval(script) }); + }, + + escapeHTML: function() { + var self = arguments.callee; + self.text.data = this; + return self.div.innerHTML; + }, + + unescapeHTML: function() { + var div = new Element('div'); + div.innerHTML = this.stripTags(); + return div.childNodes[0] ? (div.childNodes.length > 1 ? + $A(div.childNodes).inject('', function(memo, node) { return memo+node.nodeValue }) : + div.childNodes[0].nodeValue) : ''; + }, + + toQueryParams: function(separator) { + var match = this.strip().match(/([^?#]*)(#.*)?$/); + if (!match) return { }; + + return match[1].split(separator || '&').inject({ }, function(hash, pair) { + if ((pair = pair.split('='))[0]) { + var key = decodeURIComponent(pair.shift()); + var value = pair.length > 1 ? pair.join('=') : pair[0]; + if (value != undefined) value = decodeURIComponent(value); + + if (key in hash) { + if (!Object.isArray(hash[key])) hash[key] = [hash[key]]; + hash[key].push(value); + } + else hash[key] = value; + } + return hash; + }); + }, + + toArray: function() { + return this.split(''); + }, + + succ: function() { + return this.slice(0, this.length - 1) + + String.fromCharCode(this.charCodeAt(this.length - 1) + 1); + }, + + times: function(count) { + return count < 1 ? '' : new Array(count + 1).join(this); + }, + + camelize: function() { + var parts = this.split('-'), len = parts.length; + if (len == 1) return parts[0]; + + var camelized = this.charAt(0) == '-' + ? parts[0].charAt(0).toUpperCase() + parts[0].substring(1) + : parts[0]; + + for (var i = 1; i < len; i++) + camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1); + + return camelized; + }, + + capitalize: function() { + return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase(); + }, + + underscore: function() { + return this.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'#{1}_#{2}').gsub(/([a-z\d])([A-Z])/,'#{1}_#{2}').gsub(/-/,'_').toLowerCase(); + }, + + dasherize: function() { + return this.gsub(/_/,'-'); + }, + + inspect: function(useDoubleQuotes) { + var escapedString = this.gsub(/[\x00-\x1f\\]/, function(match) { + var character = String.specialChar[match[0]]; + return character ? character : '\\u00' + match[0].charCodeAt().toPaddedString(2, 16); + }); + if (useDoubleQuotes) return '"' + escapedString.replace(/"/g, '\\"') + '"'; + return "'" + escapedString.replace(/'/g, '\\\'') + "'"; + }, + + toJSON: function() { + return this.inspect(true); + }, + + unfilterJSON: function(filter) { + return this.sub(filter || Prototype.JSONFilter, '#{1}'); + }, + + isJSON: function() { + var str = this; + if (str.blank()) return false; + str = this.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, ''); + return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str); + }, + + evalJSON: function(sanitize) { + var json = this.unfilterJSON(); + try { + if (!sanitize || json.isJSON()) return eval('(' + json + ')'); + } catch (e) { } + throw new SyntaxError('Badly formed JSON string: ' + this.inspect()); + }, + + include: function(pattern) { + return this.indexOf(pattern) > -1; + }, + + startsWith: function(pattern) { + return this.indexOf(pattern) === 0; + }, + + endsWith: function(pattern) { + var d = this.length - pattern.length; + return d >= 0 && this.lastIndexOf(pattern) === d; + }, + + empty: function() { + return this == ''; + }, + + blank: function() { + return /^\s*$/.test(this); + }, + + interpolate: function(object, pattern) { + return new Template(this, pattern).evaluate(object); + } +}); + +if (Prototype.Browser.WebKit || Prototype.Browser.IE) Object.extend(String.prototype, { + escapeHTML: function() { + return this.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); + }, + unescapeHTML: function() { + return this.stripTags().replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); + } +}); + +String.prototype.gsub.prepareReplacement = function(replacement) { + if (Object.isFunction(replacement)) return replacement; + var template = new Template(replacement); + return function(match) { return template.evaluate(match) }; +}; + +String.prototype.parseQuery = String.prototype.toQueryParams; + +Object.extend(String.prototype.escapeHTML, { + div: document.createElement('div'), + text: document.createTextNode('') +}); + +String.prototype.escapeHTML.div.appendChild(String.prototype.escapeHTML.text); + +var Template = Class.create({ + initialize: function(template, pattern) { + this.template = template.toString(); + this.pattern = pattern || Template.Pattern; + }, + + evaluate: function(object) { + if (Object.isFunction(object.toTemplateReplacements)) + object = object.toTemplateReplacements(); + + return this.template.gsub(this.pattern, function(match) { + if (object == null) return ''; + + var before = match[1] || ''; + if (before == '\\') return match[2]; + + var ctx = object, expr = match[3]; + var pattern = /^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/; + match = pattern.exec(expr); + if (match == null) return before; + + while (match != null) { + var comp = match[1].startsWith('[') ? match[2].gsub('\\\\]', ']') : match[1]; + ctx = ctx[comp]; + if (null == ctx || '' == match[3]) break; + expr = expr.substring('[' == match[3] ? match[1].length : match[0].length); + match = pattern.exec(expr); + } + + return before + String.interpret(ctx); + }); + } +}); +Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/; + +var $break = { }; + +var Enumerable = { + each: function(iterator, context) { + var index = 0; + try { + this._each(function(value) { + iterator.call(context, value, index++); + }); + } catch (e) { + if (e != $break) throw e; + } + return this; + }, + + eachSlice: function(number, iterator, context) { + var index = -number, slices = [], array = this.toArray(); + if (number < 1) return array; + while ((index += number) < array.length) + slices.push(array.slice(index, index+number)); + return slices.collect(iterator, context); + }, + + all: function(iterator, context) { + iterator = iterator || Prototype.K; + var result = true; + this.each(function(value, index) { + result = result && !!iterator.call(context, value, index); + if (!result) throw $break; + }); + return result; + }, + + any: function(iterator, context) { + iterator = iterator || Prototype.K; + var result = false; + this.each(function(value, index) { + if (result = !!iterator.call(context, value, index)) + throw $break; + }); + return result; + }, + + collect: function(iterator, context) { + iterator = iterator || Prototype.K; + var results = []; + this.each(function(value, index) { + results.push(iterator.call(context, value, index)); + }); + return results; + }, + + detect: function(iterator, context) { + var result; + this.each(function(value, index) { + if (iterator.call(context, value, index)) { + result = value; + throw $break; + } + }); + return result; + }, + + findAll: function(iterator, context) { + var results = []; + this.each(function(value, index) { + if (iterator.call(context, value, index)) + results.push(value); + }); + return results; + }, + + grep: function(filter, iterator, context) { + iterator = iterator || Prototype.K; + var results = []; + + if (Object.isString(filter)) + filter = new RegExp(filter); + + this.each(function(value, index) { + if (filter.match(value)) + results.push(iterator.call(context, value, index)); + }); + return results; + }, + + include: function(object) { + if (Object.isFunction(this.indexOf)) + if (this.indexOf(object) != -1) return true; + + var found = false; + this.each(function(value) { + if (value == object) { + found = true; + throw $break; + } + }); + return found; + }, + + inGroupsOf: function(number, fillWith) { + fillWith = Object.isUndefined(fillWith) ? null : fillWith; + return this.eachSlice(number, function(slice) { + while(slice.length < number) slice.push(fillWith); + return slice; + }); + }, + + inject: function(memo, iterator, context) { + this.each(function(value, index) { + memo = iterator.call(context, memo, value, index); + }); + return memo; + }, + + invoke: function(method) { + var args = $A(arguments).slice(1); + return this.map(function(value) { + return value[method].apply(value, args); + }); + }, + + max: function(iterator, context) { + iterator = iterator || Prototype.K; + var result; + this.each(function(value, index) { + value = iterator.call(context, value, index); + if (result == null || value >= result) + result = value; + }); + return result; + }, + + min: function(iterator, context) { + iterator = iterator || Prototype.K; + var result; + this.each(function(value, index) { + value = iterator.call(context, value, index); + if (result == null || value < result) + result = value; + }); + return result; + }, + + partition: function(iterator, context) { + iterator = iterator || Prototype.K; + var trues = [], falses = []; + this.each(function(value, index) { + (iterator.call(context, value, index) ? + trues : falses).push(value); + }); + return [trues, falses]; + }, + + pluck: function(property) { + var results = []; + this.each(function(value) { + results.push(value[property]); + }); + return results; + }, + + reject: function(iterator, context) { + var results = []; + this.each(function(value, index) { + if (!iterator.call(context, value, index)) + results.push(value); + }); + return results; + }, + + sortBy: function(iterator, context) { + return this.map(function(value, index) { + return { + value: value, + criteria: iterator.call(context, value, index) + }; + }).sort(function(left, right) { + var a = left.criteria, b = right.criteria; + return a < b ? -1 : a > b ? 1 : 0; + }).pluck('value'); + }, + + toArray: function() { + return this.map(); + }, + + zip: function() { + var iterator = Prototype.K, args = $A(arguments); + if (Object.isFunction(args.last())) + iterator = args.pop(); + + var collections = [this].concat(args).map($A); + return this.map(function(value, index) { + return iterator(collections.pluck(index)); + }); + }, + + size: function() { + return this.toArray().length; + }, + + inspect: function() { + return '#<Enumerable:' + this.toArray().inspect() + '>'; + } +}; + +Object.extend(Enumerable, { + map: Enumerable.collect, + find: Enumerable.detect, + select: Enumerable.findAll, + filter: Enumerable.findAll, + member: Enumerable.include, + entries: Enumerable.toArray, + every: Enumerable.all, + some: Enumerable.any +}); +function $A(iterable) { + if (!iterable) return []; + if (iterable.toArray) return iterable.toArray(); + var length = iterable.length || 0, results = new Array(length); + while (length--) results[length] = iterable[length]; + return results; +} + +if (Prototype.Browser.WebKit) { + $A = function(iterable) { + if (!iterable) return []; + // In Safari, only use the `toArray` method if it's not a NodeList. + // A NodeList is a function, has an function `item` property, and a numeric + // `length` property. Adapted from Google Doctype. + if (!(typeof iterable === 'function' && typeof iterable.length === + 'number' && typeof iterable.item === 'function') && iterable.toArray) + return iterable.toArray(); + var length = iterable.length || 0, results = new Array(length); + while (length--) results[length] = iterable[length]; + return results; + }; +} + +Array.from = $A; + +Object.extend(Array.prototype, Enumerable); + +if (!Array.prototype._reverse) Array.prototype._reverse = Array.prototype.reverse; + +Object.extend(Array.prototype, { + _each: function(iterator) { + for (var i = 0, length = this.length; i < length; i++) + iterator(this[i]); + }, + + clear: function() { + this.length = 0; + return this; + }, + + first: function() { + return this[0]; + }, + + last: function() { + return this[this.length - 1]; + }, + + compact: function() { + return this.select(function(value) { + return value != null; + }); + }, + + flatten: function() { + return this.inject([], function(array, value) { + return array.concat(Object.isArray(value) ? + value.flatten() : [value]); + }); + }, + + without: function() { + var values = $A(arguments); + return this.select(function(value) { + return !values.include(value); + }); + }, + + reverse: function(inline) { + return (inline !== false ? this : this.toArray())._reverse(); + }, + + reduce: function() { + return this.length > 1 ? this : this[0]; + }, + + uniq: function(sorted) { + return this.inject([], function(array, value, index) { + if (0 == index || (sorted ? array.last() != value : !array.include(value))) + array.push(value); + return array; + }); + }, + + intersect: function(array) { + return this.uniq().findAll(function(item) { + return array.detect(function(value) { return item === value }); + }); + }, + + clone: function() { + return [].concat(this); + }, + + size: function() { + return this.length; + }, + + inspect: function() { + return '[' + this.map(Object.inspect).join(', ') + ']'; + }, + + toJSON: function() { + var results = []; + this.each(function(object) { + var value = Object.toJSON(object); + if (!Object.isUndefined(value)) results.push(value); + }); + return '[' + results.join(', ') + ']'; + } +}); + +// use native browser JS 1.6 implementation if available +if (Object.isFunction(Array.prototype.forEach)) + Array.prototype._each = Array.prototype.forEach; + +if (!Array.prototype.indexOf) Array.prototype.indexOf = function(item, i) { + i || (i = 0); + var length = this.length; + if (i < 0) i = length + i; + for (; i < length; i++) + if (this[i] === item) return i; + return -1; +}; + +if (!Array.prototype.lastIndexOf) Array.prototype.lastIndexOf = function(item, i) { + i = isNaN(i) ? this.length : (i < 0 ? this.length + i : i) + 1; + var n = this.slice(0, i).reverse().indexOf(item); + return (n < 0) ? n : i - n - 1; +}; + +Array.prototype.toArray = Array.prototype.clone; + +function $w(string) { + if (!Object.isString(string)) return []; + string = string.strip(); + return string ? string.split(/\s+/) : []; +} + +if (Prototype.Browser.Opera){ + Array.prototype.concat = function() { + var array = []; + for (var i = 0, length = this.length; i < length; i++) array.push(this[i]); + for (var i = 0, length = arguments.length; i < length; i++) { + if (Object.isArray(arguments[i])) { + for (var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++) + array.push(arguments[i][j]); + } else { + array.push(arguments[i]); + } + } + return array; + }; +} +Object.extend(Number.prototype, { + toColorPart: function() { + return this.toPaddedString(2, 16); + }, + + succ: function() { + return this + 1; + }, + + times: function(iterator, context) { + $R(0, this, true).each(iterator, context); + return this; + }, + + toPaddedString: function(length, radix) { + var string = this.toString(radix || 10); + return '0'.times(length - string.length) + string; + }, + + toJSON: function() { + return isFinite(this) ? this.toString() : 'null'; + } +}); + +$w('abs round ceil floor').each(function(method){ + Number.prototype[method] = Math[method].methodize(); +}); +function $H(object) { + return new Hash(object); +}; + +var Hash = Class.create(Enumerable, (function() { + + function toQueryPair(key, value) { + if (Object.isUndefined(value)) return key; + return key + '=' + encodeURIComponent(String.interpret(value)); + } + + return { + initialize: function(object) { + this._object = Object.isHash(object) ? object.toObject() : Object.clone(object); + }, + + _each: function(iterator) { + for (var key in this._object) { + var value = this._object[key], pair = [key, value]; + pair.key = key; + pair.value = value; + iterator(pair); + } + }, + + set: function(key, value) { + return this._object[key] = value; + }, + + get: function(key) { + // simulating poorly supported hasOwnProperty + if (this._object[key] !== Object.prototype[key]) + return this._object[key]; + }, + + unset: function(key) { + var value = this._object[key]; + delete this._object[key]; + return value; + }, + + toObject: function() { + return Object.clone(this._object); + }, + + keys: function() { + return this.pluck('key'); + }, + + values: function() { + return this.pluck('value'); + }, + + index: function(value) { + var match = this.detect(function(pair) { + return pair.value === value; + }); + return match && match.key; + }, + + merge: function(object) { + return this.clone().update(object); + }, + + update: function(object) { + return new Hash(object).inject(this, function(result, pair) { + result.set(pair.key, pair.value); + return result; + }); + }, + + toQueryString: function() { + return this.inject([], function(results, pair) { + var key = encodeURIComponent(pair.key), values = pair.value; + + if (values && typeof values == 'object') { + if (Object.isArray(values)) + return results.concat(values.map(toQueryPair.curry(key))); + } else results.push(toQueryPair(key, values)); + return results; + }).join('&'); + }, + + inspect: function() { + return '#<Hash:{' + this.map(function(pair) { + return pair.map(Object.inspect).join(': '); + }).join(', ') + '}>'; + }, + + toJSON: function() { + return Object.toJSON(this.toObject()); + }, + + clone: function() { + return new Hash(this); + } + } +})()); + +Hash.prototype.toTemplateReplacements = Hash.prototype.toObject; +Hash.from = $H; +var ObjectRange = Class.create(Enumerable, { + initialize: function(start, end, exclusive) { + this.start = start; + this.end = end; + this.exclusive = exclusive; + }, + + _each: function(iterator) { + var value = this.start; + while (this.include(value)) { + iterator(value); + value = value.succ(); + } + }, + + include: function(value) { + if (value < this.start) + return false; + if (this.exclusive) + return value < this.end; + return value <= this.end; + } +}); + +var $R = function(start, end, exclusive) { + return new ObjectRange(start, end, exclusive); +}; + +var Ajax = { + getTransport: function() { + return Try.these( + function() {return new XMLHttpRequest()}, + function() {return new ActiveXObject('Msxml2.XMLHTTP')}, + function() {return new ActiveXObject('Microsoft.XMLHTTP')} + ) || false; + }, + + activeRequestCount: 0 +}; + +Ajax.Responders = { + responders: [], + + _each: function(iterator) { + this.responders._each(iterator); + }, + + register: function(responder) { + if (!this.include(responder)) + this.responders.push(responder); + }, + + unregister: function(responder) { + this.responders = this.responders.without(responder); + }, + + dispatch: function(callback, request, transport, json) { + this.each(function(responder) { + if (Object.isFunction(responder[callback])) { + try { + responder[callback].apply(responder, [request, transport, json]); + } catch (e) { } + } + }); + } +}; + +Object.extend(Ajax.Responders, Enumerable); + +Ajax.Responders.register({ + onCreate: function() { Ajax.activeRequestCount++ }, + onComplete: function() { Ajax.activeRequestCount-- } +}); + +Ajax.Base = Class.create({ + initialize: function(options) { + this.options = { + method: 'post', + asynchronous: true, + contentType: 'application/x-www-form-urlencoded', + encoding: 'UTF-8', + parameters: '', + evalJSON: true, + evalJS: true + }; + Object.extend(this.options, options || { }); + + this.options.method = this.options.method.toLowerCase(); + + if (Object.isString(this.options.parameters)) + this.options.parameters = this.options.parameters.toQueryParams(); + else if (Object.isHash(this.options.parameters)) + this.options.parameters = this.options.parameters.toObject(); + } +}); + +Ajax.Request = Class.create(Ajax.Base, { + _complete: false, + + initialize: function($super, url, options) { + $super(options); + this.transport = Ajax.getTransport(); + this.request(url); + }, + + request: function(url) { + this.url = url; + this.method = this.options.method; + var params = Object.clone(this.options.parameters); + + if (!['get', 'post'].include(this.method)) { + // simulate other verbs over post + params['_method'] = this.method; + this.method = 'post'; + } + + this.parameters = params; + + if (params = Object.toQueryString(params)) { + // when GET, append parameters to URL + if (this.method == 'get') + this.url += (this.url.include('?') ? '&' : '?') + params; + else if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) + params += '&_='; + } + + try { + var response = new Ajax.Response(this); + if (this.options.onCreate) this.options.onCreate(response); + Ajax.Responders.dispatch('onCreate', this, response); + + this.transport.open(this.method.toUpperCase(), this.url, + this.options.asynchronous); + + if (this.options.asynchronous) this.respondToReadyState.bind(this).defer(1); + + this.transport.onreadystatechange = this.onStateChange.bind(this); + this.setRequestHeaders(); + + this.body = this.method == 'post' ? (this.options.postBody || params) : null; + this.transport.send(this.body); + + /* Force Firefox to handle ready state 4 for synchronous requests */ + if (!this.options.asynchronous && this.transport.overrideMimeType) + this.onStateChange(); + + } + catch (e) { + this.dispatchException(e); + } + }, + + onStateChange: function() { + var readyState = this.transport.readyState; + if (readyState > 1 && !((readyState == 4) && this._complete)) + this.respondToReadyState(this.transport.readyState); + }, + + setRequestHeaders: function() { + var headers = { + 'X-Requested-With': 'XMLHttpRequest', + 'X-Prototype-Version': Prototype.Version, + 'Accept': 'text/javascript, text/html, application/xml, text/xml, */*' + }; + + if (this.method == 'post') { + headers['Content-type'] = this.options.contentType + + (this.options.encoding ? '; charset=' + this.options.encoding : ''); + + /* Force "Connection: close" for older Mozilla browsers to work + * around a bug where XMLHttpRequest sends an incorrect + * Content-length header. See Mozilla Bugzilla #246651. + */ + if (this.transport.overrideMimeType && + (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005) + headers['Connection'] = 'close'; + } + + // user-defined headers + if (typeof this.options.requestHeaders == 'object') { + var extras = this.options.requestHeaders; + + if (Object.isFunction(extras.push)) + for (var i = 0, length = extras.length; i < length; i += 2) + headers[extras[i]] = extras[i+1]; + else + $H(extras).each(function(pair) { headers[pair.key] = pair.value }); + } + + for (var name in headers) + this.transport.setRequestHeader(name, headers[name]); + }, + + success: function() { + var status = this.getStatus(); + return !status || (status >= 200 && status < 300); + }, + + getStatus: function() { + try { + return this.transport.status || 0; + } catch (e) { return 0 } + }, + + respondToReadyState: function(readyState) { + var state = Ajax.Request.Events[readyState], response = new Ajax.Response(this); + + if (state == 'Complete') { + try { + this._complete = true; + (this.options['on' + response.status] + || this.options['on' + (this.success() ? 'Success' : 'Failure')] + || Prototype.emptyFunction)(response, response.headerJSON); + } catch (e) { + this.dispatchException(e); + } + + var contentType = response.getHeader('Content-type'); + if (this.options.evalJS == 'force' + || (this.options.evalJS && this.isSameOrigin() && contentType + && contentType.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i))) + this.evalResponse(); + } + + try { + (this.options['on' + state] || Prototype.emptyFunction)(response, response.headerJSON); + Ajax.Responders.dispatch('on' + state, this, response, response.headerJSON); + } catch (e) { + this.dispatchException(e); + } + + if (state == 'Complete') { + // avoid memory leak in MSIE: clean up + this.transport.onreadystatechange = Prototype.emptyFunction; + } + }, + + isSameOrigin: function() { + var m = this.url.match(/^\s*https?:\/\/[^\/]*/); + return !m || (m[0] == '#{protocol}//#{domain}#{port}'.interpolate({ + protocol: location.protocol, + domain: document.domain, + port: location.port ? ':' + location.port : '' + })); + }, + + getHeader: function(name) { + try { + return this.transport.getResponseHeader(name) || null; + } catch (e) { return null } + }, + + evalResponse: function() { + try { + return eval((this.transport.responseText || '').unfilterJSON()); + } catch (e) { + this.dispatchException(e); + } + }, + + dispatchException: function(exception) { + (this.options.onException || Prototype.emptyFunction)(this, exception); + Ajax.Responders.dispatch('onException', this, exception); + } +}); + +Ajax.Request.Events = + ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete']; + +Ajax.Response = Class.create({ + initialize: function(request){ + this.request = request; + var transport = this.transport = request.transport, + readyState = this.readyState = transport.readyState; + + if((readyState > 2 && !Prototype.Browser.IE) || readyState == 4) { + this.status = this.getStatus(); + this.statusText = this.getStatusText(); + this.responseText = String.interpret(transport.responseText); + this.headerJSON = this._getHeaderJSON(); + } + + if(readyState == 4) { + var xml = transport.responseXML; + this.responseXML = Object.isUndefined(xml) ? null : xml; + this.responseJSON = this._getResponseJSON(); + } + }, + + status: 0, + statusText: '', + + getStatus: Ajax.Request.prototype.getStatus, + + getStatusText: function() { + try { + return this.transport.statusText || ''; + } catch (e) { return '' } + }, + + getHeader: Ajax.Request.prototype.getHeader, + + getAllHeaders: function() { + try { + return this.getAllResponseHeaders(); + } catch (e) { return null } + }, + + getResponseHeader: function(name) { + return this.transport.getResponseHeader(name); + }, + + getAllResponseHeaders: function() { + return this.transport.getAllResponseHeaders(); + }, + + _getHeaderJSON: function() { + var json = this.getHeader('X-JSON'); + if (!json) return null; + json = decodeURIComponent(escape(json)); + try { + return json.evalJSON(this.request.options.sanitizeJSON || + !this.request.isSameOrigin()); + } catch (e) { + this.request.dispatchException(e); + } + }, + + _getResponseJSON: function() { + var options = this.request.options; + if (!options.evalJSON || (options.evalJSON != 'force' && + !(this.getHeader('Content-type') || '').include('application/json')) || + this.responseText.blank()) + return null; + try { + return this.responseText.evalJSON(options.sanitizeJSON || + !this.request.isSameOrigin()); + } catch (e) { + this.request.dispatchException(e); + } + } +}); + +Ajax.Updater = Class.create(Ajax.Request, { + initialize: function($super, container, url, options) { + this.container = { + success: (container.success || container), + failure: (container.failure || (container.success ? null : container)) + }; + + options = Object.clone(options); + var onComplete = options.onComplete; + options.onComplete = (function(response, json) { + this.updateContent(response.responseText); + if (Object.isFunction(onComplete)) onComplete(response, json); + }).bind(this); + + $super(url, options); + }, + + updateContent: function(responseText) { + var receiver = this.container[this.success() ? 'success' : 'failure'], + options = this.options; + + if (!options.evalScripts) responseText = responseText.stripScripts(); + + if (receiver = $(receiver)) { + if (options.insertion) { + if (Object.isString(options.insertion)) { + var insertion = { }; insertion[options.insertion] = responseText; + receiver.insert(insertion); + } + else options.insertion(receiver, responseText); + } + else receiver.update(responseText); + } + } +}); + +Ajax.PeriodicalUpdater = Class.create(Ajax.Base, { + initialize: function($super, container, url, options) { + $super(options); + this.onComplete = this.options.onComplete; + + this.frequency = (this.options.frequency || 2); + this.decay = (this.options.decay || 1); + + this.updater = { }; + this.container = container; + this.url = url; + + this.start(); + }, + + start: function() { + this.options.onComplete = this.updateComplete.bind(this); + this.onTimerEvent(); + }, + + stop: function() { + this.updater.options.onComplete = undefined; + clearTimeout(this.timer); + (this.onComplete || Prototype.emptyFunction).apply(this, arguments); + }, + + updateComplete: function(response) { + if (this.options.decay) { + this.decay = (response.responseText == this.lastText ? + this.decay * this.options.decay : 1); + + this.lastText = response.responseText; + } + this.timer = this.onTimerEvent.bind(this).delay(this.decay * this.frequency); + }, + + onTimerEvent: function() { + this.updater = new Ajax.Updater(this.container, this.url, this.options); + } +}); +function $(element) { + if (arguments.length > 1) { + for (var i = 0, elements = [], length = arguments.length; i < length; i++) + elements.push($(arguments[i])); + return elements; + } + if (Object.isString(element)) + element = document.getElementById(element); + return Element.extend(element); +} + +if (Prototype.BrowserFeatures.XPath) { + document._getElementsByXPath = function(expression, parentElement) { + var results = []; + var query = document.evaluate(expression, $(parentElement) || document, + null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); + for (var i = 0, length = query.snapshotLength; i < length; i++) + results.push(Element.extend(query.snapshotItem(i))); + return results; + }; +} + +/*--------------------------------------------------------------------------*/ + +if (!window.Node) var Node = { }; + +if (!Node.ELEMENT_NODE) { + // DOM level 2 ECMAScript Language Binding + Object.extend(Node, { + ELEMENT_NODE: 1, + ATTRIBUTE_NODE: 2, + TEXT_NODE: 3, + CDATA_SECTION_NODE: 4, + ENTITY_REFERENCE_NODE: 5, + ENTITY_NODE: 6, + PROCESSING_INSTRUCTION_NODE: 7, + COMMENT_NODE: 8, + DOCUMENT_NODE: 9, + DOCUMENT_TYPE_NODE: 10, + DOCUMENT_FRAGMENT_NODE: 11, + NOTATION_NODE: 12 + }); +} + +(function() { + var element = this.Element; + this.Element = function(tagName, attributes) { + attributes = attributes || { }; + tagName = tagName.toLowerCase(); + var cache = Element.cache; + if (Prototype.Browser.IE && attributes.name) { + tagName = '<' + tagName + ' name="' + attributes.name + '">'; + delete attributes.name; + return Element.writeAttribute(document.createElement(tagName), attributes); + } + if (!cache[tagName]) cache[tagName] = Element.extend(document.createElement(tagName)); + return Element.writeAttribute(cache[tagName].cloneNode(false), attributes); + }; + Object.extend(this.Element, element || { }); + if (element) this.Element.prototype = element.prototype; +}).call(window); + +Element.cache = { }; + +Element.Methods = { + visible: function(element) { + return $(element).style.display != 'none'; + }, + + toggle: function(element) { + element = $(element); + Element[Element.visible(element) ? 'hide' : 'show'](element); + return element; + }, + + hide: function(element) { + element = $(element); + element.style.display = 'none'; + return element; + }, + + show: function(element) { + element = $(element); + element.style.display = ''; + return element; + }, + + remove: function(element) { + element = $(element); + element.parentNode.removeChild(element); + return element; + }, + + update: function(element, content) { + element = $(element); + if (content && content.toElement) content = content.toElement(); + if (Object.isElement(content)) return element.update().insert(content); + content = Object.toHTML(content); + element.innerHTML = content.stripScripts(); + content.evalScripts.bind(content).defer(); + return element; + }, + + replace: function(element, content) { + element = $(element); + if (content && content.toElement) content = content.toElement(); + else if (!Object.isElement(content)) { + content = Object.toHTML(content); + var range = element.ownerDocument.createRange(); + range.selectNode(element); + content.evalScripts.bind(content).defer(); + content = range.createContextualFragment(content.stripScripts()); + } + element.parentNode.replaceChild(content, element); + return element; + }, + + insert: function(element, insertions) { + element = $(element); + + if (Object.isString(insertions) || Object.isNumber(insertions) || + Object.isElement(insertions) || (insertions && (insertions.toElement || insertions.toHTML))) + insertions = {bottom:insertions}; + + var content, insert, tagName, childNodes; + + for (var position in insertions) { + content = insertions[position]; + position = position.toLowerCase(); + insert = Element._insertionTranslations[position]; + + if (content && content.toElement) content = content.toElement(); + if (Object.isElement(content)) { + insert(element, content); + continue; + } + + content = Object.toHTML(content); + + tagName = ((position == 'before' || position == 'after') + ? element.parentNode : element).tagName.toUpperCase(); + + childNodes = Element._getContentFromAnonymousElement(tagName, content.stripScripts()); + + if (position == 'top' || position == 'after') childNodes.reverse(); + childNodes.each(insert.curry(element)); + + content.evalScripts.bind(content).defer(); + } + + return element; + }, + + wrap: function(element, wrapper, attributes) { + element = $(element); + if (Object.isElement(wrapper)) + $(wrapper).writeAttribute(attributes || { }); + else if (Object.isString(wrapper)) wrapper = new Element(wrapper, attributes); + else wrapper = new Element('div', wrapper); + if (element.parentNode) + element.parentNode.replaceChild(wrapper, element); + wrapper.appendChild(element); + return wrapper; + }, + + inspect: function(element) { + element = $(element); + var result = '<' + element.tagName.toLowerCase(); + $H({'id': 'id', 'className': 'class'}).each(function(pair) { + var property = pair.first(), attribute = pair.last(); + var value = (element[property] || '').toString(); + if (value) result += ' ' + attribute + '=' + value.inspect(true); + }); + return result + '>'; + }, + + recursivelyCollect: function(element, property) { + element = $(element); + var elements = []; + while (element = element[property]) + if (element.nodeType == 1) + elements.push(Element.extend(element)); + return elements; + }, + + ancestors: function(element) { + return $(element).recursivelyCollect('parentNode'); + }, + + descendants: function(element) { + return $(element).select("*"); + }, + + firstDescendant: function(element) { + element = $(element).firstChild; + while (element && element.nodeType != 1) element = element.nextSibling; + return $(element); + }, + + immediateDescendants: function(element) { + if (!(element = $(element).firstChild)) return []; + while (element && element.nodeType != 1) element = element.nextSibling; + if (element) return [element].concat($(element).nextSiblings()); + return []; + }, + + previousSiblings: function(element) { + return $(element).recursivelyCollect('previousSibling'); + }, + + nextSiblings: function(element) { + return $(element).recursivelyCollect('nextSibling'); + }, + + siblings: function(element) { + element = $(element); + return element.previousSiblings().reverse().concat(element.nextSiblings()); + }, + + match: function(element, selector) { + if (Object.isString(selector)) + selector = new Selector(selector); + return selector.match($(element)); + }, + + up: function(element, expression, index) { + element = $(element); + if (arguments.length == 1) return $(element.parentNode); + var ancestors = element.ancestors(); + return Object.isNumber(expression) ? ancestors[expression] : + Selector.findElement(ancestors, expression, index); + }, + + down: function(element, expression, index) { + element = $(element); + if (arguments.length == 1) return element.firstDescendant(); + return Object.isNumber(expression) ? element.descendants()[expression] : + Element.select(element, expression)[index || 0]; + }, + + previous: function(element, expression, index) { + element = $(element); + if (arguments.length == 1) return $(Selector.handlers.previousElementSibling(element)); + var previousSiblings = element.previousSiblings(); + return Object.isNumber(expression) ? previousSiblings[expression] : + Selector.findElement(previousSiblings, expression, index); + }, + + next: function(element, expression, index) { + element = $(element); + if (arguments.length == 1) return $(Selector.handlers.nextElementSibling(element)); + var nextSiblings = element.nextSiblings(); + return Object.isNumber(expression) ? nextSiblings[expression] : + Selector.findElement(nextSiblings, expression, index); + }, + + select: function() { + var args = $A(arguments), element = $(args.shift()); + return Selector.findChildElements(element, args); + }, + + adjacent: function() { + var args = $A(arguments), element = $(args.shift()); + return Selector.findChildElements(element.parentNode, args).without(element); + }, + + identify: function(element) { + element = $(element); + var id = element.readAttribute('id'), self = arguments.callee; + if (id) return id; + do { id = 'anonymous_element_' + self.counter++ } while ($(id)); + element.writeAttribute('id', id); + return id; + }, + + readAttribute: function(element, name) { + element = $(element); + if (Prototype.Browser.IE) { + var t = Element._attributeTranslations.read; + if (t.values[name]) return t.values[name](element, name); + if (t.names[name]) name = t.names[name]; + if (name.include(':')) { + return (!element.attributes || !element.attributes[name]) ? null : + element.attributes[name].value; + } + } + return element.getAttribute(name); + }, + + writeAttribute: function(element, name, value) { + element = $(element); + var attributes = { }, t = Element._attributeTranslations.write; + + if (typeof name == 'object') attributes = name; + else attributes[name] = Object.isUndefined(value) ? true : value; + + for (var attr in attributes) { + name = t.names[attr] || attr; + value = attributes[attr]; + if (t.values[attr]) name = t.values[attr](element, value); + if (value === false || value === null) + element.removeAttribute(name); + else if (value === true) + element.setAttribute(name, name); + else element.setAttribute(name, value); + } + return element; + }, + + getHeight: function(element) { + return $(element).getDimensions().height; + }, + + getWidth: function(element) { + return $(element).getDimensions().width; + }, + + classNames: function(element) { + return new Element.ClassNames(element); + }, + + hasClassName: function(element, className) { + if (!(element = $(element))) return; + var elementClassName = element.className; + return (elementClassName.length > 0 && (elementClassName == className || + new RegExp("(^|\\s)" + className + "(\\s|$)").test(elementClassName))); + }, + + addClassName: function(element, className) { + if (!(element = $(element))) return; + if (!element.hasClassName(className)) + element.className += (element.className ? ' ' : '') + className; + return element; + }, + + removeClassName: function(element, className) { + if (!(element = $(element))) return; + element.className = element.className.replace( + new RegExp("(^|\\s+)" + className + "(\\s+|$)"), ' ').strip(); + return element; + }, + + toggleClassName: function(element, className) { + if (!(element = $(element))) return; + return element[element.hasClassName(className) ? + 'removeClassName' : 'addClassName'](className); + }, + + // removes whitespace-only text node children + cleanWhitespace: function(element) { + element = $(element); + var node = element.firstChild; + while (node) { + var nextNode = node.nextSibling; + if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) + element.removeChild(node); + node = nextNode; + } + return element; + }, + + empty: function(element) { + return $(element).innerHTML.blank(); + }, + + descendantOf: function(element, ancestor) { + element = $(element), ancestor = $(ancestor); + + if (element.compareDocumentPosition) + return (element.compareDocumentPosition(ancestor) & 8) === 8; + + if (ancestor.contains) + return ancestor.contains(element) && ancestor !== element; + + while (element = element.parentNode) + if (element == ancestor) return true; + + return false; + }, + + scrollTo: function(element) { + element = $(element); + var pos = element.cumulativeOffset(); + window.scrollTo(pos[0], pos[1]); + return element; + }, + + getStyle: function(element, style) { + element = $(element); + style = style == 'float' ? 'cssFloat' : style.camelize(); + var value = element.style[style]; + if (!value || value == 'auto') { + var css = document.defaultView.getComputedStyle(element, null); + value = css ? css[style] : null; + } + if (style == 'opacity') return value ? parseFloat(value) : 1.0; + return value == 'auto' ? null : value; + }, + + getOpacity: function(element) { + return $(element).getStyle('opacity'); + }, + + setStyle: function(element, styles) { + element = $(element); + var elementStyle = element.style, match; + if (Object.isString(styles)) { + element.style.cssText += ';' + styles; + return styles.include('opacity') ? + element.setOpacity(styles.match(/opacity:\s*(\d?\.?\d*)/)[1]) : element; + } + for (var property in styles) + if (property == 'opacity') element.setOpacity(styles[property]); + else + elementStyle[(property == 'float' || property == 'cssFloat') ? + (Object.isUndefined(elementStyle.styleFloat) ? 'cssFloat' : 'styleFloat') : + property] = styles[property]; + + return element; + }, + + setOpacity: function(element, value) { + element = $(element); + element.style.opacity = (value == 1 || value === '') ? '' : + (value < 0.00001) ? 0 : value; + return element; + }, + + getDimensions: function(element) { + element = $(element); + var display = element.getStyle('display'); + if (display != 'none' && display != null) // Safari bug + return {width: element.offsetWidth, height: element.offsetHeight}; + + // All *Width and *Height properties give 0 on elements with display none, + // so enable the element temporarily + var els = element.style; + var originalVisibility = els.visibility; + var originalPosition = els.position; + var originalDisplay = els.display; + els.visibility = 'hidden'; + els.position = 'absolute'; + els.display = 'block'; + var originalWidth = element.clientWidth; + var originalHeight = element.clientHeight; + els.display = originalDisplay; + els.position = originalPosition; + els.visibility = originalVisibility; + return {width: originalWidth, height: originalHeight}; + }, + + makePositioned: function(element) { + element = $(element); + var pos = Element.getStyle(element, 'position'); + if (pos == 'static' || !pos) { + element._madePositioned = true; + element.style.position = 'relative'; + // Opera returns the offset relative to the positioning context, when an + // element is position relative but top and left have not been defined + if (Prototype.Browser.Opera) { + element.style.top = 0; + element.style.left = 0; + } + } + return element; + }, + + undoPositioned: function(element) { + element = $(element); + if (element._madePositioned) { + element._madePositioned = undefined; + element.style.position = + element.style.top = + element.style.left = + element.style.bottom = + element.style.right = ''; + } + return element; + }, + + makeClipping: function(element) { + element = $(element); + if (element._overflow) return element; + element._overflow = Element.getStyle(element, 'overflow') || 'auto'; + if (element._overflow !== 'hidden') + element.style.overflow = 'hidden'; + return element; + }, + + undoClipping: function(element) { + element = $(element); + if (!element._overflow) return element; + element.style.overflow = element._overflow == 'auto' ? '' : element._overflow; + element._overflow = null; + return element; + }, + + cumulativeOffset: function(element) { + var valueT = 0, valueL = 0; + do { + valueT += element.offsetTop || 0; + valueL += element.offsetLeft || 0; + element = element.offsetParent; + } while (element); + return Element._returnOffset(valueL, valueT); + }, + + positionedOffset: function(element) { + var valueT = 0, valueL = 0; + do { + valueT += element.offsetTop || 0; + valueL += element.offsetLeft || 0; + element = element.offsetParent; + if (element) { + if (element.tagName.toUpperCase() == 'BODY') break; + var p = Element.getStyle(element, 'position'); + if (p !== 'static') break; + } + } while (element); + return Element._returnOffset(valueL, valueT); + }, + + absolutize: function(element) { + element = $(element); + if (element.getStyle('position') == 'absolute') return element; + // Position.prepare(); // To be done manually by Scripty when it needs it. + + var offsets = element.positionedOffset(); + var top = offsets[1]; + var left = offsets[0]; + var width = element.clientWidth; + var height = element.clientHeight; + + element._originalLeft = left - parseFloat(element.style.left || 0); + element._originalTop = top - parseFloat(element.style.top || 0); + element._originalWidth = element.style.width; + element._originalHeight = element.style.height; + + element.style.position = 'absolute'; + element.style.top = top + 'px'; + element.style.left = left + 'px'; + element.style.width = width + 'px'; + element.style.height = height + 'px'; + return element; + }, + + relativize: function(element) { + element = $(element); + if (element.getStyle('position') == 'relative') return element; + // Position.prepare(); // To be done manually by Scripty when it needs it. + + element.style.position = 'relative'; + var top = parseFloat(element.style.top || 0) - (element._originalTop || 0); + var left = parseFloat(element.style.left || 0) - (element._originalLeft || 0); + + element.style.top = top + 'px'; + element.style.left = left + 'px'; + element.style.height = element._originalHeight; + element.style.width = element._originalWidth; + return element; + }, + + cumulativeScrollOffset: function(element) { + var valueT = 0, valueL = 0; + do { + valueT += element.scrollTop || 0; + valueL += element.scrollLeft || 0; + element = element.parentNode; + } while (element); + return Element._returnOffset(valueL, valueT); + }, + + getOffsetParent: function(element) { + if (element.offsetParent) return $(element.offsetParent); + if (element == document.body) return $(element); + + while ((element = element.parentNode) && element != document.body) + if (Element.getStyle(element, 'position') != 'static') + return $(element); + + return $(document.body); + }, + + viewportOffset: function(forElement) { + var valueT = 0, valueL = 0; + + var element = forElement; + do { + valueT += element.offsetTop || 0; + valueL += element.offsetLeft || 0; + + // Safari fix + if (element.offsetParent == document.body && + Element.getStyle(element, 'position') == 'absolute') break; + + } while (element = element.offsetParent); + + element = forElement; + do { + if (!Prototype.Browser.Opera || (element.tagName && (element.tagName.toUpperCase() == 'BODY'))) { + valueT -= element.scrollTop || 0; + valueL -= element.scrollLeft || 0; + } + } while (element = element.parentNode); + + return Element._returnOffset(valueL, valueT); + }, + + clonePosition: function(element, source) { + var options = Object.extend({ + setLeft: true, + setTop: true, + setWidth: true, + setHeight: true, + offsetTop: 0, + offsetLeft: 0 + }, arguments[2] || { }); + + // find page position of source + source = $(source); + var p = source.viewportOffset(); + + // find coordinate system to use + element = $(element); + var delta = [0, 0]; + var parent = null; + // delta [0,0] will do fine with position: fixed elements, + // position:absolute needs offsetParent deltas + if (Element.getStyle(element, 'position') == 'absolute') { + parent = element.getOffsetParent(); + delta = parent.viewportOffset(); + } + + // correct by body offsets (fixes Safari) + if (parent == document.body) { + delta[0] -= document.body.offsetLeft; + delta[1] -= document.body.offsetTop; + } + + // set position + if (options.setLeft) element.style.left = (p[0] - delta[0] + options.offsetLeft) + 'px'; + if (options.setTop) element.style.top = (p[1] - delta[1] + options.offsetTop) + 'px'; + if (options.setWidth) element.style.width = source.offsetWidth + 'px'; + if (options.setHeight) element.style.height = source.offsetHeight + 'px'; + return element; + } +}; + +Element.Methods.identify.counter = 1; + +Object.extend(Element.Methods, { + getElementsBySelector: Element.Methods.select, + childElements: Element.Methods.immediateDescendants +}); + +Element._attributeTranslations = { + write: { + names: { + className: 'class', + htmlFor: 'for' + }, + values: { } + } +}; + +if (Prototype.Browser.Opera) { + Element.Methods.getStyle = Element.Methods.getStyle.wrap( + function(proceed, element, style) { + switch (style) { + case 'left': case 'top': case 'right': case 'bottom': + if (proceed(element, 'position') === 'static') return null; + case 'height': case 'width': + // returns '0px' for hidden elements; we want it to return null + if (!Element.visible(element)) return null; + + // returns the border-box dimensions rather than the content-box + // dimensions, so we subtract padding and borders from the value + var dim = parseInt(proceed(element, style), 10); + + if (dim !== element['offset' + style.capitalize()]) + return dim + 'px'; + + var properties; + if (style === 'height') { + properties = ['border-top-width', 'padding-top', + 'padding-bottom', 'border-bottom-width']; + } + else { + properties = ['border-left-width', 'padding-left', + 'padding-right', 'border-right-width']; + } + return properties.inject(dim, function(memo, property) { + var val = proceed(element, property); + return val === null ? memo : memo - parseInt(val, 10); + }) + 'px'; + default: return proceed(element, style); + } + } + ); + + Element.Methods.readAttribute = Element.Methods.readAttribute.wrap( + function(proceed, element, attribute) { + if (attribute === 'title') return element.title; + return proceed(element, attribute); + } + ); +} + +else if (Prototype.Browser.IE) { + // IE doesn't report offsets correctly for static elements, so we change them + // to "relative" to get the values, then change them back. + Element.Methods.getOffsetParent = Element.Methods.getOffsetParent.wrap( + function(proceed, element) { + element = $(element); + // IE throws an error if element is not in document + try { element.offsetParent } + catch(e) { return $(document.body) } + var position = element.getStyle('position'); + if (position !== 'static') return proceed(element); + element.setStyle({ position: 'relative' }); + var value = proceed(element); + element.setStyle({ position: position }); + return value; + } + ); + + $w('positionedOffset viewportOffset').each(function(method) { + Element.Methods[method] = Element.Methods[method].wrap( + function(proceed, element) { + element = $(element); + try { element.offsetParent } + catch(e) { return Element._returnOffset(0,0) } + var position = element.getStyle('position'); + if (position !== 'static') return proceed(element); + // Trigger hasLayout on the offset parent so that IE6 reports + // accurate offsetTop and offsetLeft values for position: fixed. + var offsetParent = element.getOffsetParent(); + if (offsetParent && offsetParent.getStyle('position') === 'fixed') + offsetParent.setStyle({ zoom: 1 }); + element.setStyle({ position: 'relative' }); + var value = proceed(element); + element.setStyle({ position: position }); + return value; + } + ); + }); + + Element.Methods.cumulativeOffset = Element.Methods.cumulativeOffset.wrap( + function(proceed, element) { + try { element.offsetParent } + catch(e) { return Element._returnOffset(0,0) } + return proceed(element); + } + ); + + Element.Methods.getStyle = function(element, style) { + element = $(element); + style = (style == 'float' || style == 'cssFloat') ? 'styleFloat' : style.camelize(); + var value = element.style[style]; + if (!value && element.currentStyle) value = element.currentStyle[style]; + + if (style == 'opacity') { + if (value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/)) + if (value[1]) return parseFloat(value[1]) / 100; + return 1.0; + } + + if (value == 'auto') { + if ((style == 'width' || style == 'height') && (element.getStyle('display') != 'none')) + return element['offset' + style.capitalize()] + 'px'; + return null; + } + return value; + }; + + Element.Methods.setOpacity = function(element, value) { + function stripAlpha(filter){ + return filter.replace(/alpha\([^\)]*\)/gi,''); + } + element = $(element); + var currentStyle = element.currentStyle; + if ((currentStyle && !currentStyle.hasLayout) || + (!currentStyle && element.style.zoom == 'normal')) + element.style.zoom = 1; + + var filter = element.getStyle('filter'), style = element.style; + if (value == 1 || value === '') { + (filter = stripAlpha(filter)) ? + style.filter = filter : style.removeAttribute('filter'); + return element; + } else if (value < 0.00001) value = 0; + style.filter = stripAlpha(filter) + + 'alpha(opacity=' + (value * 100) + ')'; + return element; + }; + + Element._attributeTranslations = { + read: { + names: { + 'class': 'className', + 'for': 'htmlFor' + }, + values: { + _getAttr: function(element, attribute) { + return element.getAttribute(attribute, 2); + }, + _getAttrNode: function(element, attribute) { + var node = element.getAttributeNode(attribute); + return node ? node.value : ""; + }, + _getEv: function(element, attribute) { + attribute = element.getAttribute(attribute); + return attribute ? attribute.toString().slice(23, -2) : null; + }, + _flag: function(element, attribute) { + return $(element).hasAttribute(attribute) ? attribute : null; + }, + style: function(element) { + return element.style.cssText.toLowerCase(); + }, + title: function(element) { + return element.title; + } + } + } + }; + + Element._attributeTranslations.write = { + names: Object.extend({ + cellpadding: 'cellPadding', + cellspacing: 'cellSpacing' + }, Element._attributeTranslations.read.names), + values: { + checked: function(element, value) { + element.checked = !!value; + }, + + style: function(element, value) { + element.style.cssText = value ? value : ''; + } + } + }; + + Element._attributeTranslations.has = {}; + + $w('colSpan rowSpan vAlign dateTime accessKey tabIndex ' + + 'encType maxLength readOnly longDesc frameBorder').each(function(attr) { + Element._attributeTranslations.write.names[attr.toLowerCase()] = attr; + Element._attributeTranslations.has[attr.toLowerCase()] = attr; + }); + + (function(v) { + Object.extend(v, { + href: v._getAttr, + src: v._getAttr, + type: v._getAttr, + action: v._getAttrNode, + disabled: v._flag, + checked: v._flag, + readonly: v._flag, + multiple: v._flag, + onload: v._getEv, + onunload: v._getEv, + onclick: v._getEv, + ondblclick: v._getEv, + onmousedown: v._getEv, + onmouseup: v._getEv, + onmouseover: v._getEv, + onmousemove: v._getEv, + onmouseout: v._getEv, + onfocus: v._getEv, + onblur: v._getEv, + onkeypress: v._getEv, + onkeydown: v._getEv, + onkeyup: v._getEv, + onsubmit: v._getEv, + onreset: v._getEv, + onselect: v._getEv, + onchange: v._getEv + }); + })(Element._attributeTranslations.read.values); +} + +else if (Prototype.Browser.Gecko && /rv:1\.8\.0/.test(navigator.userAgent)) { + Element.Methods.setOpacity = function(element, value) { + element = $(element); + element.style.opacity = (value == 1) ? 0.999999 : + (value === '') ? '' : (value < 0.00001) ? 0 : value; + return element; + }; +} + +else if (Prototype.Browser.WebKit) { + Element.Methods.setOpacity = function(element, value) { + element = $(element); + element.style.opacity = (value == 1 || value === '') ? '' : + (value < 0.00001) ? 0 : value; + + if (value == 1) + if(element.tagName.toUpperCase() == 'IMG' && element.width) { + element.width++; element.width--; + } else try { + var n = document.createTextNode(' '); + element.appendChild(n); + element.removeChild(n); + } catch (e) { } + + return element; + }; + + // Safari returns margins on body which is incorrect if the child is absolutely + // positioned. For performance reasons, redefine Element#cumulativeOffset for + // KHTML/WebKit only. + Element.Methods.cumulativeOffset = function(element) { + var valueT = 0, valueL = 0; + do { + valueT += element.offsetTop || 0; + valueL += element.offsetLeft || 0; + if (element.offsetParent == document.body) + if (Element.getStyle(element, 'position') == 'absolute') break; + + element = element.offsetParent; + } while (element); + + return Element._returnOffset(valueL, valueT); + }; +} + +if (Prototype.Browser.IE || Prototype.Browser.Opera) { + // IE and Opera are missing .innerHTML support for TABLE-related and SELECT elements + Element.Methods.update = function(element, content) { + element = $(element); + + if (content && content.toElement) content = content.toElement(); + if (Object.isElement(content)) return element.update().insert(content); + + content = Object.toHTML(content); + var tagName = element.tagName.toUpperCase(); + + if (tagName in Element._insertionTranslations.tags) { + $A(element.childNodes).each(function(node) { element.removeChild(node) }); + Element._getContentFromAnonymousElement(tagName, content.stripScripts()) + .each(function(node) { element.appendChild(node) }); + } + else element.innerHTML = content.stripScripts(); + + content.evalScripts.bind(content).defer(); + return element; + }; +} + +if ('outerHTML' in document.createElement('div')) { + Element.Methods.replace = function(element, content) { + element = $(element); + + if (content && content.toElement) content = content.toElement(); + if (Object.isElement(content)) { + element.parentNode.replaceChild(content, element); + return element; + } + + content = Object.toHTML(content); + var parent = element.parentNode, tagName = parent.tagName.toUpperCase(); + + if (Element._insertionTranslations.tags[tagName]) { + var nextSibling = element.next(); + var fragments = Element._getContentFromAnonymousElement(tagName, content.stripScripts()); + parent.removeChild(element); + if (nextSibling) + fragments.each(function(node) { parent.insertBefore(node, nextSibling) }); + else + fragments.each(function(node) { parent.appendChild(node) }); + } + else element.outerHTML = content.stripScripts(); + + content.evalScripts.bind(content).defer(); + return element; + }; +} + +Element._returnOffset = function(l, t) { + var result = [l, t]; + result.left = l; + result.top = t; + return result; +}; + +Element._getContentFromAnonymousElement = function(tagName, html) { + var div = new Element('div'), t = Element._insertionTranslations.tags[tagName]; + if (t) { + div.innerHTML = t[0] + html + t[1]; + t[2].times(function() { div = div.firstChild }); + } else div.innerHTML = html; + return $A(div.childNodes); +}; + +Element._insertionTranslations = { + before: function(element, node) { + element.parentNode.insertBefore(node, element); + }, + top: function(element, node) { + element.insertBefore(node, element.firstChild); + }, + bottom: function(element, node) { + element.appendChild(node); + }, + after: function(element, node) { + element.parentNode.insertBefore(node, element.nextSibling); + }, + tags: { + TABLE: ['<table>', '</table>', 1], + TBODY: ['<table><tbody>', '</tbody></table>', 2], + TR: ['<table><tbody><tr>', '</tr></tbody></table>', 3], + TD: ['<table><tbody><tr><td>', '</td></tr></tbody></table>', 4], + SELECT: ['<select>', '</select>', 1] + } +}; + +(function() { + Object.extend(this.tags, { + THEAD: this.tags.TBODY, + TFOOT: this.tags.TBODY, + TH: this.tags.TD + }); +}).call(Element._insertionTranslations); + +Element.Methods.Simulated = { + hasAttribute: function(element, attribute) { + attribute = Element._attributeTranslations.has[attribute] || attribute; + var node = $(element).getAttributeNode(attribute); + return !!(node && node.specified); + } +}; + +Element.Methods.ByTag = { }; + +Object.extend(Element, Element.Methods); + +if (!Prototype.BrowserFeatures.ElementExtensions && + document.createElement('div')['__proto__']) { + window.HTMLElement = { }; + window.HTMLElement.prototype = document.createElement('div')['__proto__']; + Prototype.BrowserFeatures.ElementExtensions = true; +} + +Element.extend = (function() { + if (Prototype.BrowserFeatures.SpecificElementExtensions) + return Prototype.K; + + var Methods = { }, ByTag = Element.Methods.ByTag; + + var extend = Object.extend(function(element) { + if (!element || element._extendedByPrototype || + element.nodeType != 1 || element == window) return element; + + var methods = Object.clone(Methods), + tagName = element.tagName.toUpperCase(), property, value; + + // extend methods for specific tags + if (ByTag[tagName]) Object.extend(methods, ByTag[tagName]); + + for (property in methods) { + value = methods[property]; + if (Object.isFunction(value) && !(property in element)) + element[property] = value.methodize(); + } + + element._extendedByPrototype = Prototype.emptyFunction; + return element; + + }, { + refresh: function() { + // extend methods for all tags (Safari doesn't need this) + if (!Prototype.BrowserFeatures.ElementExtensions) { + Object.extend(Methods, Element.Methods); + Object.extend(Methods, Element.Methods.Simulated); + } + } + }); + + extend.refresh(); + return extend; +})(); + +Element.hasAttribute = function(element, attribute) { + if (element.hasAttribute) return element.hasAttribute(attribute); + return Element.Methods.Simulated.hasAttribute(element, attribute); +}; + +Element.addMethods = function(methods) { + var F = Prototype.BrowserFeatures, T = Element.Methods.ByTag; + + if (!methods) { + Object.extend(Form, Form.Methods); + Object.extend(Form.Element, Form.Element.Methods); + Object.extend(Element.Methods.ByTag, { + "FORM": Object.clone(Form.Methods), + "INPUT": Object.clone(Form.Element.Methods), + "SELECT": Object.clone(Form.Element.Methods), + "TEXTAREA": Object.clone(Form.Element.Methods) + }); + } + + if (arguments.length == 2) { + var tagName = methods; + methods = arguments[1]; + } + + if (!tagName) Object.extend(Element.Methods, methods || { }); + else { + if (Object.isArray(tagName)) tagName.each(extend); + else extend(tagName); + } + + function extend(tagName) { + tagName = tagName.toUpperCase(); + if (!Element.Methods.ByTag[tagName]) + Element.Methods.ByTag[tagName] = { }; + Object.extend(Element.Methods.ByTag[tagName], methods); + } + + function copy(methods, destination, onlyIfAbsent) { + onlyIfAbsent = onlyIfAbsent || false; + for (var property in methods) { + var value = methods[property]; + if (!Object.isFunction(value)) continue; + if (!onlyIfAbsent || !(property in destination)) + destination[property] = value.methodize(); + } + } + + function findDOMClass(tagName) { + var klass; + var trans = { + "OPTGROUP": "OptGroup", "TEXTAREA": "TextArea", "P": "Paragraph", + "FIELDSET": "FieldSet", "UL": "UList", "OL": "OList", "DL": "DList", + "DIR": "Directory", "H1": "Heading", "H2": "Heading", "H3": "Heading", + "H4": "Heading", "H5": "Heading", "H6": "Heading", "Q": "Quote", + "INS": "Mod", "DEL": "Mod", "A": "Anchor", "IMG": "Image", "CAPTION": + "TableCaption", "COL": "TableCol", "COLGROUP": "TableCol", "THEAD": + "TableSection", "TFOOT": "TableSection", "TBODY": "TableSection", "TR": + "TableRow", "TH": "TableCell", "TD": "TableCell", "FRAMESET": + "FrameSet", "IFRAME": "IFrame" + }; + if (trans[tagName]) klass = 'HTML' + trans[tagName] + 'Element'; + if (window[klass]) return window[klass]; + klass = 'HTML' + tagName + 'Element'; + if (window[klass]) return window[klass]; + klass = 'HTML' + tagName.capitalize() + 'Element'; + if (window[klass]) return window[klass]; + + window[klass] = { }; + window[klass].prototype = document.createElement(tagName)['__proto__']; + return window[klass]; + } + + if (F.ElementExtensions) { + copy(Element.Methods, HTMLElement.prototype); + copy(Element.Methods.Simulated, HTMLElement.prototype, true); + } + + if (F.SpecificElementExtensions) { + for (var tag in Element.Methods.ByTag) { + var klass = findDOMClass(tag); + if (Object.isUndefined(klass)) continue; + copy(T[tag], klass.prototype); + } + } + + Object.extend(Element, Element.Methods); + delete Element.ByTag; + + if (Element.extend.refresh) Element.extend.refresh(); + Element.cache = { }; +}; + +document.viewport = { + getDimensions: function() { + var dimensions = { }, B = Prototype.Browser; + $w('width height').each(function(d) { + var D = d.capitalize(); + if (B.WebKit && !document.evaluate) { + // Safari <3.0 needs self.innerWidth/Height + dimensions[d] = self['inner' + D]; + } else if (B.Opera && parseFloat(window.opera.version()) < 9.5) { + // Opera <9.5 needs document.body.clientWidth/Height + dimensions[d] = document.body['client' + D] + } else { + dimensions[d] = document.documentElement['client' + D]; + } + }); + return dimensions; + }, + + getWidth: function() { + return this.getDimensions().width; + }, + + getHeight: function() { + return this.getDimensions().height; + }, + + getScrollOffsets: function() { + return Element._returnOffset( + window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft, + window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop); + } +}; +/* Portions of the Selector class are derived from Jack Slocum's DomQuery, + * part of YUI-Ext version 0.40, distributed under the terms of an MIT-style + * license. Please see http://www.yui-ext.com/ for more information. */ + +var Selector = Class.create({ + initialize: function(expression) { + this.expression = expression.strip(); + + if (this.shouldUseSelectorsAPI()) { + this.mode = 'selectorsAPI'; + } else if (this.shouldUseXPath()) { + this.mode = 'xpath'; + this.compileXPathMatcher(); + } else { + this.mode = "normal"; + this.compileMatcher(); + } + + }, + + shouldUseXPath: function() { + if (!Prototype.BrowserFeatures.XPath) return false; + + var e = this.expression; + + // Safari 3 chokes on :*-of-type and :empty + if (Prototype.Browser.WebKit && + (e.include("-of-type") || e.include(":empty"))) + return false; + + // XPath can't do namespaced attributes, nor can it read + // the "checked" property from DOM nodes + if ((/(\[[\w-]*?:|:checked)/).test(e)) + return false; + + return true; + }, + + shouldUseSelectorsAPI: function() { + if (!Prototype.BrowserFeatures.SelectorsAPI) return false; + + if (!Selector._div) Selector._div = new Element('div'); + + // Make sure the browser treats the selector as valid. Test on an + // isolated element to minimize cost of this check. + try { + Selector._div.querySelector(this.expression); + } catch(e) { + return false; + } + + return true; + }, + + compileMatcher: function() { + var e = this.expression, ps = Selector.patterns, h = Selector.handlers, + c = Selector.criteria, le, p, m; + + if (Selector._cache[e]) { + this.matcher = Selector._cache[e]; + return; + } + + this.matcher = ["this.matcher = function(root) {", + "var r = root, h = Selector.handlers, c = false, n;"]; + + while (e && le != e && (/\S/).test(e)) { + le = e; + for (var i in ps) { + p = ps[i]; + if (m = e.match(p)) { + this.matcher.push(Object.isFunction(c[i]) ? c[i](m) : + new Template(c[i]).evaluate(m)); + e = e.replace(m[0], ''); + break; + } + } + } + + this.matcher.push("return h.unique(n);\n}"); + eval(this.matcher.join('\n')); + Selector._cache[this.expression] = this.matcher; + }, + + compileXPathMatcher: function() { + var e = this.expression, ps = Selector.patterns, + x = Selector.xpath, le, m; + + if (Selector._cache[e]) { + this.xpath = Selector._cache[e]; return; + } + + this.matcher = ['.//*']; + while (e && le != e && (/\S/).test(e)) { + le = e; + for (var i in ps) { + if (m = e.match(ps[i])) { + this.matcher.push(Object.isFunction(x[i]) ? x[i](m) : + new Template(x[i]).evaluate(m)); + e = e.replace(m[0], ''); + break; + } + } + } + + this.xpath = this.matcher.join(''); + Selector._cache[this.expression] = this.xpath; + }, + + findElements: function(root) { + root = root || document; + var e = this.expression, results; + + switch (this.mode) { + case 'selectorsAPI': + // querySelectorAll queries document-wide, then filters to descendants + // of the context element. That's not what we want. + // Add an explicit context to the selector if necessary. + if (root !== document) { + var oldId = root.id, id = $(root).identify(); + e = "#" + id + " " + e; + } + + results = $A(root.querySelectorAll(e)).map(Element.extend); + root.id = oldId; + + return results; + case 'xpath': + return document._getElementsByXPath(this.xpath, root); + default: + return this.matcher(root); + } + }, + + match: function(element) { + this.tokens = []; + + var e = this.expression, ps = Selector.patterns, as = Selector.assertions; + var le, p, m; + + while (e && le !== e && (/\S/).test(e)) { + le = e; + for (var i in ps) { + p = ps[i]; + if (m = e.match(p)) { + // use the Selector.assertions methods unless the selector + // is too complex. + if (as[i]) { + this.tokens.push([i, Object.clone(m)]); + e = e.replace(m[0], ''); + } else { + // reluctantly do a document-wide search + // and look for a match in the array + return this.findElements(document).include(element); + } + } + } + } + + var match = true, name, matches; + for (var i = 0, token; token = this.tokens[i]; i++) { + name = token[0], matches = token[1]; + if (!Selector.assertions[name](element, matches)) { + match = false; break; + } + } + + return match; + }, + + toString: function() { + return this.expression; + }, + + inspect: function() { + return "#<Selector:" + this.expression.inspect() + ">"; + } +}); + +Object.extend(Selector, { + _cache: { }, + + xpath: { + descendant: "//*", + child: "/*", + adjacent: "/following-sibling::*[1]", + laterSibling: '/following-sibling::*', + tagName: function(m) { + if (m[1] == '*') return ''; + return "[local-name()='" + m[1].toLowerCase() + + "' or local-name()='" + m[1].toUpperCase() + "']"; + }, + className: "[contains(concat(' ', @class, ' '), ' #{1} ')]", + id: "[@id='#{1}']", + attrPresence: function(m) { + m[1] = m[1].toLowerCase(); + return new Template("[@#{1}]").evaluate(m); + }, + attr: function(m) { + m[1] = m[1].toLowerCase(); + m[3] = m[5] || m[6]; + return new Template(Selector.xpath.operators[m[2]]).evaluate(m); + }, + pseudo: function(m) { + var h = Selector.xpath.pseudos[m[1]]; + if (!h) return ''; + if (Object.isFunction(h)) return h(m); + return new Template(Selector.xpath.pseudos[m[1]]).evaluate(m); + }, + operators: { + '=': "[@#{1}='#{3}']", + '!=': "[@#{1}!='#{3}']", + '^=': "[starts-with(@#{1}, '#{3}')]", + '$=': "[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']", + '*=': "[contains(@#{1}, '#{3}')]", + '~=': "[contains(concat(' ', @#{1}, ' '), ' #{3} ')]", + '|=': "[contains(concat('-', @#{1}, '-'), '-#{3}-')]" + }, + pseudos: { + 'first-child': '[not(preceding-sibling::*)]', + 'last-child': '[not(following-sibling::*)]', + 'only-child': '[not(preceding-sibling::* or following-sibling::*)]', + 'empty': "[count(*) = 0 and (count(text()) = 0)]", + 'checked': "[@checked]", + 'disabled': "[(@disabled) and (@type!='hidden')]", + 'enabled': "[not(@disabled) and (@type!='hidden')]", + 'not': function(m) { + var e = m[6], p = Selector.patterns, + x = Selector.xpath, le, v; + + var exclusion = []; + while (e && le != e && (/\S/).test(e)) { + le = e; + for (var i in p) { + if (m = e.match(p[i])) { + v = Object.isFunction(x[i]) ? x[i](m) : new Template(x[i]).evaluate(m); + exclusion.push("(" + v.substring(1, v.length - 1) + ")"); + e = e.replace(m[0], ''); + break; + } + } + } + return "[not(" + exclusion.join(" and ") + ")]"; + }, + 'nth-child': function(m) { + return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ", m); + }, + 'nth-last-child': function(m) { + return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ", m); + }, + 'nth-of-type': function(m) { + return Selector.xpath.pseudos.nth("position() ", m); + }, + 'nth-last-of-type': function(m) { + return Selector.xpath.pseudos.nth("(last() + 1 - position()) ", m); + }, + 'first-of-type': function(m) { + m[6] = "1"; return Selector.xpath.pseudos['nth-of-type'](m); + }, + 'last-of-type': function(m) { + m[6] = "1"; return Selector.xpath.pseudos['nth-last-of-type'](m); + }, + 'only-of-type': function(m) { + var p = Selector.xpath.pseudos; return p['first-of-type'](m) + p['last-of-type'](m); + }, + nth: function(fragment, m) { + var mm, formula = m[6], predicate; + if (formula == 'even') formula = '2n+0'; + if (formula == 'odd') formula = '2n+1'; + if (mm = formula.match(/^(\d+)$/)) // digit only + return '[' + fragment + "= " + mm[1] + ']'; + if (mm = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b + if (mm[1] == "-") mm[1] = -1; + var a = mm[1] ? Number(mm[1]) : 1; + var b = mm[2] ? Number(mm[2]) : 0; + predicate = "[((#{fragment} - #{b}) mod #{a} = 0) and " + + "((#{fragment} - #{b}) div #{a} >= 0)]"; + return new Template(predicate).evaluate({ + fragment: fragment, a: a, b: b }); + } + } + } + }, + + criteria: { + tagName: 'n = h.tagName(n, r, "#{1}", c); c = false;', + className: 'n = h.className(n, r, "#{1}", c); c = false;', + id: 'n = h.id(n, r, "#{1}", c); c = false;', + attrPresence: 'n = h.attrPresence(n, r, "#{1}", c); c = false;', + attr: function(m) { + m[3] = (m[5] || m[6]); + return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}", c); c = false;').evaluate(m); + }, + pseudo: function(m) { + if (m[6]) m[6] = m[6].replace(/"/g, '\\"'); + return new Template('n = h.pseudo(n, "#{1}", "#{6}", r, c); c = false;').evaluate(m); + }, + descendant: 'c = "descendant";', + child: 'c = "child";', + adjacent: 'c = "adjacent";', + laterSibling: 'c = "laterSibling";' + }, + + patterns: { + // combinators must be listed first + // (and descendant needs to be last combinator) + laterSibling: /^\s*~\s*/, + child: /^\s*>\s*/, + adjacent: /^\s*\+\s*/, + descendant: /^\s/, + + // selectors follow + tagName: /^\s*(\*|[\w\-]+)(\b|$)?/, + id: /^#([\w\-\*]+)(\b|$)/, + className: /^\.([\w\-\*]+)(\b|$)/, + pseudo: +/^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s|[:+~>]))/, + attrPresence: /^\[((?:[\w]+:)?[\w]+)\]/, + attr: /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/ + }, + + // for Selector.match and Element#match + assertions: { + tagName: function(element, matches) { + return matches[1].toUpperCase() == element.tagName.toUpperCase(); + }, + + className: function(element, matches) { + return Element.hasClassName(element, matches[1]); + }, + + id: function(element, matches) { + return element.id === matches[1]; + }, + + attrPresence: function(element, matches) { + return Element.hasAttribute(element, matches[1]); + }, + + attr: function(element, matches) { + var nodeValue = Element.readAttribute(element, matches[1]); + return nodeValue && Selector.operators[matches[2]](nodeValue, matches[5] || matches[6]); + } + }, + + handlers: { + // UTILITY FUNCTIONS + // joins two collections + concat: function(a, b) { + for (var i = 0, node; node = b[i]; i++) + a.push(node); + return a; + }, + + // marks an array of nodes for counting + mark: function(nodes) { + var _true = Prototype.emptyFunction; + for (var i = 0, node; node = nodes[i]; i++) + node._countedByPrototype = _true; + return nodes; + }, + + unmark: function(nodes) { + for (var i = 0, node; node = nodes[i]; i++) + node._countedByPrototype = undefined; + return nodes; + }, + + // mark each child node with its position (for nth calls) + // "ofType" flag indicates whether we're indexing for nth-of-type + // rather than nth-child + index: function(parentNode, reverse, ofType) { + parentNode._countedByPrototype = Prototype.emptyFunction; + if (reverse) { + for (var nodes = parentNode.childNodes, i = nodes.length - 1, j = 1; i >= 0; i--) { + var node = nodes[i]; + if (node.nodeType == 1 && (!ofType || node._countedByPrototype)) node.nodeIndex = j++; + } + } else { + for (var i = 0, j = 1, nodes = parentNode.childNodes; node = nodes[i]; i++) + if (node.nodeType == 1 && (!ofType || node._countedByPrototype)) node.nodeIndex = j++; + } + }, + + // filters out duplicates and extends all nodes + unique: function(nodes) { + if (nodes.length == 0) return nodes; + var results = [], n; + for (var i = 0, l = nodes.length; i < l; i++) + if (!(n = nodes[i])._countedByPrototype) { + n._countedByPrototype = Prototype.emptyFunction; + results.push(Element.extend(n)); + } + return Selector.handlers.unmark(results); + }, + + // COMBINATOR FUNCTIONS + descendant: function(nodes) { + var h = Selector.handlers; + for (var i = 0, results = [], node; node = nodes[i]; i++) + h.concat(results, node.getElementsByTagName('*')); + return results; + }, + + child: function(nodes) { + var h = Selector.handlers; + for (var i = 0, results = [], node; node = nodes[i]; i++) { + for (var j = 0, child; child = node.childNodes[j]; j++) + if (child.nodeType == 1 && child.tagName != '!') results.push(child); + } + return results; + }, + + adjacent: function(nodes) { + for (var i = 0, results = [], node; node = nodes[i]; i++) { + var next = this.nextElementSibling(node); + if (next) results.push(next); + } + return results; + }, + + laterSibling: function(nodes) { + var h = Selector.handlers; + for (var i = 0, results = [], node; node = nodes[i]; i++) + h.concat(results, Element.nextSiblings(node)); + return results; + }, + + nextElementSibling: function(node) { + while (node = node.nextSibling) + if (node.nodeType == 1) return node; + return null; + }, + + previousElementSibling: function(node) { + while (node = node.previousSibling) + if (node.nodeType == 1) return node; + return null; + }, + + // TOKEN FUNCTIONS + tagName: function(nodes, root, tagName, combinator) { + var uTagName = tagName.toUpperCase(); + var results = [], h = Selector.handlers; + if (nodes) { + if (combinator) { + // fastlane for ordinary descendant combinators + if (combinator == "descendant") { + for (var i = 0, node; node = nodes[i]; i++) + h.concat(results, node.getElementsByTagName(tagName)); + return results; + } else nodes = this[combinator](nodes); + if (tagName == "*") return nodes; + } + for (var i = 0, node; node = nodes[i]; i++) + if (node.tagName.toUpperCase() === uTagName) results.push(node); + return results; + } else return root.getElementsByTagName(tagName); + }, + + id: function(nodes, root, id, combinator) { + var targetNode = $(id), h = Selector.handlers; + if (!targetNode) return []; + if (!nodes && root == document) return [targetNode]; + if (nodes) { + if (combinator) { + if (combinator == 'child') { + for (var i = 0, node; node = nodes[i]; i++) + if (targetNode.parentNode == node) return [targetNode]; + } else if (combinator == 'descendant') { + for (var i = 0, node; node = nodes[i]; i++) + if (Element.descendantOf(targetNode, node)) return [targetNode]; + } else if (combinator == 'adjacent') { + for (var i = 0, node; node = nodes[i]; i++) + if (Selector.handlers.previousElementSibling(targetNode) == node) + return [targetNode]; + } else nodes = h[combinator](nodes); + } + for (var i = 0, node; node = nodes[i]; i++) + if (node == targetNode) return [targetNode]; + return []; + } + return (targetNode && Element.descendantOf(targetNode, root)) ? [targetNode] : []; + }, + + className: function(nodes, root, className, combinator) { + if (nodes && combinator) nodes = this[combinator](nodes); + return Selector.handlers.byClassName(nodes, root, className); + }, + + byClassName: function(nodes, root, className) { + if (!nodes) nodes = Selector.handlers.descendant([root]); + var needle = ' ' + className + ' '; + for (var i = 0, results = [], node, nodeClassName; node = nodes[i]; i++) { + nodeClassName = node.className; + if (nodeClassName.length == 0) continue; + if (nodeClassName == className || (' ' + nodeClassName + ' ').include(needle)) + results.push(node); + } + return results; + }, + + attrPresence: function(nodes, root, attr, combinator) { + if (!nodes) nodes = root.getElementsByTagName("*"); + if (nodes && combinator) nodes = this[combinator](nodes); + var results = []; + for (var i = 0, node; node = nodes[i]; i++) + if (Element.hasAttribute(node, attr)) results.push(node); + return results; + }, + + attr: function(nodes, root, attr, value, operator, combinator) { + if (!nodes) nodes = root.getElementsByTagName("*"); + if (nodes && combinator) nodes = this[combinator](nodes); + var handler = Selector.operators[operator], results = []; + for (var i = 0, node; node = nodes[i]; i++) { + var nodeValue = Element.readAttribute(node, attr); + if (nodeValue === null) continue; + if (handler(nodeValue, value)) results.push(node); + } + return results; + }, + + pseudo: function(nodes, name, value, root, combinator) { + if (nodes && combinator) nodes = this[combinator](nodes); + if (!nodes) nodes = root.getElementsByTagName("*"); + return Selector.pseudos[name](nodes, value, root); + } + }, + + pseudos: { + 'first-child': function(nodes, value, root) { + for (var i = 0, results = [], node; node = nodes[i]; i++) { + if (Selector.handlers.previousElementSibling(node)) continue; + results.push(node); + } + return results; + }, + 'last-child': function(nodes, value, root) { + for (var i = 0, results = [], node; node = nodes[i]; i++) { + if (Selector.handlers.nextElementSibling(node)) continue; + results.push(node); + } + return results; + }, + 'only-child': function(nodes, value, root) { + var h = Selector.handlers; + for (var i = 0, results = [], node; node = nodes[i]; i++) + if (!h.previousElementSibling(node) && !h.nextElementSibling(node)) + results.push(node); + return results; + }, + 'nth-child': function(nodes, formula, root) { + return Selector.pseudos.nth(nodes, formula, root); + }, + 'nth-last-child': function(nodes, formula, root) { + return Selector.pseudos.nth(nodes, formula, root, true); + }, + 'nth-of-type': function(nodes, formula, root) { + return Selector.pseudos.nth(nodes, formula, root, false, true); + }, + 'nth-last-of-type': function(nodes, formula, root) { + return Selector.pseudos.nth(nodes, formula, root, true, true); + }, + 'first-of-type': function(nodes, formula, root) { + return Selector.pseudos.nth(nodes, "1", root, false, true); + }, + 'last-of-type': function(nodes, formula, root) { + return Selector.pseudos.nth(nodes, "1", root, true, true); + }, + 'only-of-type': function(nodes, formula, root) { + var p = Selector.pseudos; + return p['last-of-type'](p['first-of-type'](nodes, formula, root), formula, root); + }, + + // handles the an+b logic + getIndices: function(a, b, total) { + if (a == 0) return b > 0 ? [b] : []; + return $R(1, total).inject([], function(memo, i) { + if (0 == (i - b) % a && (i - b) / a >= 0) memo.push(i); + return memo; + }); + }, + + // handles nth(-last)-child, nth(-last)-of-type, and (first|last)-of-type + nth: function(nodes, formula, root, reverse, ofType) { + if (nodes.length == 0) return []; + if (formula == 'even') formula = '2n+0'; + if (formula == 'odd') formula = '2n+1'; + var h = Selector.handlers, results = [], indexed = [], m; + h.mark(nodes); + for (var i = 0, node; node = nodes[i]; i++) { + if (!node.parentNode._countedByPrototype) { + h.index(node.parentNode, reverse, ofType); + indexed.push(node.parentNode); + } + } + if (formula.match(/^\d+$/)) { // just a number + formula = Number(formula); + for (var i = 0, node; node = nodes[i]; i++) + if (node.nodeIndex == formula) results.push(node); + } else if (m = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b + if (m[1] == "-") m[1] = -1; + var a = m[1] ? Number(m[1]) : 1; + var b = m[2] ? Number(m[2]) : 0; + var indices = Selector.pseudos.getIndices(a, b, nodes.length); + for (var i = 0, node, l = indices.length; node = nodes[i]; i++) { + for (var j = 0; j < l; j++) + if (node.nodeIndex == indices[j]) results.push(node); + } + } + h.unmark(nodes); + h.unmark(indexed); + return results; + }, + + 'empty': function(nodes, value, root) { + for (var i = 0, results = [], node; node = nodes[i]; i++) { + // IE treats comments as element nodes + if (node.tagName == '!' || node.firstChild) continue; + results.push(node); + } + return results; + }, + + 'not': function(nodes, selector, root) { + var h = Selector.handlers, selectorType, m; + var exclusions = new Selector(selector).findElements(root); + h.mark(exclusions); + for (var i = 0, results = [], node; node = nodes[i]; i++) + if (!node._countedByPrototype) results.push(node); + h.unmark(exclusions); + return results; + }, + + 'enabled': function(nodes, value, root) { + for (var i = 0, results = [], node; node = nodes[i]; i++) + if (!node.disabled && (!node.type || node.type !== 'hidden')) + results.push(node); + return results; + }, + + 'disabled': function(nodes, value, root) { + for (var i = 0, results = [], node; node = nodes[i]; i++) + if (node.disabled) results.push(node); + return results; + }, + + 'checked': function(nodes, value, root) { + for (var i = 0, results = [], node; node = nodes[i]; i++) + if (node.checked) results.push(node); + return results; + } + }, + + operators: { + '=': function(nv, v) { return nv == v; }, + '!=': function(nv, v) { return nv != v; }, + '^=': function(nv, v) { return nv == v || nv && nv.startsWith(v); }, + '$=': function(nv, v) { return nv == v || nv && nv.endsWith(v); }, + '*=': function(nv, v) { return nv == v || nv && nv.include(v); }, + '$=': function(nv, v) { return nv.endsWith(v); }, + '*=': function(nv, v) { return nv.include(v); }, + '~=': function(nv, v) { return (' ' + nv + ' ').include(' ' + v + ' '); }, + '|=': function(nv, v) { return ('-' + (nv || "").toUpperCase() + + '-').include('-' + (v || "").toUpperCase() + '-'); } + }, + + split: function(expression) { + var expressions = []; + expression.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/, function(m) { + expressions.push(m[1].strip()); + }); + return expressions; + }, + + matchElements: function(elements, expression) { + var matches = $$(expression), h = Selector.handlers; + h.mark(matches); + for (var i = 0, results = [], element; element = elements[i]; i++) + if (element._countedByPrototype) results.push(element); + h.unmark(matches); + return results; + }, + + findElement: function(elements, expression, index) { + if (Object.isNumber(expression)) { + index = expression; expression = false; + } + return Selector.matchElements(elements, expression || '*')[index || 0]; + }, + + findChildElements: function(element, expressions) { + expressions = Selector.split(expressions.join(',')); + var results = [], h = Selector.handlers; + for (var i = 0, l = expressions.length, selector; i < l; i++) { + selector = new Selector(expressions[i].strip()); + h.concat(results, selector.findElements(element)); + } + return (l > 1) ? h.unique(results) : results; + } +}); + +if (Prototype.Browser.IE) { + Object.extend(Selector.handlers, { + // IE returns comment nodes on getElementsByTagName("*"). + // Filter them out. + concat: function(a, b) { + for (var i = 0, node; node = b[i]; i++) + if (node.tagName !== "!") a.push(node); + return a; + }, + + // IE improperly serializes _countedByPrototype in (inner|outer)HTML. + unmark: function(nodes) { + for (var i = 0, node; node = nodes[i]; i++) + node.removeAttribute('_countedByPrototype'); + return nodes; + } + }); +} + +function $$() { + return Selector.findChildElements(document, $A(arguments)); +} +var Form = { + reset: function(form) { + $(form).reset(); + return form; + }, + + serializeElements: function(elements, options) { + if (typeof options != 'object') options = { hash: !!options }; + else if (Object.isUndefined(options.hash)) options.hash = true; + var key, value, submitted = false, submit = options.submit; + + var data = elements.inject({ }, function(result, element) { + if (!element.disabled && element.name) { + key = element.name; value = $(element).getValue(); + if (value != null && element.type != 'file' && (element.type != 'submit' || (!submitted && + submit !== false && (!submit || key == submit) && (submitted = true)))) { + if (key in result) { + // a key is already present; construct an array of values + if (!Object.isArray(result[key])) result[key] = [result[key]]; + result[key].push(value); + } + else result[key] = value; + } + } + return result; + }); + + return options.hash ? data : Object.toQueryString(data); + } +}; + +Form.Methods = { + serialize: function(form, options) { + return Form.serializeElements(Form.getElements(form), options); + }, + + getElements: function(form) { + return $A($(form).getElementsByTagName('*')).inject([], + function(elements, child) { + if (Form.Element.Serializers[child.tagName.toLowerCase()]) + elements.push(Element.extend(child)); + return elements; + } + ); + }, + + getInputs: function(form, typeName, name) { + form = $(form); + var inputs = form.getElementsByTagName('input'); + + if (!typeName && !name) return $A(inputs).map(Element.extend); + + for (var i = 0, matchingInputs = [], length = inputs.length; i < length; i++) { + var input = inputs[i]; + if ((typeName && input.type != typeName) || (name && input.name != name)) + continue; + matchingInputs.push(Element.extend(input)); + } + + return matchingInputs; + }, + + disable: function(form) { + form = $(form); + Form.getElements(form).invoke('disable'); + return form; + }, + + enable: function(form) { + form = $(form); + Form.getElements(form).invoke('enable'); + return form; + }, + + findFirstElement: function(form) { + var elements = $(form).getElements().findAll(function(element) { + return 'hidden' != element.type && !element.disabled; + }); + var firstByIndex = elements.findAll(function(element) { + return element.hasAttribute('tabIndex') && element.tabIndex >= 0; + }).sortBy(function(element) { return element.tabIndex }).first(); + + return firstByIndex ? firstByIndex : elements.find(function(element) { + return ['input', 'select', 'textarea'].include(element.tagName.toLowerCase()); + }); + }, + + focusFirstElement: function(form) { + form = $(form); + form.findFirstElement().activate(); + return form; + }, + + request: function(form, options) { + form = $(form), options = Object.clone(options || { }); + + var params = options.parameters, action = form.readAttribute('action') || ''; + if (action.blank()) action = window.location.href; + options.parameters = form.serialize(true); + + if (params) { + if (Object.isString(params)) params = params.toQueryParams(); + Object.extend(options.parameters, params); + } + + if (form.hasAttribute('method') && !options.method) + options.method = form.method; + + return new Ajax.Request(action, options); + } +}; + +/*--------------------------------------------------------------------------*/ + +Form.Element = { + focus: function(element) { + $(element).focus(); + return element; + }, + + select: function(element) { + $(element).select(); + return element; + } +}; + +Form.Element.Methods = { + serialize: function(element) { + element = $(element); + if (!element.disabled && element.name) { + var value = element.getValue(); + if (value != undefined) { + var pair = { }; + pair[element.name] = value; + return Object.toQueryString(pair); + } + } + return ''; + }, + + getValue: function(element) { + element = $(element); + var method = element.tagName.toLowerCase(); + return Form.Element.Serializers[method](element); + }, + + setValue: function(element, value) { + element = $(element); + var method = element.tagName.toLowerCase(); + Form.Element.Serializers[method](element, value); + return element; + }, + + clear: function(element) { + $(element).value = ''; + return element; + }, + + present: function(element) { + return $(element).value != ''; + }, + + activate: function(element) { + element = $(element); + try { + element.focus(); + if (element.select && (element.tagName.toLowerCase() != 'input' || + !['button', 'reset', 'submit'].include(element.type))) + element.select(); + } catch (e) { } + return element; + }, + + disable: function(element) { + element = $(element); + element.disabled = true; + return element; + }, + + enable: function(element) { + element = $(element); + element.disabled = false; + return element; + } +}; + +/*--------------------------------------------------------------------------*/ + +var Field = Form.Element; +var $F = Form.Element.Methods.getValue; + +/*--------------------------------------------------------------------------*/ + +Form.Element.Serializers = { + input: function(element, value) { + switch (element.type.toLowerCase()) { + case 'checkbox': + case 'radio': + return Form.Element.Serializers.inputSelector(element, value); + default: + return Form.Element.Serializers.textarea(element, value); + } + }, + + inputSelector: function(element, value) { + if (Object.isUndefined(value)) return element.checked ? element.value : null; + else element.checked = !!value; + }, + + textarea: function(element, value) { + if (Object.isUndefined(value)) return element.value; + else element.value = value; + }, + + select: function(element, value) { + if (Object.isUndefined(value)) + return this[element.type == 'select-one' ? + 'selectOne' : 'selectMany'](element); + else { + var opt, currentValue, single = !Object.isArray(value); + for (var i = 0, length = element.length; i < length; i++) { + opt = element.options[i]; + currentValue = this.optionValue(opt); + if (single) { + if (currentValue == value) { + opt.selected = true; + return; + } + } + else opt.selected = value.include(currentValue); + } + } + }, + + selectOne: function(element) { + var index = element.selectedIndex; + return index >= 0 ? this.optionValue(element.options[index]) : null; + }, + + selectMany: function(element) { + var values, length = element.length; + if (!length) return null; + + for (var i = 0, values = []; i < length; i++) { + var opt = element.options[i]; + if (opt.selected) values.push(this.optionValue(opt)); + } + return values; + }, + + optionValue: function(opt) { + // extend element because hasAttribute may not be native + return Element.extend(opt).hasAttribute('value') ? opt.value : opt.text; + } +}; + +/*--------------------------------------------------------------------------*/ + +Abstract.TimedObserver = Class.create(PeriodicalExecuter, { + initialize: function($super, element, frequency, callback) { + $super(callback, frequency); + this.element = $(element); + this.lastValue = this.getValue(); + }, + + execute: function() { + var value = this.getValue(); + if (Object.isString(this.lastValue) && Object.isString(value) ? + this.lastValue != value : String(this.lastValue) != String(value)) { + this.callback(this.element, value); + this.lastValue = value; + } + } +}); + +Form.Element.Observer = Class.create(Abstract.TimedObserver, { + getValue: function() { + return Form.Element.getValue(this.element); + } +}); + +Form.Observer = Class.create(Abstract.TimedObserver, { + getValue: function() { + return Form.serialize(this.element); + } +}); + +/*--------------------------------------------------------------------------*/ + +Abstract.EventObserver = Class.create({ + initialize: function(element, callback) { + this.element = $(element); + this.callback = callback; + + this.lastValue = this.getValue(); + if (this.element.tagName.toLowerCase() == 'form') + this.registerFormCallbacks(); + else + this.registerCallback(this.element); + }, + + onElementEvent: function() { + var value = this.getValue(); + if (this.lastValue != value) { + this.callback(this.element, value); + this.lastValue = value; + } + }, + + registerFormCallbacks: function() { + Form.getElements(this.element).each(this.registerCallback, this); + }, + + registerCallback: function(element) { + if (element.type) { + switch (element.type.toLowerCase()) { + case 'checkbox': + case 'radio': + Event.observe(element, 'click', this.onElementEvent.bind(this)); + break; + default: + Event.observe(element, 'change', this.onElementEvent.bind(this)); + break; + } + } + } +}); + +Form.Element.EventObserver = Class.create(Abstract.EventObserver, { + getValue: function() { + return Form.Element.getValue(this.element); + } +}); + +Form.EventObserver = Class.create(Abstract.EventObserver, { + getValue: function() { + return Form.serialize(this.element); + } +}); +if (!window.Event) var Event = { }; + +Object.extend(Event, { + KEY_BACKSPACE: 8, + KEY_TAB: 9, + KEY_RETURN: 13, + KEY_ESC: 27, + KEY_LEFT: 37, + KEY_UP: 38, + KEY_RIGHT: 39, + KEY_DOWN: 40, + KEY_DELETE: 46, + KEY_HOME: 36, + KEY_END: 35, + KEY_PAGEUP: 33, + KEY_PAGEDOWN: 34, + KEY_INSERT: 45, + + cache: { }, + + relatedTarget: function(event) { + var element; + switch(event.type) { + case 'mouseover': element = event.fromElement; break; + case 'mouseout': element = event.toElement; break; + default: return null; + } + return Element.extend(element); + } +}); + +Event.Methods = (function() { + var isButton; + + if (Prototype.Browser.IE) { + var buttonMap = { 0: 1, 1: 4, 2: 2 }; + isButton = function(event, code) { + return event.button == buttonMap[code]; + }; + + } else if (Prototype.Browser.WebKit) { + isButton = function(event, code) { + switch (code) { + case 0: return event.which == 1 && !event.metaKey; + case 1: return event.which == 1 && event.metaKey; + default: return false; + } + }; + + } else { + isButton = function(event, code) { + return event.which ? (event.which === code + 1) : (event.button === code); + }; + } + + return { + isLeftClick: function(event) { return isButton(event, 0) }, + isMiddleClick: function(event) { return isButton(event, 1) }, + isRightClick: function(event) { return isButton(event, 2) }, + + element: function(event) { + event = Event.extend(event); + + var node = event.target, + type = event.type, + currentTarget = event.currentTarget; + + if (currentTarget && currentTarget.tagName) { + // Firefox screws up the "click" event when moving between radio buttons + // via arrow keys. It also screws up the "load" and "error" events on images, + // reporting the document as the target instead of the original image. + if (type === 'load' || type === 'error' || + (type === 'click' && currentTarget.tagName.toLowerCase() === 'input' + && currentTarget.type === 'radio')) + node = currentTarget; + } + if (node.nodeType == Node.TEXT_NODE) node = node.parentNode; + return Element.extend(node); + }, + + findElement: function(event, expression) { + var element = Event.element(event); + if (!expression) return element; + var elements = [element].concat(element.ancestors()); + return Selector.findElement(elements, expression, 0); + }, + + pointer: function(event) { + var docElement = document.documentElement, + body = document.body || { scrollLeft: 0, scrollTop: 0 }; + return { + x: event.pageX || (event.clientX + + (docElement.scrollLeft || body.scrollLeft) - + (docElement.clientLeft || 0)), + y: event.pageY || (event.clientY + + (docElement.scrollTop || body.scrollTop) - + (docElement.clientTop || 0)) + }; + }, + + pointerX: function(event) { return Event.pointer(event).x }, + pointerY: function(event) { return Event.pointer(event).y }, + + stop: function(event) { + Event.extend(event); + event.preventDefault(); + event.stopPropagation(); + event.stopped = true; + } + }; +})(); + +Event.extend = (function() { + var methods = Object.keys(Event.Methods).inject({ }, function(m, name) { + m[name] = Event.Methods[name].methodize(); + return m; + }); + + if (Prototype.Browser.IE) { + Object.extend(methods, { + stopPropagation: function() { this.cancelBubble = true }, + preventDefault: function() { this.returnValue = false }, + inspect: function() { return "[object Event]" } + }); + + return function(event) { + if (!event) return false; + if (event._extendedByPrototype) return event; + + event._extendedByPrototype = Prototype.emptyFunction; + var pointer = Event.pointer(event); + Object.extend(event, { + target: event.srcElement, + relatedTarget: Event.relatedTarget(event), + pageX: pointer.x, + pageY: pointer.y + }); + return Object.extend(event, methods); + }; + + } else { + Event.prototype = Event.prototype || document.createEvent("HTMLEvents")['__proto__']; + Object.extend(Event.prototype, methods); + return Prototype.K; + } +})(); + +Object.extend(Event, (function() { + var cache = Event.cache; + + function getEventID(element) { + if (element._prototypeEventID) return element._prototypeEventID[0]; + arguments.callee.id = arguments.callee.id || 1; + return element._prototypeEventID = [++arguments.callee.id]; + } + + function getDOMEventName(eventName) { + if (eventName && eventName.include(':')) return "dataavailable"; + return eventName; + } + + function getCacheForID(id) { + return cache[id] = cache[id] || { }; + } + + function getWrappersForEventName(id, eventName) { + var c = getCacheForID(id); + return c[eventName] = c[eventName] || []; + } + + function createWrapper(element, eventName, handler) { + var id = getEventID(element); + var c = getWrappersForEventName(id, eventName); + if (c.pluck("handler").include(handler)) return false; + + var wrapper = function(event) { + if (!Event || !Event.extend || + (event.eventName && event.eventName != eventName)) + return false; + + Event.extend(event); + handler.call(element, event); + }; + + wrapper.handler = handler; + c.push(wrapper); + return wrapper; + } + + function findWrapper(id, eventName, handler) { + var c = getWrappersForEventName(id, eventName); + return c.find(function(wrapper) { return wrapper.handler == handler }); + } + + function destroyWrapper(id, eventName, handler) { + var c = getCacheForID(id); + if (!c[eventName]) return false; + c[eventName] = c[eventName].without(findWrapper(id, eventName, handler)); + } + + function destroyCache() { + for (var id in cache) + for (var eventName in cache[id]) + cache[id][eventName] = null; + } + + + // Internet Explorer needs to remove event handlers on page unload + // in order to avoid memory leaks. + if (window.attachEvent) { + window.attachEvent("onunload", destroyCache); + } + + // Safari has a dummy event handler on page unload so that it won't + // use its bfcache. Safari <= 3.1 has an issue with restoring the "document" + // object when page is returned to via the back button using its bfcache. + if (Prototype.Browser.WebKit) { + window.addEventListener('unload', Prototype.emptyFunction, false); + } + + return { + observe: function(element, eventName, handler) { + element = $(element); + var name = getDOMEventName(eventName); + + var wrapper = createWrapper(element, eventName, handler); + if (!wrapper) return element; + + if (element.addEventListener) { + element.addEventListener(name, wrapper, false); + } else { + element.attachEvent("on" + name, wrapper); + } + + return element; + }, + + stopObserving: function(element, eventName, handler) { + element = $(element); + var id = getEventID(element), name = getDOMEventName(eventName); + + if (!handler && eventName) { + getWrappersForEventName(id, eventName).each(function(wrapper) { + element.stopObserving(eventName, wrapper.handler); + }); + return element; + + } else if (!eventName) { + Object.keys(getCacheForID(id)).each(function(eventName) { + element.stopObserving(eventName); + }); + return element; + } + + var wrapper = findWrapper(id, eventName, handler); + if (!wrapper) return element; + + if (element.removeEventListener) { + element.removeEventListener(name, wrapper, false); + } else { + element.detachEvent("on" + name, wrapper); + } + + destroyWrapper(id, eventName, handler); + + return element; + }, + + fire: function(element, eventName, memo) { + element = $(element); + if (element == document && document.createEvent && !element.dispatchEvent) + element = document.documentElement; + + var event; + if (document.createEvent) { + event = document.createEvent("HTMLEvents"); + event.initEvent("dataavailable", true, true); + } else { + event = document.createEventObject(); + event.eventType = "ondataavailable"; + } + + event.eventName = eventName; + event.memo = memo || { }; + + if (document.createEvent) { + element.dispatchEvent(event); + } else { + element.fireEvent(event.eventType, event); + } + + return Event.extend(event); + } + }; +})()); + +Object.extend(Event, Event.Methods); + +Element.addMethods({ + fire: Event.fire, + observe: Event.observe, + stopObserving: Event.stopObserving +}); + +Object.extend(document, { + fire: Element.Methods.fire.methodize(), + observe: Element.Methods.observe.methodize(), + stopObserving: Element.Methods.stopObserving.methodize(), + loaded: false +}); + +(function() { + /* Support for the DOMContentLoaded event is based on work by Dan Webb, + Matthias Miller, Dean Edwards and John Resig. */ + + var timer; + + function fireContentLoadedEvent() { + if (document.loaded) return; + if (timer) window.clearInterval(timer); + document.fire("dom:loaded"); + document.loaded = true; + } + + if (document.addEventListener) { + if (Prototype.Browser.WebKit) { + timer = window.setInterval(function() { + if (/loaded|complete/.test(document.readyState)) + fireContentLoadedEvent(); + }, 0); + + Event.observe(window, "load", fireContentLoadedEvent); + + } else { + document.addEventListener("DOMContentLoaded", + fireContentLoadedEvent, false); + } + + } else { + document.write("<script id=__onDOMContentLoaded defer src=//:><\/script>"); + $("__onDOMContentLoaded").onreadystatechange = function() { + if (this.readyState == "complete") { + this.onreadystatechange = null; + fireContentLoadedEvent(); + } + }; + } +})(); +/*------------------------------- DEPRECATED -------------------------------*/ + +Hash.toQueryString = Object.toQueryString; + +var Toggle = { display: Element.toggle }; + +Element.Methods.childOf = Element.Methods.descendantOf; + +var Insertion = { + Before: function(element, content) { + return Element.insert(element, {before:content}); + }, + + Top: function(element, content) { + return Element.insert(element, {top:content}); + }, + + Bottom: function(element, content) { + return Element.insert(element, {bottom:content}); + }, + + After: function(element, content) { + return Element.insert(element, {after:content}); + } +}; + +var $continue = new Error('"throw $continue" is deprecated, use "return" instead'); + +// This should be moved to script.aculo.us; notice the deprecated methods +// further below, that map to the newer Element methods. +var Position = { + // set to true if needed, warning: firefox performance problems + // NOT neeeded for page scrolling, only if draggable contained in + // scrollable elements + includeScrollOffsets: false, + + // must be called before calling withinIncludingScrolloffset, every time the + // page is scrolled + prepare: function() { + this.deltaX = window.pageXOffset + || document.documentElement.scrollLeft + || document.body.scrollLeft + || 0; + this.deltaY = window.pageYOffset + || document.documentElement.scrollTop + || document.body.scrollTop + || 0; + }, + + // caches x/y coordinate pair to use with overlap + within: function(element, x, y) { + if (this.includeScrollOffsets) + return this.withinIncludingScrolloffsets(element, x, y); + this.xcomp = x; + this.ycomp = y; + this.offset = Element.cumulativeOffset(element); + + return (y >= this.offset[1] && + y < this.offset[1] + element.offsetHeight && + x >= this.offset[0] && + x < this.offset[0] + element.offsetWidth); + }, + + withinIncludingScrolloffsets: function(element, x, y) { + var offsetcache = Element.cumulativeScrollOffset(element); + + this.xcomp = x + offsetcache[0] - this.deltaX; + this.ycomp = y + offsetcache[1] - this.deltaY; + this.offset = Element.cumulativeOffset(element); + + return (this.ycomp >= this.offset[1] && + this.ycomp < this.offset[1] + element.offsetHeight && + this.xcomp >= this.offset[0] && + this.xcomp < this.offset[0] + element.offsetWidth); + }, + + // within must be called directly before + overlap: function(mode, element) { + if (!mode) return 0; + if (mode == 'vertical') + return ((this.offset[1] + element.offsetHeight) - this.ycomp) / + element.offsetHeight; + if (mode == 'horizontal') + return ((this.offset[0] + element.offsetWidth) - this.xcomp) / + element.offsetWidth; + }, + + // Deprecation layer -- use newer Element methods now (1.5.2). + + cumulativeOffset: Element.Methods.cumulativeOffset, + + positionedOffset: Element.Methods.positionedOffset, + + absolutize: function(element) { + Position.prepare(); + return Element.absolutize(element); + }, + + relativize: function(element) { + Position.prepare(); + return Element.relativize(element); + }, + + realOffset: Element.Methods.cumulativeScrollOffset, + + offsetParent: Element.Methods.getOffsetParent, + + page: Element.Methods.viewportOffset, + + clone: function(source, target, options) { + options = options || { }; + return Element.clonePosition(target, source, options); + } +}; + +/*--------------------------------------------------------------------------*/ + +if (!document.getElementsByClassName) document.getElementsByClassName = function(instanceMethods){ + function iter(name) { + return name.blank() ? null : "[contains(concat(' ', @class, ' '), ' " + name + " ')]"; + } + + instanceMethods.getElementsByClassName = Prototype.BrowserFeatures.XPath ? + function(element, className) { + className = className.toString().strip(); + var cond = /\s/.test(className) ? $w(className).map(iter).join('') : iter(className); + return cond ? document._getElementsByXPath('.//*' + cond, element) : []; + } : function(element, className) { + className = className.toString().strip(); + var elements = [], classNames = (/\s/.test(className) ? $w(className) : null); + if (!classNames && !className) return elements; + + var nodes = $(element).getElementsByTagName('*'); + className = ' ' + className + ' '; + + for (var i = 0, child, cn; child = nodes[i]; i++) { + if (child.className && (cn = ' ' + child.className + ' ') && (cn.include(className) || + (classNames && classNames.all(function(name) { + return !name.toString().blank() && cn.include(' ' + name + ' '); + })))) + elements.push(Element.extend(child)); + } + return elements; + }; + + return function(className, parentElement) { + return $(parentElement || document.body).getElementsByClassName(className); + }; +}(Element.Methods); + +/*--------------------------------------------------------------------------*/ + +Element.ClassNames = Class.create(); +Element.ClassNames.prototype = { + initialize: function(element) { + this.element = $(element); + }, + + _each: function(iterator) { + this.element.className.split(/\s+/).select(function(name) { + return name.length > 0; + })._each(iterator); + }, + + set: function(className) { + this.element.className = className; + }, + + add: function(classNameToAdd) { + if (this.include(classNameToAdd)) return; + this.set($A(this).concat(classNameToAdd).join(' ')); + }, + + remove: function(classNameToRemove) { + if (!this.include(classNameToRemove)) return; + this.set($A(this).without(classNameToRemove).join(' ')); + }, + + toString: function() { + return $A(this).join(' '); + } +}; + +Object.extend(Element.ClassNames.prototype, Enumerable); + +/*--------------------------------------------------------------------------*/ + +Element.addMethods();
\ No newline at end of file diff --git a/samples/src/main/java/gwtquery/samples/public/prototypebench.html b/samples/src/main/java/gwtquery/samples/public/prototypebench.html new file mode 100644 index 00000000..13fcb9cb --- /dev/null +++ b/samples/src/main/java/gwtquery/samples/public/prototypebench.html @@ -0,0 +1,3172 @@ +<html>
+<head>
+ <title>JQuery</title>
+ <script type="text/javascript" src="prototype-1.6.0.3.js"></script>
+ <script type="text/javascript">
+ window.parent.prototypebenchmark = function(sel) {
+ return $$(sel).length;
+ }
+ </script>
+</head>
+<body>
+<div style="display: none">
+<div style="display: none" class="head">
+ <p><a href="http://www.w3.org/"><img height=48 alt=W3C
+ src="http://www.w3.org/Icons/w3c_home"
+ width=72></a>
+
+ <h1 id="title">Selectors</h1>
+
+ <h2>W3C Working Draft 15 December 2005</h2>
+
+ <dl>
+
+ <dt>This version:
+
+ <dd><a href="http://www.w3.org/TR/2005/WD-css3-selectors-20051215">
+ http://www.w3.org/TR/2005/WD-css3-selectors-20051215</a>
+
+ <dt>Latest version:
+
+ <dd><a href="http://www.w3.org/TR/css3-selectors">
+ http://www.w3.org/TR/css3-selectors</a>
+
+ <dt>Previous version:
+
+ <dd><a href="http://www.w3.org/TR/2001/CR-css3-selectors-20011113">
+ http://www.w3.org/TR/2001/CR-css3-selectors-20011113</a>
+
+ <dt><a name=editors-list></a>Editors:
+
+ <dd class="vcard"><span class="fn">Daniel Glazman</span> (Invited
+ Expert)
+ </dd>
+
+ <dd class="vcard"><a lang="tr" class="url fn"
+ href="http://www.tantek.com/">Tantek Çelik</a>
+ (Invited Expert)
+
+ <dd class="vcard"><a href="mailto:ian@hixie.ch" class="url fn">Ian
+ Hickson</a> (<span
+ class="company"><a
+ href="http://www.google.com/">Google</a></span>)
+
+ <dd class="vcard"><span class="fn">Peter Linss</span> (former
+ editor, <span class="company"><a
+ href="http://www.netscape.com/">Netscape/AOL</a></span>)
+
+ <dd class="vcard"><span class="fn">John Williams</span> (former editor, <span
+ class="company"><a
+ href="http://www.quark.com/">Quark, Inc.</a></span>)
+
+ </dl>
+
+ <p class="copyright"><a
+ href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">
+ Copyright</a> © 2005 <a href="http://www.w3.org/"><abbr
+ title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup>
+ (<a href="http://www.csail.mit.edu/"><abbr title="Massachusetts
+ Institute of Technology">MIT</abbr></a>, <a
+ href="http://www.ercim.org/"><acronym title="European Research
+ Consortium for Informatics and Mathematics">ERCIM</acronym></a>, <a
+ href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved.
+ W3C
+ <a
+ href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
+ <a
+ href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>,
+ <a
+ href="http://www.w3.org/Consortium/Legal/copyright-documents">document
+ use</a> rules apply.
+
+ <hr title="Separator for header">
+
+</div>
+
+<h2><a name=abstract></a>Abstract</h2>
+
+<p><em>Selectors</em> are patterns that match against elements in a
+ tree. Selectors have been optimized for use with HTML and XML, and
+ are designed to be usable in performance-critical code.</p>
+
+<p><acronym title="Cascading Style Sheets">CSS</acronym> (Cascading
+ Style Sheets) is a language for describing the rendering of <acronym
+ title="Hypertext Markup Language">HTML</acronym> and <acronym
+ title="Extensible Markup Language">XML</acronym> documents on
+ screen, on paper, in speech, etc. CSS uses Selectors for binding
+ style properties to elements in the document. This document
+ describes extensions to the selectors defined in CSS level 2. These
+ extended selectors will be used by CSS level 3.
+
+<p>Selectors define the following function:</p>
+
+<pre>expression ∗ element → boolean</pre>
+
+<p>That is, given an element and a selector, this specification
+ defines whether that element matches the selector.</p>
+
+<p>These expressions can also be used, for instance, to select a set
+ of elements, or a single element from a set of elements, by
+ evaluating the expression across all the elements in a
+ subtree. <acronym title="Simple Tree Transformation
+ Sheets">STTS</acronym> (Simple Tree Transformation Sheets), a
+ language for transforming XML trees, uses this mechanism. <a
+ href="#refsSTTS">[STTS]</a></p>
+
+<h2><a name=status></a>Status of this document</h2>
+
+<p><em>This section describes the status of this document at the
+ time of its publication. Other documents may supersede this
+ document. A list of current W3C publications and the latest revision
+ of this technical report can be found in the <a
+ href="http://www.w3.org/TR/">W3C technical reports index at
+ http://www.w3.org/TR/.</a></em></p>
+
+<p>This document describes the selectors that already exist in <a
+ href="#refsCSS1"><abbr title="CSS level 1">CSS1</abbr></a> and <a
+ href="#refsCSS21"><abbr title="CSS level 2">CSS2</abbr></a>, and
+ also proposes new selectors for <abbr title="CSS level
+ 3">CSS3</abbr> and other languages that may need them.</p>
+
+<p>The CSS Working Group doesn't expect that all implementations of
+ CSS3 will have to implement all selectors. Instead, there will
+ probably be a small number of variants of CSS3, called profiles. For
+ example, it may be that only a profile for interactive user agents
+ will include all of the selectors.</p>
+
+<p>This specification is a last call working draft for the the <a
+ href="http://www.w3.org/Style/CSS/members">CSS Working Group</a>
+ (<a href="/Style/">Style Activity</a>). This
+ document is a revision of the <a
+ href="http://www.w3.org/TR/2001/CR-css3-selectors-20011113/">Candidate
+ Recommendation dated 2001 November 13</a>, and has incorporated
+ implementation feedback received in the past few years. It is
+ expected that this last call will proceed straight to Proposed
+ Recommendation stage since it is believed that interoperability will
+ be demonstrable.</p>
+
+<p>All persons are encouraged to review and implement this
+ specification and return comments to the (<a
+ href="http://lists.w3.org/Archives/Public/www-style/">archived</a>)
+ public mailing list <a
+ href="http://www.w3.org/Mail/Lists.html#www-style">www-style</a>
+ (see <a href="http://www.w3.org/Mail/Request">instructions</a>). W3C
+ Members can also send comments directly to the CSS Working
+ Group.
+ The deadline for comments is 14 January 2006.</p>
+
+<p>This is still a draft document and may be updated, replaced, or
+ obsoleted by other documents at any time. It is inappropriate to
+ cite a W3C Working Draft as other than "work in progress".
+
+<p>This document may be available in <a
+ href="http://www.w3.org/Style/css3-selectors-updates/translations">translation</a>.
+ The English version of this specification is the only normative
+ version.
+
+<div class="subtoc">
+
+ <h2><a name=contents>Table of contents</a></h2>
+
+ <ul class="toc">
+ <li class="tocline2"><a href="#context">1. Introduction</a>
+ <ul>
+ <li><a href="#dependencies">1.1. Dependencies</a></li>
+ <li><a href="#terminology">1.2. Terminology</a></li>
+ <li><a href="#changesFromCSS2">1.3. Changes from CSS2</a></li>
+ </ul>
+ <li class="tocline2"><a href="#selectors">2. Selectors</a>
+ <li class="tocline2"><a href="#casesens">3. Case sensitivity</a>
+ <li class="tocline2"><a href="#selector-syntax">4. Selector syntax</a>
+ <li class="tocline2"><a href="#grouping">5. Groups of selectors</a>
+ <li class="tocline2"><a href="#simple-selectors">6. Simple selectors</a>
+ <ul class="toc">
+ <li class="tocline3"><a href="#type-selectors">6.1. Type
+ selectors</a>
+ <ul class="toc">
+ <li class="tocline4"><a href="#typenmsp">6.1.1. Type
+ selectors and namespaces</a></li>
+ </ul>
+ <li class="tocline3"><a href="#universal-selector">6.2.
+ Universal selector</a>
+ <ul>
+ <li><a href="#univnmsp">6.2.1. Universal selector and
+ namespaces</a></li>
+ </ul>
+ <li class="tocline3"><a href="#attribute-selectors">6.3.
+ Attribute selectors</a>
+ <ul class="toc">
+ <li class="tocline4"><a
+ href="#attribute-representation">6.3.1.
+ Representation of attributes and attributes
+ values</a>
+ <li><a href="#attribute-substrings">6.3.2. Substring
+ matching attribute selectors</a>
+ <li class="tocline4"><a href="#attrnmsp">6.3.3.
+ Attribute selectors and namespaces</a>
+ <li class="tocline4"><a href="#def-values">6.3.4.
+ Default attribute values in DTDs</a></li>
+ </ul>
+ <li class="tocline3"><a href="#class-html">6.4. Class
+ selectors</a>
+ <li class="tocline3"><a href="#id-selectors">6.5. ID
+ selectors</a>
+ <li class="tocline3"><a href="#pseudo-classes">6.6.
+ Pseudo-classes</a>
+ <ul class="toc">
+ <li class="tocline4"><a href="#dynamic-pseudos">6.6.1.
+ Dynamic pseudo-classes</a>
+ <li class="tocline4"><a href="#target-pseudo">6.6.2. The
+ :target pseudo-class</a>
+ <li class="tocline4"><a href="#lang-pseudo">6.6.3. The
+ :lang() pseudo-class</a>
+ <li class="tocline4"><a href="#UIstates">6.6.4. UI
+ element states pseudo-classes</a>
+ <li class="tocline4"><a href="#structural-pseudos">6.6.5.
+ Structural pseudo-classes</a>
+ <ul>
+ <li><a href="#root-pseudo">:root
+ pseudo-class</a>
+ <li><a href="#nth-child-pseudo">:nth-child()
+ pseudo-class</a>
+ <li><a href="#nth-last-child-pseudo">:nth-last-child()</a>
+ <li><a href="#nth-of-type-pseudo">:nth-of-type()
+ pseudo-class</a>
+ <li><a href="#nth-last-of-type-pseudo">:nth-last-of-type()</a>
+ <li><a href="#first-child-pseudo">:first-child
+ pseudo-class</a>
+ <li><a href="#last-child-pseudo">:last-child
+ pseudo-class</a>
+ <li><a href="#first-of-type-pseudo">:first-of-type
+ pseudo-class</a>
+ <li><a href="#last-of-type-pseudo">:last-of-type
+ pseudo-class</a>
+ <li><a href="#only-child-pseudo">:only-child
+ pseudo-class</a>
+ <li><a href="#only-of-type-pseudo">:only-of-type
+ pseudo-class</a>
+ <li><a href="#empty-pseudo">:empty
+ pseudo-class</a></li>
+ </ul>
+ <li class="tocline4"><a href="#negation">6.6.7. The
+ negation pseudo-class</a></li>
+ </ul>
+ </li>
+ </ul>
+ <li><a href="#pseudo-elements">7. Pseudo-elements</a>
+ <ul>
+ <li><a href="#first-line">7.1. The ::first-line
+ pseudo-element</a>
+ <li><a href="#first-letter">7.2. The ::first-letter
+ pseudo-element</a>
+ <li><a href="#UIfragments">7.3. The ::selection
+ pseudo-element</a>
+ <li><a href="#gen-content">7.4. The ::before and ::after
+ pseudo-elements</a></li>
+ </ul>
+ <li class="tocline2"><a href="#combinators">8. Combinators</a>
+ <ul class="toc">
+ <li class="tocline3"><a href="#descendant-combinators">8.1.
+ Descendant combinators</a>
+ <li class="tocline3"><a href="#child-combinators">8.2. Child
+ combinators</a>
+ <li class="tocline3"><a href="#sibling-combinators">8.3. Sibling
+ combinators</a>
+ <ul class="toc">
+ <li class="tocline4"><a
+ href="#adjacent-sibling-combinators">8.3.1.
+ Adjacent sibling combinator</a>
+ <li class="tocline4"><a
+ href="#general-sibling-combinators">8.3.2.
+ General sibling combinator</a></li>
+ </ul>
+ </li>
+ </ul>
+ <li class="tocline2"><a href="#specificity">9. Calculating a selector's
+ specificity</a>
+ <li class="tocline2"><a href="#w3cselgrammar">10. The grammar of
+ Selectors</a>
+ <ul class="toc">
+ <li class="tocline3"><a href="#grammar">10.1. Grammar</a>
+ <li class="tocline3"><a href="#lex">10.2. Lexical scanner</a>
+ </li>
+ </ul>
+ <li class="tocline2"><a href="#downlevel">11. Namespaces and down-level
+ clients</a>
+ <li class="tocline2"><a href="#profiling">12. Profiles</a>
+ <li><a href="#Conformance">13. Conformance and requirements</a>
+ <li><a href="#Tests">14. Tests</a>
+ <li><a href="#ACKS">15. Acknowledgements</a>
+ <li class="tocline2"><a href="#references">16. References</a>
+ </ul>
+
+</div>
+
+<h2><a name=context>1. Introduction</a></h2>
+
+<h3><a name=dependencies></a>1.1. Dependencies</h3>
+
+<p>Some features of this specification are specific to CSS, or have
+ particular limitations or rules specific to CSS. In this
+ specification, these have been described in terms of CSS2.1. <a
+ href="#refsCSS21">[CSS21]</a></p>
+
+<h3><a name=terminology></a>1.2. Terminology</h3>
+
+<p>All of the text of this specification is normative except
+ examples, notes, and sections explicitly marked as
+ non-normative.</p>
+
+<h3><a name=changesFromCSS2></a>1.3. Changes from CSS2</h3>
+
+<p><em>This section is non-normative.</em></p>
+
+<p>The main differences between the selectors in CSS2 and those in
+ Selectors are:
+
+<ul>
+
+ <li>the list of basic definitions (selector, group of selectors,
+ simple selector, etc.) has been changed; in particular, what was
+ referred to in CSS2 as a simple selector is now called a sequence
+ of simple selectors, and the term "simple selector" is now used for
+ the components of this sequence
+ </li>
+
+ <li>an optional namespace component is now allowed in type element
+ selectors, the universal selector and attribute selectors
+ </li>
+
+ <li>a <a href="#general-sibling-combinators">new combinator</a> has been
+ introduced
+ </li>
+
+ <li>new simple selectors including substring matching attribute
+ selectors, and new pseudo-classes
+ </li>
+
+ <li>new pseudo-elements, and introduction of the "::" convention
+ for pseudo-elements
+ </li>
+
+ <li>the grammar has been rewritten</li>
+
+ <li>profiles to be added to specifications integrating Selectors
+ and defining the set of selectors which is actually supported by
+ each specification
+ </li>
+
+ <li>Selectors are now a CSS3 Module and an independent
+ specification; other specifications can now refer to this document
+ independently of CSS
+ </li>
+
+ <li>the specification now has its own test suite</li>
+
+</ul>
+
+<h2><a name=selectors></a>2. Selectors</h2>
+
+<p><em>This section is non-normative, as it merely summarizes the
+ following sections.</em></p>
+
+<p>A Selector represents a structure. This structure can be used as a
+ condition (e.g. in a CSS rule) that determines which elements a
+ selector matches in the document tree, or as a flat description of the
+ HTML or XML fragment corresponding to that structure.</p>
+
+<p>Selectors may range from simple element names to rich contextual
+ representations.</p>
+
+<p>The following table summarizes the Selector syntax:</p>
+
+<table class="selectorsReview">
+<thead>
+<tr>
+ <th class="pattern">Pattern</th>
+ <th class="meaning">Meaning</th>
+ <th class="described">Described in section</th>
+ <th class="origin">First defined in CSS level</th>
+</tr>
+<tbody>
+<tr>
+ <td class="pattern">*</td>
+ <td class="meaning">any element</td>
+ <td class="described"><a
+ href="#universal-selector">Universal
+ selector</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
+ <td class="pattern">E</td>
+ <td class="meaning">an element of type E</td>
+ <td class="described"><a
+ href="#type-selectors">Type selector</a></td>
+ <td class="origin">1</td>
+</tr>
+<tr>
+ <td class="pattern">E[foo]</td>
+ <td class="meaning">an E element with a "foo" attribute</td>
+ <td class="described"><a
+ href="#attribute-selectors">Attribute
+ selectors</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
+ <td class="pattern">E[foo="bar"]</td>
+ <td class="meaning">an E element whose "foo" attribute value is exactly
+ equal to "bar"
+ </td>
+ <td class="described"><a
+ href="#attribute-selectors">Attribute
+ selectors</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
+ <td class="pattern">E[foo~="bar"]</td>
+ <td class="meaning">an E element whose "foo" attribute value is a list of
+ space-separated values, one of which is exactly equal to "bar"
+ </td>
+ <td class="described"><a
+ href="#attribute-selectors">Attribute
+ selectors</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
+ <td class="pattern">E[foo^="bar"]</td>
+ <td class="meaning">an E element whose "foo" attribute value begins exactly
+ with the string "bar"
+ </td>
+ <td class="described"><a
+ href="#attribute-selectors">Attribute
+ selectors</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E[foo$="bar"]</td>
+ <td class="meaning">an E element whose "foo" attribute value ends exactly
+ with the string "bar"
+ </td>
+ <td class="described"><a
+ href="#attribute-selectors">Attribute
+ selectors</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E[foo*="bar"]</td>
+ <td class="meaning">an E element whose "foo" attribute value contains the
+ substring "bar"
+ </td>
+ <td class="described"><a
+ href="#attribute-selectors">Attribute
+ selectors</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E[hreflang|="en"]</td>
+ <td class="meaning">an E element whose "hreflang" attribute has a
+ hyphen-separated
+ list of values beginning (from the left) with "en"
+ </td>
+ <td class="described"><a
+ href="#attribute-selectors">Attribute
+ selectors</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
+ <td class="pattern">E:root</td>
+ <td class="meaning">an E element, root of the document</td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:nth-child(n)</td>
+ <td class="meaning">an E element, the n-th child of its parent</td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:nth-last-child(n)</td>
+ <td class="meaning">an E element, the n-th child of its parent, counting
+ from the last one
+ </td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:nth-of-type(n)</td>
+ <td class="meaning">an E element, the n-th sibling of its type</td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:nth-last-of-type(n)</td>
+ <td class="meaning">an E element, the n-th sibling of its type, counting
+ from the last one
+ </td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:first-child</td>
+ <td class="meaning">an E element, first child of its parent</td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
+ <td class="pattern">E:last-child</td>
+ <td class="meaning">an E element, last child of its parent</td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:first-of-type</td>
+ <td class="meaning">an E element, first sibling of its type</td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:last-of-type</td>
+ <td class="meaning">an E element, last sibling of its type</td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:only-child</td>
+ <td class="meaning">an E element, only child of its parent</td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:only-of-type</td>
+ <td class="meaning">an E element, only sibling of its type</td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:empty</td>
+ <td class="meaning">an E element that has no children (including text
+ nodes)
+ </td>
+ <td class="described"><a
+ href="#structural-pseudos">Structural
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:link<br>E:visited</td>
+ <td class="meaning">an E element being the source anchor of a hyperlink of
+ which the target is not yet visited (:link) or already visited
+ (:visited)
+ </td>
+ <td class="described"><a
+ href="#link">The link
+ pseudo-classes</a></td>
+ <td class="origin">1</td>
+</tr>
+<tr>
+ <td class="pattern">E:active<br>E:hover<br>E:focus</td>
+ <td class="meaning">an E element during certain user actions</td>
+ <td class="described"><a
+ href="#useraction-pseudos">The user
+ action pseudo-classes</a></td>
+ <td class="origin">1 and 2</td>
+</tr>
+<tr>
+ <td class="pattern">E:target</td>
+ <td class="meaning">an E element being the target of the referring URI</td>
+ <td class="described"><a
+ href="#target-pseudo">The target
+ pseudo-class</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:lang(fr)</td>
+ <td class="meaning">an element of type E in language "fr" (the document
+ language specifies how language is determined)
+ </td>
+ <td class="described"><a
+ href="#lang-pseudo">The :lang()
+ pseudo-class</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
+ <td class="pattern">E:enabled<br>E:disabled</td>
+ <td class="meaning">a user interface element E which is enabled or
+ disabled
+ </td>
+ <td class="described"><a
+ href="#UIstates">The UI element states
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E:checked<!--<br>E:indeterminate--></td>
+ <td class="meaning">a user interface element E which is checked<!-- or in an
+ indeterminate state--> (for instance a radio-button or checkbox)
+ </td>
+ <td class="described"><a
+ href="#UIstates">The UI element states
+ pseudo-classes</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E::first-line</td>
+ <td class="meaning">the first formatted line of an E element</td>
+ <td class="described"><a
+ href="#first-line">The ::first-line
+ pseudo-element</a></td>
+ <td class="origin">1</td>
+</tr>
+<tr>
+ <td class="pattern">E::first-letter</td>
+ <td class="meaning">the first formatted letter of an E element</td>
+ <td class="described"><a
+ href="#first-letter">The ::first-letter
+ pseudo-element</a></td>
+ <td class="origin">1</td>
+</tr>
+<tr>
+ <td class="pattern">E::selection</td>
+ <td class="meaning">the portion of an E element that is currently
+ selected/highlighted by the user
+ </td>
+ <td class="described"><a
+ href="#UIfragments">The UI element
+ fragments pseudo-elements</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E::before</td>
+ <td class="meaning">generated content before an E element</td>
+ <td class="described"><a
+ href="#gen-content">The ::before
+ pseudo-element</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
+ <td class="pattern">E::after</td>
+ <td class="meaning">generated content after an E element</td>
+ <td class="described"><a
+ href="#gen-content">The ::after
+ pseudo-element</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
+ <td class="pattern">E.warning</td>
+ <td class="meaning">an E element whose class is
+ "warning" (the document language specifies how class is determined).
+ </td>
+ <td class="described"><a
+ href="#class-html">Class
+ selectors</a></td>
+ <td class="origin">1</td>
+</tr>
+<tr>
+ <td class="pattern">E#myid</td>
+ <td class="meaning">an E element with ID equal to "myid".</td>
+ <td class="described"><a
+ href="#id-selectors">ID
+ selectors</a></td>
+ <td class="origin">1</td>
+</tr>
+<tr>
+ <td class="pattern">E:not(s)</td>
+ <td class="meaning">an E element that does not match simple selector s</td>
+ <td class="described"><a
+ href="#negation">Negation
+ pseudo-class</a></td>
+ <td class="origin">3</td>
+</tr>
+<tr>
+ <td class="pattern">E F</td>
+ <td class="meaning">an F element descendant of an E element</td>
+ <td class="described"><a
+ href="#descendant-combinators">Descendant
+ combinator</a></td>
+ <td class="origin">1</td>
+</tr>
+<tr>
+ <td class="pattern">E > F</td>
+ <td class="meaning">an F element child of an E element</td>
+ <td class="described"><a
+ href="#child-combinators">Child
+ combinator</a></td>
+ <td class="origin">2</td>
+</tr>
+<tr>
+ <td class="pattern">E + F</td>
+ <td class="meaning">an F element immediately preceded by an E element</td>
+ <td class="described"><a
+ href="#adjacent-sibling-combinators">Adjacent sibling combinator</a>
+ </td>
+ <td class="origin">2</td>
+</tr>
+<tr>
+ <td class="pattern">E ~ F</td>
+ <td class="meaning">an F element preceded by an E element</td>
+ <td class="described"><a
+ href="#general-sibling-combinators">General sibling combinator</a>
+ </td>
+ <td class="origin">3</td>
+</tr>
+</tbody>
+</table>
+
+<p>The meaning of each selector is derived from the table above by
+ prepending "matches" to the contents of each cell in the "Meaning"
+ column.</p>
+
+<h2><a name=casesens>3. Case sensitivity</a></h2>
+
+<p>The case sensitivity of document language element names, attribute
+ names, and attribute values in selectors depends on the document
+ language. For example, in HTML, element names are case-insensitive,
+ but in XML, they are case-sensitive.</p>
+
+<h2><a name=selector-syntax>4. Selector syntax</a></h2>
+
+<p>A <dfn><a name=selector>selector</a></dfn> is a chain of one
+ or more <a href="#sequence">sequences of simple selectors</a>
+ separated by <a href="#combinators">combinators</a>.</p>
+
+<p>A <dfn><a name=sequence>sequence of simple selectors</a></dfn>
+ is a chain of <a href="#simple-selectors-dfn">simple selectors</a>
+ that are not separated by a <a href="#combinators">combinator</a>. It
+ always begins with a <a href="#type-selectors">type selector</a> or a
+ <a href="#universal-selector">universal selector</a>. No other type
+ selector or universal selector is allowed in the sequence.</p>
+
+<p>A <dfn><a name=simple-selectors-dfn></a><a
+ href="#simple-selectors">simple selector</a></dfn> is either a <a
+ href="#type-selectors">type selector</a>, <a
+ href="#universal-selector">universal selector</a>, <a
+ href="#attribute-selectors">attribute selector</a>, <a
+ href="#class-html">class selector</a>, <a
+ href="#id-selectors">ID selector</a>, <a
+ href="#content-selectors">content selector</a>, or <a
+ href="#pseudo-classes">pseudo-class</a>. One <a
+ href="#pseudo-elements">pseudo-element</a> may be appended to the last
+ sequence of simple selectors.</p>
+
+<p><dfn>Combinators</dfn> are: white space, "greater-than
+ sign" (U+003E, <code>></code>), "plus sign" (U+002B,
+ <code>+</code>) and "tilde" (U+007E, <code>~</code>). White
+ space may appear between a combinator and the simple selectors around
+ it. <a name=whitespace></a>Only the characters "space" (U+0020), "tab"
+ (U+0009), "line feed" (U+000A), "carriage return" (U+000D), and "form
+ feed" (U+000C) can occur in white space. Other space-like characters,
+ such as "em-space" (U+2003) and "ideographic space" (U+3000), are
+ never part of white space.</p>
+
+<p>The elements of a document tree that are represented by a selector
+ are the <dfn><a name=subject></a>subjects of the selector</dfn>. A
+ selector consisting of a single sequence of simple selectors
+ represents any element satisfying its requirements. Prepending another
+ sequence of simple selectors and a combinator to a sequence imposes
+ additional matching constraints, so the subjects of a selector are
+ always a subset of the elements represented by the last sequence of
+ simple selectors.</p>
+
+<p>An empty selector, containing no sequence of simple selectors and
+ no pseudo-element, is an <a href="#Conformance">invalid
+ selector</a>.</p>
+
+<h2><a name=grouping>5. Groups of selectors</a></h2>
+
+<p>When several selectors share the same declarations, they may be
+ grouped into a comma-separated list. (A comma is U+002C.)</p>
+
+<div class="example">
+ <p>CSS examples:</p>
+
+ <p>In this example, we condense three rules with identical
+ declarations into one. Thus,</p>
+<pre>h1 { font-family: sans-serif }
+h2 { font-family: sans-serif }
+h3 { font-family: sans-serif }</pre>
+ <p>is equivalent to:</p>
+ <pre>h1, h2, h3 { font-family: sans-serif }</pre>
+</div>
+
+<p><strong>Warning</strong>: the equivalence is true in this example
+ because all the selectors are valid selectors. If just one of these
+ selectors were invalid, the entire group of selectors would be
+ invalid. This would invalidate the rule for all three heading
+ elements, whereas in the former case only one of the three individual
+ heading rules would be invalidated.</p>
+
+
+<h2><a name=simple-selectors>6. Simple selectors</a></h2>
+
+<h3><a name=type-selectors>6.1. Type selector</a></h3>
+
+<p>A <dfn>type selector</dfn> is the name of a document language
+ element type. A type selector represents an instance of the element
+ type in the document tree.</p>
+
+<div class="example">
+ <p>Example:</p>
+
+ <p>The following selector represents an <code>h1</code> element in the
+ document tree:</p>
+ <pre>h1</pre>
+</div>
+
+
+<h4><a name=typenmsp>6.1.1. Type selectors and namespaces</a></h4>
+
+<p>Type selectors allow an optional namespace (<a
+ href="#refsXMLNAMES">[XMLNAMES]</a>) component. A namespace prefix
+ that has been previously declared may be prepended to the element name
+ separated by the namespace separator "vertical bar"
+ (U+007C, <code>|</code>).</p>
+
+<p>The namespace component may be left empty to indicate that the
+ selector is only to represent elements with no declared namespace.</p>
+
+<p>An asterisk may be used for the namespace prefix, indicating that
+ the selector represents elements in any namespace (including elements
+ with no namespace).</p>
+
+<p>Element type selectors that have no namespace component (no
+ namespace separator), represent elements without regard to the
+ element's namespace (equivalent to "<code>*|</code>") unless a default
+ namespace has been declared. If a default namespace has been declared,
+ the selector will represent only elements in the default
+ namespace.</p>
+
+<p>A type selector containing a namespace prefix that has not been
+ previously declared is an <a href="#Conformance">invalid</a> selector.
+ The mechanism for declaring a namespace prefix is left up to the
+ language implementing Selectors. In CSS, such a mechanism is defined
+ in the General Syntax module.</p>
+
+<p>In a namespace-aware client, element type selectors will only match
+ against the <a
+ href="http://www.w3.org/TR/REC-xml-names/#NT-LocalPart">local
+ part</a>
+ of the element's <a
+ href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">qualified
+ name</a>. See <a href="#downlevel">below</a> for notes about matching
+ behaviors in down-level clients.</p>
+
+<p>In summary:</p>
+
+<dl>
+ <dt><code>ns|E</code></dt>
+ <dd>elements with name E in namespace ns</dd>
+ <dt><code>*|E</code></dt>
+ <dd>elements with name E in any namespace, including those without any
+ declared namespace
+ </dd>
+ <dt><code>|E</code></dt>
+ <dd>elements with name E without any declared namespace</dd>
+ <dt><code>E</code></dt>
+ <dd>if no default namespace has been specified, this is equivalent to *|E.
+ Otherwise it is equivalent to ns|E where ns is the default namespace.
+ </dd>
+</dl>
+
+<div class="example">
+ <p>CSS examples:</p>
+
+ <pre>@namespace foo url(http://www.example.com);
+ foo|h1 { color: blue }
+ foo|* { color: yellow }
+ |h1 { color: red }
+ *|h1 { color: green }
+ h1 { color: green }</pre>
+
+ <p>The first rule will match only <code>h1</code> elements in the
+ "http://www.example.com" namespace.</p>
+
+ <p>The second rule will match all elements in the
+ "http://www.example.com" namespace.</p>
+
+ <p>The third rule will match only <code>h1</code> elements without
+ any declared namespace.</p>
+
+ <p>The fourth rule will match <code>h1</code> elements in any
+ namespace (including those without any declared namespace).</p>
+
+ <p>The last rule is equivalent to the fourth rule because no default
+ namespace has been defined.</p>
+
+</div>
+
+<h3><a name=universal-selector>6.2. Universal selector</a></h3>
+
+<p>The <dfn>universal selector</dfn>, written "asterisk"
+ (<code>*</code>), represents the qualified name of any element
+ type. It represents any single element in the document tree in any
+ namespace (including those without any declared namespace) if no
+ default namespace has been specified. If a default namespace has been
+ specified, see <a href="#univnmsp">Universal selector and
+ Namespaces</a> below.</p>
+
+<p>If the universal selector is not the only component of a sequence
+ of simple selectors, the <code>*</code> may be omitted.</p>
+
+<div class="example">
+ <p>Examples:</p>
+ <ul>
+ <li><code>*[hreflang|=en]</code> and <code>[hreflang|=en]</code> are
+ equivalent,
+ </li>
+ <li><code>*.warning</code> and <code>.warning</code> are equivalent,
+ </li>
+ <li><code>*#myid</code> and <code>#myid</code> are equivalent.</li>
+ </ul>
+</div>
+
+<p class="note"><strong>Note:</strong> it is recommended that the
+ <code>*</code>, representing the universal selector, not be
+ omitted.</p>
+
+<h4><a name=univnmsp>6.2.1. Universal selector and namespaces</a></h4>
+
+<p>The universal selector allows an optional namespace component. It
+ is used as follows:</p>
+
+<dl>
+ <dt><code>ns|*</code></dt>
+ <dd>all elements in namespace ns</dd>
+ <dt><code>*|*</code></dt>
+ <dd>all elements</dd>
+ <dt><code>|*</code></dt>
+ <dd>all elements without any declared namespace</dd>
+ <dt><code>*</code></dt>
+ <dd>if no default namespace has been specified, this is equivalent to *|*.
+ Otherwise it is equivalent to ns|* where ns is the default namespace.
+ </dd>
+</dl>
+
+<p>A universal selector containing a namespace prefix that has not
+ been previously declared is an <a href="#Conformance">invalid</a>
+ selector. The mechanism for declaring a namespace prefix is left up
+ to the language implementing Selectors. In CSS, such a mechanism is
+ defined in the General Syntax module.</p>
+
+
+<h3><a name=attribute-selectors>6.3. Attribute selectors</a></h3>
+
+<p>Selectors allow the representation of an element's attributes. When
+ a selector is used as an expression to match against an element,
+ attribute selectors must be considered to match an element if that
+ element has an attribute that matches the attribute represented by the
+ attribute selector.</p>
+
+<h4><a name=attribute-representation>6.3.1. Attribute presence and values
+ selectors</a></h4>
+
+<p>CSS2 introduced four attribute selectors:</p>
+
+<dl>
+ <dt><code>[att]</code>
+ <dd>Represents an element with the <code>att</code> attribute, whatever the
+ value of
+ the attribute.
+ </dd>
+ <dt><code>[att=val]</code></dt>
+ <dd>Represents an element with the <code>att</code> attribute whose value is
+ exactly
+ "val".
+ </dd>
+ <dt><code>[att~=val]</code></dt>
+ <dd>Represents an element with the <code>att</code> attribute whose value is
+ a <a
+ href="#whitespace">whitespace</a>-separated list of words, one
+ of
+ which is exactly "val". If "val" contains whitespace, it will never
+ represent anything (since the words are <em>separated</em> by
+ spaces).
+ </dd>
+ <dt><code>[att|=val]</code>
+ <dd>Represents an element with the <code>att</code> attribute, its value
+ either
+ being exactly "val" or beginning with "val" immediately followed by
+ "-" (U+002D). This is primarily intended to allow language subcode
+ matches (e.g., the <code>hreflang</code> attribute on the
+ <code>link</code> element in HTML) as described in RFC 3066 (<a
+ href="#refsRFC3066">[RFC3066]</a>). For <code>lang</code> (or
+ <code>xml:lang</code>) language subcode matching, please see <a
+ href="#lang-pseudo">the <code>:lang</code> pseudo-class</a>.
+ </dd>
+</dl>
+
+<p>Attribute values must be identifiers or strings. The
+ case-sensitivity of attribute names and values in selectors depends on
+ the document language.</p>
+
+<div class="example">
+
+ <p>Examples:</p>
+
+ <p>The following attribute selector represents an <code>h1</code>
+ element that carries the <code>title</code> attribute, whatever its
+ value:</p>
+
+ <pre>h1[title]</pre>
+
+ <p>In the following example, the selector represents a
+ <code>span</code> element whose <code>class</code> attribute has
+ exactly the value "example":</p>
+
+ <pre>span[class="example"]</pre>
+
+ <p>Multiple attribute selectors can be used to represent several
+ attributes of an element, or several conditions on the same
+ attribute. Here, the selector represents a <code>span</code> element
+ whose <code>hello</code> attribute has exactly the value "Cleveland"
+ and whose <code>goodbye</code> attribute has exactly the value
+ "Columbus":</p>
+
+ <pre>span[hello="Cleveland"][goodbye="Columbus"]</pre>
+
+ <p>The following selectors illustrate the differences between "="
+ and "~=". The first selector will represent, for example, the value
+ "copyright copyleft copyeditor" on a <code>rel</code> attribute. The
+ second selector will only represent an <code>a</code> element with
+ an <code>href</code> attribute having the exact value
+ "http://www.w3.org/".</p>
+
+ <pre>a[rel~="copyright"]
+a[href="http://www.w3.org/"]</pre>
+
+ <p>The following selector represents a <code>link</code> element
+ whose <code>hreflang</code> attribute is exactly "fr".</p>
+
+ <pre>link[hreflang=fr]</pre>
+
+ <p>The following selector represents a <code>link</code> element for
+ which the values of the <code>hreflang</code> attribute begins with
+ "en", including "en", "en-US", and "en-cockney":</p>
+
+ <pre>link[hreflang|="en"]</pre>
+
+ <p>Similarly, the following selectors represents a
+ <code>DIALOGUE</code> element whenever it has one of two different
+ values for an attribute <code>character</code>:</p>
+
+ <pre>DIALOGUE[character=romeo]
+DIALOGUE[character=juliet]</pre>
+
+</div>
+
+<h4><a name=attribute-substrings></a>6.3.2. Substring matching attribute
+ selectors</h4>
+
+<p>Three additional attribute selectors are provided for matching
+ substrings in the value of an attribute:</p>
+
+<dl>
+ <dt><code>[att^=val]</code></dt>
+ <dd>Represents an element with the <code>att</code> attribute whose value
+ begins
+ with the prefix "val".
+ </dd>
+ <dt><code>[att$=val]</code>
+ <dd>Represents an element with the <code>att</code> attribute whose value
+ ends with
+ the suffix "val".
+ </dd>
+ <dt><code>[att*=val]</code>
+ <dd>Represents an element with the <code>att</code> attribute whose value
+ contains
+ at least one instance of the substring "val".
+ </dd>
+</dl>
+
+<p>Attribute values must be identifiers or strings. The
+ case-sensitivity of attribute names in selectors depends on the
+ document language.</p>
+
+<div class="example">
+ <p>Examples:</p>
+
+ <p>The following selector represents an HTML <code>object</code>,
+ referencing an
+ image:</p>
+ <pre>object[type^="image/"]</pre>
+ <p>The following selector represents an HTML anchor <code>a</code> with an
+ <code>href</code> attribute whose value ends with ".html".</p>
+ <pre>a[href$=".html"]</pre>
+ <p>The following selector represents an HTML paragraph with a
+ <code>title</code>
+ attribute whose value contains the substring "hello"</p>
+ <pre>p[title*="hello"]</pre>
+</div>
+
+<h4><a name=attrnmsp>6.3.3. Attribute selectors and namespaces</a></h4>
+
+<p>Attribute selectors allow an optional namespace component to the
+ attribute name. A namespace prefix that has been previously declared
+ may be prepended to the attribute name separated by the namespace
+ separator "vertical bar" (<code>|</code>). In keeping with
+ the Namespaces in the XML recommendation, default namespaces do not
+ apply to attributes, therefore attribute selectors without a namespace
+ component apply only to attributes that have no declared namespace
+ (equivalent to "<code>|attr</code>"). An asterisk may be used for the
+ namespace prefix indicating that the selector is to match all
+ attribute names without regard to the attribute's namespace.
+
+<p>An attribute selector with an attribute name containing a namespace
+ prefix that has not been previously declared is an <a
+ href="#Conformance">invalid</a> selector. The mechanism for
+ declaring
+ a namespace prefix is left up to the language implementing Selectors.
+ In CSS, such a mechanism is defined in the General Syntax module.
+
+<div class="example">
+ <p>CSS examples:</p>
+ <pre>@namespace foo "http://www.example.com";
+[foo|att=val] { color: blue }
+[*|att] { color: yellow }
+[|att] { color: green }
+[att] { color: green }</pre>
+
+ <p>The first rule will match only elements with the attribute
+ <code>att</code> in the "http://www.example.com" namespace with the
+ value "val".</p>
+
+ <p>The second rule will match only elements with the attribute
+ <code>att</code> regardless of the namespace of the attribute
+ (including no declared namespace).</p>
+
+ <p>The last two rules are equivalent and will match only elements
+ with the attribute <code>att</code> where the attribute is not
+ declared to be in a namespace.</p>
+
+</div>
+
+<h4><a name=def-values>6.3.4. Default attribute values in DTDs</a></h4>
+
+<p>Attribute selectors represent explicitly set attribute values in
+ the document tree. Default attribute values may be defined in a DTD or
+ elsewhere, but cannot always be selected by attribute
+ selectors. Selectors should be designed so that they work even if the
+ default values are not included in the document tree.</p>
+
+<p>More precisely, a UA is <em>not</em> required to read an "external
+ subset" of the DTD but <em>is</em> required to look for default
+ attribute values in the document's "internal subset." (See <a
+ href="#refsXML10">[XML10]</a> for definitions of these subsets.)</p>
+
+<p>A UA that recognizes an XML namespace <a
+ href="#refsXMLNAMES">[XMLNAMES]</a> is not required to use its
+ knowledge of that namespace to treat default attribute values as if
+ they were present in the document. (For example, an XHTML UA is not
+ required to use its built-in knowledge of the XHTML DTD.)</p>
+
+<p class="note"><strong>Note:</strong> Typically, implementations
+ choose to ignore external subsets.</p>
+
+<div class="example">
+ <p>Example:</p>
+
+ <p>Consider an element EXAMPLE with an attribute "notation" that has a
+ default value of "decimal". The DTD fragment might be</p>
+
+ <pre class="dtd-example"><!ATTLIST EXAMPLE notation (decimal,octal) "decimal"></pre>
+
+ <p>If the style sheet contains the rules</p>
+
+<pre>EXAMPLE[notation=decimal] { /*... default property settings ...*/ }
+EXAMPLE[notation=octal] { /*... other settings...*/ }</pre>
+
+ <p>the first rule will not match elements whose "notation" attribute
+ is set by default, i.e. not set explicitly. To catch all cases, the
+ attribute selector for the default value must be dropped:</p>
+
+<pre>EXAMPLE { /*... default property settings ...*/ }
+EXAMPLE[notation=octal] { /*... other settings...*/ }</pre>
+
+ <p>Here, because the selector <code>EXAMPLE[notation=octal]</code> is
+ more specific than the tag
+ selector alone, the style declarations in the second rule will override
+ those in the first for elements that have a "notation" attribute value
+ of "octal". Care has to be taken that all property declarations that
+ are to apply only to the default case are overridden in the non-default
+ cases' style rules.</p>
+
+</div>
+
+<h3><a name=class-html>6.4. Class selectors</a></h3>
+
+<p>Working with HTML, authors may use the period (U+002E,
+ <code>.</code>) notation as an alternative to the <code>~=</code>
+ notation when representing the <code>class</code> attribute. Thus, for
+ HTML, <code>div.value</code> and <code>div[class~=value]</code> have
+ the same meaning. The attribute value must immediately follow the
+ "period" (<code>.</code>).</p>
+
+<p>UAs may apply selectors using the period (.) notation in XML
+ documents if the UA has namespace-specific knowledge that allows it to
+ determine which attribute is the "class" attribute for the
+ respective namespace. One such example of namespace-specific knowledge
+ is the prose in the specification for a particular namespace (e.g. SVG
+ 1.0 <a href="#refsSVG">[SVG]</a> describes the <a
+ href="http://www.w3.org/TR/2001/PR-SVG-20010719/styling.html#ClassAttribute">SVG
+ "class" attribute</a> and how a UA should interpret it, and
+ similarly MathML 1.01 <a href="#refsMATH">[MATH]</a> describes the <a
+ href="http://www.w3.org/1999/07/REC-MathML-19990707/chapter2.html#sec2.3.4">MathML
+ "class" attribute</a>.)</p>
+
+<div class="example">
+ <p>CSS examples:</p>
+
+ <p>We can assign style information to all elements with
+ <code>class~="pastoral"</code> as follows:</p>
+
+ <pre>*.pastoral { color: green } /* all elements with class~=pastoral */</pre>
+
+ <p>or just</p>
+
+ <pre>.pastoral { color: green } /* all elements with class~=pastoral */</pre>
+
+ <p>The following assigns style only to H1 elements with
+ <code>class~="pastoral"</code>:</p>
+
+ <pre>H1.pastoral { color: green } /* H1 elements with class~=pastoral */</pre>
+
+ <p>Given these rules, the first H1 instance below would not have
+ green text, while the second would:</p>
+
+ <pre><H1>Not green</H1>
+<H1 class="pastoral">Very green</H1></pre>
+
+</div>
+
+<p>To represent a subset of "class" values, each value must be preceded
+ by a ".", in any order.</P>
+
+<div class="example">
+
+ <p>CSS example:</p>
+
+ <p>The following rule matches any P element whose "class" attribute
+ has been assigned a list of <a
+ href="#whitespace">whitespace</a>-separated values that includes
+ "pastoral" and "marine":</p>
+
+ <pre>p.pastoral.marine { color: green }</pre>
+
+ <p>This rule matches when <code>class="pastoral blue aqua
+ marine"</code> but does not match for <code>class="pastoral
+ blue"</code>.</p>
+
+</div>
+
+<p class="note"><strong>Note:</strong> Because CSS gives considerable
+ power to the "class" attribute, authors could conceivably design their
+ own "document language" based on elements with almost no associated
+ presentation (such as DIV and SPAN in HTML) and assigning style
+ information through the "class" attribute. Authors should avoid this
+ practice since the structural elements of a document language often
+ have recognized and accepted meanings and author-defined classes may
+ not.</p>
+
+<p class="note"><strong>Note:</strong> If an element has multiple
+ class attributes, their values must be concatenated with spaces
+ between the values before searching for the class. As of this time the
+ working group is not aware of any manner in which this situation can
+ be reached, however, so this behavior is explicitly non-normative in
+ this specification.</p>
+
+<h3><a name=id-selectors>6.5. ID selectors</a></h3>
+
+<p>Document languages may contain attributes that are declared to be
+ of type ID. What makes attributes of type ID special is that no two
+ such attributes can have the same value in a document, regardless of
+ the type of the elements that carry them; whatever the document
+ language, an ID typed attribute can be used to uniquely identify its
+ element. In HTML all ID attributes are named "id"; XML applications
+ may name ID attributes differently, but the same restriction
+ applies.</p>
+
+<p>An ID-typed attribute of a document language allows authors to
+ assign an identifier to one element instance in the document tree. W3C
+ ID selectors represent an element instance based on its identifier. An
+ ID selector contains a "number sign" (U+0023,
+ <code>#</code>) immediately followed by the ID value, which must be an
+ identifier.</p>
+
+<p>Selectors does not specify how a UA knows the ID-typed attribute of
+ an element. The UA may, e.g., read a document's DTD, have the
+ information hard-coded or ask the user.
+
+<div class="example">
+ <p>Examples:</p>
+
+ <p>The following ID selector represents an <code>h1</code> element
+ whose ID-typed attribute has the value "chapter1":</p>
+ <pre>h1#chapter1</pre>
+ <p>The following ID selector represents any element whose ID-typed
+ attribute has the value "chapter1":</p>
+ <pre>#chapter1</pre>
+ <p>The following selector represents any element whose ID-typed
+ attribute has the value "z98y".</p>
+ <pre>*#z98y</pre>
+</div>
+
+<p class="note"><strong>Note.</strong> In XML 1.0 <a
+ href="#refsXML10">[XML10]</a>, the information about which attribute
+ contains an element's IDs is contained in a DTD or a schema. When
+ parsing XML, UAs do not always read the DTD, and thus may not know
+ what the ID of an element is (though a UA may have namespace-specific
+ knowledge that allows it to determine which attribute is the ID
+ attribute for that namespace). If a style sheet designer knows or
+ suspects that a UA may not know what the ID of an element is, he
+ should use normal attribute selectors instead:
+ <code>[name=p371]</code> instead of <code>#p371</code>. Elements in
+ XML 1.0 documents without a DTD do not have IDs at all.</p>
+
+<p>If an element has multiple ID attributes, all of them must be
+ treated as IDs for that element for the purposes of the ID
+ selector. Such a situation could be reached using mixtures of xml:id,
+ DOM3 Core, XML DTDs, and namespace-specific knowledge.</p>
+
+<h3><a name=pseudo-classes>6.6. Pseudo-classes</a></h3>
+
+<p>The pseudo-class concept is introduced to permit selection based on
+ information that lies outside of the document tree or that cannot be
+ expressed using the other simple selectors.</p>
+
+<p>A pseudo-class always consists of a "colon"
+ (<code>:</code>) followed by the name of the pseudo-class and
+ optionally by a value between parentheses.</p>
+
+<p>Pseudo-classes are allowed in all sequences of simple selectors
+ contained in a selector. Pseudo-classes are allowed anywhere in
+ sequences of simple selectors, after the leading type selector or
+ universal selector (possibly omitted). Pseudo-class names are
+ case-insensitive. Some pseudo-classes are mutually exclusive, while
+ others can be applied simultaneously to the same
+ element. Pseudo-classes may be dynamic, in the sense that an element
+ may acquire or lose a pseudo-class while a user interacts with the
+ document.</p>
+
+
+<h4><a name=dynamic-pseudos>6.6.1. Dynamic pseudo-classes</a></h4>
+
+<p>Dynamic pseudo-classes classify elements on characteristics other
+ than their name, attributes, or content, in principle characteristics
+ that cannot be deduced from the document tree.</p>
+
+<p>Dynamic pseudo-classes do not appear in the document source or
+ document tree.</p>
+
+
+<h5>The <a name=link>link pseudo-classes: :link and :visited</a></h5>
+
+<p>User agents commonly display unvisited links differently from
+ previously visited ones. Selectors
+ provides the pseudo-classes <code>:link</code> and
+ <code>:visited</code> to distinguish them:</p>
+
+<ul>
+ <li>The <code>:link</code> pseudo-class applies to links that have
+ not yet been visited.
+ </li>
+ <li>The <code>:visited</code> pseudo-class applies once the link has
+ been visited by the user.
+ </li>
+</ul>
+
+<p>After some amount of time, user agents may choose to return a
+ visited link to the (unvisited) ':link' state.</p>
+
+<p>The two states are mutually exclusive.</p>
+
+<div class="example">
+
+ <p>Example:</p>
+
+ <p>The following selector represents links carrying class
+ <code>external</code> and already visited:</p>
+
+ <pre>a.external:visited</pre>
+
+</div>
+
+<p class="note"><strong>Note:</strong> It is possible for style sheet
+ authors to abuse the :link and :visited pseudo-classes to determine
+ which sites a user has visited without the user's consent.
+
+<p>UAs may therefore treat all links as unvisited links, or implement
+ other measures to preserve the user's privacy while rendering visited
+ and unvisited links differently.</p>
+
+<h5>The <a name=useraction-pseudos>user action pseudo-classes
+ :hover, :active, and :focus</a></h5>
+
+<p>Interactive user agents sometimes change the rendering in response
+ to user actions. Selectors provides
+ three pseudo-classes for the selection of an element the user is
+ acting on.</p>
+
+<ul>
+
+ <li>The <code>:hover</code> pseudo-class applies while the user
+ designates an element with a pointing device, but does not activate
+ it. For example, a visual user agent could apply this pseudo-class
+ when the cursor (mouse pointer) hovers over a box generated by the
+ element. User agents not that do not support <a
+ href="http://www.w3.org/TR/REC-CSS2/media.html#interactive-media-group">interactive
+ media</a> do not have to support this pseudo-class. Some conforming
+ user agents that support <a
+ href="http://www.w3.org/TR/REC-CSS2/media.html#interactive-media-group">interactive
+ media</a> may not be able to support this pseudo-class (e.g., a pen
+ device that does not detect hovering).
+ </li>
+
+ <li>The <code>:active</code> pseudo-class applies while an element
+ is being activated by the user. For example, between the times the
+ user presses the mouse button and releases it.
+ </li>
+
+ <li>The <code>:focus</code> pseudo-class applies while an element
+ has the focus (accepts keyboard or mouse events, or other forms of
+ input).
+ </li>
+
+</ul>
+
+<p>There may be document language or implementation specific limits on
+ which elements can become <code>:active</code> or acquire
+ <code>:focus</code>.</p>
+
+<p>These pseudo-classes are not mutually exclusive. An element may
+ match several pseudo-classes at the same time.</p>
+
+<p>Selectors doesn't define if the parent of an element that is
+ ':active' or ':hover' is also in that state.</p>
+
+<div class="example">
+ <p>Examples:</p>
+ <pre>a:link /* unvisited links */
+a:visited /* visited links */
+a:hover /* user hovers */
+a:active /* active links */</pre>
+ <p>An example of combining dynamic pseudo-classes:</p>
+ <pre>a:focus
+a:focus:hover</pre>
+ <p>The last selector matches <code>a</code> elements that are in
+ the pseudo-class :focus and in the pseudo-class :hover.</p>
+</div>
+
+<p class="note"><strong>Note:</strong> An element can be both ':visited'
+ and ':active' (or ':link' and ':active').</p>
+
+<h4><a name=target-pseudo>6.6.2. The target pseudo-class :target</a></h4>
+
+<p>Some URIs refer to a location within a resource. This kind of URI
+ ends with a "number sign" (#) followed by an anchor
+ identifier (called the fragment identifier).</p>
+
+<p>URIs with fragment identifiers link to a certain element within the
+ document, known as the target element. For instance, here is a URI
+ pointing to an anchor named <code>section_2</code> in an HTML
+ document:</p>
+
+<pre>http://example.com/html/top.html#section_2</pre>
+
+<p>A target element can be represented by the <code>:target</code>
+ pseudo-class. If the document's URI has no fragment identifier, then
+ the document has no target element.</p>
+
+<div class="example">
+ <p>Example:</p>
+ <pre>p.note:target</pre>
+ <p>This selector represents a <code>p</code> element of class
+ <code>note</code> that is the target element of the referring
+ URI.</p>
+</div>
+
+<div class="example">
+ <p>CSS example:</p>
+
+ <p>Here, the <code>:target</code> pseudo-class is used to make the
+ target element red and place an image before it, if there is one:</p>
+ <pre>*:target { color : red }
+*:target::before { content : url(target.png) }</pre>
+</div>
+
+<h4><a name=lang-pseudo>6.6.3. The language pseudo-class :lang</a></h4>
+
+<p>If the document language specifies how the human language of an
+ element is determined, it is possible to write selectors that
+ represent an element based on its language. For example, in HTML <a
+ href="#refsHTML4">[HTML4]</a>, the language is determined by a
+ combination of the <code>lang</code> attribute, the <code>meta</code>
+ element, and possibly by information from the protocol (such as HTTP
+ headers). XML uses an attribute called <code>xml:lang</code>, and
+ there may be other document language-specific methods for determining
+ the language.</p>
+
+<p>The pseudo-class <code>:lang(C)</code> represents an element that
+ is in language C. Whether an element is represented by a
+ <code>:lang()</code> selector is based solely on the identifier C
+ being either equal to, or a hyphen-separated substring of, the
+ element's language value, in the same way as if performed by the <a
+ href="#attribute-representation">'|='</a> operator in attribute
+ selectors. The identifier C does not have to be a valid language
+ name.</p>
+
+<p>C must not be empty. (If it is, the selector is invalid.)</p>
+
+<p class="note"><strong>Note:</strong> It is recommended that
+ documents and protocols indicate language using codes from RFC 3066 <a
+ href="#refsRFC3066">[RFC3066]</a> or its successor, and by means of
+ "xml:lang" attributes in the case of XML-based documents <a
+ href="#refsXML10">[XML10]</a>. See <a
+ href="http://www.w3.org/International/questions/qa-lang-2or3.html">
+ "FAQ: Two-letter or three-letter language codes."</a></p>
+
+<div class="example">
+ <p>Examples:</p>
+
+ <p>The two following selectors represent an HTML document that is in
+ Belgian, French, or German. The two next selectors represent
+ <code>q</code> quotations in an arbitrary element in Belgian, French,
+ or German.</p>
+ <pre>html:lang(fr-be)
+html:lang(de)
+:lang(fr-be) > q
+:lang(de) > q</pre>
+</div>
+
+<h4><a name=UIstates>6.6.4. The UI element states pseudo-classes</a></h4>
+
+<h5><a name=enableddisabled>The :enabled and :disabled pseudo-classes</a></h5>
+
+<p>The <code>:enabled</code> pseudo-class allows authors to customize
+ the look of user interface elements that are enabled — which the
+ user can select or activate in some fashion (e.g. clicking on a button
+ with a mouse). There is a need for such a pseudo-class because there
+ is no way to programmatically specify the default appearance of say,
+ an enabled <code>input</code> element without also specifying what it
+ would look like when it was disabled.</p>
+
+<p>Similar to <code>:enabled</code>, <code>:disabled</code> allows the
+ author to specify precisely how a disabled or inactive user interface
+ element should look.</p>
+
+<p>Most elements will be neither enabled nor disabled. An element is
+ enabled if the user can either activate it or transfer the focus to
+ it. An element is disabled if it could be enabled, but the user cannot
+ presently activate it or transfer focus to it.</p>
+
+
+<h5><a name=checked>The :checked pseudo-class</a></h5>
+
+<p>Radio and checkbox elements can be toggled by the user. Some menu
+ items are "checked" when the user selects them. When such elements are
+ toggled "on" the <code>:checked</code> pseudo-class applies. The
+ <code>:checked</code> pseudo-class initially applies to such elements
+ that have the HTML4 <code>selected</code> and <code>checked</code>
+ attributes as described in <a
+ href="http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.2.1">Section
+ 17.2.1 of HTML4</a>, but of course the user can toggle "off" such
+ elements in which case the <code>:checked</code> pseudo-class would no
+ longer apply. While the <code>:checked</code> pseudo-class is dynamic
+ in nature, and is altered by user action, since it can also be based
+ on the presence of the semantic HTML4 <code>selected</code> and
+ <code>checked</code> attributes, it applies to all media.
+
+
+<h5><a name=indeterminate>The :indeterminate pseudo-class</a></h5>
+
+<div class="note">
+
+ <p>Radio and checkbox elements can be toggled by the user, but are
+ sometimes in an indeterminate state, neither checked nor unchecked.
+ This can be due to an element attribute, or DOM manipulation.</p>
+
+ <p>A future version of this specification may introduce an
+ <code>:indeterminate</code> pseudo-class that applies to such elements.
+ <!--While the <code>:indeterminate</code> pseudo-class is dynamic in
+ nature, and is altered by user action, since it can also be based on
+ the presence of an element attribute, it applies to all media.</p>
+
+ <p>Components of a radio-group initialized with no pre-selected choice
+ are an example of :indeterminate state.--></p>
+
+</div>
+
+
+<h4><a name=structural-pseudos>6.6.5. Structural pseudo-classes</a></h4>
+
+<p>Selectors introduces the concept of <dfn>structural
+ pseudo-classes</dfn> to permit selection based on extra information that
+ lies in
+ the document tree but cannot be represented by other simple selectors or
+ combinators.
+
+<p>Note that standalone pieces of PCDATA (text nodes in the DOM) are
+ not counted when calculating the position of an element in the list of
+ children of its parent. When calculating the position of an element in
+ the list of children of its parent, the index numbering starts at 1.
+
+
+<h5><a name=root-pseudo>:root pseudo-class</a></h5>
+
+<p>The <code>:root</code> pseudo-class represents an element that is
+ the root of the document. In HTML 4, this is always the
+ <code>HTML</code> element.
+
+
+<h5><a name=nth-child-pseudo>:nth-child() pseudo-class</a></h5>
+
+<p>The
+ <code>:nth-child(<var>a</var><code>n</code>+<var>b</var>)</code>
+ pseudo-class notation represents an element that has
+ <var>a</var><code>n</code>+<var>b</var>-1 siblings
+ <strong>before</strong> it in the document tree, for a given positive
+ integer or zero value of <code>n</code>, and has a parent element. In
+ other words, this matches the <var>b</var>th child of an element after
+ all the children have been split into groups of <var>a</var> elements
+ each. For example, this allows the selectors to address every other
+ row in a table, and could be used to alternate the color
+ of paragraph text in a cycle of four. The <var>a</var> and
+ <var>b</var> values must be zero, negative integers or positive
+ integers. The index of the first child of an element is 1.
+
+<p>In addition to this, <code>:nth-child()</code> can take
+ '<code>odd</code>' and '<code>even</code>' as arguments instead.
+ '<code>odd</code>' has the same signification as <code>2n+1</code>,
+ and '<code>even</code>' has the same signification as <code>2n</code>.
+
+
+<div class="example">
+ <p>Examples:</p>
+<pre>tr:nth-child(2n+1) /* represents every odd row of an HTML table */
+tr:nth-child(odd) /* same */
+tr:nth-child(2n) /* represents every even row of an HTML table */
+tr:nth-child(even) /* same */
+
+/* Alternate paragraph colours in CSS */
+p:nth-child(4n+1) { color: navy; }
+p:nth-child(4n+2) { color: green; }
+p:nth-child(4n+3) { color: maroon; }
+p:nth-child(4n+4) { color: purple; }</pre>
+</div>
+
+<p>When <var>a</var>=0, no repeating is used, so for example
+ <code>:nth-child(0n+5)</code> matches only the fifth child. When
+ <var>a</var>=0, the <var>a</var><code>n</code> part need not be
+ included, so the syntax simplifies to
+ <code>:nth-child(<var>b</var>)</code> and the last example simplifies
+ to <code>:nth-child(5)</code>.
+
+<div class="example">
+ <p>Examples:</p>
+<pre>foo:nth-child(0n+1) /* represents an element foo, first child of its parent element */
+foo:nth-child(1) /* same */</pre>
+</div>
+
+<p>When <var>a</var>=1, the number may be omitted from the rule.
+
+<div class="example">
+ <p>Examples:</p>
+
+ <p>The following selectors are therefore equivalent:</p>
+<pre>bar:nth-child(1n+0) /* represents all bar elements, specificity (0,1,1) */
+bar:nth-child(n+0) /* same */
+bar:nth-child(n) /* same */
+bar /* same but lower specificity (0,0,1) */</pre>
+</div>
+
+<p>If <var>b</var>=0, then every <var>a</var>th element is picked. In
+ such a case, the <var>b</var> part may be omitted.
+
+<div class="example">
+ <p>Examples:</p>
+<pre>tr:nth-child(2n+0) /* represents every even row of an HTML table */
+tr:nth-child(2n) /* same */</pre>
+</div>
+
+<p>If both <var>a</var> and <var>b</var> are equal to zero, the
+ pseudo-class represents no element in the document tree.</p>
+
+<p>The value <var>a</var> can be negative, but only the positive
+ values of <var>a</var><code>n</code>+<var>b</var>, for
+ <code>n</code>≥0, may represent an element in the document
+ tree.</p>
+
+<div class="example">
+ <p>Example:</p>
+ <pre>html|tr:nth-child(-n+6) /* represents the 6 first rows of XHTML tables */</pre>
+</div>
+
+<p>When the value <var>b</var> is negative, the "+" character in the
+ expression must be removed (it is effectively replaced by the "-"
+ character indicating the negative value of <var>b</var>).</p>
+
+<div class="example">
+ <p>Examples:</p>
+<pre>:nth-child(10n-1) /* represents the 9th, 19th, 29th, etc, element */
+:nth-child(10n+9) /* Same */
+:nth-child(10n+-1) /* Syntactically invalid, and would be ignored */</pre>
+</div>
+
+
+<h5><a name=nth-last-child-pseudo>:nth-last-child() pseudo-class</a></h5>
+
+<p>The <code>:nth-last-child(<var>a</var>n+<var>b</var>)</code>
+ pseudo-class notation represents an element that has
+ <var>a</var><code>n</code>+<var>b</var>-1 siblings
+ <strong>after</strong> it in the document tree, for a given positive
+ integer or zero value of <code>n</code>, and has a parent element. See
+ <code>:nth-child()</code> pseudo-class for the syntax of its argument.
+ It also accepts the '<code>even</code>' and '<code>odd</code>' values
+ as arguments.
+
+
+<div class="example">
+ <p>Examples:</p>
+<pre>tr:nth-last-child(-n+2) /* represents the two last rows of an HTML table */
+
+foo:nth-last-child(odd) /* represents all odd foo elements in their parent element,
+ counting from the last one */</pre>
+</div>
+
+
+<h5><a name=nth-of-type-pseudo>:nth-of-type() pseudo-class</a></h5>
+
+<p>The <code>:nth-of-type(<var>a</var>n+<var>b</var>)</code>
+ pseudo-class notation represents an element that has
+ <var>a</var><code>n</code>+<var>b</var>-1 siblings with the same
+ element name <strong>before</strong> it in the document tree, for a
+ given zero or positive integer value of <code>n</code>, and has a
+ parent element. In other words, this matches the <var>b</var>th child
+ of that type after all the children of that type have been split into
+ groups of a elements each. See <code>:nth-child()</code> pseudo-class
+ for the syntax of its argument. It also accepts the
+ '<code>even</code>' and '<code>odd</code>' values.
+
+
+<div class="example">
+ <p>CSS example:</p>
+
+ <p>This allows an author to alternate the position of floated images:</p>
+<pre>img:nth-of-type(2n+1) { float: right; }
+img:nth-of-type(2n) { float: left; }</pre>
+</div>
+
+
+<h5><a name=nth-last-of-type-pseudo>:nth-last-of-type() pseudo-class</a></h5>
+
+<p>The <code>:nth-last-of-type(<var>a</var>n+<var>b</var>)</code>
+ pseudo-class notation represents an element that has
+ <var>a</var><code>n</code>+<var>b</var>-1 siblings with the same
+ element name <strong>after</strong> it in the document tree, for a
+ given zero or positive integer value of <code>n</code>, and has a
+ parent element. See <code>:nth-child()</code> pseudo-class for the
+ syntax of its argument. It also accepts the '<code>even</code>' and '<code>odd</code>'
+ values.
+
+
+<div class="example">
+ <p>Example:</p>
+
+ <p>To represent all <code>h2</code> children of an XHTML
+ <code>body</code> except the first and last, one could use the
+ following selector:</p>
+ <pre>body > h2:nth-of-type(n+2):nth-last-of-type(n+2)</pre>
+ <p>In this case, one could also use <code>:not()</code>, although the
+ selector ends up being just as long:</p>
+ <pre>body > h2:not(:first-of-type):not(:last-of-type)</pre>
+</div>
+
+
+<h5><a name=first-child-pseudo>:first-child pseudo-class</a></h5>
+
+<p>Same as <code>:nth-child(1)</code>. The <code>:first-child</code>
+ pseudo-class
+ represents an element that is the first child of some other element.
+
+
+<div class="example">
+ <p>Examples:</p>
+
+ <p>The following selector represents a <code>p</code> element that is
+ the first child of a <code>div</code> element:</p>
+ <pre>div > p:first-child</pre>
+ <p>This selector can represent the <code>p</code> inside the
+ <code>div</code> of the following fragment:</p>
+ <pre><p> The last P before the note.</p>
+<div class="note">
+ <p> The first P inside the note.</p>
+</div></pre>
+ but cannot represent the second <code>p</code> in the following
+ fragment:
+ <pre><p> The last P before the note.</p>
+<div class="note">
+ <h2> Note </h2>
+ <p> The first P inside the note.</p>
+</div></pre>
+ <p>The following two selectors are usually equivalent:</p>
+ <pre>* > a:first-child /* a is first child of any element */
+a:first-child /* Same (assuming a is not the root element) */</pre>
+</div>
+
+<h5><a name=last-child-pseudo>:last-child pseudo-class</a></h5>
+
+<p>Same as <code>:nth-last-child(1)</code>. The <code>:last-child</code>
+ pseudo-class
+ represents an element that is the last child of some other element.
+
+<div class="example">
+ <p>Example:</p>
+
+ <p>The following selector represents a list item <code>li</code> that
+ is the last child of an ordered list <code>ol</code>.
+ <pre>ol > li:last-child</pre>
+</div>
+
+<h5><a name=first-of-type-pseudo>:first-of-type pseudo-class</a></h5>
+
+<p>Same as <code>:nth-of-type(1)</code>. The <code>:first-of-type</code>
+ pseudo-class
+ represents an element that is the first sibling of its type in the list of
+ children of its parent element.
+
+<div class="example">
+ <p>Example:</p>
+
+ <p>The following selector represents a definition title
+ <code>dt</code> inside a definition list <code>dl</code>, this
+ <code>dt</code> being the first of its type in the list of children of
+ its parent element.</p>
+ <pre>dl dt:first-of-type</pre>
+ <p>It is a valid description for the first two <code>dt</code>
+ elements in the following example but not for the third one:</p>
+<pre><dl>
+ <dt>gigogne</dt>
+ <dd>
+ <dl>
+ <dt>fusée</dt>
+ <dd>multistage rocket</dd>
+ <dt>table</dt>
+ <dd>nest of tables</dd>
+ </dl>
+ </dd>
+</dl></pre>
+</div>
+
+<h5><a name=last-of-type-pseudo>:last-of-type pseudo-class</a></h5>
+
+<p>Same as <code>:nth-last-of-type(1)</code>. The
+ <code>:last-of-type</code> pseudo-class represents an element that is
+ the last sibling of its type in the list of children of its parent
+ element.</p>
+
+<div class="example">
+ <p>Example:</p>
+
+ <p>The following selector represents the last data cell
+ <code>td</code> of a table row.</p>
+ <pre>tr > td:last-of-type</pre>
+</div>
+
+<h5><a name=only-child-pseudo>:only-child pseudo-class</a></h5>
+
+<p>Represents an element that has a parent element and whose parent
+ element has no other element children. Same as
+ <code>:first-child:last-child</code> or
+ <code>:nth-child(1):nth-last-child(1)</code>, but with a lower
+ specificity.</p>
+
+<h5><a name=only-of-type-pseudo>:only-of-type pseudo-class</a></h5>
+
+<p>Represents an element that has a parent element and whose parent
+ element has no other element children with the same element name. Same
+ as <code>:first-of-type:last-of-type</code> or
+ <code>:nth-of-type(1):nth-last-of-type(1)</code>, but with a lower
+ specificity.</p>
+
+
+<h5><a name=empty-pseudo></a>:empty pseudo-class</h5>
+
+<p>The <code>:empty</code> pseudo-class represents an element that has
+ no children at all. In terms of the DOM, only element nodes and text
+ nodes (including CDATA nodes and entity references) whose data has a
+ non-zero length must be considered as affecting emptiness; comments,
+ PIs, and other nodes must not affect whether an element is considered
+ empty or not.</p>
+
+<div class="example">
+ <p>Examples:</p>
+
+ <p><code>p:empty</code> is a valid representation of the following fragment:
+ </p>
+ <pre><p></p></pre>
+ <p><code>foo:empty</code> is not a valid representation for the
+ following fragments:</p>
+ <pre><foo>bar</foo></pre>
+ <pre><foo><bar>bla</bar></foo></pre>
+ <pre><foo>this is not <bar>:empty</bar></foo></pre>
+</div>
+
+<h4><a name=content-selectors>6.6.6. Blank</a></h4>
+<!-- It's the Return of Appendix H!!! Run away! -->
+
+<p>This section intentionally left blank.</p>
+<!-- (used to be :contains()) -->
+
+<h4><a name=negation></a>6.6.7. The negation pseudo-class</h4>
+
+<p>The negation pseudo-class, <code>:not(<var>X</var>)</code>, is a
+ functional notation taking a <a href="#simple-selectors-dfn">simple
+ selector</a> (excluding the negation pseudo-class itself and
+ pseudo-elements) as an argument. It represents an element that is not
+ represented by the argument.
+
+ <!-- pseudo-elements are not simple selectors, so the above paragraph
+may be a bit confusing -->
+
+<div class="example">
+ <p>Examples:</p>
+
+ <p>The following CSS selector matches all <code>button</code>
+ elements in an HTML document that are not disabled.</p>
+ <pre>button:not([DISABLED])</pre>
+ <p>The following selector represents all but <code>FOO</code>
+ elements.</p>
+ <pre>*:not(FOO)</pre>
+ <p>The following group of selectors represents all HTML elements
+ except links.</p>
+ <pre>html|*:not(:link):not(:visited)</pre>
+</div>
+
+<p>Default namespace declarations do not affect the argument of the
+ negation pseudo-class unless the argument is a universal selector or a
+ type selector.</p>
+
+<div class="example">
+ <p>Examples:</p>
+
+ <p>Assuming that the default namespace is bound to
+ "http://example.com/", the following selector represents all
+ elements that are not in that namespace:</p>
+ <pre>*|*:not(*)</pre>
+ <p>The following CSS selector matches any element being hovered,
+ regardless of its namespace. In particular, it is not limited to
+ only matching elements in the default namespace that are not being
+ hovered, and elements not in the default namespace don't match the
+ rule when they <em>are</em> being hovered.</p>
+ <pre>*|*:not(:hover)</pre>
+</div>
+
+<p class="note"><strong>Note</strong>: the :not() pseudo allows
+ useless selectors to be written. For instance <code>:not(*|*)</code>,
+ which represents no element at all, or <code>foo:not(bar)</code>,
+ which is equivalent to <code>foo</code> but with a higher
+ specificity.</p>
+
+<h3><a name=pseudo-elements>7. Pseudo-elements</a></h3>
+
+<p>Pseudo-elements create abstractions about the document tree beyond
+ those specified by the document language. For instance, document
+ languages do not offer mechanisms to access the first letter or first
+ line of an element's content. Pseudo-elements allow designers to refer
+ to this otherwise inaccessible information. Pseudo-elements may also
+ provide designers a way to refer to content that does not exist in the
+ source document (e.g., the <code>::before</code> and
+ <code>::after</code> pseudo-elements give access to generated
+ content).</p>
+
+<p>A pseudo-element is made of two colons (<code>::</code>) followed
+ by the name of the pseudo-element.</p>
+
+<p>This <code>::</code> notation is introduced by the current document
+ in order to establish a discrimination between pseudo-classes and
+ pseudo-elements. For compatibility with existing style sheets, user
+ agents must also accept the previous one-colon notation for
+ pseudo-elements introduced in CSS levels 1 and 2 (namely,
+ <code>:first-line</code>, <code>:first-letter</code>,
+ <code>:before</code> and <code>:after</code>). This compatibility is
+ not allowed for the new pseudo-elements introduced in CSS level 3.</p>
+
+<p>Only one pseudo-element may appear per selector, and if present it
+ must appear after the sequence of simple selectors that represents the
+ <a href="#subject">subjects</a> of the selector. <span class="note">A
+future version of this specification may allow multiple
+pesudo-elements per selector.</span></p>
+
+<h4><a name=first-line>7.1. The ::first-line pseudo-element</a></h4>
+
+<p>The <code>::first-line</code> pseudo-element describes the contents
+ of the first formatted line of an element.
+
+<div class="example">
+ <p>CSS example:</p>
+ <pre>p::first-line { text-transform: uppercase }</pre>
+ <p>The above rule means "change the letters of the first line of every
+ paragraph to uppercase".</p>
+</div>
+
+<p>The selector <code>p::first-line</code> does not match any real
+ HTML element. It does match a pseudo-element that conforming user
+ agents will insert at the beginning of every paragraph.</p>
+
+<p>Note that the length of the first line depends on a number of
+ factors, including the width of the page, the font size, etc. Thus,
+ an ordinary HTML paragraph such as:</p>
+
+<pre>
+<P>This is a somewhat long HTML
+paragraph that will be broken into several
+lines. The first line will be identified
+by a fictional tag sequence. The other lines
+will be treated as ordinary lines in the
+paragraph.</P>
+</pre>
+
+<p>the lines of which happen to be broken as follows:
+
+<pre>
+THIS IS A SOMEWHAT LONG HTML PARAGRAPH THAT
+will be broken into several lines. The first
+line will be identified by a fictional tag
+sequence. The other lines will be treated as
+ordinary lines in the paragraph.
+</pre>
+
+<p>This paragraph might be "rewritten" by user agents to include the
+ <em>fictional tag sequence</em> for <code>::first-line</code>. This
+ fictional tag sequence helps to show how properties are inherited.</p>
+
+<pre>
+<P><b><P::first-line></b> This is a somewhat long HTML
+paragraph that <b></P::first-line></b> will be broken into several
+lines. The first line will be identified
+by a fictional tag sequence. The other lines
+will be treated as ordinary lines in the
+paragraph.</P>
+</pre>
+
+<p>If a pseudo-element breaks up a real element, the desired effect
+ can often be described by a fictional tag sequence that closes and
+ then re-opens the element. Thus, if we mark up the previous paragraph
+ with a <code>span</code> element:</p>
+
+<pre>
+<P><b><SPAN class="test"></b> This is a somewhat long HTML
+paragraph that will be broken into several
+lines.<b></SPAN></b> The first line will be identified
+by a fictional tag sequence. The other lines
+will be treated as ordinary lines in the
+paragraph.</P>
+</pre>
+
+<p>the user agent could simulate start and end tags for
+ <code>span</code> when inserting the fictional tag sequence for
+ <code>::first-line</code>.
+
+<pre>
+<P><P::first-line><b><SPAN class="test"></b> This is a
+somewhat long HTML
+paragraph that will <b></SPAN></b></P::first-line><b><SPAN
+ class="test"></b> be
+broken into several
+lines.<b></SPAN></b> The first line will be identified
+by a fictional tag sequence. The other lines
+will be treated as ordinary lines in the
+paragraph.</P>
+</pre>
+
+<p>In CSS, the <code>::first-line</code> pseudo-element can only be
+ attached to a block-level element, an inline-block, a table-caption,
+ or a table-cell.</p>
+
+<p><a name="first-formatted-line"></a>The "first formatted line" of an
+ element may occur inside a
+ block-level descendant in the same flow (i.e., a block-level
+ descendant that is not positioned and not a float). E.g., the first
+ line of the <code>div</code> in <code><DIV><P>This
+ line...</P></DIV></code> is the first line of the <code>p</code>
+ (assuming
+ that both <code>p</code> and <code>div</code> are block-level).
+
+<p>The first line of a table-cell or inline-block cannot be the first
+ formatted line of an ancestor element. Thus, in <code><DIV><P
+ STYLE="display: inline-block">Hello<BR>Goodbye</P>
+ etcetera</DIV></code> the first formatted line of the
+ <code>div</code> is not the line "Hello".
+
+<p class="note">Note that the first line of the <code>p</code> in this
+ fragment: <code><p><br>First...</code> doesn't contain any
+ letters (assuming the default style for <code>br</code> in HTML
+ 4). The word "First" is not on the first formatted line.
+
+<p>A UA should act as if the fictional start tags of the
+ <code>::first-line</code> pseudo-elements were nested just inside the
+ innermost enclosing block-level element. (Since CSS1 and CSS2 were
+ silent on this case, authors should not rely on this behavior.) Here
+ is an example. The fictional tag sequence for</p>
+
+<pre>
+<DIV>
+ <P>First paragraph</P>
+ <P>Second paragraph</P>
+</DIV>
+</pre>
+
+<p>is</p>
+
+<pre>
+<DIV>
+ <P><DIV::first-line><P::first-line>First paragraph</P::first-line></DIV::first-line></P>
+ <P><P::first-line>Second paragraph</P::first-line></P>
+</DIV>
+</pre>
+
+<p>The <code>::first-line</code> pseudo-element is similar to an
+ inline-level element, but with certain restrictions. In CSS, the
+ following properties apply to a <code>::first-line</code>
+ pseudo-element: font properties, color property, background
+ properties, 'word-spacing', 'letter-spacing', 'text-decoration',
+ 'vertical-align', 'text-transform', 'line-height'. UAs may apply other
+ properties as well.</p>
+
+
+<h4><a name=first-letter>7.2. The ::first-letter pseudo-element</a></h4>
+
+<p>The <code>::first-letter</code> pseudo-element represents the first
+ letter of the first line of a block, if it is not preceded by any
+ other content (such as images or inline tables) on its line. The
+ ::first-letter pseudo-element may be used for "initial caps" and "drop
+ caps", which are common typographical effects. This type of initial
+ letter is similar to an inline-level element if its 'float' property
+ is 'none'; otherwise, it is similar to a floated element.</p>
+
+<p>In CSS, these are the properties that apply to <code>::first-letter</code>
+ pseudo-elements: font properties, 'text-decoration', 'text-transform',
+ 'letter-spacing', 'word-spacing' (when appropriate), 'line-height',
+ 'float', 'vertical-align' (only if 'float' is 'none'), margin
+ properties, padding properties, border properties, color property,
+ background properties. UAs may apply other properties as well. To
+ allow UAs to render a typographically correct drop cap or initial cap,
+ the UA may choose a line-height, width and height based on the shape
+ of the letter, unlike for normal elements.</p>
+
+<div class="example">
+ <p>Example:</p>
+
+ <p>This example shows a possible rendering of an initial cap. Note
+ that the 'line-height' that is inherited by the
+ <code>::first-letter</code>
+ pseudo-element is 1.1, but the UA in this example has computed the
+ height of the first letter differently, so that it doesn't cause any
+ unnecessary space between the first two lines. Also note that the
+ fictional start tag of the first letter is inside the <span>span</span>,
+ and thus
+ the font weight of the first letter is normal, not bold as the <span>span</span>:
+<pre>
+p { line-height: 1.1 }
+p::first-letter { font-size: 3em; font-weight: normal }
+span { font-weight: bold }
+...
+<p><span>Het hemelsche</span> gerecht heeft zich ten lange lesten<br>
+Erbarremt over my en mijn benaeuwde vesten<br>
+En arme burgery, en op mijn volcx gebed<br>
+En dagelix geschrey de bange stad ontzet.
+</pre>
+ <div class="figure">
+ <p><img src="initial-cap.png"
+ alt="Image illustrating the ::first-letter pseudo-element">
+ </div>
+</div>
+
+<div class="example">
+ <p>The following CSS will make a drop cap initial letter span about two
+ lines:</p>
+
+<pre>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
+<HTML>
+ <HEAD>
+ <TITLE>Drop cap initial letter</TITLE>
+ <STYLE type="text/css">
+ P { font-size: 12pt; line-height: 1.2 }
+ P::first-letter { font-size: 200%; font-weight: bold; float: left }
+ SPAN { text-transform: uppercase }
+ </STYLE>
+ </HEAD>
+ <BODY>
+ <P><SPAN>The first</SPAN> few words of an article
+ in The Economist.</P>
+ </BODY>
+</HTML>
+</pre>
+
+ <p>This example might be formatted as follows:</p>
+
+ <div class="figure">
+ <P><img src="first-letter.gif"
+ alt="Image illustrating the combined effect of the ::first-letter and ::first-line pseudo-elements">
+ </p>
+ </div>
+
+ <p>The <span class="index-inst" title="fictional tag
+sequence">fictional tag sequence</span> is:</p>
+
+<pre>
+<P>
+<SPAN>
+<P::first-letter>
+T
+</P::first-letter>he first
+</SPAN>
+few words of an article in the Economist.
+</P>
+</pre>
+
+ <p>Note that the <code>::first-letter</code> pseudo-element tags abut
+ the content (i.e., the initial character), while the ::first-line
+ pseudo-element start tag is inserted right after the start tag of the
+ block element.</p></div>
+
+<p>In order to achieve traditional drop caps formatting, user agents
+ may approximate font sizes, for example to align baselines. Also, the
+ glyph outline may be taken into account when formatting.</p>
+
+<p>Punctuation (i.e, characters defined in Unicode in the "open" (Ps),
+ "close" (Pe), "initial" (Pi). "final" (Pf) and "other" (Po)
+ punctuation classes), that precedes or follows the first letter should
+ be included. <a href="#refsUNICODE">[UNICODE]</a></p>
+
+<div class="figure">
+ <P><img src="first-letter2.gif" alt="Quotes that precede the
+first letter should be included."></p>
+</div>
+
+<p>The <code>::first-letter</code> also applies if the first letter is
+ in fact a digit, e.g., the "6" in "67 million dollars is a lot of
+ money."</p>
+
+<p>In CSS, the <code>::first-letter</code> pseudo-element applies to
+ block, list-item, table-cell, table-caption, and inline-block
+ elements. <span class="note">A future version of this specification
+may allow this pesudo-element to apply to more element
+types.</span></p>
+
+<p>The <code>::first-letter</code> pseudo-element can be used with all
+ such elements that contain text, or that have a descendant in the same
+ flow that contains text. A UA should act as if the fictional start tag
+ of the ::first-letter pseudo-element is just before the first text of
+ the element, even if that first text is in a descendant.</p>
+
+<div class="example">
+ <p>Example:</p>
+
+ <p>The fictional tag sequence for this HTMLfragment:
+<pre><div>
+<p>The first text.</pre>
+ <p>is:
+<pre><div>
+<p><div::first-letter><p::first-letter>T</...></...>he first text.</pre>
+</div>
+
+<p>The first letter of a table-cell or inline-block cannot be the
+ first letter of an ancestor element. Thus, in <code><DIV><P
+ STYLE="display: inline-block">Hello<BR>Goodbye</P>
+ etcetera</DIV></code> the first letter of the <code>div</code> is
+ not the
+ letter "H". In fact, the <code>div</code> doesn't have a first letter.
+
+<p>The first letter must occur on the <a
+ href="#first-formatted-line">first formatted line.</a> For example, in
+ this fragment: <code><p><br>First...</code> the first line
+ doesn't contain any letters and <code>::first-letter</code> doesn't
+ match anything (assuming the default style for <code>br</code> in HTML
+ 4). In particular, it does not match the "F" of "First."
+
+<p>In CSS, if an element is a list item ('display: list-item'), the
+ <code>::first-letter</code> applies to the first letter in the
+ principal box after the marker. UAs may ignore
+ <code>::first-letter</code> on list items with 'list-style-position:
+ inside'. If an element has <code>::before</code> or
+ <code>::after</code> content, the <code>::first-letter</code> applies
+ to the first letter of the element <em>including</em> that content.
+
+<div class="example">
+ <p>Example:</p>
+
+ <p>After the rule 'p::before {content: "Note: "}', the selector
+ 'p::first-letter' matches the "N" of "Note".</p>
+</div>
+
+<p>Some languages may have specific rules about how to treat certain
+ letter combinations. In Dutch, for example, if the letter combination
+ "ij" appears at the beginning of a word, both letters should be
+ considered within the <code>::first-letter</code> pseudo-element.
+
+<p>If the letters that would form the ::first-letter are not in the
+ same element, such as "'T" in <code><p>'<em>T...</code>, the UA
+ may create a ::first-letter pseudo-element from one of the elements,
+ both elements, or simply not create a pseudo-element.</p>
+
+<p>Similarly, if the first letter(s) of the block are not at the start
+ of the line (for example due to bidirectional reordering), then the UA
+ need not create the pseudo-element(s).
+
+<div class="example">
+ <p>Example:</p>
+
+ <p><a name="overlapping-example">The following example</a> illustrates
+ how overlapping pseudo-elements may interact. The first letter of
+ each P element will be green with a font size of '24pt'. The rest of
+ the first formatted line will be 'blue' while the rest of the
+ paragraph will be 'red'.</p>
+
+<pre>p { color: red; font-size: 12pt }
+p::first-letter { color: green; font-size: 200% }
+p::first-line { color: blue }
+
+<P>Some text that ends up on two lines</P></pre>
+
+ <p>Assuming that a line break will occur before the word "ends", the
+<span class="index-inst" title="fictional tag sequence">fictional tag
+sequence</span> for this fragment might be:</p>
+
+<pre><P>
+<P::first-line>
+<P::first-letter>
+S
+</P::first-letter>ome text that
+</P::first-line>
+ends up on two lines
+</P></pre>
+
+ <p>Note that the <code>::first-letter</code> element is inside the <code>::first-line</code>
+ element. Properties set on <code>::first-line</code> are inherited by
+ <code>::first-letter</code>, but are overridden if the same property is
+ set on
+ <code>::first-letter</code>.</p>
+</div>
+
+
+<h4><a name=UIfragments>7.3.</a> <a name=selection>The ::selection
+ pseudo-element</a></h4>
+
+<p>The <code>::selection</code> pseudo-element applies to the portion
+ of a document that has been highlighted by the user. This also
+ applies, for example, to selected text within an editable text
+ field. This pseudo-element should not be confused with the <code><a
+ href="#checked">:checked</a></code> pseudo-class (which used to be
+ named <code>:selected</code>)
+
+<p>Although the <code>::selection</code> pseudo-element is dynamic in
+ nature, and is altered by user action, it is reasonable to expect that
+ when a UA re-renders to a static medium (such as a printed page, see
+ <a href="#refsCSS21">[CSS21]</a>) which was originally rendered to a
+ dynamic medium (like screen), the UA may wish to transfer the current
+ <code>::selection</code> state to that other medium, and have all the
+ appropriate formatting and rendering take effect as well. This is not
+ required — UAs may omit the <code>::selection</code>
+ pseudo-element for static media.
+
+<p>These are the CSS properties that apply to <code>::selection</code>
+ pseudo-elements: color, background, cursor (optional), outline
+ (optional). The computed value of the 'background-image' property on
+ <code>::selection</code> may be ignored.
+
+
+<h4><a name=gen-content>7.4. The ::before and ::after pseudo-elements</a></h4>
+
+<p>The <code>::before</code> and <code>::after</code> pseudo-elements
+ can be used to describe generated content before or after an element's
+ content. They are explained in CSS 2.1 <a
+ href="#refsCSS21">[CSS21]</a>.</p>
+
+<p>When the <code>::first-letter</code> and <code>::first-line</code>
+ pseudo-elements are combined with <code>::before</code> and
+ <code>::after</code>, they apply to the first letter or line of the
+ element including the inserted text.</p>
+
+<h2><a name=combinators>8. Combinators</a></h2>
+
+<h3><a name=descendant-combinators>8.1. Descendant combinator</a></h3>
+
+<p>At times, authors may want selectors to describe an element that is
+ the descendant of another element in the document tree (e.g., "an
+ <code>EM</code> element that is contained within an <code>H1</code>
+ element"). Descendant combinators express such a relationship. A
+ descendant combinator is <a href="#whitespace">white space</a> that
+ separates two sequences of simple selectors. A selector of the form
+ "<code>A B</code>" represents an element <code>B</code> that is an
+ arbitrary descendant of some ancestor element <code>A</code>.
+
+<div class="example">
+ <p>Examples:</p>
+
+ <p>For example, consider the following selector:</p>
+ <pre>h1 em</pre>
+ <p>It represents an <code>em</code> element being the descendant of
+ an <code>h1</code> element. It is a correct and valid, but partial,
+ description of the following fragment:</p>
+ <pre><h1>This <span class="myclass">headline
+is <em>very</em> important</span></h1></pre>
+ <p>The following selector:</p>
+ <pre>div * p</pre>
+ <p>represents a <code>p</code> element that is a grandchild or later
+ descendant of a <code>div</code> element. Note the whitespace on
+ either side of the "*" is not part of the universal selector; the
+ whitespace is a combinator indicating that the DIV must be the
+ ancestor of some element, and that that element must be an ancestor
+ of the P.</p>
+
+ <p>The following selector, which combines descendant combinators and
+ <a href="#attribute-selectors">attribute selectors</a>, represents an
+ element that (1) has the <code>href</code> attribute set and (2) is
+ inside a <code>p</code> that is itself inside a <code>div</code>:</p>
+ <pre>div p *[href]</pre>
+</div>
+
+<h3><a name=child-combinators>8.2. Child combinators</a></h3>
+
+<p>A <dfn>child combinator</dfn> describes a childhood relationship
+ between two elements. A child combinator is made of the
+ "greater-than sign" (<code>></code>) character and
+ separates two sequences of simple selectors.
+
+
+<div class="example">
+ <p>Examples:</p>
+
+ <p>The following selector represents a <code>p</code> element that is
+ child of <code>body</code>:</p>
+ <pre>body > p</pre>
+ <p>The following example combines descendant combinators and child
+ combinators.</p>
+ <pre>div ol>li p</pre>
+ <!-- LEAVE THOSE SPACES OUT! see below -->
+ <p>It represents a <code>p</code> element that is a descendant of an
+ <code>li</code> element; the <code>li</code> element must be the
+ child of an <code>ol</code> element; the <code>ol</code> element must
+ be a descendant of a <code>div</code>. Notice that the optional white
+ space around the ">" combinator has been left out.</p>
+</div>
+
+<p>For information on selecting the first child of an element, please
+ see the section on the <code><a
+ href="#structural-pseudos">:first-child</a></code> pseudo-class
+ above.</p>
+
+<h3><a name=sibling-combinators>8.3. Sibling combinators</a></h3>
+
+<p>There are two different sibling combinators: the adjacent sibling
+ combinator and the general sibling combinator. In both cases,
+ non-element nodes (e.g. text between elements) are ignored when
+ considering adjacency of elements.</p>
+
+<h4><a name=adjacent-sibling-combinators>8.3.1. Adjacent sibling combinator</a>
+</h4>
+
+<p>The adjacent sibling combinator is made of the "plus
+ sign" (U+002B, <code>+</code>) character that separates two
+ sequences of simple selectors. The elements represented by the two
+ sequences share the same parent in the document tree and the element
+ represented by the first sequence immediately precedes the element
+ represented by the second one.</p>
+
+<div class="example">
+ <p>Examples:</p>
+
+ <p>The following selector represents a <code>p</code> element
+ immediately following a <code>math</code> element:</p>
+ <pre>math + p</pre>
+ <p>The following selector is conceptually similar to the one in the
+ previous example, except that it adds an attribute selector — it
+ adds a constraint to the <code>h1</code> element, that it must have
+ <code>class="opener"</code>:</p>
+ <pre>h1.opener + h2</pre>
+</div>
+
+
+<h4><a name=general-sibling-combinators>8.3.2. General sibling combinator</a>
+</h4>
+
+<p>The general sibling combinator is made of the "tilde"
+ (U+007E, <code>~</code>) character that separates two sequences of
+ simple selectors. The elements represented by the two sequences share
+ the same parent in the document tree and the element represented by
+ the first sequence precedes (not necessarily immediately) the element
+ represented by the second one.</p>
+
+<div class="example">
+ <p>Example:</p>
+ <pre>h1 ~ pre</pre>
+ <p>represents a <code>pre</code> element following an <code>h1</code>. It
+ is a correct and valid, but partial, description of:</p>
+ <pre><h1>Definition of the function a</h1>
+<p>Function a(x) has to be applied to all figures in the table.</p>
+<pre>function a(x) = 12x/13.5</pre></pre>
+</div>
+
+<h2><a name=specificity>9. Calculating a selector's specificity</a></h2>
+
+<p>A selector's specificity is calculated as follows:</p>
+
+<ul>
+ <li>count the number of ID selectors in the selector (= a)</li>
+ <li>count the number of class selectors, attributes selectors, and
+ pseudo-classes in the selector (= b)
+ </li>
+ <li>count the number of element names in the selector (= c)</li>
+ <li>ignore pseudo-elements</li>
+</ul>
+
+<p>Selectors inside <a href="#negation">the negation pseudo-class</a>
+ are counted like any other, but the negation itself does not count as
+ a pseudo-class.</p>
+
+<p>Concatenating the three numbers a-b-c (in a number system with a
+ large base) gives the specificity.</p>
+
+<div class="example">
+ <p>Examples:</p>
+<pre>* /* a=0 b=0 c=0 -> specificity = 0 */
+LI /* a=0 b=0 c=1 -> specificity = 1 */
+UL LI /* a=0 b=0 c=2 -> specificity = 2 */
+UL OL+LI /* a=0 b=0 c=3 -> specificity = 3 */
+H1 + *[REL=up] /* a=0 b=1 c=1 -> specificity = 11 */
+UL OL LI.red /* a=0 b=1 c=3 -> specificity = 13 */
+LI.red.level /* a=0 b=2 c=1 -> specificity = 21 */
+#x34y /* a=1 b=0 c=0 -> specificity = 100 */
+#s12:not(FOO) /* a=1 b=0 c=1 -> specificity = 101 */
+</pre>
+</div>
+
+<p class="note"><strong>Note:</strong> the specificity of the styles
+ specified in an HTML <code>style</code> attribute is described in CSS
+ 2.1. <a href="#refsCSS21">[CSS21]</a>.</p>
+
+<h2><a name=w3cselgrammar>10. The grammar of Selectors</a></h2>
+
+<h3><a name=grammar>10.1. Grammar</a></h3>
+
+<p>The grammar below defines the syntax of Selectors. It is globally
+ LL(1) and can be locally LL(2) (but note that most UA's should not use
+ it directly, since it doesn't express the parsing conventions). The
+ format of the productions is optimized for human consumption and some
+ shorthand notations beyond Yacc (see <a href="#refsYACC">[YACC]</a>)
+ are used:</p>
+
+<ul>
+ <li><b>*</b>: 0 or more
+ <li><b>+</b>: 1 or more
+ <li><b>?</b>: 0 or 1
+ <li><b>|</b>: separates alternatives
+ <li><b>[ ]</b>: grouping</li>
+</ul>
+
+<p>The productions are:</p>
+
+<pre>selectors_group
+ : selector [ COMMA S* selector ]*
+ ;
+
+selector
+ : simple_selector_sequence [ combinator simple_selector_sequence ]*
+ ;
+
+combinator
+ /* combinators can be surrounded by white space */
+ : PLUS S* | GREATER S* | TILDE S* | S+
+ ;
+
+simple_selector_sequence
+ : [ type_selector | universal ]
+ [ HASH | class | attrib | pseudo | negation ]*
+ | [ HASH | class | attrib | pseudo | negation ]+
+ ;
+
+type_selector
+ : [ namespace_prefix ]? element_name
+ ;
+
+namespace_prefix
+ : [ IDENT | '*' ]? '|'
+ ;
+
+element_name
+ : IDENT
+ ;
+
+universal
+ : [ namespace_prefix ]? '*'
+ ;
+
+class
+ : '.' IDENT
+ ;
+
+attrib
+ : '[' S* [ namespace_prefix ]? IDENT S*
+ [ [ PREFIXMATCH |
+ SUFFIXMATCH |
+ SUBSTRINGMATCH |
+ '=' |
+ INCLUDES |
+ DASHMATCH ] S* [ IDENT | STRING ] S*
+ ]? ']'
+ ;
+
+pseudo
+ /* '::' starts a pseudo-element, ':' a pseudo-class */
+ /* Exceptions: :first-line, :first-letter, :before and :after. */
+ /* Note that pseudo-elements are restricted to one per selector and */
+ /* occur only in the last simple_selector_sequence. */
+ : ':' ':'? [ IDENT | functional_pseudo ]
+ ;
+
+functional_pseudo
+ : FUNCTION S* expression ')'
+ ;
+
+expression
+ /* In CSS3, the expressions are identifiers, strings, */
+ /* or of the form "an+b" */
+ : [ [ PLUS | '-' | DIMENSION | NUMBER | STRING | IDENT ] S* ]+
+ ;
+
+negation
+ : NOT S* negation_arg S* ')'
+ ;
+
+negation_arg
+ : type_selector | universal | HASH | class | attrib | pseudo
+ ;</pre>
+
+
+<h3><a name=lex>10.2. Lexical scanner</a></h3>
+
+<p>The following is the <a name=x3>tokenizer</a>, written in Flex (see
+ <a href="#refsFLEX">[FLEX]</a>) notation. The tokenizer is
+ case-insensitive.</p>
+
+<p>The two occurrences of "\377" represent the highest character
+ number that current versions of Flex can deal with (decimal 255). They
+ should be read as "\4177777" (decimal 1114111), which is the highest
+ possible code point in Unicode/ISO-10646. <a
+ href="#refsUNICODE">[UNICODE]</a></p>
+
+<pre>%option case-insensitive
+
+ident [-]?{nmstart}{nmchar}*
+name {nmchar}+
+nmstart [_a-z]|{nonascii}|{escape}
+nonascii [^\0-\177]
+unicode \\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?
+escape {unicode}|\\[^\n\r\f0-9a-f]
+nmchar [_a-z0-9-]|{nonascii}|{escape}
+num [0-9]+|[0-9]*\.[0-9]+
+string {string1}|{string2}
+string1 \"([^\n\r\f\\"]|\\{nl}|{nonascii}|{escape})*\"
+string2 \'([^\n\r\f\\']|\\{nl}|{nonascii}|{escape})*\'
+invalid {invalid1}|{invalid2}
+invalid1 \"([^\n\r\f\\"]|\\{nl}|{nonascii}|{escape})*
+invalid2 \'([^\n\r\f\\']|\\{nl}|{nonascii}|{escape})*
+nl \n|\r\n|\r|\f
+w [ \t\r\n\f]*
+
+%%
+
+[ \t\r\n\f]+ return S;
+
+"~=" return INCLUDES;
+"|=" return DASHMATCH;
+"^=" return PREFIXMATCH;
+"$=" return SUFFIXMATCH;
+"*=" return SUBSTRINGMATCH;
+{ident} return IDENT;
+{string} return STRING;
+{ident}"(" return FUNCTION;
+{num} return NUMBER;
+"#"{name} return HASH;
+{w}"+" return PLUS;
+{w}">" return GREATER;
+{w}"," return COMMA;
+{w}"~" return TILDE;
+":not(" return NOT;
+@{ident} return ATKEYWORD;
+{invalid} return INVALID;
+{num}% return PERCENTAGE;
+{num}{ident} return DIMENSION;
+"<!--" return CDO;
+"-->" return CDC;
+
+"url("{w}{string}{w}")" return URI;
+"url("{w}([!#$%&*-~]|{nonascii}|{escape})*{w}")" return URI;
+U\+[0-9a-f?]{1,6}(-[0-9a-f]{1,6})? return UNICODE_RANGE;
+
+\/\*[^*]*\*+([^/*][^*]*\*+)*\/ /* ignore comments */
+
+. return *yytext;</pre>
+
+
+<h2><a name=downlevel>11. Namespaces and down-level clients</a></h2>
+
+<p>An important issue is the interaction of CSS selectors with XML
+ documents in web clients that were produced prior to this
+ document. Unfortunately, due to the fact that namespaces must be
+ matched based on the URI which identifies the namespace, not the
+ namespace prefix, some mechanism is required to identify namespaces in
+ CSS by their URI as well. Without such a mechanism, it is impossible
+ to construct a CSS style sheet which will properly match selectors in
+ all cases against a random set of XML documents. However, given
+ complete knowledge of the XML document to which a style sheet is to be
+ applied, and a limited use of namespaces within the XML document, it
+ is possible to construct a style sheet in which selectors would match
+ elements and attributes correctly.</p>
+
+<p>It should be noted that a down-level CSS client will (if it
+ properly conforms to CSS forward compatible parsing rules) ignore all
+ <code>@namespace</code> at-rules, as well as all style rules that make
+ use of namespace qualified element type or attribute selectors. The
+ syntax of delimiting namespace prefixes in CSS was deliberately chosen
+ so that down-level CSS clients would ignore the style rules rather
+ than possibly match them incorrectly.</p>
+
+<p>The use of default namespaces in CSS makes it possible to write
+ element type selectors that will function in both namespace aware CSS
+ clients as well as down-level clients. It should be noted that
+ down-level clients may incorrectly match selectors against XML
+ elements in other namespaces.</p>
+
+<p>The following are scenarios and examples in which it is possible to
+ construct style sheets which would function properly in web clients
+ that do not implement this proposal.</p>
+
+<ol>
+ <li>
+
+ <p>The XML document does not use namespaces.</p>
+
+ <ul>
+
+ <li>In this case, it is obviously not necessary to declare or use
+ namespaces in the style sheet. Standard CSS element type and
+ attribute selectors will function adequately in a down-level
+ client.
+ </li>
+
+ <li>In a CSS namespace aware client, the default behavior of
+ element selectors matching without regard to namespace will
+ function properly against all elements, since no namespaces are
+ present. However, the use of specific element type selectors
+ that
+ match only elements that have no namespace ("<code>|name</code>")
+ will guarantee that selectors will match only XML elements that
+ do
+ not have a declared namespace.
+ </li>
+
+ </ul>
+
+ </li>
+
+ <li>
+
+ <p>The XML document defines a single, default namespace used
+ throughout the document. No namespace prefixes are used in element
+ names.</p>
+
+ <ul>
+
+ <li>In this case, a down-level client will function as if
+ namespaces were not used in the XML document at all. Standard
+ CSS
+ element type and attribute selectors will match against all
+ elements.
+ </li>
+
+ </ul>
+
+ </li>
+
+ <li>
+
+ <p>The XML document does <b>not</b> use a default namespace, all
+ namespace prefixes used are known to the style sheet author, and
+ there is a direct mapping between namespace prefixes and namespace
+ URIs. (A given prefix may only be mapped to one namespace URI
+ throughout the XML document; there may be multiple prefixes mapped
+ to the same URI).</p>
+
+ <ul>
+
+ <li>In this case, the down-level client will view and match
+ element type and attribute selectors based on their fully
+ qualified name, not the local part as outlined in the <a
+ href="#typenmsp">Type selectors and Namespaces</a>
+ section. CSS
+ selectors may be declared using an escaped colon
+ "<code>\:</code>"
+ to describe the fully qualified names, e.g.
+ "<code>html\:h1</code>" will match
+ <code><html:h1></code>. Selectors using the qualified name
+ will only match XML elements that use the same prefix. Other
+ namespace prefixes used in the XML that are mapped to the same
+ URI
+ will not match as expected unless additional CSS style rules are
+ declared for them.
+ </li>
+
+ <li>Note that selectors declared in this fashion will
+ <em>only</em> match in down-level clients. A CSS namespace aware
+ client will match element type and attribute selectors based on
+ the name's local part. Selectors declared with the fully
+ qualified name will not match (unless there is no namespace
+ prefix
+ in the fully qualified name).
+ </li>
+
+ </ul>
+
+ </li>
+
+</ol>
+
+<p>In other scenarios: when the namespace prefixes used in the XML are
+ not known in advance by the style sheet author; or a combination of
+ elements with no namespace are used in conjunction with elements using
+ a default namespace; or the same namespace prefix is mapped to
+ <em>different</em> namespace URIs within the same document, or in
+ different documents; it is impossible to construct a CSS style sheet
+ that will function properly against all elements in those documents,
+ unless, the style sheet is written using a namespace URI syntax (as
+ outlined in this document or similar) and the document is processed by
+ a CSS and XML namespace aware client.</p>
+
+<h2><a name=profiling>12. Profiles</a></h2>
+
+<p>Each specification using Selectors must define the subset of W3C
+ Selectors it allows and excludes, and describe the local meaning of
+ all the components of that subset.</p>
+
+<p>Non normative examples:
+
+<div class="profile">
+ <table class="tprofile">
+ <tbody>
+ <tr>
+ <th class="title" colspan=2>Selectors profile</th>
+ </tr>
+ <tr>
+ <th>Specification</th>
+ <td>CSS level 1</td>
+ </tr>
+ <tr>
+ <th>Accepts</th>
+ <td>type selectors<br>class selectors<br>ID selectors<br>:link,
+ :visited and :active pseudo-classes<br>descendant combinator
+ <br>::first-line and ::first-letter pseudo-elements
+ </td>
+ </tr>
+ <tr>
+ <th>Excludes</th>
+ <td>
+
+ <p>universal selector<br>attribute selectors<br>:hover and
+ :focus
+ pseudo-classes<br>:target pseudo-class<br>:lang()
+ pseudo-class<br>all UI
+ element states pseudo-classes<br>all structural
+ pseudo-classes<br>negation pseudo-class<br>all
+ UI element fragments pseudo-elements<br>::before and ::after
+ pseudo-elements<br>child combinators<br>sibling combinators
+
+ <p>namespaces</td>
+ </tr>
+ <tr>
+ <th>Extra constraints</th>
+ <td>only one class selector allowed per sequence of simple
+ selectors
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ <br><br>
+ <table class="tprofile">
+ <tbody>
+ <tr>
+ <th class="title" colspan=2>Selectors profile</th>
+ </tr>
+ <tr>
+ <th>Specification</th>
+ <td>CSS level 2</td>
+ </tr>
+ <tr>
+ <th>Accepts</th>
+ <td>type selectors<br>universal selector<br>attribute presence and
+ values selectors<br>class selectors<br>ID selectors<br>:link,
+ :visited,
+ :active, :hover, :focus, :lang() and :first-child pseudo-classes
+ <br>descendant combinator<br>child combinator<br>adjacent
+ sibling
+ combinator<br>::first-line and ::first-letter
+ pseudo-elements<br>::before
+ and ::after pseudo-elements
+ </td>
+ </tr>
+ <tr>
+ <th>Excludes</th>
+ <td>
+
+ <p>content selectors<br>substring matching attribute
+ selectors<br>:target pseudo-classes<br>all UI element
+ states pseudo-classes<br>all structural pseudo-classes other
+ than :first-child<br>negation pseudo-class<br>all UI element
+ fragments pseudo-elements<br>general sibling combinators
+
+ <p>namespaces</td>
+ </tr>
+ <tr>
+ <th>Extra constraints</th>
+ <td>more than one class selector per sequence of simple selectors
+ (CSS1
+ constraint) allowed
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+ <p>In CSS, selectors express pattern matching rules that determine which
+ style
+ rules apply to elements in the document tree.
+
+ <p>The following selector (CSS level 2) will <b>match</b> all anchors <code>a</code>
+ with attribute <code>name</code> set inside a section 1 header
+ <code>h1</code>:
+ <pre>h1 a[name]</pre>
+
+ <p>All CSS declarations attached to such a selector are applied to elements
+ matching it.</div>
+
+<div class="profile">
+ <table class="tprofile">
+ <tbody>
+ <tr>
+ <th class="title" colspan=2>Selectors profile</th>
+ </tr>
+ <tr>
+ <th>Specification</th>
+ <td>STTS 3</td>
+ </tr>
+ <tr>
+ <th>Accepts</th>
+ <td>
+
+ <p>type selectors<br>universal selectors<br>attribute
+ selectors<br>class
+ selectors<br>ID selectors<br>all structural
+ pseudo-classes<br>
+ all combinators
+
+ <p>namespaces</td>
+ </tr>
+ <tr>
+ <th>Excludes</th>
+ <td>non-accepted pseudo-classes<br>pseudo-elements<br></td>
+ </tr>
+ <tr>
+ <th>Extra constraints</th>
+ <td>some selectors and combinators are not allowed in fragment
+ descriptions on the right side of STTS declarations.
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+ <p>Selectors can be used in STTS 3 in two different
+ manners:
+ <ol>
+ <li>a selection mechanism equivalent to CSS selection mechanism:
+ declarations
+ attached to a given selector are applied to elements matching that
+ selector,
+ <li>fragment descriptions that appear on the right side of declarations.
+ </li>
+ </ol>
+</div>
+
+<h2><a name=Conformance></a>13. Conformance and requirements</h2>
+
+<p>This section defines conformance with the present specification only.
+
+<p>The inability of a user agent to implement part of this specification due to
+ the limitations of a particular device (e.g., non interactive user agents
+ will
+ probably not implement dynamic pseudo-classes because they make no sense
+ without
+ interactivity) does not imply non-conformance.
+
+<p>All specifications reusing Selectors must contain a <a
+ href="#profiling">Profile</a> listing the
+ subset of Selectors it accepts or excludes, and describing the constraints
+ it adds to the current specification.
+
+<p>Invalidity is caused by a parsing error, e.g. an unrecognized token or a
+ token
+ which is not allowed at the current parsing point.
+
+<p>User agents must observe the rules for handling parsing errors:
+<ul>
+ <li>a simple selector containing an undeclared namespace prefix is invalid
+ </li>
+ <li>a selector containing an invalid simple selector, an invalid combinator
+ or an invalid token is invalid.
+ </li>
+ <li>a group of selectors containing an invalid selector is invalid.</li>
+</ul>
+
+<p>Specifications reusing Selectors must define how to handle parsing
+ errors. (In the case of CSS, the entire rule in which the selector is
+ used is dropped.)</p>
+
+<!-- Apparently all these references are out of date:
+<p>Implementations of this specification must behave as
+"recipients of text data" as defined by <a href="#refsCWWW">[CWWW]</a>
+when parsing selectors and attempting matches. (In particular,
+implementations must assume the data is normalized and must not
+normalize it.) Normative rules for matching strings are defined in
+<a href="#refsCWWW">[CWWW]</a> and <a
+href="#refsUNICODE">[UNICODE]</a> and apply to implementations of this
+specification.</p>-->
+
+<h2><a name=Tests></a>14. Tests</h2>
+
+<p>This specification has <a
+ href="http://www.w3.org/Style/CSS/Test/CSS3/Selectors/current/">a test
+ suite</a> allowing user agents to verify their basic conformance to
+ the specification. This test suite does not pretend to be exhaustive
+ and does not cover all possible combined cases of Selectors.</p>
+
+<h2><a name=ACKS></a>15. Acknowledgements</h2>
+
+<p>The CSS working group would like to thank everyone who has sent
+ comments on this specification over the years.</p>
+
+<p>The working group would like to extend special thanks to Donna
+ McManus, Justin Baker, Joel Sklar, and Molly Ives Brower who perfermed
+ the final editorial review.</p>
+
+<h2><a name=references>16. References</a></h2>
+
+<dl class="refs">
+
+ <dt>[CSS1]
+ <dd><a name=refsCSS1></a> Bert Bos, Håkon Wium Lie; "<cite>Cascading
+ Style Sheets, level 1</cite>", W3C Recommendation, 17 Dec 1996, revised
+ 11 Jan 1999
+ <dd>(<code><a href="http://www.w3.org/TR/REC-CSS1">http://www.w3.org/TR/REC-CSS1</a></code>)
+
+ <dt>[CSS21]
+ <dd><a name=refsCSS21></a> Bert Bos, Tantek Çelik, Ian Hickson, Håkon
+ Wium Lie, editors; "<cite>Cascading Style Sheets, level 2 revision
+ 1</cite>", W3C Working Draft, 13 June 2005
+ <dd>(<code><a
+ href="http://www.w3.org/TR/CSS21">http://www.w3.org/TR/CSS21</a></code>)
+
+ <dt>[CWWW]
+ <dd><a name=refsCWWW></a> Martin J. Dürst, François Yergeau,
+ Misha Wolf, Asmus Freytag, Tex Texin, editors; "<cite>Character Model
+ for the World Wide Web</cite>", W3C Recommendation, 15 February 2005
+ <dd>(<code><a href="http://www.w3.org/TR/charmod/">http://www.w3.org/TR/charmod/</a></code>)
+
+ <dt>[FLEX]
+ <dd><a name="refsFLEX"></a> "<cite>Flex: The Lexical Scanner
+ Generator</cite>", Version 2.3.7, ISBN 1882114213
+
+ <dt>[HTML4]
+ <dd><a name="refsHTML4"></a> Dave Ragget, Arnaud Le Hors, Ian Jacobs,
+ editors; "<cite>HTML 4.01 Specification</cite>", W3C Recommendation, 24
+ December 1999
+ <dd>
+ (<a href="http://www.w3.org/TR/html4/"><code>http://www.w3.org/TR/html4/</code></a>)
+
+ <dt>[MATH]
+ <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
+ <dd>(<code><a href="http://www.w3.org/TR/REC-MathML/">http://www.w3.org/TR/REC-MathML/</a></code>)
+
+ <dt>[RFC3066]
+ <dd><a name="refsRFC3066"></a> H. Alvestrand; "<cite>Tags for the
+ Identification of Languages</cite>", Request for Comments 3066, January
+ 2001
+ <dd>(<a href="http://www.ietf.org/rfc/rfc3066.txt"><code>http://www.ietf.org/rfc/rfc3066.txt</code></a>)
+
+ <dt>[STTS]
+ <dd><a name=refsSTTS></a> Daniel Glazman; "<cite>Simple Tree Transformation
+ Sheets 3</cite>", Electricité de France, submission to the W3C,
+ 11 November 1998
+ <dd>(<code><a href="http://www.w3.org/TR/NOTE-STTS3">http://www.w3.org/TR/NOTE-STTS3</a></code>)
+
+ <dt>[SVG]
+ <dd><a name="refsSVG"></a> Jon Ferraiolo, 藤沢 淳, Dean
+ Jackson, editors; "<cite>Scalable Vector Graphics (SVG) 1.1
+ Specification</cite>", W3C Recommendation, 14 January 2003
+ <dd>(<code><a href="http://www.w3.org/TR/SVG/">http://www.w3.org/TR/SVG/</a></code>)
+
+ <dt>[UNICODE]</dt>
+ <dd><a name="refsUNICODE"></a> <cite><a
+ 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>.
+ <dd>(<code><a href="http://www.unicode.org/versions/">http://www.unicode.org/versions/</a></code>)
+ </dd>
+
+ <dt>[XML10]
+ <dd><a name="refsXML10"></a> Tim Bray, Jean Paoli, C. M. Sperberg-McQueen,
+ Eve Maler, François Yergeau, editors; "<cite>Extensible Markup
+ Language (XML) 1.0 (Third Edition)</cite>", W3C Recommendation, 4
+ February 2004
+ <dd>(<a href="http://www.w3.org/TR/REC-xml/"><code>http://www.w3.org/TR/REC-xml/</code></a>)
+
+ <dt>[XMLNAMES]
+ <dd><a name="refsXMLNAMES"></a> Tim Bray, Dave Hollander, Andrew Layman,
+ editors; "<cite>Namespaces in XML</cite>", W3C Recommendation, 14
+ January 1999
+ <dd>(<a href="http://www.w3.org/TR/REC-xml-names/"><code>http://www.w3.org/TR/REC-xml-names/</code></a>)
+
+ <dt>[YACC]
+ <dd><a name="refsYACC"></a> S. C. Johnson; "<cite>YACC — Yet another
+ compiler compiler</cite>", Technical Report, Murray Hill, 1975
+
+</dl>
+</div>
+</body>
+</html>
diff --git a/samples/src/main/java/gwtquery/samples/public/racetrack.html b/samples/src/main/java/gwtquery/samples/public/racetrack.html new file mode 100644 index 00000000..ca937868 --- /dev/null +++ b/samples/src/main/java/gwtquery/samples/public/racetrack.html @@ -0,0 +1,68 @@ +<html> +<head> + <title>Benchmark Racetrack</title> + <script type="text/javascript"> + var horses = {};// var intervals = {}; + window.parent.moveHorse = function(id, amt) { + var elt = document.getElementById(id + "horse"); + var pos = horses[id]; + if (!pos) { + pos = horses[id] = 0; + } + horses[id] = pos + amt; + elt.style.left = '' + horses[id] + 'px'; + + // var start = new Date().getTime(); + // if(intervals[id]) { + // clearInterval(intervals[id]); + // } + // intervals[id]=setInterval(function() { + // end = new Date().getTime(); + // if(end-start > 300) { + // elt.style.left = '' + horses[id] + 'px'; + // clearInterval(intervals[id]); + // } else { + // elt.style.left = '' + pos + amt * (end-start)/300 + 'px'; + // } + // }, 20); + + } + </script> + <style type="text/css"> + img { + width: 124px; + height: 73px; + } + + .horse { + position: relative; + } + + .horse span { + font-weight: bold; + font-size: 150%; + color: white; + } + </style> +</head> +<body style="overflow: hidden"> +<div id="racefield" + style="width:790px; background-image: url(grass-texture.jpg)"> + <div id="gwthorse" class="horse"> + <img src="horse.png"><span>GWT</span><br> + </div> + <div id="jqueryhorse" class="horse"> + <img src="horse.png"><span>jQuery</span><br> + </div> + <div id="dojohorse" class="horse"> + + <img src="horse.png"><span>dojo</span><br> + </div> + <div id="prototypehorse" class="horse"> + + <img src="horse.png"><span>Prototype</span> + </div> + +</div> +</body> +</html>
\ No newline at end of file |