From b33dcfdaad5ff4e37ea8a4b5815ca3769813d656 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Mon, 11 Jan 2016 13:09:26 -0800 Subject: [PATCH] Remove the Dromaeo and TodoMVC samples. No one was maintaining or using these, and they were stale to the point that they were breaking pkgbuild tests because their dependencies weren't compatible with the latest SDK. This also removes tools/testing/perf_testing, which only tested these two samples. R=kevmoo@google.com Review URL: https://codereview.chromium.org/1576153002 . --- LICENSE | 1 - pkg/pkgbuild.status | 7 - samples/third_party/dromaeo/.gitignore | 1 - .../third_party/dromaeo/lib/transformer.dart | 60 - samples/third_party/dromaeo/pubspec.yaml | 17 - samples/third_party/dromaeo/web/Dromaeo.dart | 243 -- samples/third_party/dromaeo/web/LICENSE | 30 - samples/third_party/dromaeo/web/README | 57 - samples/third_party/dromaeo/web/Suites.dart | 174 - .../third_party/dromaeo/web/application.css | 115 - .../dromaeo/web/common/BenchUtil.dart | 84 - .../dromaeo/web/common/Interval.dart | 32 - .../third_party/dromaeo/web/common/Math2.dart | 51 - .../dromaeo/web/common/common.dart | 10 - samples/third_party/dromaeo/web/favicon.ico | Bin 1406 -> 0 bytes samples/third_party/dromaeo/web/favicon.png | Bin 448 -> 0 bytes samples/third_party/dromaeo/web/htmlrunner.js | 142 - samples/third_party/dromaeo/web/images/bg.png | Bin 711 -> 0 bytes .../third_party/dromaeo/web/images/clouds.png | Bin 1130 -> 0 bytes .../dromaeo/web/images/clouds2.png | Bin 1341 -> 0 bytes .../third_party/dromaeo/web/images/comets.png | Bin 4047 -> 0 bytes .../third_party/dromaeo/web/images/dino1.png | Bin 1276 -> 0 bytes .../third_party/dromaeo/web/images/dino2.png | Bin 1354 -> 0 bytes .../third_party/dromaeo/web/images/dino3.png | Bin 3345 -> 0 bytes .../third_party/dromaeo/web/images/dino4.png | Bin 1331 -> 0 bytes .../third_party/dromaeo/web/images/dino5.png | Bin 2360 -> 0 bytes .../third_party/dromaeo/web/images/dino6.png | Bin 1374 -> 0 bytes .../third_party/dromaeo/web/images/dino7.png | Bin 2445 -> 0 bytes .../third_party/dromaeo/web/images/dino8.png | Bin 2090 -> 0 bytes .../third_party/dromaeo/web/images/left.png | Bin 8908 -> 0 bytes .../third_party/dromaeo/web/images/logo.png | Bin 24809 -> 0 bytes .../third_party/dromaeo/web/images/logo2.png | Bin 19809 -> 0 bytes .../third_party/dromaeo/web/images/logo3.png | Bin 9172 -> 0 bytes .../third_party/dromaeo/web/images/right.png | Bin 1821 -> 0 bytes .../third_party/dromaeo/web/images/top.png | Bin 890 -> 0 bytes .../third_party/dromaeo/web/images/water.png | Bin 1371 -> 0 bytes samples/third_party/dromaeo/web/index.html | 43 - samples/third_party/dromaeo/web/reset.css | 38 - .../third_party/dromaeo/web/test-head.html | 4 - .../third_party/dromaeo/web/test-tail.html | 4 - .../third_party/dromaeo/web/tests/Common.dart | 53 - .../dromaeo/web/tests/RunnerSuite.dart | 132 - .../dromaeo/web/tests/dom-attr-html.dart | 36 - .../dromaeo/web/tests/dom-attr-html.html | 2900 ---------------- .../dromaeo/web/tests/dom-attr.html | 2946 ---------------- .../dromaeo/web/tests/dom-modify-html.dart | 72 - .../dromaeo/web/tests/dom-modify-html.html | 2900 ---------------- .../dromaeo/web/tests/dom-modify.html | 2973 ---------------- .../dromaeo/web/tests/dom-query-html.dart | 106 - .../dromaeo/web/tests/dom-query-html.html | 2900 ---------------- .../dromaeo/web/tests/dom-query.html | 3000 ----------------- .../dromaeo/web/tests/dom-traverse-html.dart | 91 - .../dromaeo/web/tests/dom-traverse-html.html | 2900 ---------------- .../dromaeo/web/tests/dom-traverse.html | 2972 ---------------- samples/third_party/dromaeo/web/web-style.css | 24 - .../todomvc_performance/.gitignore | 1 - .../third_party/todomvc_performance/AUTHORS | 9 - .../third_party/todomvc_performance/LICENSE | 27 - .../third_party/todomvc_performance/PATENTS | 23 - .../third_party/todomvc_performance/README.md | 4 - .../todomvc_performance/js_todomvc/AUTHORS | 9 - .../js_todomvc/CONTRIBUTING.md | 1 - .../todomvc_performance/js_todomvc/LICENSE | 27 - .../todomvc_performance/js_todomvc/PATENTS | 23 - .../todomvc_performance/js_todomvc/README.md | 46 - .../js_todomvc/app/app.css | 206 -- .../todomvc_performance/js_todomvc/bower.json | 10 - .../components/flatiron-director/.bower.json | 18 - .../components/flatiron-director/AUTHORS | 9 - .../flatiron-director/CONTRIBUTING.md | 1 - .../components/flatiron-director/LICENSE | 28 - .../components/flatiron-director/PATENTS | 23 - .../components/flatiron-director/bower.json | 8 - .../components/flatiron-director/demo.html | 29 - .../flatiron-director/director/LICENSE | 19 - .../director/director.min.js | 7 - .../flatiron-director/flatiron-director.html | 37 - .../components/flatiron-director/index.html | 64 - .../components/platform/.bower.json | 26 - .../js_todomvc/components/platform/AUTHORS | 9 - .../components/platform/CONTRIBUTING.md | 73 - .../js_todomvc/components/platform/LICENSE | 27 - .../js_todomvc/components/platform/PATENTS | 23 - .../js_todomvc/components/platform/README.md | 6 - .../js_todomvc/components/platform/bower.json | 17 - .../components/platform/platform.js | 38 - .../components/platform/platform.js.map | 1 - .../polymer-localstorage/.bower.json | 18 - .../components/polymer-localstorage/AUTHORS | 9 - .../polymer-localstorage/CONTRIBUTING.md | 1 - .../components/polymer-localstorage/LICENSE | 27 - .../components/polymer-localstorage/PATENTS | 23 - .../polymer-localstorage/bower.json | 8 - .../components/polymer-localstorage/demo.html | 38 - .../polymer-localstorage/index.html | 64 - .../polymer-localstorage.html | 127 - .../test/html/polymer-localstorage.html | 28 - .../test/js/polymer-localstorage.js | 9 - .../polymer-localstorage/test/runner.html | 31 - .../components/polymer-selection/.bower.json | 18 - .../components/polymer-selection/AUTHORS | 9 - .../polymer-selection/CONTRIBUTING.md | 1 - .../components/polymer-selection/LICENSE | 27 - .../components/polymer-selection/PATENTS | 23 - .../components/polymer-selection/bower.json | 8 - .../components/polymer-selection/demo.html | 47 - .../components/polymer-selection/index.html | 64 - .../polymer-selection/polymer-selection.html | 153 - .../test/html/polymer-selection-multi.html | 43 - .../test/html/polymer-selection.html | 42 - .../test/js/polymer-selection.js | 10 - .../polymer-selection/test/runner.html | 31 - .../components/polymer-selector/.bower.json | 19 - .../components/polymer-selector/AUTHORS | 9 - .../polymer-selector/CONTRIBUTING.md | 1 - .../components/polymer-selector/LICENSE | 27 - .../components/polymer-selector/PATENTS | 23 - .../components/polymer-selector/README.md | 8 - .../components/polymer-selector/bower.json | 9 - .../components/polymer-selector/demo.html | 98 - .../components/polymer-selector/docs.json | 224 -- .../components/polymer-selector/index.html | 64 - .../polymer-selector/polymer-selector.html | 371 -- .../html/polymer-selector-activate-event.html | 41 - .../test/html/polymer-selector-basic.html | 96 - .../test/html/polymer-selector-multi.html | 78 - .../test/js/polymer-selector.js | 11 - .../polymer-selector/test/runner.html | 31 - .../js_todomvc/components/polymer/.bower.json | 29 - .../js_todomvc/components/polymer/AUTHORS | 9 - .../components/polymer/CONTRIBUTING.md | 73 - .../js_todomvc/components/polymer/LICENSE | 27 - .../js_todomvc/components/polymer/PATENTS | 23 - .../js_todomvc/components/polymer/README.md | 17 - .../js_todomvc/components/polymer/bower.json | 20 - .../components/polymer/polymer-body.html | 33 - .../components/polymer/polymer.html | 8 - .../js_todomvc/components/polymer/polymer.js | 33 - .../components/polymer/polymer.js.map | 1 - .../components/todomvc-common/.bower.json | 14 - .../components/todomvc-common/base.css | 556 --- .../components/todomvc-common/base.js | 209 -- .../components/todomvc-common/bg.png | Bin 2126 -> 0 bytes .../components/todomvc-common/bower.json | 4 - .../components/todomvc-common/readme.md | 8 - .../js_todomvc/elements/td-input.html | 24 - .../js_todomvc/elements/td-item.css | 161 - .../js_todomvc/elements/td-item.html | 47 - .../js_todomvc/elements/td-model.html | 74 - .../js_todomvc/elements/td-todos.css | 267 -- .../js_todomvc/elements/td-todos.html | 79 - .../todomvc_performance/js_todomvc/index.html | 37 - .../js_todomvc/pubspec.yaml | 7 - .../todomvc_performance/pubspec.yaml | 14 - .../todomvc_performance/web/app/app.css | 206 -- .../todomvc_performance/web/app/bg.png | Bin 2126 -> 0 bytes .../web/elements/td_input.dart | 27 - .../web/elements/td_input.html | 4 - .../web/elements/td_item.css | 161 - .../web/elements/td_item.dart | 45 - .../web/elements/td_item.html | 17 - .../web/elements/td_model.dart | 101 - .../web/elements/td_model.html | 3 - .../web/elements/td_todos.css | 267 -- .../web/elements/td_todos.dart | 61 - .../web/elements/td_todos.html | 51 - .../web/lib-elements/polymer-selection.html | 151 - .../web/lib-elements/polymer-selector.html | 353 -- .../lib-elements/polymer_localstorage.dart | 40 - .../lib-elements/polymer_localstorage.html | 27 - .../web/lib-elements/simple_router.dart | 41 - .../web/lib-elements/simple_router.html | 8 - .../todomvc_performance/web/performance.dart | 23 - .../web/startup-performance.html | 58 - tests/html/dromaeo_noop/dromaeo_smoke.dart | 28 - tests/html/dromaeo_noop/dromaeo_smoke.dart.js | 9 - tests/html/dromaeo_smoke-html.html | 12 - tests/html/dromaeo_smoke_test.dart | 56 - tests/html/html.status | 1 - tools/testing/perf_testing/appengine/app.yaml | 70 - .../perf_testing/calc_and_send_mail.py | 141 - tools/testing/perf_testing/data.html | 17 - tools/testing/perf_testing/dromaeo.html | 55 - .../testing/perf_testing/get_current_stats.py | 94 - tools/testing/perf_testing/index.html | 100 - tools/testing/perf_testing/run_perf_tests.py | 1087 ------ tools/testing/run_selenium.py | 9 +- 187 files changed, 1 insertion(+), 33032 deletions(-) delete mode 100644 samples/third_party/dromaeo/.gitignore delete mode 100644 samples/third_party/dromaeo/lib/transformer.dart delete mode 100644 samples/third_party/dromaeo/pubspec.yaml delete mode 100644 samples/third_party/dromaeo/web/Dromaeo.dart delete mode 100644 samples/third_party/dromaeo/web/LICENSE delete mode 100644 samples/third_party/dromaeo/web/README delete mode 100644 samples/third_party/dromaeo/web/Suites.dart delete mode 100644 samples/third_party/dromaeo/web/application.css delete mode 100644 samples/third_party/dromaeo/web/common/BenchUtil.dart delete mode 100644 samples/third_party/dromaeo/web/common/Interval.dart delete mode 100644 samples/third_party/dromaeo/web/common/Math2.dart delete mode 100644 samples/third_party/dromaeo/web/common/common.dart delete mode 100644 samples/third_party/dromaeo/web/favicon.ico delete mode 100644 samples/third_party/dromaeo/web/favicon.png delete mode 100644 samples/third_party/dromaeo/web/htmlrunner.js delete mode 100644 samples/third_party/dromaeo/web/images/bg.png delete mode 100644 samples/third_party/dromaeo/web/images/clouds.png delete mode 100644 samples/third_party/dromaeo/web/images/clouds2.png delete mode 100644 samples/third_party/dromaeo/web/images/comets.png delete mode 100644 samples/third_party/dromaeo/web/images/dino1.png delete mode 100644 samples/third_party/dromaeo/web/images/dino2.png delete mode 100644 samples/third_party/dromaeo/web/images/dino3.png delete mode 100644 samples/third_party/dromaeo/web/images/dino4.png delete mode 100644 samples/third_party/dromaeo/web/images/dino5.png delete mode 100644 samples/third_party/dromaeo/web/images/dino6.png delete mode 100644 samples/third_party/dromaeo/web/images/dino7.png delete mode 100644 samples/third_party/dromaeo/web/images/dino8.png delete mode 100644 samples/third_party/dromaeo/web/images/left.png delete mode 100644 samples/third_party/dromaeo/web/images/logo.png delete mode 100644 samples/third_party/dromaeo/web/images/logo2.png delete mode 100644 samples/third_party/dromaeo/web/images/logo3.png delete mode 100644 samples/third_party/dromaeo/web/images/right.png delete mode 100644 samples/third_party/dromaeo/web/images/top.png delete mode 100644 samples/third_party/dromaeo/web/images/water.png delete mode 100644 samples/third_party/dromaeo/web/index.html delete mode 100644 samples/third_party/dromaeo/web/reset.css delete mode 100644 samples/third_party/dromaeo/web/test-head.html delete mode 100644 samples/third_party/dromaeo/web/test-tail.html delete mode 100644 samples/third_party/dromaeo/web/tests/Common.dart delete mode 100644 samples/third_party/dromaeo/web/tests/RunnerSuite.dart delete mode 100644 samples/third_party/dromaeo/web/tests/dom-attr-html.dart delete mode 100644 samples/third_party/dromaeo/web/tests/dom-attr-html.html delete mode 100644 samples/third_party/dromaeo/web/tests/dom-attr.html delete mode 100644 samples/third_party/dromaeo/web/tests/dom-modify-html.dart delete mode 100644 samples/third_party/dromaeo/web/tests/dom-modify-html.html delete mode 100644 samples/third_party/dromaeo/web/tests/dom-modify.html delete mode 100644 samples/third_party/dromaeo/web/tests/dom-query-html.dart delete mode 100644 samples/third_party/dromaeo/web/tests/dom-query-html.html delete mode 100644 samples/third_party/dromaeo/web/tests/dom-query.html delete mode 100644 samples/third_party/dromaeo/web/tests/dom-traverse-html.dart delete mode 100644 samples/third_party/dromaeo/web/tests/dom-traverse-html.html delete mode 100644 samples/third_party/dromaeo/web/tests/dom-traverse.html delete mode 100644 samples/third_party/dromaeo/web/web-style.css delete mode 100644 samples/third_party/todomvc_performance/.gitignore delete mode 100644 samples/third_party/todomvc_performance/AUTHORS delete mode 100644 samples/third_party/todomvc_performance/LICENSE delete mode 100644 samples/third_party/todomvc_performance/PATENTS delete mode 100644 samples/third_party/todomvc_performance/README.md delete mode 100755 samples/third_party/todomvc_performance/js_todomvc/AUTHORS delete mode 100755 samples/third_party/todomvc_performance/js_todomvc/CONTRIBUTING.md delete mode 100755 samples/third_party/todomvc_performance/js_todomvc/LICENSE delete mode 100755 samples/third_party/todomvc_performance/js_todomvc/PATENTS delete mode 100755 samples/third_party/todomvc_performance/js_todomvc/README.md delete mode 100755 samples/third_party/todomvc_performance/js_todomvc/app/app.css delete mode 100755 samples/third_party/todomvc_performance/js_todomvc/bower.json delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/.bower.json delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/AUTHORS delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/CONTRIBUTING.md delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/LICENSE delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/PATENTS delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/bower.json delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/demo.html delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/director/LICENSE delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/director/director.min.js delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/flatiron-director.html delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/index.html delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/platform/.bower.json delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/platform/AUTHORS delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/platform/CONTRIBUTING.md delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/platform/LICENSE delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/platform/PATENTS delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/platform/README.md delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/platform/bower.json delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/platform/platform.js delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/platform/platform.js.map delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-localstorage/.bower.json delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-localstorage/AUTHORS delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-localstorage/CONTRIBUTING.md delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-localstorage/LICENSE delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-localstorage/PATENTS delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-localstorage/bower.json delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-localstorage/demo.html delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-localstorage/index.html delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-localstorage/polymer-localstorage.html delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-localstorage/test/html/polymer-localstorage.html delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-localstorage/test/js/polymer-localstorage.js delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-localstorage/test/runner.html delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-selection/.bower.json delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-selection/AUTHORS delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-selection/CONTRIBUTING.md delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-selection/LICENSE delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-selection/PATENTS delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-selection/bower.json delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-selection/demo.html delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-selection/index.html delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-selection/polymer-selection.html delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-selection/test/html/polymer-selection-multi.html delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-selection/test/html/polymer-selection.html delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-selection/test/js/polymer-selection.js delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-selection/test/runner.html delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-selector/.bower.json delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-selector/AUTHORS delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-selector/CONTRIBUTING.md delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-selector/LICENSE delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-selector/PATENTS delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-selector/README.md delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-selector/bower.json delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-selector/demo.html delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-selector/docs.json delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-selector/index.html delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-selector/polymer-selector.html delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-selector/test/html/polymer-selector-activate-event.html delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-selector/test/html/polymer-selector-basic.html delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-selector/test/html/polymer-selector-multi.html delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-selector/test/js/polymer-selector.js delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer-selector/test/runner.html delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer/.bower.json delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer/AUTHORS delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer/CONTRIBUTING.md delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer/LICENSE delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer/PATENTS delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer/README.md delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer/bower.json delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer/polymer-body.html delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer/polymer.html delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer/polymer.js delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/polymer/polymer.js.map delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/todomvc-common/.bower.json delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/todomvc-common/base.css delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/todomvc-common/base.js delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/todomvc-common/bg.png delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/todomvc-common/bower.json delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/components/todomvc-common/readme.md delete mode 100755 samples/third_party/todomvc_performance/js_todomvc/elements/td-input.html delete mode 100755 samples/third_party/todomvc_performance/js_todomvc/elements/td-item.css delete mode 100755 samples/third_party/todomvc_performance/js_todomvc/elements/td-item.html delete mode 100755 samples/third_party/todomvc_performance/js_todomvc/elements/td-model.html delete mode 100755 samples/third_party/todomvc_performance/js_todomvc/elements/td-todos.css delete mode 100755 samples/third_party/todomvc_performance/js_todomvc/elements/td-todos.html delete mode 100755 samples/third_party/todomvc_performance/js_todomvc/index.html delete mode 100644 samples/third_party/todomvc_performance/js_todomvc/pubspec.yaml delete mode 100644 samples/third_party/todomvc_performance/pubspec.yaml delete mode 100644 samples/third_party/todomvc_performance/web/app/app.css delete mode 100644 samples/third_party/todomvc_performance/web/app/bg.png delete mode 100644 samples/third_party/todomvc_performance/web/elements/td_input.dart delete mode 100644 samples/third_party/todomvc_performance/web/elements/td_input.html delete mode 100644 samples/third_party/todomvc_performance/web/elements/td_item.css delete mode 100644 samples/third_party/todomvc_performance/web/elements/td_item.dart delete mode 100644 samples/third_party/todomvc_performance/web/elements/td_item.html delete mode 100644 samples/third_party/todomvc_performance/web/elements/td_model.dart delete mode 100644 samples/third_party/todomvc_performance/web/elements/td_model.html delete mode 100644 samples/third_party/todomvc_performance/web/elements/td_todos.css delete mode 100644 samples/third_party/todomvc_performance/web/elements/td_todos.dart delete mode 100644 samples/third_party/todomvc_performance/web/elements/td_todos.html delete mode 100644 samples/third_party/todomvc_performance/web/lib-elements/polymer-selection.html delete mode 100644 samples/third_party/todomvc_performance/web/lib-elements/polymer-selector.html delete mode 100644 samples/third_party/todomvc_performance/web/lib-elements/polymer_localstorage.dart delete mode 100644 samples/third_party/todomvc_performance/web/lib-elements/polymer_localstorage.html delete mode 100644 samples/third_party/todomvc_performance/web/lib-elements/simple_router.dart delete mode 100644 samples/third_party/todomvc_performance/web/lib-elements/simple_router.html delete mode 100644 samples/third_party/todomvc_performance/web/performance.dart delete mode 100644 samples/third_party/todomvc_performance/web/startup-performance.html delete mode 100644 tests/html/dromaeo_noop/dromaeo_smoke.dart delete mode 100644 tests/html/dromaeo_noop/dromaeo_smoke.dart.js delete mode 100644 tests/html/dromaeo_smoke-html.html delete mode 100644 tests/html/dromaeo_smoke_test.dart delete mode 100644 tools/testing/perf_testing/appengine/app.yaml delete mode 100644 tools/testing/perf_testing/calc_and_send_mail.py delete mode 100644 tools/testing/perf_testing/data.html delete mode 100644 tools/testing/perf_testing/dromaeo.html delete mode 100644 tools/testing/perf_testing/get_current_stats.py delete mode 100644 tools/testing/perf_testing/index.html delete mode 100755 tools/testing/perf_testing/run_perf_tests.py diff --git a/LICENSE b/LICENSE index fa95f120458..68bcabfb39b 100644 --- a/LICENSE +++ b/LICENSE @@ -9,7 +9,6 @@ args4j - in third_party/args4j bzip2 - in third_party/bzip2 Commons IO - in third_party/commons-io Commons Lang in third_party/commons-lang -dromaeo - in samples/third_party/dromaeo Eclipse - in third_party/eclipse gsutil - in third_party/gsutil Guava - in third_party/guava diff --git a/pkg/pkgbuild.status b/pkg/pkgbuild.status index 2404f3ee3ca..1366f47e715 100644 --- a/pkg/pkgbuild.status +++ b/pkg/pkgbuild.status @@ -2,22 +2,15 @@ # for details. All rights reserved. Use of this source code is governed by a # BSD-style license that can be found in the LICENSE file. -samples/third_party/dromaeo: Pass, Slow samples/searchable_list: Pass, Slow [ $use_repository_packages ] pkg/analyzer: PubGetError samples/third_party/angular_todo: Fail # angular needs to be updated -samples/third_party/todomvc_performance: Skip # dependencies are not in the repo [ $use_public_packages ] pkg/compiler: SkipByDesign # js_ast is not published samples/third_party/angular_todo: Pass, Slow -samples/third_party/todomvc_performance: Pass, Slow [ $builder_tag == russian ] samples/third_party/angular_todo: Fail # Issue 16356 -samples/third_party/dromaeo: Fail # Issue 23760 - -[ $use_public_packages && $system == windows ] -samples/third_party/todomvc_performance: Fail # Issue 18086 diff --git a/samples/third_party/dromaeo/.gitignore b/samples/third_party/dromaeo/.gitignore deleted file mode 100644 index 378eac25d31..00000000000 --- a/samples/third_party/dromaeo/.gitignore +++ /dev/null @@ -1 +0,0 @@ -build diff --git a/samples/third_party/dromaeo/lib/transformer.dart b/samples/third_party/dromaeo/lib/transformer.dart deleted file mode 100644 index fa50ea3d87b..00000000000 --- a/samples/third_party/dromaeo/lib/transformer.dart +++ /dev/null @@ -1,60 +0,0 @@ -library dromaeo.transformer; - -import 'dart:async'; -import 'package:barback/barback.dart'; - -/// Transformer used by `pub build` and `pub serve` to rewrite dromaeo html -/// files to run performance tests. -class DromaeoTransformer extends Transformer { - - final BarbackSettings settings; - - DromaeoTransformer.asPlugin(this.settings); - - /// The index.html file and the tests/dom-*-html.html files are the ones we - /// apply this transform to. - Future isPrimary(AssetId id) { - var reg = new RegExp('(tests/dom-.+-html\.html\$)|(index\.html\$)'); - return new Future.value(reg.hasMatch(id.path)); - } - - Future apply(Transform transform) { - Asset primaryAsset = transform.primaryInput; - AssetId primaryAssetId = primaryAsset.id; - - return primaryAsset.readAsString().then((String fileContents) { - var filename = primaryAssetId.toString(); - var outputFileContents = fileContents; - - if (filename.endsWith('index.html')) { - var index = outputFileContents.indexOf( - '\n' + - outputFileContents.substring(index); - transform.addOutput(new Asset.fromString(new AssetId.parse( - primaryAssetId.toString().replaceAll('.html', '-dart.html')), - outputFileContents)); - } - - outputFileContents = _sourceJsNotDart(outputFileContents); - // Rename the script to take the JavaScript source. - transform.addOutput(new Asset.fromString(new AssetId.parse( - _appendJs(primaryAssetId.toString())), - outputFileContents)); - }); - } - - String _appendJs(String path) => path.replaceAll('.html', '-js.html'); - - /// Given an html file that sources a Dart file, rewrite the html to instead - /// source the compiled JavaScript file. - String _sourceJsNotDart(String fileContents) { - var dartScript = new RegExp( - ' - - - -
- - - - - - - - - - - - - - - - - -
-
-
-
Mozilla JavaScript performance test suite.
More information about Dromaeo can be found on the Mozilla wiki.
-

Performance Tests
Est. Time: 0:00
« View All Tests


-
    -
  • DOM Core Tests
    (Tests DOM Querying, Traversing, Manipulation, and Attributes.)
  • -
-
-
- - diff --git a/samples/third_party/dromaeo/web/reset.css b/samples/third_party/dromaeo/web/reset.css deleted file mode 100644 index 4a3cf941537..00000000000 --- a/samples/third_party/dromaeo/web/reset.css +++ /dev/null @@ -1,38 +0,0 @@ -/* -------------------------------------------------------------- - - reset.css - * Resets default browser CSS. - - Based on work by Eric Meyer: - * meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/ - --------------------------------------------------------------- */ - -html, body, div, span, object, iframe, -h1, h2, h3, h4, h5, h6, p, blockquote, pre, -a, abbr, acronym, address, code, -del, dfn, em, img, q, dl, dt, dd, ol, ul, li, -fieldset, form, label, legend, -table, caption, tbody, tfoot, thead, tr, th, td { - margin: 0; - padding: 0; - border: 0; - font-weight: inherit; - font-style: inherit; - font-size: 100%; - font-family: inherit; - vertical-align: baseline; -} - - -body { line-height: 1.5; background: #fff; margin:1.5em 0; } - -/* Tables still need 'cellspacing="0"' in the markup. */ -caption, th, td { text-align: left; font-weight:400; } - -/* Remove possible quote marks (") from ,
. */ -blockquote:before, blockquote:after, q:before, q:after { content: ""; } -blockquote, q { quotes: "" ""; } - -a img { border: none; } - diff --git a/samples/third_party/dromaeo/web/test-head.html b/samples/third_party/dromaeo/web/test-head.html deleted file mode 100644 index 481251c502d..00000000000 --- a/samples/third_party/dromaeo/web/test-head.html +++ /dev/null @@ -1,4 +0,0 @@ - - - - - - - diff --git a/samples/third_party/dromaeo/web/tests/Common.dart b/samples/third_party/dromaeo/web/tests/Common.dart deleted file mode 100644 index f763fb98a2f..00000000000 --- a/samples/third_party/dromaeo/web/tests/Common.dart +++ /dev/null @@ -1,53 +0,0 @@ -part of dromaeo; - -class Result { - int get runs { return _sorted.length; } - - double get sum { - double result = 0.0; - _sorted.forEach((double e) { result += e; }); - return result; - } - - double get min { return _sorted[0]; } - double get max { return _sorted[runs - 1]; } - - double get mean { return sum / runs; } - - double get median { - return (runs % 2 == 0) ? - (_sorted[runs ~/ 2] + _sorted[runs ~/ 2 + 1]) / 2 : _sorted[runs ~/ 2]; - } - - double get variance { - double m = mean; - double result = 0.0; - _sorted.forEach((double e) { result += Math.pow(e - m, 2.0); }); - return result / (runs - 1); - } - - double get deviation { return Math.sqrt(variance); } - - // Compute Standard Errors Mean - double get sem { return (deviation / Math.sqrt(runs)) * T_DISTRIBUTION; } - - double get error { return (sem / mean) * 100; } - - // TODO: Implement writeOn. - String toString() { - return '[Result: mean = ${mean}]'; - } - - factory Result(List runsPerSecond) { - runsPerSecond.sort((a, b) => a.compareTo(b)); - return new Result._internal(runsPerSecond); - } - - Result._internal(this._sorted) {} - - List _sorted; - - // Populated from: http://www.medcalc.be/manual/t-distribution.php - // 95% confidence for N - 1 = 4 - static const double T_DISTRIBUTION = 2.776; -} diff --git a/samples/third_party/dromaeo/web/tests/RunnerSuite.dart b/samples/third_party/dromaeo/web/tests/RunnerSuite.dart deleted file mode 100644 index e1e0945e3ca..00000000000 --- a/samples/third_party/dromaeo/web/tests/RunnerSuite.dart +++ /dev/null @@ -1,132 +0,0 @@ -part of dromaeo; - -typedef void Test(); -typedef void Operation(); -typedef void Reporter(Map results); - -class Suite { - /** - * Ctor. - * [:_window:] The window of the suite. - * [:_name:] The name of the suite. - */ - Suite(this._window, this._name) : - _operations = new List(), - _nTests = 0, _nRanTests = 0 { - starter(MessageEvent event) { - String command = event.data; - switch (command) { - case 'start': - _run(); - return; - default: - _window.alert('[${_name}]: unknown command ${command}'); - } - }; - _window.onMessage.listen(starter); - } - - /** - * Adds a preparation step to the suite. - * [:operation:] The operation to be performed. - */ - Suite prep(Operation operation){ - return _addOperation(operation); - } - - // How many times each individual test should be ran. - static const int _N_RUNS = 5; - - /** - * Adds another test to the suite. - * [:name:] The unique name of the test - * [:test:] A function holding the test to run - */ - Suite test(String name, Test test_) { - _nTests++; - // Don't execute the test immediately. - return _addOperation(() { - // List of number of runs in seconds. - List runsPerSecond = new List(); - - // Run the test several times. - try { - // TODO(antonm): use timer to schedule next run as JS - // version does. That allows to report the intermidiate results - // more smoothly as well. - for (int i = 0; i < _N_RUNS; i++) { - int runs = 0; - final int start = new DateTime.now().millisecondsSinceEpoch; - - int cur = new DateTime.now().millisecondsSinceEpoch; - while ((cur - start) < 1000) { - test_(); - cur = new DateTime.now().millisecondsSinceEpoch; - runs++; - } - - runsPerSecond.add((runs * 1000.0) / (cur - start)); - } - } catch (exception, stacktrace) { - _window.alert('Exception ${exception}: ${stacktrace}'); - return; - } - _reportTestResults(name, new Result(runsPerSecond)); - }); - } - - /** - * Finalizes the suite. - * It might either run the tests immediately or schedule them to be ran later. - */ - void end() { - _postMessage('inited', { 'nTests': _nTests }); - - } - - _run() { - int currentOperation = 0; - handler() { - if (currentOperation < _operations.length) { - _operations[currentOperation](); - currentOperation++; - new Timer(const Duration(milliseconds: 1), handler); - } else { - _postMessage('over'); - } - } - Timer.run(handler); - } - - _reportTestResults(String name, Result result) { - _nRanTests++; - _postMessage('result', { - 'testName': name, - 'mean': result.mean, - 'error': result.error, - 'percent': (100.0 * _nRanTests / _nTests) - }); - } - - _postMessage(String command, [var data = null]) { - final payload = { 'command': command }; - if (data != null) { - payload['data'] = data; - } - _window.parent.postMessage(JSON.encode(payload), '*'); - } - - // Implementation. - - final Window _window; - final String _name; - - List _operations; - int _nTests; - int _nRanTests; - - Suite _addOperation(Operation operation) { - _operations.add(operation); - return this; - } -} diff --git a/samples/third_party/dromaeo/web/tests/dom-attr-html.dart b/samples/third_party/dromaeo/web/tests/dom-attr-html.dart deleted file mode 100644 index f1b103112a9..00000000000 --- a/samples/third_party/dromaeo/web/tests/dom-attr-html.dart +++ /dev/null @@ -1,36 +0,0 @@ -library dromaeo; -import 'dart:async'; -import 'dart:html'; -import "dart:convert"; -import 'dart:math' as Math; -part 'Common.dart'; -part 'RunnerSuite.dart'; - -void main() { - final int num = 10240; - - // Try to force real results. - var ret; - - Element elem = document.querySelector('#test1'); - Element a = document.querySelector('a'); - - new Suite(window, 'dom-attr') - .test('getAttribute', () { - for (int i = 0; i < num; i++) - ret = elem.getAttribute('id'); - }) - .test('element.property', () { - for (int i = 0; i < num * 2; i++) - ret = elem.id; - }) - .test('setAttribute', () { - for (int i = 0; i < num; i++) - a.setAttribute('id', 'foo'); - }) - .test('element.property = value', () { - for (int i = 0; i < num; i++) - a.id = 'foo'; - }) - .end(); -} diff --git a/samples/third_party/dromaeo/web/tests/dom-attr-html.html b/samples/third_party/dromaeo/web/tests/dom-attr-html.html deleted file mode 100644 index 62079e63f46..00000000000 --- a/samples/third_party/dromaeo/web/tests/dom-attr-html.html +++ /dev/null @@ -1,2900 +0,0 @@ - - - - - - -
-

W3C - -

Selectors

- -

W3C Working Draft 15 December 2005

- -
- -
This version: - -
- http://www.w3.org/TR/2005/WD-css3-selectors-20051215 - -
Latest version: - -
- http://www.w3.org/TR/css3-selectors - -
Previous version: - -
- http://www.w3.org/TR/2001/CR-css3-selectors-20011113 - -
Editors: - -
Daniel Glazman (Invited Expert)
- -
Tantek Çelik (Invited Expert) - -
Ian Hickson (Google) - -
Peter Linss (former editor, Netscape/AOL) - -
John Williams (former editor, Quark, Inc.) - -
- -
- -
- -

Abstract

- -

Selectors 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.

- -

CSS (Cascading - Style Sheets) is a language for describing the rendering of HTML and XML 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. - -

Selectors define the following function:

- -
expression ∗ element → boolean
- -

That is, given an element and a selector, this specification - defines whether that element matches the selector.

- -

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. STTS (Simple Tree Transformation Sheets), a - language for transforming XML trees, uses this mechanism. [STTS]

- -

Status of this document

- -

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 W3C technical reports index at - http://www.w3.org/TR/.

- -

This document describes the selectors that already exist in CSS1 and CSS2, and - also proposes new selectors for CSS3 and other languages that may need them.

- -

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.

- -

This specification is a last call working draft for the the CSS Working Group - (Style Activity). This - document is a revision of the Candidate - Recommendation dated 2001 November 13, 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.

- -

All persons are encouraged to review and implement this - specification and return comments to the (archived) - public mailing list www-style - (see instructions). W3C - Members can also send comments directly to the CSS Working - Group. - The deadline for comments is 14 January 2006.

- -

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". - -

This document may be available in translation. - The English version of this specification is the only normative - version. - -

- -

Table of contents

- - - -
- -

1. Introduction

- -

1.1. Dependencies

- -

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. [CSS21]

- -

1.2. Terminology

- -

All of the text of this specification is normative except - examples, notes, and sections explicitly marked as - non-normative.

- -

1.3. Changes from CSS2

- -

This section is non-normative.

- -

The main differences between the selectors in CSS2 and those in - Selectors are: - -

    - -
  • 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
  • - -
  • an optional namespace component is now allowed in type element - selectors, the universal selector and attribute selectors
  • - -
  • a new combinator has been introduced
  • - -
  • new simple selectors including substring matching attribute - selectors, and new pseudo-classes
  • - -
  • new pseudo-elements, and introduction of the "::" convention - for pseudo-elements
  • - -
  • the grammar has been rewritten
  • - -
  • profiles to be added to specifications integrating Selectors - and defining the set of selectors which is actually supported by - each specification
  • - -
  • Selectors are now a CSS3 Module and an independent - specification; other specifications can now refer to this document - independently of CSS
  • - -
  • the specification now has its own test suite
  • - -
- -

2. Selectors

- -

This section is non-normative, as it merely summarizes the -following sections.

- -

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.

- -

Selectors may range from simple element names to rich contextual -representations.

- -

The following table summarizes the Selector syntax:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PatternMeaningDescribed in sectionFirst defined in CSS level
*any elementUniversal - selector2
Ean element of type EType selector1
E[foo]an E element with a "foo" attributeAttribute - selectors2
E[foo="bar"]an E element whose "foo" attribute value is exactly - equal to "bar"Attribute - selectors2
E[foo~="bar"]an E element whose "foo" attribute value is a list of - space-separated values, one of which is exactly equal to "bar"Attribute - selectors2
E[foo^="bar"]an E element whose "foo" attribute value begins exactly - with the string "bar"Attribute - selectors3
E[foo$="bar"]an E element whose "foo" attribute value ends exactly - with the string "bar"Attribute - selectors3
E[foo*="bar"]an E element whose "foo" attribute value contains the - substring "bar"Attribute - selectors3
E[hreflang|="en"]an E element whose "hreflang" attribute has a hyphen-separated - list of values beginning (from the left) with "en"Attribute - selectors2
E:rootan E element, root of the documentStructural - pseudo-classes3
E:nth-child(n)an E element, the n-th child of its parentStructural - pseudo-classes3
E:nth-last-child(n)an E element, the n-th child of its parent, counting - from the last oneStructural - pseudo-classes3
E:nth-of-type(n)an E element, the n-th sibling of its typeStructural - pseudo-classes3
E:nth-last-of-type(n)an E element, the n-th sibling of its type, counting - from the last oneStructural - pseudo-classes3
E:first-childan E element, first child of its parentStructural - pseudo-classes2
E:last-childan E element, last child of its parentStructural - pseudo-classes3
E:first-of-typean E element, first sibling of its typeStructural - pseudo-classes3
E:last-of-typean E element, last sibling of its typeStructural - pseudo-classes3
E:only-childan E element, only child of its parentStructural - pseudo-classes3
E:only-of-typean E element, only sibling of its typeStructural - pseudo-classes3
E:emptyan E element that has no children (including text - nodes)Structural - pseudo-classes3
E:link
E:visited
an E element being the source anchor of a hyperlink of - which the target is not yet visited (:link) or already visited - (:visited)The link - pseudo-classes1
E:active
E:hover
E:focus
an E element during certain user actionsThe user - action pseudo-classes1 and 2
E:targetan E element being the target of the referring URIThe target - pseudo-class3
E:lang(fr)an element of type E in language "fr" (the document - language specifies how language is determined)The :lang() - pseudo-class2
E:enabled
E:disabled
a user interface element E which is enabled or - disabledThe UI element states - pseudo-classes3
E:checkeda user interface element E which is checked (for instance a radio-button or checkbox)The UI element states - pseudo-classes3
E::first-linethe first formatted line of an E elementThe ::first-line - pseudo-element1
E::first-letterthe first formatted letter of an E elementThe ::first-letter - pseudo-element1
E::selectionthe portion of an E element that is currently - selected/highlighted by the userThe UI element - fragments pseudo-elements3
E::beforegenerated content before an E elementThe ::before - pseudo-element2
E::aftergenerated content after an E elementThe ::after - pseudo-element2
E.warningan E element whose class is -"warning" (the document language specifies how class is determined).Class - selectors1
E#myidan E element with ID equal to "myid".ID - selectors1
E:not(s)an E element that does not match simple selector sNegation - pseudo-class3
E Fan F element descendant of an E elementDescendant - combinator1
E > Fan F element child of an E elementChild - combinator2
E + Fan F element immediately preceded by an E elementAdjacent sibling combinator2
E ~ Fan F element preceded by an E elementGeneral sibling combinator3
- -

The meaning of each selector is derived from the table above by -prepending "matches" to the contents of each cell in the "Meaning" -column.

- -

3. Case sensitivity

- -

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.

- -

4. Selector syntax

- -

A selector is a chain of one -or more sequences of simple selectors -separated by combinators.

- -

A sequence of simple selectors -is a chain of simple selectors -that are not separated by a combinator. It -always begins with a type selector or a -universal selector. No other type -selector or universal selector is allowed in the sequence.

- -

A simple selector is either a type selector, universal selector, attribute selector, class selector, ID selector, content selector, or pseudo-class. One pseudo-element may be appended to the last -sequence of simple selectors.

- -

Combinators are: white space, "greater-than -sign" (U+003E, >), "plus sign" (U+002B, -+) and "tilde" (U+007E, ~). White -space may appear between a combinator and the simple selectors around -it. 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.

- -

The elements of a document tree that are represented by a selector -are the subjects of the selector. 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.

- -

An empty selector, containing no sequence of simple selectors and -no pseudo-element, is an invalid -selector.

- -

5. Groups of selectors

- -

When several selectors share the same declarations, they may be -grouped into a comma-separated list. (A comma is U+002C.)

- -
-

CSS examples:

-

In this example, we condense three rules with identical -declarations into one. Thus,

-
h1 { font-family: sans-serif }
-h2 { font-family: sans-serif }
-h3 { font-family: sans-serif }
-

is equivalent to:

-
h1, h2, h3 { font-family: sans-serif }
-
- -

Warning: 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.

- - -

6. Simple selectors

- -

6.1. Type selector

- -

A type selector is the name of a document language -element type. A type selector represents an instance of the element -type in the document tree.

- -
-

Example:

-

The following selector represents an h1 element in the document tree:

-
h1
-
- - -

6.1.1. Type selectors and namespaces

- -

Type selectors allow an optional namespace ([XMLNAMES]) 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, |).

- -

The namespace component may be left empty to indicate that the -selector is only to represent elements with no declared namespace.

- -

An asterisk may be used for the namespace prefix, indicating that -the selector represents elements in any namespace (including elements -with no namespace).

- -

Element type selectors that have no namespace component (no -namespace separator), represent elements without regard to the -element's namespace (equivalent to "*|") unless a default -namespace has been declared. If a default namespace has been declared, -the selector will represent only elements in the default -namespace.

- -

A type selector containing a namespace prefix that has not been -previously declared is an invalid 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.

- -

In a namespace-aware client, element type selectors will only match -against the local part -of the element's qualified -name. See below for notes about matching -behaviors in down-level clients.

- -

In summary:

- -
-
ns|E
-
elements with name E in namespace ns
-
*|E
-
elements with name E in any namespace, including those without any - declared namespace
-
|E
-
elements with name E without any declared namespace
-
E
-
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.
-
- -
-

CSS examples:

- -
@namespace foo url(http://www.example.com);
- foo|h1 { color: blue }
- foo|* { color: yellow }
- |h1 { color: red }
- *|h1 { color: green }
- h1 { color: green }
- -

The first rule will match only h1 elements in the - "http://www.example.com" namespace.

- -

The second rule will match all elements in the - "http://www.example.com" namespace.

- -

The third rule will match only h1 elements without - any declared namespace.

- -

The fourth rule will match h1 elements in any - namespace (including those without any declared namespace).

- -

The last rule is equivalent to the fourth rule because no default - namespace has been defined.

- -
- -

6.2. Universal selector

- -

The universal selector, written "asterisk" -(*), 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 Universal selector and -Namespaces below.

- -

If the universal selector is not the only component of a sequence -of simple selectors, the * may be omitted.

- -
-

Examples:

-
    -
  • *[hreflang|=en] and [hreflang|=en] are equivalent,
  • -
  • *.warning and .warning are equivalent,
  • -
  • *#myid and #myid are equivalent.
  • -
-
- -

Note: it is recommended that the -*, representing the universal selector, not be -omitted.

- -

6.2.1. Universal selector and namespaces

- -

The universal selector allows an optional namespace component. It -is used as follows:

- -
-
ns|*
-
all elements in namespace ns
-
*|*
-
all elements
-
|*
-
all elements without any declared namespace
-
*
-
if no default namespace has been specified, this is equivalent to *|*. - Otherwise it is equivalent to ns|* where ns is the default namespace.
-
- -

A universal selector containing a namespace prefix that has not -been previously declared is an invalid -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.

- - -

6.3. Attribute selectors

- -

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.

- -

6.3.1. Attribute presence and values -selectors

- -

CSS2 introduced four attribute selectors:

- -
-
[att] -
Represents an element with the att attribute, whatever the value of - the attribute.
-
[att=val]
-
Represents an element with the att attribute whose value is exactly - "val".
-
[att~=val]
-
Represents an element with the att attribute whose value is a whitespace-separated list of words, one of - which is exactly "val". If "val" contains whitespace, it will never - represent anything (since the words are separated by - spaces).
-
[att|=val] -
Represents an element with the att 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 hreflang attribute on the - link element in HTML) as described in RFC 3066 ([RFC3066]). For lang (or - xml:lang) language subcode matching, please see the :lang pseudo-class.
-
- -

Attribute values must be identifiers or strings. The -case-sensitivity of attribute names and values in selectors depends on -the document language.

- -
- -

Examples:

- -

The following attribute selector represents an h1 - element that carries the title attribute, whatever its - value:

- -
h1[title]
- -

In the following example, the selector represents a - span element whose class attribute has - exactly the value "example":

- -
span[class="example"]
- -

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 span element - whose hello attribute has exactly the value "Cleveland" - and whose goodbye attribute has exactly the value - "Columbus":

- -
span[hello="Cleveland"][goodbye="Columbus"]
- -

The following selectors illustrate the differences between "=" - and "~=". The first selector will represent, for example, the value - "copyright copyleft copyeditor" on a rel attribute. The - second selector will only represent an a element with - an href attribute having the exact value - "http://www.w3.org/".

- -
a[rel~="copyright"]
-a[href="http://www.w3.org/"]
- -

The following selector represents a link element - whose hreflang attribute is exactly "fr".

- -
link[hreflang=fr]
- -

The following selector represents a link element for - which the values of the hreflang attribute begins with - "en", including "en", "en-US", and "en-cockney":

- -
link[hreflang|="en"]
- -

Similarly, the following selectors represents a - DIALOGUE element whenever it has one of two different - values for an attribute character:

- -
DIALOGUE[character=romeo]
-DIALOGUE[character=juliet]
- -
- -

6.3.2. Substring matching attribute -selectors

- -

Three additional attribute selectors are provided for matching -substrings in the value of an attribute:

- -
-
[att^=val]
-
Represents an element with the att attribute whose value begins - with the prefix "val".
-
[att$=val] -
Represents an element with the att attribute whose value ends with - the suffix "val".
-
[att*=val] -
Represents an element with the att attribute whose value contains - at least one instance of the substring "val".
-
- -

Attribute values must be identifiers or strings. The -case-sensitivity of attribute names in selectors depends on the -document language.

- -
-

Examples:

-

The following selector represents an HTML object, referencing an - image:

-
object[type^="image/"]
-

The following selector represents an HTML anchor a with an - href attribute whose value ends with ".html".

-
a[href$=".html"]
-

The following selector represents an HTML paragraph with a title - attribute whose value contains the substring "hello"

-
p[title*="hello"]
-
- -

6.3.3. Attribute selectors and namespaces

- -

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" (|). 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 "|attr"). 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. - -

An attribute selector with an attribute name containing a namespace -prefix that has not been previously declared is an invalid 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. - -

-

CSS examples:

-
@namespace foo "http://www.example.com";
-[foo|att=val] { color: blue }
-[*|att] { color: yellow }
-[|att] { color: green }
-[att] { color: green }
- -

The first rule will match only elements with the attribute - att in the "http://www.example.com" namespace with the - value "val".

- -

The second rule will match only elements with the attribute - att regardless of the namespace of the attribute - (including no declared namespace).

- -

The last two rules are equivalent and will match only elements - with the attribute att where the attribute is not - declared to be in a namespace.

- -
- -

6.3.4. Default attribute values in DTDs

- -

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.

- -

More precisely, a UA is not required to read an "external -subset" of the DTD but is required to look for default -attribute values in the document's "internal subset." (See [XML10] for definitions of these subsets.)

- -

A UA that recognizes an XML namespace [XMLNAMES] 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.)

- -

Note: Typically, implementations -choose to ignore external subsets.

- -
-

Example:

- -

Consider an element EXAMPLE with an attribute "notation" that has a -default value of "decimal". The DTD fragment might be

- -
<!ATTLIST EXAMPLE notation (decimal,octal) "decimal">
- -

If the style sheet contains the rules

- -
EXAMPLE[notation=decimal] { /*... default property settings ...*/ }
-EXAMPLE[notation=octal]   { /*... other settings...*/ }
- -

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:

- -
EXAMPLE                   { /*... default property settings ...*/ }
-EXAMPLE[notation=octal]   { /*... other settings...*/ }
- -

Here, because the selector EXAMPLE[notation=octal] 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.

- -
- -

6.4. Class selectors

- -

Working with HTML, authors may use the period (U+002E, -.) notation as an alternative to the ~= -notation when representing the class attribute. Thus, for -HTML, div.value and div[class~=value] have -the same meaning. The attribute value must immediately follow the -"period" (.).

- -

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 [SVG] describes the SVG -"class" attribute and how a UA should interpret it, and -similarly MathML 1.01 [MATH] describes the MathML -"class" attribute.)

- -
-

CSS examples:

- -

We can assign style information to all elements with - class~="pastoral" as follows:

- -
*.pastoral { color: green }  /* all elements with class~=pastoral */
- -

or just

- -
.pastoral { color: green }  /* all elements with class~=pastoral */
- -

The following assigns style only to H1 elements with - class~="pastoral":

- -
H1.pastoral { color: green }  /* H1 elements with class~=pastoral */
- -

Given these rules, the first H1 instance below would not have - green text, while the second would:

- -
<H1>Not green</H1>
-<H1 class="pastoral">Very green</H1>
- -
- -

To represent a subset of "class" values, each value must be preceded -by a ".", in any order.

- -
- -

CSS example:

- -

The following rule matches any P element whose "class" attribute - has been assigned a list of whitespace-separated values that includes - "pastoral" and "marine":

- -
p.pastoral.marine { color: green }
- -

This rule matches when class="pastoral blue aqua - marine" but does not match for class="pastoral - blue".

- -
- -

Note: 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.

- -

Note: 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.

- -

6.5. ID selectors

- -

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.

- -

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, -#) immediately followed by the ID value, which must be an -identifier.

- -

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. - -

-

Examples:

-

The following ID selector represents an h1 element - whose ID-typed attribute has the value "chapter1":

-
h1#chapter1
-

The following ID selector represents any element whose ID-typed - attribute has the value "chapter1":

-
#chapter1
-

The following selector represents any element whose ID-typed - attribute has the value "z98y".

-
*#z98y
-
- -

Note. In XML 1.0 [XML10], 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: -[name=p371] instead of #p371. Elements in -XML 1.0 documents without a DTD do not have IDs at all.

- -

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.

- -

6.6. Pseudo-classes

- -

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.

- -

A pseudo-class always consists of a "colon" -(:) followed by the name of the pseudo-class and -optionally by a value between parentheses.

- -

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.

- - -

6.6.1. Dynamic pseudo-classes

- -

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.

- -

Dynamic pseudo-classes do not appear in the document source or -document tree.

- - -
The link pseudo-classes: :link and :visited
- -

User agents commonly display unvisited links differently from -previously visited ones. Selectors -provides the pseudo-classes :link and -:visited to distinguish them:

- -
    -
  • The :link pseudo-class applies to links that have - not yet been visited.
  • -
  • The :visited pseudo-class applies once the link has - been visited by the user.
  • -
- -

After some amount of time, user agents may choose to return a -visited link to the (unvisited) ':link' state.

- -

The two states are mutually exclusive.

- -
- -

Example:

- -

The following selector represents links carrying class - external and already visited:

- -
a.external:visited
- -
- -

Note: 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. - -

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.

- -
The user action pseudo-classes -:hover, :active, and :focus
- -

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.

- -
    - -
  • The :hover 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 interactive - media do not have to support this pseudo-class. Some conforming - user agents that support interactive - media may not be able to support this pseudo-class (e.g., a pen - device that does not detect hovering).
  • - -
  • The :active 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.
  • - -
  • The :focus pseudo-class applies while an element - has the focus (accepts keyboard or mouse events, or other forms of - input).
  • - -
- -

There may be document language or implementation specific limits on -which elements can become :active or acquire -:focus.

- -

These pseudo-classes are not mutually exclusive. An element may -match several pseudo-classes at the same time.

- -

Selectors doesn't define if the parent of an element that is -':active' or ':hover' is also in that state.

- -
-

Examples:

-
a:link    /* unvisited links */
-a:visited /* visited links */
-a:hover   /* user hovers */
-a:active  /* active links */
-

An example of combining dynamic pseudo-classes:

-
a:focus
-a:focus:hover
-

The last selector matches a elements that are in - the pseudo-class :focus and in the pseudo-class :hover.

-
- -

Note: An element can be both ':visited' -and ':active' (or ':link' and ':active').

- -

6.6.2. The target pseudo-class :target

- -

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).

- -

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 section_2 in an HTML -document:

- -
http://example.com/html/top.html#section_2
- -

A target element can be represented by the :target -pseudo-class. If the document's URI has no fragment identifier, then -the document has no target element.

- -
-

Example:

-
p.note:target
-

This selector represents a p element of class - note that is the target element of the referring - URI.

-
- -
-

CSS example:

-

Here, the :target pseudo-class is used to make the - target element red and place an image before it, if there is one:

-
*:target { color : red }
-*:target::before { content : url(target.png) }
-
- -

6.6.3. The language pseudo-class :lang

- -

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 [HTML4], the language is determined by a -combination of the lang attribute, the meta -element, and possibly by information from the protocol (such as HTTP -headers). XML uses an attribute called xml:lang, and -there may be other document language-specific methods for determining -the language.

- -

The pseudo-class :lang(C) represents an element that -is in language C. Whether an element is represented by a -:lang() 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 '|=' operator in attribute -selectors. The identifier C does not have to be a valid language -name.

- -

C must not be empty. (If it is, the selector is invalid.)

- -

Note: It is recommended that -documents and protocols indicate language using codes from RFC 3066 [RFC3066] or its successor, and by means of -"xml:lang" attributes in the case of XML-based documents [XML10]. See -"FAQ: Two-letter or three-letter language codes."

- -
-

Examples:

-

The two following selectors represent an HTML document that is in - Belgian, French, or German. The two next selectors represent - q quotations in an arbitrary element in Belgian, French, - or German.

-
html:lang(fr-be)
-html:lang(de)
-:lang(fr-be) > q
-:lang(de) > q
-
- -

6.6.4. The UI element states pseudo-classes

- -
The :enabled and :disabled pseudo-classes
- -

The :enabled 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 input element without also specifying what it -would look like when it was disabled.

- -

Similar to :enabled, :disabled allows the -author to specify precisely how a disabled or inactive user interface -element should look.

- -

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.

- - -
The :checked pseudo-class
- -

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 :checked pseudo-class applies. The -:checked pseudo-class initially applies to such elements -that have the HTML4 selected and checked -attributes as described in Section -17.2.1 of HTML4, but of course the user can toggle "off" such -elements in which case the :checked pseudo-class would no -longer apply. While the :checked 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 selected and -checked attributes, it applies to all media. - - -

The :indeterminate pseudo-class
- -
- -

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.

- -

A future version of this specification may introduce an -:indeterminate pseudo-class that applies to such elements. -

- -
- - -

6.6.5. Structural pseudo-classes

- -

Selectors introduces the concept of structural -pseudo-classes to permit selection based on extra information that lies in -the document tree but cannot be represented by other simple selectors or -combinators. - -

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. - - -

:root pseudo-class
- -

The :root pseudo-class represents an element that is -the root of the document. In HTML 4, this is always the -HTML element. - - -

:nth-child() pseudo-class
- -

The -:nth-child(an+b) -pseudo-class notation represents an element that has -an+b-1 siblings -before it in the document tree, for a given positive -integer or zero value of n, and has a parent element. In -other words, this matches the bth child of an element after -all the children have been split into groups of a 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 a and -b values must be zero, negative integers or positive -integers. The index of the first child of an element is 1. - -

In addition to this, :nth-child() can take -'odd' and 'even' as arguments instead. -'odd' has the same signification as 2n+1, -and 'even' has the same signification as 2n. - - -

-

Examples:

-
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; }
-
- -

When a=0, no repeating is used, so for example -:nth-child(0n+5) matches only the fifth child. When -a=0, the an part need not be -included, so the syntax simplifies to -:nth-child(b) and the last example simplifies -to :nth-child(5). - -

-

Examples:

-
foo:nth-child(0n+1)   /* represents an element foo, first child of its parent element */
-foo:nth-child(1)      /* same */
-
- -

When a=1, the number may be omitted from the rule. - -

-

Examples:

-

The following selectors are therefore equivalent:

-
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) */
-
- -

If b=0, then every ath element is picked. In -such a case, the b part may be omitted. - -

-

Examples:

-
tr:nth-child(2n+0) /* represents every even row of an HTML table */
-tr:nth-child(2n) /* same */
-
- -

If both a and b are equal to zero, the -pseudo-class represents no element in the document tree.

- -

The value a can be negative, but only the positive -values of an+b, for -n≥0, may represent an element in the document -tree.

- -
-

Example:

-
html|tr:nth-child(-n+6)  /* represents the 6 first rows of XHTML tables */
-
- -

When the value b is negative, the "+" character in the -expression must be removed (it is effectively replaced by the "-" -character indicating the negative value of b).

- -
-

Examples:

-
: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 */
-
- - -
:nth-last-child() pseudo-class
- -

The :nth-last-child(an+b) -pseudo-class notation represents an element that has -an+b-1 siblings -after it in the document tree, for a given positive -integer or zero value of n, and has a parent element. See -:nth-child() pseudo-class for the syntax of its argument. -It also accepts the 'even' and 'odd' values -as arguments. - - -

-

Examples:

-
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 */
-
- - -
:nth-of-type() pseudo-class
- -

The :nth-of-type(an+b) -pseudo-class notation represents an element that has -an+b-1 siblings with the same -element name before it in the document tree, for a -given zero or positive integer value of n, and has a -parent element. In other words, this matches the bth child -of that type after all the children of that type have been split into -groups of a elements each. See :nth-child() pseudo-class -for the syntax of its argument. It also accepts the -'even' and 'odd' values. - - -

-

CSS example:

-

This allows an author to alternate the position of floated images:

-
img:nth-of-type(2n+1) { float: right; }
-img:nth-of-type(2n) { float: left; }
-
- - -
:nth-last-of-type() pseudo-class
- -

The :nth-last-of-type(an+b) -pseudo-class notation represents an element that has -an+b-1 siblings with the same -element name after it in the document tree, for a -given zero or positive integer value of n, and has a -parent element. See :nth-child() pseudo-class for the -syntax of its argument. It also accepts the 'even' and 'odd' values. - - -

-

Example:

-

To represent all h2 children of an XHTML - body except the first and last, one could use the - following selector:

-
body > h2:nth-of-type(n+2):nth-last-of-type(n+2)
-

In this case, one could also use :not(), although the - selector ends up being just as long:

-
body > h2:not(:first-of-type):not(:last-of-type)
-
- - -
:first-child pseudo-class
- -

Same as :nth-child(1). The :first-child pseudo-class -represents an element that is the first child of some other element. - - -

-

Examples:

-

The following selector represents a p element that is - the first child of a div element:

-
div > p:first-child
-

This selector can represent the p inside the - div of the following fragment:

-
<p> The last P before the note.</p>
-<div class="note">
-   <p> The first P inside the note.</p>
-</div>
but cannot represent the second p in the following -fragment: -
<p> The last P before the note.</p>
-<div class="note">
-   <h2> Note </h2>
-   <p> The first P inside the note.</p>
-</div>
-

The following two selectors are usually equivalent:

-
* > a:first-child /* a is first child of any element */
-a:first-child /* Same (assuming a is not the root element) */
-
- -
:last-child pseudo-class
- -

Same as :nth-last-child(1). The :last-child pseudo-class -represents an element that is the last child of some other element. - -

-

Example:

-

The following selector represents a list item li that - is the last child of an ordered list ol. -

ol > li:last-child
-
- -
:first-of-type pseudo-class
- -

Same as :nth-of-type(1). The :first-of-type pseudo-class -represents an element that is the first sibling of its type in the list of -children of its parent element. - -

-

Example:

-

The following selector represents a definition title -dt inside a definition list dl, this -dt being the first of its type in the list of children of -its parent element.

-
dl dt:first-of-type
-

It is a valid description for the first two dt -elements in the following example but not for the third one:

-
<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>
-
- -
:last-of-type pseudo-class
- -

Same as :nth-last-of-type(1). The -:last-of-type pseudo-class represents an element that is -the last sibling of its type in the list of children of its parent -element.

- -
-

Example:

-

The following selector represents the last data cell - td of a table row.

-
tr > td:last-of-type
-
- -
:only-child pseudo-class
- -

Represents an element that has a parent element and whose parent -element has no other element children. Same as -:first-child:last-child or -:nth-child(1):nth-last-child(1), but with a lower -specificity.

- -
:only-of-type pseudo-class
- -

Represents an element that has a parent element and whose parent -element has no other element children with the same element name. Same -as :first-of-type:last-of-type or -:nth-of-type(1):nth-last-of-type(1), but with a lower -specificity.

- - -
:empty pseudo-class
- -

The :empty 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.

- -
-

Examples:

-

p:empty is a valid representation of the following fragment:

-
<p></p>
-

foo:empty is not a valid representation for the - following fragments:

-
<foo>bar</foo>
-
<foo><bar>bla</bar></foo>
-
<foo>this is not <bar>:empty</bar></foo>
-
- -

6.6.6. Blank

- -

This section intentionally left blank.

- - -

6.6.7. The negation pseudo-class

- -

The negation pseudo-class, :not(X), is a -functional notation taking a simple -selector (excluding the negation pseudo-class itself and -pseudo-elements) as an argument. It represents an element that is not -represented by the argument. - - - -

-

Examples:

-

The following CSS selector matches all button - elements in an HTML document that are not disabled.

-
button:not([DISABLED])
-

The following selector represents all but FOO - elements.

-
*:not(FOO)
-

The following group of selectors represents all HTML elements - except links.

-
html|*:not(:link):not(:visited)
-
- -

Default namespace declarations do not affect the argument of the -negation pseudo-class unless the argument is a universal selector or a -type selector.

- -
-

Examples:

-

Assuming that the default namespace is bound to - "http://example.com/", the following selector represents all - elements that are not in that namespace:

-
*|*:not(*)
-

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 are being hovered.

-
*|*:not(:hover)
-
- -

Note: the :not() pseudo allows -useless selectors to be written. For instance :not(*|*), -which represents no element at all, or foo:not(bar), -which is equivalent to foo but with a higher -specificity.

- -

7. Pseudo-elements

- -

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 ::before and -::after pseudo-elements give access to generated -content).

- -

A pseudo-element is made of two colons (::) followed -by the name of the pseudo-element.

- -

This :: 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, -:first-line, :first-letter, -:before and :after). This compatibility is -not allowed for the new pseudo-elements introduced in CSS level 3.

- -

Only one pseudo-element may appear per selector, and if present it -must appear after the sequence of simple selectors that represents the -subjects of the selector. A -future version of this specification may allow multiple -pesudo-elements per selector.

- -

7.1. The ::first-line pseudo-element

- -

The ::first-line pseudo-element describes the contents -of the first formatted line of an element. - -

-

CSS example:

-
p::first-line { text-transform: uppercase }
-

The above rule means "change the letters of the first line of every -paragraph to uppercase".

-
- -

The selector p::first-line 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.

- -

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>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>
-
- -

the lines of which happen to be broken as follows: - -

-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.
-
- -

This paragraph might be "rewritten" by user agents to include the -fictional tag sequence for ::first-line. This -fictional tag sequence helps to show how properties are inherited.

- -
-<P><P::first-line> This is a somewhat long HTML 
-paragraph that </P::first-line> 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>
-
- -

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 span element:

- -
-<P><SPAN class="test"> This is a somewhat long HTML
-paragraph that will be broken into several
-lines.</SPAN> The first line will be identified
-by a fictional tag sequence. The other lines 
-will be treated as ordinary lines in the 
-paragraph.</P>
-
- -

the user agent could simulate start and end tags for -span when inserting the fictional tag sequence for -::first-line. - -

-<P><P::first-line><SPAN class="test"> This is a
-somewhat long HTML
-paragraph that will </SPAN></P::first-line><SPAN class="test"> be
-broken into several
-lines.</SPAN> The first line will be identified
-by a fictional tag sequence. The other lines
-will be treated as ordinary lines in the 
-paragraph.</P>
-
- -

In CSS, the ::first-line pseudo-element can only be -attached to a block-level element, an inline-block, a table-caption, -or a table-cell.

- -

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 div in <DIV><P>This -line...</P></DIV> is the first line of the p (assuming -that both p and div are block-level). - -

The first line of a table-cell or inline-block cannot be the first -formatted line of an ancestor element. Thus, in <DIV><P -STYLE="display: inline-block">Hello<BR>Goodbye</P> -etcetera</DIV> the first formatted line of the -div is not the line "Hello". - -

Note that the first line of the p in this -fragment: <p><br>First... doesn't contain any -letters (assuming the default style for br in HTML -4). The word "First" is not on the first formatted line. - -

A UA should act as if the fictional start tags of the -::first-line 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

- -
-<DIV>
-  <P>First paragraph</P>
-  <P>Second paragraph</P>
-</DIV>
-
- -

is

- -
-<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>
-
- -

The ::first-line pseudo-element is similar to an -inline-level element, but with certain restrictions. In CSS, the -following properties apply to a ::first-line -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.

- - -

7.2. The ::first-letter pseudo-element

- -

The ::first-letter 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.

- -

In CSS, these are the properties that apply to ::first-letter -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.

- -
-

Example:

-

This example shows a possible rendering of an initial cap. Note -that the 'line-height' that is inherited by the ::first-letter -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, and thus -the font weight of the first letter is normal, not bold as the span: -

-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.
-
-
-

Image illustrating the ::first-letter pseudo-element -

-
- -
-

The following CSS will make a drop cap initial letter span about two lines:

- -
-<!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>
-
- -

This example might be formatted as follows:

- -
-

Image illustrating the combined effect of the ::first-letter and ::first-line pseudo-elements

-
- -

The fictional tag sequence is:

- -
-<P>
-<SPAN>
-<P::first-letter>
-T
-</P::first-letter>he first
-</SPAN> 
-few words of an article in the Economist.
-</P>
-
- -

Note that the ::first-letter 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.

- -

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.

- -

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. [UNICODE]

- -
-

Quotes that precede the
-first letter should be included.

-
- -

The ::first-letter also applies if the first letter is -in fact a digit, e.g., the "6" in "67 million dollars is a lot of -money."

- -

In CSS, the ::first-letter pseudo-element applies to -block, list-item, table-cell, table-caption, and inline-block -elements. A future version of this specification -may allow this pesudo-element to apply to more element -types.

- -

The ::first-letter 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.

- -
-

Example:

-

The fictional tag sequence for this HTMLfragment: -

<div>
-<p>The first text.
-

is: -

<div>
-<p><div::first-letter><p::first-letter>T</...></...>he first text.
-
- -

The first letter of a table-cell or inline-block cannot be the -first letter of an ancestor element. Thus, in <DIV><P -STYLE="display: inline-block">Hello<BR>Goodbye</P> -etcetera</DIV> the first letter of the div is not the -letter "H". In fact, the div doesn't have a first letter. - -

The first letter must occur on the first formatted line. For example, in -this fragment: <p><br>First... the first line -doesn't contain any letters and ::first-letter doesn't -match anything (assuming the default style for br in HTML -4). In particular, it does not match the "F" of "First." - -

In CSS, if an element is a list item ('display: list-item'), the -::first-letter applies to the first letter in the -principal box after the marker. UAs may ignore -::first-letter on list items with 'list-style-position: -inside'. If an element has ::before or -::after content, the ::first-letter applies -to the first letter of the element including that content. - -

-

Example:

-

After the rule 'p::before {content: "Note: "}', the selector -'p::first-letter' matches the "N" of "Note".

-
- -

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 ::first-letter pseudo-element. - -

If the letters that would form the ::first-letter are not in the -same element, such as "'T" in <p>'<em>T..., the UA -may create a ::first-letter pseudo-element from one of the elements, -both elements, or simply not create a pseudo-element.

- -

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). - -

-

Example:

-

The following example 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 { 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>
- -

Assuming that a line break will occur before the word "ends", the -fictional tag -sequence for this fragment might be:

- -
<P>
-<P::first-line>
-<P::first-letter> 
-S 
-</P::first-letter>ome text that 
-</P::first-line> 
-ends up on two lines 
-</P>
- -

Note that the ::first-letter element is inside the ::first-line -element. Properties set on ::first-line are inherited by -::first-letter, but are overridden if the same property is set on -::first-letter.

-
- - -

7.3. The ::selection pseudo-element

- -

The ::selection 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 :checked pseudo-class (which used to be -named :selected) - -

Although the ::selection 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 -[CSS21]) which was originally rendered to a -dynamic medium (like screen), the UA may wish to transfer the current -::selection 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 ::selection -pseudo-element for static media. - -

These are the CSS properties that apply to ::selection -pseudo-elements: color, background, cursor (optional), outline -(optional). The computed value of the 'background-image' property on -::selection may be ignored. - - -

7.4. The ::before and ::after pseudo-elements

- -

The ::before and ::after pseudo-elements -can be used to describe generated content before or after an element's -content. They are explained in CSS 2.1 [CSS21].

- -

When the ::first-letter and ::first-line -pseudo-elements are combined with ::before and -::after, they apply to the first letter or line of the -element including the inserted text.

- -

8. Combinators

- -

8.1. Descendant combinator

- -

At times, authors may want selectors to describe an element that is -the descendant of another element in the document tree (e.g., "an -EM element that is contained within an H1 -element"). Descendant combinators express such a relationship. A -descendant combinator is white space that -separates two sequences of simple selectors. A selector of the form -"A B" represents an element B that is an -arbitrary descendant of some ancestor element A. - -

-

Examples:

-

For example, consider the following selector:

-
h1 em
-

It represents an em element being the descendant of - an h1 element. It is a correct and valid, but partial, - description of the following fragment:

-
<h1>This <span class="myclass">headline
-is <em>very</em> important</span></h1>
-

The following selector:

-
div * p
-

represents a p element that is a grandchild or later - descendant of a div 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.

-

The following selector, which combines descendant combinators and - attribute selectors, represents an - element that (1) has the href attribute set and (2) is - inside a p that is itself inside a div:

-
div p *[href]
-
- -

8.2. Child combinators

- -

A child combinator describes a childhood relationship -between two elements. A child combinator is made of the -"greater-than sign" (>) character and -separates two sequences of simple selectors. - - -

-

Examples:

-

The following selector represents a p element that is - child of body:

-
body > p
-

The following example combines descendant combinators and child - combinators.

-
div ol>li p
-

It represents a p element that is a descendant of an - li element; the li element must be the - child of an ol element; the ol element must - be a descendant of a div. Notice that the optional white - space around the ">" combinator has been left out.

-
- -

For information on selecting the first child of an element, please -see the section on the :first-child pseudo-class -above.

- -

8.3. Sibling combinators

- -

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.

- -

8.3.1. Adjacent sibling combinator

- -

The adjacent sibling combinator is made of the "plus -sign" (U+002B, +) 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.

- -
-

Examples:

-

The following selector represents a p element - immediately following a math element:

-
math + 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 h1 element, that it must have - class="opener":

-
h1.opener + h2
-
- - -

8.3.2. General sibling combinator

- -

The general sibling combinator is made of the "tilde" -(U+007E, ~) 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.

- -
-

Example:

-
h1 ~ pre
-

represents a pre element following an h1. It - is a correct and valid, but partial, description of:

-
<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>
-
- -

9. Calculating a selector's specificity

- -

A selector's specificity is calculated as follows:

- -
    -
  • count the number of ID selectors in the selector (= a)
  • -
  • count the number of class selectors, attributes selectors, and pseudo-classes in the selector (= b)
  • -
  • count the number of element names in the selector (= c)
  • -
  • ignore pseudo-elements
  • -
- -

Selectors inside the negation pseudo-class -are counted like any other, but the negation itself does not count as -a pseudo-class.

- -

Concatenating the three numbers a-b-c (in a number system with a -large base) gives the specificity.

- -
-

Examples:

-
*               /* 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 */
-
-
- -

Note: the specificity of the styles -specified in an HTML style attribute is described in CSS -2.1. [CSS21].

- -

10. The grammar of Selectors

- -

10.1. Grammar

- -

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 [YACC]) -are used:

- -
    -
  • *: 0 or more -
  • +: 1 or more -
  • ?: 0 or 1 -
  • |: separates alternatives -
  • [ ]: grouping
  • -
- -

The productions are:

- -
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
-  ;
- - -

10.2. Lexical scanner

- -

The following is the tokenizer, written in Flex (see -[FLEX]) notation. The tokenizer is -case-insensitive.

- -

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. [UNICODE]

- -
%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;
- - - -

11. Namespaces and down-level clients

- -

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.

- -

It should be noted that a down-level CSS client will (if it -properly conforms to CSS forward compatible parsing rules) ignore all -@namespace 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.

- -

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.

- -

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.

- -
    -
  1. - -

    The XML document does not use namespaces.

    - -
      - -
    • 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.
    • - -
    • 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 ("|name") - will guarantee that selectors will match only XML elements that do - not have a declared namespace.
    • - -
    - -
  2. - -
  3. - -

    The XML document defines a single, default namespace used - throughout the document. No namespace prefixes are used in element - names.

    - -
      - -
    • 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.
    • - -
    - -
  4. - -
  5. - -

    The XML document does not 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).

    - -
      - -
    • 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 Type selectors and Namespaces section. CSS - selectors may be declared using an escaped colon "\:" - to describe the fully qualified names, e.g. - "html\:h1" will match - <html:h1>. 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.
    • - -
    • Note that selectors declared in this fashion will - only 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).
    • - -
    - -
  6. - -
- -

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 -different 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.

- -

12. Profiles

- -

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.

- -

Non normative examples: - -

- - - - - - - - - - - - - - - -
Selectors profile
SpecificationCSS level 1
Acceptstype selectors
class selectors
ID selectors
:link, - :visited and :active pseudo-classes
descendant combinator -
::first-line and ::first-letter pseudo-elements
Excludes - -

universal selector
attribute selectors
:hover and :focus - pseudo-classes
:target pseudo-class
:lang() pseudo-class
all UI - element states pseudo-classes
all structural - pseudo-classes
negation pseudo-class
all - UI element fragments pseudo-elements
::before and ::after - pseudo-elements
child combinators
sibling combinators - -

namespaces

Extra constraintsonly one class selector allowed per sequence of simple - selectors


- - - - - - - - - - - - - - - -
Selectors profile
SpecificationCSS level 2
Acceptstype selectors
universal selector
attribute presence and - values selectors
class selectors
ID selectors
:link, :visited, - :active, :hover, :focus, :lang() and :first-child pseudo-classes -
descendant combinator
child combinator
adjacent sibling - combinator
::first-line and ::first-letter pseudo-elements
::before - and ::after pseudo-elements
Excludes - -

content selectors
substring matching attribute - selectors
:target pseudo-classes
all UI element - states pseudo-classes
all structural pseudo-classes other - than :first-child
negation pseudo-class
all UI element - fragments pseudo-elements
general sibling combinators - -

namespaces

Extra constraintsmore than one class selector per sequence of simple selectors (CSS1 - constraint) allowed
- -

In CSS, selectors express pattern matching rules that determine which style -rules apply to elements in the document tree. - -

The following selector (CSS level 2) will match all anchors a -with attribute name set inside a section 1 header h1: -

h1 a[name]
- -

All CSS declarations attached to such a selector are applied to elements -matching it.

- -
- - - - - - - - - - - - - - - - -
Selectors profile
SpecificationSTTS 3
Accepts - -

type selectors
universal selectors
attribute selectors
class - selectors
ID selectors
all structural pseudo-classes
- all combinators - -

namespaces

Excludesnon-accepted pseudo-classes
pseudo-elements
Extra constraintssome selectors and combinators are not allowed in fragment - descriptions on the right side of STTS declarations.
-
- - - - - - - - - - - - - - - - - - - - - - - - - -
- -

Selectors can be used in STTS 3 in two different - manners: -

    -
  1. a selection mechanism equivalent to CSS selection mechanism: declarations - attached to a given selector are applied to elements matching that selector, -
  2. fragment descriptions that appear on the right side of declarations. -
- -

13. Conformance and requirements

- -

This section defines conformance with the present specification only. - -

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. - -

All specifications reusing Selectors must contain a Profile listing the -subset of Selectors it accepts or excludes, and describing the constraints -it adds to the current specification. - -

Invalidity is caused by a parsing error, e.g. an unrecognized token or a token -which is not allowed at the current parsing point. - -

User agents must observe the rules for handling parsing errors: -

    -
  • a simple selector containing an undeclared namespace prefix is invalid
  • -
  • a selector containing an invalid simple selector, an invalid combinator - or an invalid token is invalid.
  • -
  • a group of selectors containing an invalid selector is invalid.
  • -
- -

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.)

- - - -

14. Tests

- -

This specification has a test -suite 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.

- -

15. Acknowledgements

- -

The CSS working group would like to thank everyone who has sent -comments on this specification over the years.

- -

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.

- -

16. References

- -
- -
[CSS1] -
Bert Bos, Håkon Wium Lie; "Cascading Style Sheets, level 1", W3C Recommendation, 17 Dec 1996, revised 11 Jan 1999 -
(http://www.w3.org/TR/REC-CSS1) - -
[CSS21] -
Bert Bos, Tantek Çelik, Ian Hickson, Håkon Wium Lie, editors; "Cascading Style Sheets, level 2 revision 1", W3C Working Draft, 13 June 2005 -
(http://www.w3.org/TR/CSS21) - -
[CWWW] -
Martin J. Dürst, François Yergeau, Misha Wolf, Asmus Freytag, Tex Texin, editors; "Character Model for the World Wide Web", W3C Recommendation, 15 February 2005 -
(http://www.w3.org/TR/charmod/) - -
[FLEX] -
"Flex: The Lexical Scanner Generator", Version 2.3.7, ISBN 1882114213 - -
[HTML4] -
Dave Ragget, Arnaud Le Hors, Ian Jacobs, editors; "HTML 4.01 Specification", W3C Recommendation, 24 December 1999 -
(http://www.w3.org/TR/html4/) - -
[MATH] -
Patrick Ion, Robert Miner, editors; "Mathematical Markup Language (MathML) 1.01", W3C Recommendation, revision of 7 July 1999 -
(http://www.w3.org/TR/REC-MathML/) - -
[RFC3066] -
H. Alvestrand; "Tags for the Identification of Languages", Request for Comments 3066, January 2001 -
(http://www.ietf.org/rfc/rfc3066.txt) - -
[STTS] -
Daniel Glazman; "Simple Tree Transformation Sheets 3", Electricité de France, submission to the W3C, 11 November 1998 -
(http://www.w3.org/TR/NOTE-STTS3) - -
[SVG] -
Jon Ferraiolo, 藤沢 淳, Dean Jackson, editors; "Scalable Vector Graphics (SVG) 1.1 Specification", W3C Recommendation, 14 January 2003 -
(http://www.w3.org/TR/SVG/) - -
[UNICODE]
-
The Unicode Standard, Version 4.1, The Unicode Consortium. Boston, MA, Addison-Wesley, March 2005. ISBN 0-321-18578-1, as amended by Unicode 4.0.1 and Unicode 4.1.0. -
(http://www.unicode.org/versions/)
- -
[XML10] -
Tim Bray, Jean Paoli, C. M. Sperberg-McQueen, Eve Maler, François Yergeau, editors; "Extensible Markup Language (XML) 1.0 (Third Edition)", W3C Recommendation, 4 February 2004 -
(http://www.w3.org/TR/REC-xml/) - -
[XMLNAMES] -
Tim Bray, Dave Hollander, Andrew Layman, editors; "Namespaces in XML", W3C Recommendation, 14 January 1999 -
(http://www.w3.org/TR/REC-xml-names/) - -
[YACC] -
S. C. Johnson; "YACC — Yet another compiler compiler", Technical Report, Murray Hill, 1975 - -
- - diff --git a/samples/third_party/dromaeo/web/tests/dom-attr.html b/samples/third_party/dromaeo/web/tests/dom-attr.html deleted file mode 100644 index 29ff1258070..00000000000 --- a/samples/third_party/dromaeo/web/tests/dom-attr.html +++ /dev/null @@ -1,2946 +0,0 @@ - - - - - - -
-

W3C - -

Selectors

- -

W3C Working Draft 15 December 2005

- -
- -
This version: - -
- http://www.w3.org/TR/2005/WD-css3-selectors-20051215 - -
Latest version: - -
- http://www.w3.org/TR/css3-selectors - -
Previous version: - -
- http://www.w3.org/TR/2001/CR-css3-selectors-20011113 - -
Editors: - -
Daniel Glazman (Invited Expert)
- -
Tantek Çelik (Invited Expert) - -
Ian Hickson (Google) - -
Peter Linss (former editor, Netscape/AOL) - -
John Williams (former editor, Quark, Inc.) - -
- -
- -
- -

Abstract

- -

Selectors 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.

- -

CSS (Cascading - Style Sheets) is a language for describing the rendering of HTML and XML 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. - -

Selectors define the following function:

- -
expression ∗ element → boolean
- -

That is, given an element and a selector, this specification - defines whether that element matches the selector.

- -

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. STTS (Simple Tree Transformation Sheets), a - language for transforming XML trees, uses this mechanism. [STTS]

- -

Status of this document

- -

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 W3C technical reports index at - http://www.w3.org/TR/.

- -

This document describes the selectors that already exist in CSS1 and CSS2, and - also proposes new selectors for CSS3 and other languages that may need them.

- -

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.

- -

This specification is a last call working draft for the the CSS Working Group - (Style Activity). This - document is a revision of the Candidate - Recommendation dated 2001 November 13, 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.

- -

All persons are encouraged to review and implement this - specification and return comments to the (archived) - public mailing list www-style - (see instructions). W3C - Members can also send comments directly to the CSS Working - Group. - The deadline for comments is 14 January 2006.

- -

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". - -

This document may be available in translation. - The English version of this specification is the only normative - version. - -

- -

Table of contents

- - - -
- -

1. Introduction

- -

1.1. Dependencies

- -

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. [CSS21]

- -

1.2. Terminology

- -

All of the text of this specification is normative except - examples, notes, and sections explicitly marked as - non-normative.

- -

1.3. Changes from CSS2

- -

This section is non-normative.

- -

The main differences between the selectors in CSS2 and those in - Selectors are: - -

    - -
  • 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
  • - -
  • an optional namespace component is now allowed in type element - selectors, the universal selector and attribute selectors
  • - -
  • a new combinator has been introduced
  • - -
  • new simple selectors including substring matching attribute - selectors, and new pseudo-classes
  • - -
  • new pseudo-elements, and introduction of the "::" convention - for pseudo-elements
  • - -
  • the grammar has been rewritten
  • - -
  • profiles to be added to specifications integrating Selectors - and defining the set of selectors which is actually supported by - each specification
  • - -
  • Selectors are now a CSS3 Module and an independent - specification; other specifications can now refer to this document - independently of CSS
  • - -
  • the specification now has its own test suite
  • - -
- -

2. Selectors

- -

This section is non-normative, as it merely summarizes the -following sections.

- -

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.

- -

Selectors may range from simple element names to rich contextual -representations.

- -

The following table summarizes the Selector syntax:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PatternMeaningDescribed in sectionFirst defined in CSS level
*any elementUniversal - selector2
Ean element of type EType selector1
E[foo]an E element with a "foo" attributeAttribute - selectors2
E[foo="bar"]an E element whose "foo" attribute value is exactly - equal to "bar"Attribute - selectors2
E[foo~="bar"]an E element whose "foo" attribute value is a list of - space-separated values, one of which is exactly equal to "bar"Attribute - selectors2
E[foo^="bar"]an E element whose "foo" attribute value begins exactly - with the string "bar"Attribute - selectors3
E[foo$="bar"]an E element whose "foo" attribute value ends exactly - with the string "bar"Attribute - selectors3
E[foo*="bar"]an E element whose "foo" attribute value contains the - substring "bar"Attribute - selectors3
E[hreflang|="en"]an E element whose "hreflang" attribute has a hyphen-separated - list of values beginning (from the left) with "en"Attribute - selectors2
E:rootan E element, root of the documentStructural - pseudo-classes3
E:nth-child(n)an E element, the n-th child of its parentStructural - pseudo-classes3
E:nth-last-child(n)an E element, the n-th child of its parent, counting - from the last oneStructural - pseudo-classes3
E:nth-of-type(n)an E element, the n-th sibling of its typeStructural - pseudo-classes3
E:nth-last-of-type(n)an E element, the n-th sibling of its type, counting - from the last oneStructural - pseudo-classes3
E:first-childan E element, first child of its parentStructural - pseudo-classes2
E:last-childan E element, last child of its parentStructural - pseudo-classes3
E:first-of-typean E element, first sibling of its typeStructural - pseudo-classes3
E:last-of-typean E element, last sibling of its typeStructural - pseudo-classes3
E:only-childan E element, only child of its parentStructural - pseudo-classes3
E:only-of-typean E element, only sibling of its typeStructural - pseudo-classes3
E:emptyan E element that has no children (including text - nodes)Structural - pseudo-classes3
E:link
E:visited
an E element being the source anchor of a hyperlink of - which the target is not yet visited (:link) or already visited - (:visited)The link - pseudo-classes1
E:active
E:hover
E:focus
an E element during certain user actionsThe user - action pseudo-classes1 and 2
E:targetan E element being the target of the referring URIThe target - pseudo-class3
E:lang(fr)an element of type E in language "fr" (the document - language specifies how language is determined)The :lang() - pseudo-class2
E:enabled
E:disabled
a user interface element E which is enabled or - disabledThe UI element states - pseudo-classes3
E:checkeda user interface element E which is checked (for instance a radio-button or checkbox)The UI element states - pseudo-classes3
E::first-linethe first formatted line of an E elementThe ::first-line - pseudo-element1
E::first-letterthe first formatted letter of an E elementThe ::first-letter - pseudo-element1
E::selectionthe portion of an E element that is currently - selected/highlighted by the userThe UI element - fragments pseudo-elements3
E::beforegenerated content before an E elementThe ::before - pseudo-element2
E::aftergenerated content after an E elementThe ::after - pseudo-element2
E.warningan E element whose class is -"warning" (the document language specifies how class is determined).Class - selectors1
E#myidan E element with ID equal to "myid".ID - selectors1
E:not(s)an E element that does not match simple selector sNegation - pseudo-class3
E Fan F element descendant of an E elementDescendant - combinator1
E > Fan F element child of an E elementChild - combinator2
E + Fan F element immediately preceded by an E elementAdjacent sibling combinator2
E ~ Fan F element preceded by an E elementGeneral sibling combinator3
- -

The meaning of each selector is derived from the table above by -prepending "matches" to the contents of each cell in the "Meaning" -column.

- -

3. Case sensitivity

- -

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.

- -

4. Selector syntax

- -

A selector is a chain of one -or more sequences of simple selectors -separated by combinators.

- -

A sequence of simple selectors -is a chain of simple selectors -that are not separated by a combinator. It -always begins with a type selector or a -universal selector. No other type -selector or universal selector is allowed in the sequence.

- -

A simple selector is either a type selector, universal selector, attribute selector, class selector, ID selector, content selector, or pseudo-class. One pseudo-element may be appended to the last -sequence of simple selectors.

- -

Combinators are: white space, "greater-than -sign" (U+003E, >), "plus sign" (U+002B, -+) and "tilde" (U+007E, ~). White -space may appear between a combinator and the simple selectors around -it. 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.

- -

The elements of a document tree that are represented by a selector -are the subjects of the selector. 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.

- -

An empty selector, containing no sequence of simple selectors and -no pseudo-element, is an invalid -selector.

- -

5. Groups of selectors

- -

When several selectors share the same declarations, they may be -grouped into a comma-separated list. (A comma is U+002C.)

- -
-

CSS examples:

-

In this example, we condense three rules with identical -declarations into one. Thus,

-
h1 { font-family: sans-serif }
-h2 { font-family: sans-serif }
-h3 { font-family: sans-serif }
-

is equivalent to:

-
h1, h2, h3 { font-family: sans-serif }
-
- -

Warning: 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.

- - -

6. Simple selectors

- -

6.1. Type selector

- -

A type selector is the name of a document language -element type. A type selector represents an instance of the element -type in the document tree.

- -
-

Example:

-

The following selector represents an h1 element in the document tree:

-
h1
-
- - -

6.1.1. Type selectors and namespaces

- -

Type selectors allow an optional namespace ([XMLNAMES]) 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, |).

- -

The namespace component may be left empty to indicate that the -selector is only to represent elements with no declared namespace.

- -

An asterisk may be used for the namespace prefix, indicating that -the selector represents elements in any namespace (including elements -with no namespace).

- -

Element type selectors that have no namespace component (no -namespace separator), represent elements without regard to the -element's namespace (equivalent to "*|") unless a default -namespace has been declared. If a default namespace has been declared, -the selector will represent only elements in the default -namespace.

- -

A type selector containing a namespace prefix that has not been -previously declared is an invalid 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.

- -

In a namespace-aware client, element type selectors will only match -against the local part -of the element's qualified -name. See below for notes about matching -behaviors in down-level clients.

- -

In summary:

- -
-
ns|E
-
elements with name E in namespace ns
-
*|E
-
elements with name E in any namespace, including those without any - declared namespace
-
|E
-
elements with name E without any declared namespace
-
E
-
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.
-
- -
-

CSS examples:

- -
@namespace foo url(http://www.example.com);
- foo|h1 { color: blue }
- foo|* { color: yellow }
- |h1 { color: red }
- *|h1 { color: green }
- h1 { color: green }
- -

The first rule will match only h1 elements in the - "http://www.example.com" namespace.

- -

The second rule will match all elements in the - "http://www.example.com" namespace.

- -

The third rule will match only h1 elements without - any declared namespace.

- -

The fourth rule will match h1 elements in any - namespace (including those without any declared namespace).

- -

The last rule is equivalent to the fourth rule because no default - namespace has been defined.

- -
- -

6.2. Universal selector

- -

The universal selector, written "asterisk" -(*), 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 Universal selector and -Namespaces below.

- -

If the universal selector is not the only component of a sequence -of simple selectors, the * may be omitted.

- -
-

Examples:

-
    -
  • *[hreflang|=en] and [hreflang|=en] are equivalent,
  • -
  • *.warning and .warning are equivalent,
  • -
  • *#myid and #myid are equivalent.
  • -
-
- -

Note: it is recommended that the -*, representing the universal selector, not be -omitted.

- -

6.2.1. Universal selector and namespaces

- -

The universal selector allows an optional namespace component. It -is used as follows:

- -
-
ns|*
-
all elements in namespace ns
-
*|*
-
all elements
-
|*
-
all elements without any declared namespace
-
*
-
if no default namespace has been specified, this is equivalent to *|*. - Otherwise it is equivalent to ns|* where ns is the default namespace.
-
- -

A universal selector containing a namespace prefix that has not -been previously declared is an invalid -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.

- - -

6.3. Attribute selectors

- -

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.

- -

6.3.1. Attribute presence and values -selectors

- -

CSS2 introduced four attribute selectors:

- -
-
[att] -
Represents an element with the att attribute, whatever the value of - the attribute.
-
[att=val]
-
Represents an element with the att attribute whose value is exactly - "val".
-
[att~=val]
-
Represents an element with the att attribute whose value is a whitespace-separated list of words, one of - which is exactly "val". If "val" contains whitespace, it will never - represent anything (since the words are separated by - spaces).
-
[att|=val] -
Represents an element with the att 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 hreflang attribute on the - link element in HTML) as described in RFC 3066 ([RFC3066]). For lang (or - xml:lang) language subcode matching, please see the :lang pseudo-class.
-
- -

Attribute values must be identifiers or strings. The -case-sensitivity of attribute names and values in selectors depends on -the document language.

- -
- -

Examples:

- -

The following attribute selector represents an h1 - element that carries the title attribute, whatever its - value:

- -
h1[title]
- -

In the following example, the selector represents a - span element whose class attribute has - exactly the value "example":

- -
span[class="example"]
- -

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 span element - whose hello attribute has exactly the value "Cleveland" - and whose goodbye attribute has exactly the value - "Columbus":

- -
span[hello="Cleveland"][goodbye="Columbus"]
- -

The following selectors illustrate the differences between "=" - and "~=". The first selector will represent, for example, the value - "copyright copyleft copyeditor" on a rel attribute. The - second selector will only represent an a element with - an href attribute having the exact value - "http://www.w3.org/".

- -
a[rel~="copyright"]
-a[href="http://www.w3.org/"]
- -

The following selector represents a link element - whose hreflang attribute is exactly "fr".

- -
link[hreflang=fr]
- -

The following selector represents a link element for - which the values of the hreflang attribute begins with - "en", including "en", "en-US", and "en-cockney":

- -
link[hreflang|="en"]
- -

Similarly, the following selectors represents a - DIALOGUE element whenever it has one of two different - values for an attribute character:

- -
DIALOGUE[character=romeo]
-DIALOGUE[character=juliet]
- -
- -

6.3.2. Substring matching attribute -selectors

- -

Three additional attribute selectors are provided for matching -substrings in the value of an attribute:

- -
-
[att^=val]
-
Represents an element with the att attribute whose value begins - with the prefix "val".
-
[att$=val] -
Represents an element with the att attribute whose value ends with - the suffix "val".
-
[att*=val] -
Represents an element with the att attribute whose value contains - at least one instance of the substring "val".
-
- -

Attribute values must be identifiers or strings. The -case-sensitivity of attribute names in selectors depends on the -document language.

- -
-

Examples:

-

The following selector represents an HTML object, referencing an - image:

-
object[type^="image/"]
-

The following selector represents an HTML anchor a with an - href attribute whose value ends with ".html".

-
a[href$=".html"]
-

The following selector represents an HTML paragraph with a title - attribute whose value contains the substring "hello"

-
p[title*="hello"]
-
- -

6.3.3. Attribute selectors and namespaces

- -

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" (|). 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 "|attr"). 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. - -

An attribute selector with an attribute name containing a namespace -prefix that has not been previously declared is an invalid 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. - -

-

CSS examples:

-
@namespace foo "http://www.example.com";
-[foo|att=val] { color: blue }
-[*|att] { color: yellow }
-[|att] { color: green }
-[att] { color: green }
- -

The first rule will match only elements with the attribute - att in the "http://www.example.com" namespace with the - value "val".

- -

The second rule will match only elements with the attribute - att regardless of the namespace of the attribute - (including no declared namespace).

- -

The last two rules are equivalent and will match only elements - with the attribute att where the attribute is not - declared to be in a namespace.

- -
- -

6.3.4. Default attribute values in DTDs

- -

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.

- -

More precisely, a UA is not required to read an "external -subset" of the DTD but is required to look for default -attribute values in the document's "internal subset." (See [XML10] for definitions of these subsets.)

- -

A UA that recognizes an XML namespace [XMLNAMES] 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.)

- -

Note: Typically, implementations -choose to ignore external subsets.

- -
-

Example:

- -

Consider an element EXAMPLE with an attribute "notation" that has a -default value of "decimal". The DTD fragment might be

- -
<!ATTLIST EXAMPLE notation (decimal,octal) "decimal">
- -

If the style sheet contains the rules

- -
EXAMPLE[notation=decimal] { /*... default property settings ...*/ }
-EXAMPLE[notation=octal]   { /*... other settings...*/ }
- -

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:

- -
EXAMPLE                   { /*... default property settings ...*/ }
-EXAMPLE[notation=octal]   { /*... other settings...*/ }
- -

Here, because the selector EXAMPLE[notation=octal] 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.

- -
- -

6.4. Class selectors

- -

Working with HTML, authors may use the period (U+002E, -.) notation as an alternative to the ~= -notation when representing the class attribute. Thus, for -HTML, div.value and div[class~=value] have -the same meaning. The attribute value must immediately follow the -"period" (.).

- -

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 [SVG] describes the SVG -"class" attribute and how a UA should interpret it, and -similarly MathML 1.01 [MATH] describes the MathML -"class" attribute.)

- -
-

CSS examples:

- -

We can assign style information to all elements with - class~="pastoral" as follows:

- -
*.pastoral { color: green }  /* all elements with class~=pastoral */
- -

or just

- -
.pastoral { color: green }  /* all elements with class~=pastoral */
- -

The following assigns style only to H1 elements with - class~="pastoral":

- -
H1.pastoral { color: green }  /* H1 elements with class~=pastoral */
- -

Given these rules, the first H1 instance below would not have - green text, while the second would:

- -
<H1>Not green</H1>
-<H1 class="pastoral">Very green</H1>
- -
- -

To represent a subset of "class" values, each value must be preceded -by a ".", in any order.

- -
- -

CSS example:

- -

The following rule matches any P element whose "class" attribute - has been assigned a list of whitespace-separated values that includes - "pastoral" and "marine":

- -
p.pastoral.marine { color: green }
- -

This rule matches when class="pastoral blue aqua - marine" but does not match for class="pastoral - blue".

- -
- -

Note: 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.

- -

Note: 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.

- -

6.5. ID selectors

- -

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.

- -

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, -#) immediately followed by the ID value, which must be an -identifier.

- -

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. - -

-

Examples:

-

The following ID selector represents an h1 element - whose ID-typed attribute has the value "chapter1":

-
h1#chapter1
-

The following ID selector represents any element whose ID-typed - attribute has the value "chapter1":

-
#chapter1
-

The following selector represents any element whose ID-typed - attribute has the value "z98y".

-
*#z98y
-
- -

Note. In XML 1.0 [XML10], 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: -[name=p371] instead of #p371. Elements in -XML 1.0 documents without a DTD do not have IDs at all.

- -

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.

- -

6.6. Pseudo-classes

- -

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.

- -

A pseudo-class always consists of a "colon" -(:) followed by the name of the pseudo-class and -optionally by a value between parentheses.

- -

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.

- - -

6.6.1. Dynamic pseudo-classes

- -

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.

- -

Dynamic pseudo-classes do not appear in the document source or -document tree.

- - -
The link pseudo-classes: :link and :visited
- -

User agents commonly display unvisited links differently from -previously visited ones. Selectors -provides the pseudo-classes :link and -:visited to distinguish them:

- -
    -
  • The :link pseudo-class applies to links that have - not yet been visited.
  • -
  • The :visited pseudo-class applies once the link has - been visited by the user.
  • -
- -

After some amount of time, user agents may choose to return a -visited link to the (unvisited) ':link' state.

- -

The two states are mutually exclusive.

- -
- -

Example:

- -

The following selector represents links carrying class - external and already visited:

- -
a.external:visited
- -
- -

Note: 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. - -

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.

- -
The user action pseudo-classes -:hover, :active, and :focus
- -

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.

- -
    - -
  • The :hover 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 interactive - media do not have to support this pseudo-class. Some conforming - user agents that support interactive - media may not be able to support this pseudo-class (e.g., a pen - device that does not detect hovering).
  • - -
  • The :active 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.
  • - -
  • The :focus pseudo-class applies while an element - has the focus (accepts keyboard or mouse events, or other forms of - input).
  • - -
- -

There may be document language or implementation specific limits on -which elements can become :active or acquire -:focus.

- -

These pseudo-classes are not mutually exclusive. An element may -match several pseudo-classes at the same time.

- -

Selectors doesn't define if the parent of an element that is -':active' or ':hover' is also in that state.

- -
-

Examples:

-
a:link    /* unvisited links */
-a:visited /* visited links */
-a:hover   /* user hovers */
-a:active  /* active links */
-

An example of combining dynamic pseudo-classes:

-
a:focus
-a:focus:hover
-

The last selector matches a elements that are in - the pseudo-class :focus and in the pseudo-class :hover.

-
- -

Note: An element can be both ':visited' -and ':active' (or ':link' and ':active').

- -

6.6.2. The target pseudo-class :target

- -

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).

- -

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 section_2 in an HTML -document:

- -
http://example.com/html/top.html#section_2
- -

A target element can be represented by the :target -pseudo-class. If the document's URI has no fragment identifier, then -the document has no target element.

- -
-

Example:

-
p.note:target
-

This selector represents a p element of class - note that is the target element of the referring - URI.

-
- -
-

CSS example:

-

Here, the :target pseudo-class is used to make the - target element red and place an image before it, if there is one:

-
*:target { color : red }
-*:target::before { content : url(target.png) }
-
- -

6.6.3. The language pseudo-class :lang

- -

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 [HTML4], the language is determined by a -combination of the lang attribute, the meta -element, and possibly by information from the protocol (such as HTTP -headers). XML uses an attribute called xml:lang, and -there may be other document language-specific methods for determining -the language.

- -

The pseudo-class :lang(C) represents an element that -is in language C. Whether an element is represented by a -:lang() 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 '|=' operator in attribute -selectors. The identifier C does not have to be a valid language -name.

- -

C must not be empty. (If it is, the selector is invalid.)

- -

Note: It is recommended that -documents and protocols indicate language using codes from RFC 3066 [RFC3066] or its successor, and by means of -"xml:lang" attributes in the case of XML-based documents [XML10]. See -"FAQ: Two-letter or three-letter language codes."

- -
-

Examples:

-

The two following selectors represent an HTML document that is in - Belgian, French, or German. The two next selectors represent - q quotations in an arbitrary element in Belgian, French, - or German.

-
html:lang(fr-be)
-html:lang(de)
-:lang(fr-be) > q
-:lang(de) > q
-
- -

6.6.4. The UI element states pseudo-classes

- -
The :enabled and :disabled pseudo-classes
- -

The :enabled 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 input element without also specifying what it -would look like when it was disabled.

- -

Similar to :enabled, :disabled allows the -author to specify precisely how a disabled or inactive user interface -element should look.

- -

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.

- - -
The :checked pseudo-class
- -

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 :checked pseudo-class applies. The -:checked pseudo-class initially applies to such elements -that have the HTML4 selected and checked -attributes as described in Section -17.2.1 of HTML4, but of course the user can toggle "off" such -elements in which case the :checked pseudo-class would no -longer apply. While the :checked 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 selected and -checked attributes, it applies to all media. - - -

The :indeterminate pseudo-class
- -
- -

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.

- -

A future version of this specification may introduce an -:indeterminate pseudo-class that applies to such elements. -

- -
- - -

6.6.5. Structural pseudo-classes

- -

Selectors introduces the concept of structural -pseudo-classes to permit selection based on extra information that lies in -the document tree but cannot be represented by other simple selectors or -combinators. - -

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. - - -

:root pseudo-class
- -

The :root pseudo-class represents an element that is -the root of the document. In HTML 4, this is always the -HTML element. - - -

:nth-child() pseudo-class
- -

The -:nth-child(an+b) -pseudo-class notation represents an element that has -an+b-1 siblings -before it in the document tree, for a given positive -integer or zero value of n, and has a parent element. In -other words, this matches the bth child of an element after -all the children have been split into groups of a 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 a and -b values must be zero, negative integers or positive -integers. The index of the first child of an element is 1. - -

In addition to this, :nth-child() can take -'odd' and 'even' as arguments instead. -'odd' has the same signification as 2n+1, -and 'even' has the same signification as 2n. - - -

-

Examples:

-
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; }
-
- -

When a=0, no repeating is used, so for example -:nth-child(0n+5) matches only the fifth child. When -a=0, the an part need not be -included, so the syntax simplifies to -:nth-child(b) and the last example simplifies -to :nth-child(5). - -

-

Examples:

-
foo:nth-child(0n+1)   /* represents an element foo, first child of its parent element */
-foo:nth-child(1)      /* same */
-
- -

When a=1, the number may be omitted from the rule. - -

-

Examples:

-

The following selectors are therefore equivalent:

-
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) */
-
- -

If b=0, then every ath element is picked. In -such a case, the b part may be omitted. - -

-

Examples:

-
tr:nth-child(2n+0) /* represents every even row of an HTML table */
-tr:nth-child(2n) /* same */
-
- -

If both a and b are equal to zero, the -pseudo-class represents no element in the document tree.

- -

The value a can be negative, but only the positive -values of an+b, for -n≥0, may represent an element in the document -tree.

- -
-

Example:

-
html|tr:nth-child(-n+6)  /* represents the 6 first rows of XHTML tables */
-
- -

When the value b is negative, the "+" character in the -expression must be removed (it is effectively replaced by the "-" -character indicating the negative value of b).

- -
-

Examples:

-
: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 */
-
- - -
:nth-last-child() pseudo-class
- -

The :nth-last-child(an+b) -pseudo-class notation represents an element that has -an+b-1 siblings -after it in the document tree, for a given positive -integer or zero value of n, and has a parent element. See -:nth-child() pseudo-class for the syntax of its argument. -It also accepts the 'even' and 'odd' values -as arguments. - - -

-

Examples:

-
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 */
-
- - -
:nth-of-type() pseudo-class
- -

The :nth-of-type(an+b) -pseudo-class notation represents an element that has -an+b-1 siblings with the same -element name before it in the document tree, for a -given zero or positive integer value of n, and has a -parent element. In other words, this matches the bth child -of that type after all the children of that type have been split into -groups of a elements each. See :nth-child() pseudo-class -for the syntax of its argument. It also accepts the -'even' and 'odd' values. - - -

-

CSS example:

-

This allows an author to alternate the position of floated images:

-
img:nth-of-type(2n+1) { float: right; }
-img:nth-of-type(2n) { float: left; }
-
- - -
:nth-last-of-type() pseudo-class
- -

The :nth-last-of-type(an+b) -pseudo-class notation represents an element that has -an+b-1 siblings with the same -element name after it in the document tree, for a -given zero or positive integer value of n, and has a -parent element. See :nth-child() pseudo-class for the -syntax of its argument. It also accepts the 'even' and 'odd' values. - - -

-

Example:

-

To represent all h2 children of an XHTML - body except the first and last, one could use the - following selector:

-
body > h2:nth-of-type(n+2):nth-last-of-type(n+2)
-

In this case, one could also use :not(), although the - selector ends up being just as long:

-
body > h2:not(:first-of-type):not(:last-of-type)
-
- - -
:first-child pseudo-class
- -

Same as :nth-child(1). The :first-child pseudo-class -represents an element that is the first child of some other element. - - -

-

Examples:

-

The following selector represents a p element that is - the first child of a div element:

-
div > p:first-child
-

This selector can represent the p inside the - div of the following fragment:

-
<p> The last P before the note.</p>
-<div class="note">
-   <p> The first P inside the note.</p>
-</div>
but cannot represent the second p in the following -fragment: -
<p> The last P before the note.</p>
-<div class="note">
-   <h2> Note </h2>
-   <p> The first P inside the note.</p>
-</div>
-

The following two selectors are usually equivalent:

-
* > a:first-child /* a is first child of any element */
-a:first-child /* Same (assuming a is not the root element) */
-
- -
:last-child pseudo-class
- -

Same as :nth-last-child(1). The :last-child pseudo-class -represents an element that is the last child of some other element. - -

-

Example:

-

The following selector represents a list item li that - is the last child of an ordered list ol. -

ol > li:last-child
-
- -
:first-of-type pseudo-class
- -

Same as :nth-of-type(1). The :first-of-type pseudo-class -represents an element that is the first sibling of its type in the list of -children of its parent element. - -

-

Example:

-

The following selector represents a definition title -dt inside a definition list dl, this -dt being the first of its type in the list of children of -its parent element.

-
dl dt:first-of-type
-

It is a valid description for the first two dt -elements in the following example but not for the third one:

-
<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>
-
- -
:last-of-type pseudo-class
- -

Same as :nth-last-of-type(1). The -:last-of-type pseudo-class represents an element that is -the last sibling of its type in the list of children of its parent -element.

- -
-

Example:

-

The following selector represents the last data cell - td of a table row.

-
tr > td:last-of-type
-
- -
:only-child pseudo-class
- -

Represents an element that has a parent element and whose parent -element has no other element children. Same as -:first-child:last-child or -:nth-child(1):nth-last-child(1), but with a lower -specificity.

- -
:only-of-type pseudo-class
- -

Represents an element that has a parent element and whose parent -element has no other element children with the same element name. Same -as :first-of-type:last-of-type or -:nth-of-type(1):nth-last-of-type(1), but with a lower -specificity.

- - -
:empty pseudo-class
- -

The :empty 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.

- -
-

Examples:

-

p:empty is a valid representation of the following fragment:

-
<p></p>
-

foo:empty is not a valid representation for the - following fragments:

-
<foo>bar</foo>
-
<foo><bar>bla</bar></foo>
-
<foo>this is not <bar>:empty</bar></foo>
-
- -

6.6.6. Blank

- -

This section intentionally left blank.

- - -

6.6.7. The negation pseudo-class

- -

The negation pseudo-class, :not(X), is a -functional notation taking a simple -selector (excluding the negation pseudo-class itself and -pseudo-elements) as an argument. It represents an element that is not -represented by the argument. - - - -

-

Examples:

-

The following CSS selector matches all button - elements in an HTML document that are not disabled.

-
button:not([DISABLED])
-

The following selector represents all but FOO - elements.

-
*:not(FOO)
-

The following group of selectors represents all HTML elements - except links.

-
html|*:not(:link):not(:visited)
-
- -

Default namespace declarations do not affect the argument of the -negation pseudo-class unless the argument is a universal selector or a -type selector.

- -
-

Examples:

-

Assuming that the default namespace is bound to - "http://example.com/", the following selector represents all - elements that are not in that namespace:

-
*|*:not(*)
-

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 are being hovered.

-
*|*:not(:hover)
-
- -

Note: the :not() pseudo allows -useless selectors to be written. For instance :not(*|*), -which represents no element at all, or foo:not(bar), -which is equivalent to foo but with a higher -specificity.

- -

7. Pseudo-elements

- -

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 ::before and -::after pseudo-elements give access to generated -content).

- -

A pseudo-element is made of two colons (::) followed -by the name of the pseudo-element.

- -

This :: 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, -:first-line, :first-letter, -:before and :after). This compatibility is -not allowed for the new pseudo-elements introduced in CSS level 3.

- -

Only one pseudo-element may appear per selector, and if present it -must appear after the sequence of simple selectors that represents the -subjects of the selector. A -future version of this specification may allow multiple -pesudo-elements per selector.

- -

7.1. The ::first-line pseudo-element

- -

The ::first-line pseudo-element describes the contents -of the first formatted line of an element. - -

-

CSS example:

-
p::first-line { text-transform: uppercase }
-

The above rule means "change the letters of the first line of every -paragraph to uppercase".

-
- -

The selector p::first-line 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.

- -

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>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>
-
- -

the lines of which happen to be broken as follows: - -

-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.
-
- -

This paragraph might be "rewritten" by user agents to include the -fictional tag sequence for ::first-line. This -fictional tag sequence helps to show how properties are inherited.

- -
-<P><P::first-line> This is a somewhat long HTML 
-paragraph that </P::first-line> 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>
-
- -

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 span element:

- -
-<P><SPAN class="test"> This is a somewhat long HTML
-paragraph that will be broken into several
-lines.</SPAN> The first line will be identified
-by a fictional tag sequence. The other lines 
-will be treated as ordinary lines in the 
-paragraph.</P>
-
- -

the user agent could simulate start and end tags for -span when inserting the fictional tag sequence for -::first-line. - -

-<P><P::first-line><SPAN class="test"> This is a
-somewhat long HTML
-paragraph that will </SPAN></P::first-line><SPAN class="test"> be
-broken into several
-lines.</SPAN> The first line will be identified
-by a fictional tag sequence. The other lines
-will be treated as ordinary lines in the 
-paragraph.</P>
-
- -

In CSS, the ::first-line pseudo-element can only be -attached to a block-level element, an inline-block, a table-caption, -or a table-cell.

- -

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 div in <DIV><P>This -line...</P></DIV> is the first line of the p (assuming -that both p and div are block-level). - -

The first line of a table-cell or inline-block cannot be the first -formatted line of an ancestor element. Thus, in <DIV><P -STYLE="display: inline-block">Hello<BR>Goodbye</P> -etcetera</DIV> the first formatted line of the -div is not the line "Hello". - -

Note that the first line of the p in this -fragment: <p><br>First... doesn't contain any -letters (assuming the default style for br in HTML -4). The word "First" is not on the first formatted line. - -

A UA should act as if the fictional start tags of the -::first-line 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

- -
-<DIV>
-  <P>First paragraph</P>
-  <P>Second paragraph</P>
-</DIV>
-
- -

is

- -
-<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>
-
- -

The ::first-line pseudo-element is similar to an -inline-level element, but with certain restrictions. In CSS, the -following properties apply to a ::first-line -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.

- - -

7.2. The ::first-letter pseudo-element

- -

The ::first-letter 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.

- -

In CSS, these are the properties that apply to ::first-letter -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.

- -
-

Example:

-

This example shows a possible rendering of an initial cap. Note -that the 'line-height' that is inherited by the ::first-letter -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, and thus -the font weight of the first letter is normal, not bold as the span: -

-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.
-
-
-

Image illustrating the ::first-letter pseudo-element -

-
- -
-

The following CSS will make a drop cap initial letter span about two lines:

- -
-<!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>
-
- -

This example might be formatted as follows:

- -
-

Image illustrating the combined effect of the ::first-letter and ::first-line pseudo-elements

-
- -

The fictional tag sequence is:

- -
-<P>
-<SPAN>
-<P::first-letter>
-T
-</P::first-letter>he first
-</SPAN> 
-few words of an article in the Economist.
-</P>
-
- -

Note that the ::first-letter 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.

- -

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.

- -

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. [UNICODE]

- -
-

Quotes that precede the
-first letter should be included.

-
- -

The ::first-letter also applies if the first letter is -in fact a digit, e.g., the "6" in "67 million dollars is a lot of -money."

- -

In CSS, the ::first-letter pseudo-element applies to -block, list-item, table-cell, table-caption, and inline-block -elements. A future version of this specification -may allow this pesudo-element to apply to more element -types.

- -

The ::first-letter 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.

- -
-

Example:

-

The fictional tag sequence for this HTMLfragment: -

<div>
-<p>The first text.
-

is: -

<div>
-<p><div::first-letter><p::first-letter>T</...></...>he first text.
-
- -

The first letter of a table-cell or inline-block cannot be the -first letter of an ancestor element. Thus, in <DIV><P -STYLE="display: inline-block">Hello<BR>Goodbye</P> -etcetera</DIV> the first letter of the div is not the -letter "H". In fact, the div doesn't have a first letter. - -

The first letter must occur on the first formatted line. For example, in -this fragment: <p><br>First... the first line -doesn't contain any letters and ::first-letter doesn't -match anything (assuming the default style for br in HTML -4). In particular, it does not match the "F" of "First." - -

In CSS, if an element is a list item ('display: list-item'), the -::first-letter applies to the first letter in the -principal box after the marker. UAs may ignore -::first-letter on list items with 'list-style-position: -inside'. If an element has ::before or -::after content, the ::first-letter applies -to the first letter of the element including that content. - -

-

Example:

-

After the rule 'p::before {content: "Note: "}', the selector -'p::first-letter' matches the "N" of "Note".

-
- -

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 ::first-letter pseudo-element. - -

If the letters that would form the ::first-letter are not in the -same element, such as "'T" in <p>'<em>T..., the UA -may create a ::first-letter pseudo-element from one of the elements, -both elements, or simply not create a pseudo-element.

- -

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). - -

-

Example:

-

The following example 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 { 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>
- -

Assuming that a line break will occur before the word "ends", the -fictional tag -sequence for this fragment might be:

- -
<P>
-<P::first-line>
-<P::first-letter> 
-S 
-</P::first-letter>ome text that 
-</P::first-line> 
-ends up on two lines 
-</P>
- -

Note that the ::first-letter element is inside the ::first-line -element. Properties set on ::first-line are inherited by -::first-letter, but are overridden if the same property is set on -::first-letter.

-
- - -

7.3. The ::selection pseudo-element

- -

The ::selection 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 :checked pseudo-class (which used to be -named :selected) - -

Although the ::selection 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 -[CSS21]) which was originally rendered to a -dynamic medium (like screen), the UA may wish to transfer the current -::selection 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 ::selection -pseudo-element for static media. - -

These are the CSS properties that apply to ::selection -pseudo-elements: color, background, cursor (optional), outline -(optional). The computed value of the 'background-image' property on -::selection may be ignored. - - -

7.4. The ::before and ::after pseudo-elements

- -

The ::before and ::after pseudo-elements -can be used to describe generated content before or after an element's -content. They are explained in CSS 2.1 [CSS21].

- -

When the ::first-letter and ::first-line -pseudo-elements are combined with ::before and -::after, they apply to the first letter or line of the -element including the inserted text.

- -

8. Combinators

- -

8.1. Descendant combinator

- -

At times, authors may want selectors to describe an element that is -the descendant of another element in the document tree (e.g., "an -EM element that is contained within an H1 -element"). Descendant combinators express such a relationship. A -descendant combinator is white space that -separates two sequences of simple selectors. A selector of the form -"A B" represents an element B that is an -arbitrary descendant of some ancestor element A. - -

-

Examples:

-

For example, consider the following selector:

-
h1 em
-

It represents an em element being the descendant of - an h1 element. It is a correct and valid, but partial, - description of the following fragment:

-
<h1>This <span class="myclass">headline
-is <em>very</em> important</span></h1>
-

The following selector:

-
div * p
-

represents a p element that is a grandchild or later - descendant of a div 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.

-

The following selector, which combines descendant combinators and - attribute selectors, represents an - element that (1) has the href attribute set and (2) is - inside a p that is itself inside a div:

-
div p *[href]
-
- -

8.2. Child combinators

- -

A child combinator describes a childhood relationship -between two elements. A child combinator is made of the -"greater-than sign" (>) character and -separates two sequences of simple selectors. - - -

-

Examples:

-

The following selector represents a p element that is - child of body:

-
body > p
-

The following example combines descendant combinators and child - combinators.

-
div ol>li p
-

It represents a p element that is a descendant of an - li element; the li element must be the - child of an ol element; the ol element must - be a descendant of a div. Notice that the optional white - space around the ">" combinator has been left out.

-
- -

For information on selecting the first child of an element, please -see the section on the :first-child pseudo-class -above.

- -

8.3. Sibling combinators

- -

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.

- -

8.3.1. Adjacent sibling combinator

- -

The adjacent sibling combinator is made of the "plus -sign" (U+002B, +) 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.

- -
-

Examples:

-

The following selector represents a p element - immediately following a math element:

-
math + 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 h1 element, that it must have - class="opener":

-
h1.opener + h2
-
- - -

8.3.2. General sibling combinator

- -

The general sibling combinator is made of the "tilde" -(U+007E, ~) 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.

- -
-

Example:

-
h1 ~ pre
-

represents a pre element following an h1. It - is a correct and valid, but partial, description of:

-
<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>
-
- -

9. Calculating a selector's specificity

- -

A selector's specificity is calculated as follows:

- -
    -
  • count the number of ID selectors in the selector (= a)
  • -
  • count the number of class selectors, attributes selectors, and pseudo-classes in the selector (= b)
  • -
  • count the number of element names in the selector (= c)
  • -
  • ignore pseudo-elements
  • -
- -

Selectors inside the negation pseudo-class -are counted like any other, but the negation itself does not count as -a pseudo-class.

- -

Concatenating the three numbers a-b-c (in a number system with a -large base) gives the specificity.

- -
-

Examples:

-
*               /* 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 */
-
-
- -

Note: the specificity of the styles -specified in an HTML style attribute is described in CSS -2.1. [CSS21].

- -

10. The grammar of Selectors

- -

10.1. Grammar

- -

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 [YACC]) -are used:

- -
    -
  • *: 0 or more -
  • +: 1 or more -
  • ?: 0 or 1 -
  • |: separates alternatives -
  • [ ]: grouping
  • -
- -

The productions are:

- -
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
-  ;
- - -

10.2. Lexical scanner

- -

The following is the tokenizer, written in Flex (see -[FLEX]) notation. The tokenizer is -case-insensitive.

- -

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. [UNICODE]

- -
%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;
- - - -

11. Namespaces and down-level clients

- -

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.

- -

It should be noted that a down-level CSS client will (if it -properly conforms to CSS forward compatible parsing rules) ignore all -@namespace 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.

- -

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.

- -

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.

- -
    -
  1. - -

    The XML document does not use namespaces.

    - -
      - -
    • 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.
    • - -
    • 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 ("|name") - will guarantee that selectors will match only XML elements that do - not have a declared namespace.
    • - -
    - -
  2. - -
  3. - -

    The XML document defines a single, default namespace used - throughout the document. No namespace prefixes are used in element - names.

    - -
      - -
    • 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.
    • - -
    - -
  4. - -
  5. - -

    The XML document does not 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).

    - -
      - -
    • 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 Type selectors and Namespaces section. CSS - selectors may be declared using an escaped colon "\:" - to describe the fully qualified names, e.g. - "html\:h1" will match - <html:h1>. 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.
    • - -
    • Note that selectors declared in this fashion will - only 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).
    • - -
    - -
  6. - -
- -

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 -different 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.

- -

12. Profiles

- -

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.

- -

Non normative examples: - -

- - - - - - - - - - - - - - - -
Selectors profile
SpecificationCSS level 1
Acceptstype selectors
class selectors
ID selectors
:link, - :visited and :active pseudo-classes
descendant combinator -
::first-line and ::first-letter pseudo-elements
Excludes - -

universal selector
attribute selectors
:hover and :focus - pseudo-classes
:target pseudo-class
:lang() pseudo-class
all UI - element states pseudo-classes
all structural - pseudo-classes
negation pseudo-class
all - UI element fragments pseudo-elements
::before and ::after - pseudo-elements
child combinators
sibling combinators - -

namespaces

Extra constraintsonly one class selector allowed per sequence of simple - selectors


- - - - - - - - - - - - - - - -
Selectors profile
SpecificationCSS level 2
Acceptstype selectors
universal selector
attribute presence and - values selectors
class selectors
ID selectors
:link, :visited, - :active, :hover, :focus, :lang() and :first-child pseudo-classes -
descendant combinator
child combinator
adjacent sibling - combinator
::first-line and ::first-letter pseudo-elements
::before - and ::after pseudo-elements
Excludes - -

content selectors
substring matching attribute - selectors
:target pseudo-classes
all UI element - states pseudo-classes
all structural pseudo-classes other - than :first-child
negation pseudo-class
all UI element - fragments pseudo-elements
general sibling combinators - -

namespaces

Extra constraintsmore than one class selector per sequence of simple selectors (CSS1 - constraint) allowed
- -

In CSS, selectors express pattern matching rules that determine which style -rules apply to elements in the document tree. - -

The following selector (CSS level 2) will match all anchors a -with attribute name set inside a section 1 header h1: -

h1 a[name]
- -

All CSS declarations attached to such a selector are applied to elements -matching it.

- -
- - - - - - - - - - - - - - - - -
Selectors profile
SpecificationSTTS 3
Accepts - -

type selectors
universal selectors
attribute selectors
class - selectors
ID selectors
all structural pseudo-classes
- all combinators - -

namespaces

Excludesnon-accepted pseudo-classes
pseudo-elements
Extra constraintssome selectors and combinators are not allowed in fragment - descriptions on the right side of STTS declarations.
-
- - - - - - - - - - - - - - - - - - - - - - - - - -
- -

Selectors can be used in STTS 3 in two different - manners: -

    -
  1. a selection mechanism equivalent to CSS selection mechanism: declarations - attached to a given selector are applied to elements matching that selector, -
  2. fragment descriptions that appear on the right side of declarations. -
- -

13. Conformance and requirements

- -

This section defines conformance with the present specification only. - -

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. - -

All specifications reusing Selectors must contain a Profile listing the -subset of Selectors it accepts or excludes, and describing the constraints -it adds to the current specification. - -

Invalidity is caused by a parsing error, e.g. an unrecognized token or a token -which is not allowed at the current parsing point. - -

User agents must observe the rules for handling parsing errors: -

    -
  • a simple selector containing an undeclared namespace prefix is invalid
  • -
  • a selector containing an invalid simple selector, an invalid combinator - or an invalid token is invalid.
  • -
  • a group of selectors containing an invalid selector is invalid.
  • -
- -

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.)

- - - -

14. Tests

- -

This specification has a test -suite 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.

- -

15. Acknowledgements

- -

The CSS working group would like to thank everyone who has sent -comments on this specification over the years.

- -

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.

- -

16. References

- -
- -
[CSS1] -
Bert Bos, Håkon Wium Lie; "Cascading Style Sheets, level 1", W3C Recommendation, 17 Dec 1996, revised 11 Jan 1999 -
(http://www.w3.org/TR/REC-CSS1) - -
[CSS21] -
Bert Bos, Tantek Çelik, Ian Hickson, Håkon Wium Lie, editors; "Cascading Style Sheets, level 2 revision 1", W3C Working Draft, 13 June 2005 -
(http://www.w3.org/TR/CSS21) - -
[CWWW] -
Martin J. Dürst, François Yergeau, Misha Wolf, Asmus Freytag, Tex Texin, editors; "Character Model for the World Wide Web", W3C Recommendation, 15 February 2005 -
(http://www.w3.org/TR/charmod/) - -
[FLEX] -
"Flex: The Lexical Scanner Generator", Version 2.3.7, ISBN 1882114213 - -
[HTML4] -
Dave Ragget, Arnaud Le Hors, Ian Jacobs, editors; "HTML 4.01 Specification", W3C Recommendation, 24 December 1999 -
(http://www.w3.org/TR/html4/) - -
[MATH] -
Patrick Ion, Robert Miner, editors; "Mathematical Markup Language (MathML) 1.01", W3C Recommendation, revision of 7 July 1999 -
(http://www.w3.org/TR/REC-MathML/) - -
[RFC3066] -
H. Alvestrand; "Tags for the Identification of Languages", Request for Comments 3066, January 2001 -
(http://www.ietf.org/rfc/rfc3066.txt) - -
[STTS] -
Daniel Glazman; "Simple Tree Transformation Sheets 3", Electricité de France, submission to the W3C, 11 November 1998 -
(http://www.w3.org/TR/NOTE-STTS3) - -
[SVG] -
Jon Ferraiolo, 藤沢 淳, Dean Jackson, editors; "Scalable Vector Graphics (SVG) 1.1 Specification", W3C Recommendation, 14 January 2003 -
(http://www.w3.org/TR/SVG/) - -
[UNICODE]
-
The Unicode Standard, Version 4.1, The Unicode Consortium. Boston, MA, Addison-Wesley, March 2005. ISBN 0-321-18578-1, as amended by Unicode 4.0.1 and Unicode 4.1.0. -
(http://www.unicode.org/versions/)
- -
[XML10] -
Tim Bray, Jean Paoli, C. M. Sperberg-McQueen, Eve Maler, François Yergeau, editors; "Extensible Markup Language (XML) 1.0 (Third Edition)", W3C Recommendation, 4 February 2004 -
(http://www.w3.org/TR/REC-xml/) - -
[XMLNAMES] -
Tim Bray, Dave Hollander, Andrew Layman, editors; "Namespaces in XML", W3C Recommendation, 14 January 1999 -
(http://www.w3.org/TR/REC-xml-names/) - -
[YACC] -
S. C. Johnson; "YACC — Yet another compiler compiler", Technical Report, Murray Hill, 1975 - -
- - diff --git a/samples/third_party/dromaeo/web/tests/dom-modify-html.dart b/samples/third_party/dromaeo/web/tests/dom-modify-html.dart deleted file mode 100644 index e9cb8be7071..00000000000 --- a/samples/third_party/dromaeo/web/tests/dom-modify-html.dart +++ /dev/null @@ -1,72 +0,0 @@ -library dromaeo; -import 'dart:async'; -import 'dart:html'; -import "dart:convert"; -import 'dart:math' as Math; -part 'Common.dart'; -part 'RunnerSuite.dart'; - -void main() { - final int num = 400; - var random = new Math.Random(); - - String str = 'null'; - // Very ugly way to build up the string, but let's mimic JS version as much as - // possible. - for (int i = 0; i < 1024; i++) { - str += new String.fromCharCode(((25 * random.nextDouble()) + 97).toInt()); - } - - List elems = []; - - // Try to force real results. - var ret; - - final htmlstr = document.body.innerHtml; - - new Suite(window, 'dom-modify') - .test('createElement', () { - for (int i = 0; i < num; i++) { - ret = new Element.tag('div'); - ret = new Element.tag('span'); - ret = new Element.tag('table'); - ret = new Element.tag('tr'); - ret = new Element.tag('select'); - } - }) - .test('createTextNode', () { - for (int i = 0; i < num; i++) { - ret = new Text(str); - ret = new Text('${str}2'); - ret = new Text('${str}3'); - ret = new Text('${str}4'); - ret = new Text('${str}5'); - } - }) - .test('innerHtml', () { - document.body.innerHtml = htmlstr; - }) - .prep(() { - elems = new List(); - final telems = document.body.nodes; - for (int i = 0; i < telems.length; i++) { - elems.add(telems[i]); - } - }) - .test('cloneNode', () { - for (int i = 0; i < elems.length; i++) { - ret = elems[i].clone(false); - ret = elems[i].clone(true); - ret = elems[i].clone(true); - } - }) - .test('appendChild', () { - for (int i = 0; i < elems.length; i++) - document.body.append(elems[i]); - }) - .test('insertBefore', () { - for (int i = 0; i < elems.length; i++) - document.body.insertBefore(elems[i], document.body.firstChild); - }) - .end(); -} diff --git a/samples/third_party/dromaeo/web/tests/dom-modify-html.html b/samples/third_party/dromaeo/web/tests/dom-modify-html.html deleted file mode 100644 index 4663c13c29a..00000000000 --- a/samples/third_party/dromaeo/web/tests/dom-modify-html.html +++ /dev/null @@ -1,2900 +0,0 @@ - - - - - - -
-

W3C - -

Selectors

- -

W3C Working Draft 15 December 2005

- -
- -
This version: - -
- http://www.w3.org/TR/2005/WD-css3-selectors-20051215 - -
Latest version: - -
- http://www.w3.org/TR/css3-selectors - -
Previous version: - -
- http://www.w3.org/TR/2001/CR-css3-selectors-20011113 - -
Editors: - -
Daniel Glazman (Invited Expert)
- -
Tantek Çelik (Invited Expert) - -
Ian Hickson (Google) - -
Peter Linss (former editor, Netscape/AOL) - -
John Williams (former editor, Quark, Inc.) - -
- -
- -
- -

Abstract

- -

Selectors 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.

- -

CSS (Cascading - Style Sheets) is a language for describing the rendering of HTML and XML 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. - -

Selectors define the following function:

- -
expression ∗ element → boolean
- -

That is, given an element and a selector, this specification - defines whether that element matches the selector.

- -

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. STTS (Simple Tree Transformation Sheets), a - language for transforming XML trees, uses this mechanism. [STTS]

- -

Status of this document

- -

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 W3C technical reports index at - http://www.w3.org/TR/.

- -

This document describes the selectors that already exist in CSS1 and CSS2, and - also proposes new selectors for CSS3 and other languages that may need them.

- -

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.

- -

This specification is a last call working draft for the the CSS Working Group - (Style Activity). This - document is a revision of the Candidate - Recommendation dated 2001 November 13, 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.

- -

All persons are encouraged to review and implement this - specification and return comments to the (archived) - public mailing list www-style - (see instructions). W3C - Members can also send comments directly to the CSS Working - Group. - The deadline for comments is 14 January 2006.

- -

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". - -

This document may be available in translation. - The English version of this specification is the only normative - version. - -

- -

Table of contents

- - - -
- -

1. Introduction

- -

1.1. Dependencies

- -

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. [CSS21]

- -

1.2. Terminology

- -

All of the text of this specification is normative except - examples, notes, and sections explicitly marked as - non-normative.

- -

1.3. Changes from CSS2

- -

This section is non-normative.

- -

The main differences between the selectors in CSS2 and those in - Selectors are: - -

    - -
  • 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
  • - -
  • an optional namespace component is now allowed in type element - selectors, the universal selector and attribute selectors
  • - -
  • a new combinator has been introduced
  • - -
  • new simple selectors including substring matching attribute - selectors, and new pseudo-classes
  • - -
  • new pseudo-elements, and introduction of the "::" convention - for pseudo-elements
  • - -
  • the grammar has been rewritten
  • - -
  • profiles to be added to specifications integrating Selectors - and defining the set of selectors which is actually supported by - each specification
  • - -
  • Selectors are now a CSS3 Module and an independent - specification; other specifications can now refer to this document - independently of CSS
  • - -
  • the specification now has its own test suite
  • - -
- -

2. Selectors

- -

This section is non-normative, as it merely summarizes the -following sections.

- -

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.

- -

Selectors may range from simple element names to rich contextual -representations.

- -

The following table summarizes the Selector syntax:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PatternMeaningDescribed in sectionFirst defined in CSS level
*any elementUniversal - selector2
Ean element of type EType selector1
E[foo]an E element with a "foo" attributeAttribute - selectors2
E[foo="bar"]an E element whose "foo" attribute value is exactly - equal to "bar"Attribute - selectors2
E[foo~="bar"]an E element whose "foo" attribute value is a list of - space-separated values, one of which is exactly equal to "bar"Attribute - selectors2
E[foo^="bar"]an E element whose "foo" attribute value begins exactly - with the string "bar"Attribute - selectors3
E[foo$="bar"]an E element whose "foo" attribute value ends exactly - with the string "bar"Attribute - selectors3
E[foo*="bar"]an E element whose "foo" attribute value contains the - substring "bar"Attribute - selectors3
E[hreflang|="en"]an E element whose "hreflang" attribute has a hyphen-separated - list of values beginning (from the left) with "en"Attribute - selectors2
E:rootan E element, root of the documentStructural - pseudo-classes3
E:nth-child(n)an E element, the n-th child of its parentStructural - pseudo-classes3
E:nth-last-child(n)an E element, the n-th child of its parent, counting - from the last oneStructural - pseudo-classes3
E:nth-of-type(n)an E element, the n-th sibling of its typeStructural - pseudo-classes3
E:nth-last-of-type(n)an E element, the n-th sibling of its type, counting - from the last oneStructural - pseudo-classes3
E:first-childan E element, first child of its parentStructural - pseudo-classes2
E:last-childan E element, last child of its parentStructural - pseudo-classes3
E:first-of-typean E element, first sibling of its typeStructural - pseudo-classes3
E:last-of-typean E element, last sibling of its typeStructural - pseudo-classes3
E:only-childan E element, only child of its parentStructural - pseudo-classes3
E:only-of-typean E element, only sibling of its typeStructural - pseudo-classes3
E:emptyan E element that has no children (including text - nodes)Structural - pseudo-classes3
E:link
E:visited
an E element being the source anchor of a hyperlink of - which the target is not yet visited (:link) or already visited - (:visited)The link - pseudo-classes1
E:active
E:hover
E:focus
an E element during certain user actionsThe user - action pseudo-classes1 and 2
E:targetan E element being the target of the referring URIThe target - pseudo-class3
E:lang(fr)an element of type E in language "fr" (the document - language specifies how language is determined)The :lang() - pseudo-class2
E:enabled
E:disabled
a user interface element E which is enabled or - disabledThe UI element states - pseudo-classes3
E:checkeda user interface element E which is checked (for instance a radio-button or checkbox)The UI element states - pseudo-classes3
E::first-linethe first formatted line of an E elementThe ::first-line - pseudo-element1
E::first-letterthe first formatted letter of an E elementThe ::first-letter - pseudo-element1
E::selectionthe portion of an E element that is currently - selected/highlighted by the userThe UI element - fragments pseudo-elements3
E::beforegenerated content before an E elementThe ::before - pseudo-element2
E::aftergenerated content after an E elementThe ::after - pseudo-element2
E.warningan E element whose class is -"warning" (the document language specifies how class is determined).Class - selectors1
E#myidan E element with ID equal to "myid".ID - selectors1
E:not(s)an E element that does not match simple selector sNegation - pseudo-class3
E Fan F element descendant of an E elementDescendant - combinator1
E > Fan F element child of an E elementChild - combinator2
E + Fan F element immediately preceded by an E elementAdjacent sibling combinator2
E ~ Fan F element preceded by an E elementGeneral sibling combinator3
- -

The meaning of each selector is derived from the table above by -prepending "matches" to the contents of each cell in the "Meaning" -column.

- -

3. Case sensitivity

- -

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.

- -

4. Selector syntax

- -

A selector is a chain of one -or more sequences of simple selectors -separated by combinators.

- -

A sequence of simple selectors -is a chain of simple selectors -that are not separated by a combinator. It -always begins with a type selector or a -universal selector. No other type -selector or universal selector is allowed in the sequence.

- -

A simple selector is either a type selector, universal selector, attribute selector, class selector, ID selector, content selector, or pseudo-class. One pseudo-element may be appended to the last -sequence of simple selectors.

- -

Combinators are: white space, "greater-than -sign" (U+003E, >), "plus sign" (U+002B, -+) and "tilde" (U+007E, ~). White -space may appear between a combinator and the simple selectors around -it. 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.

- -

The elements of a document tree that are represented by a selector -are the subjects of the selector. 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.

- -

An empty selector, containing no sequence of simple selectors and -no pseudo-element, is an invalid -selector.

- -

5. Groups of selectors

- -

When several selectors share the same declarations, they may be -grouped into a comma-separated list. (A comma is U+002C.)

- -
-

CSS examples:

-

In this example, we condense three rules with identical -declarations into one. Thus,

-
h1 { font-family: sans-serif }
-h2 { font-family: sans-serif }
-h3 { font-family: sans-serif }
-

is equivalent to:

-
h1, h2, h3 { font-family: sans-serif }
-
- -

Warning: 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.

- - -

6. Simple selectors

- -

6.1. Type selector

- -

A type selector is the name of a document language -element type. A type selector represents an instance of the element -type in the document tree.

- -
-

Example:

-

The following selector represents an h1 element in the document tree:

-
h1
-
- - -

6.1.1. Type selectors and namespaces

- -

Type selectors allow an optional namespace ([XMLNAMES]) 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, |).

- -

The namespace component may be left empty to indicate that the -selector is only to represent elements with no declared namespace.

- -

An asterisk may be used for the namespace prefix, indicating that -the selector represents elements in any namespace (including elements -with no namespace).

- -

Element type selectors that have no namespace component (no -namespace separator), represent elements without regard to the -element's namespace (equivalent to "*|") unless a default -namespace has been declared. If a default namespace has been declared, -the selector will represent only elements in the default -namespace.

- -

A type selector containing a namespace prefix that has not been -previously declared is an invalid 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.

- -

In a namespace-aware client, element type selectors will only match -against the local part -of the element's qualified -name. See below for notes about matching -behaviors in down-level clients.

- -

In summary:

- -
-
ns|E
-
elements with name E in namespace ns
-
*|E
-
elements with name E in any namespace, including those without any - declared namespace
-
|E
-
elements with name E without any declared namespace
-
E
-
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.
-
- -
-

CSS examples:

- -
@namespace foo url(http://www.example.com);
- foo|h1 { color: blue }
- foo|* { color: yellow }
- |h1 { color: red }
- *|h1 { color: green }
- h1 { color: green }
- -

The first rule will match only h1 elements in the - "http://www.example.com" namespace.

- -

The second rule will match all elements in the - "http://www.example.com" namespace.

- -

The third rule will match only h1 elements without - any declared namespace.

- -

The fourth rule will match h1 elements in any - namespace (including those without any declared namespace).

- -

The last rule is equivalent to the fourth rule because no default - namespace has been defined.

- -
- -

6.2. Universal selector

- -

The universal selector, written "asterisk" -(*), 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 Universal selector and -Namespaces below.

- -

If the universal selector is not the only component of a sequence -of simple selectors, the * may be omitted.

- -
-

Examples:

-
    -
  • *[hreflang|=en] and [hreflang|=en] are equivalent,
  • -
  • *.warning and .warning are equivalent,
  • -
  • *#myid and #myid are equivalent.
  • -
-
- -

Note: it is recommended that the -*, representing the universal selector, not be -omitted.

- -

6.2.1. Universal selector and namespaces

- -

The universal selector allows an optional namespace component. It -is used as follows:

- -
-
ns|*
-
all elements in namespace ns
-
*|*
-
all elements
-
|*
-
all elements without any declared namespace
-
*
-
if no default namespace has been specified, this is equivalent to *|*. - Otherwise it is equivalent to ns|* where ns is the default namespace.
-
- -

A universal selector containing a namespace prefix that has not -been previously declared is an invalid -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.

- - -

6.3. Attribute selectors

- -

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.

- -

6.3.1. Attribute presence and values -selectors

- -

CSS2 introduced four attribute selectors:

- -
-
[att] -
Represents an element with the att attribute, whatever the value of - the attribute.
-
[att=val]
-
Represents an element with the att attribute whose value is exactly - "val".
-
[att~=val]
-
Represents an element with the att attribute whose value is a whitespace-separated list of words, one of - which is exactly "val". If "val" contains whitespace, it will never - represent anything (since the words are separated by - spaces).
-
[att|=val] -
Represents an element with the att 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 hreflang attribute on the - link element in HTML) as described in RFC 3066 ([RFC3066]). For lang (or - xml:lang) language subcode matching, please see the :lang pseudo-class.
-
- -

Attribute values must be identifiers or strings. The -case-sensitivity of attribute names and values in selectors depends on -the document language.

- -
- -

Examples:

- -

The following attribute selector represents an h1 - element that carries the title attribute, whatever its - value:

- -
h1[title]
- -

In the following example, the selector represents a - span element whose class attribute has - exactly the value "example":

- -
span[class="example"]
- -

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 span element - whose hello attribute has exactly the value "Cleveland" - and whose goodbye attribute has exactly the value - "Columbus":

- -
span[hello="Cleveland"][goodbye="Columbus"]
- -

The following selectors illustrate the differences between "=" - and "~=". The first selector will represent, for example, the value - "copyright copyleft copyeditor" on a rel attribute. The - second selector will only represent an a element with - an href attribute having the exact value - "http://www.w3.org/".

- -
a[rel~="copyright"]
-a[href="http://www.w3.org/"]
- -

The following selector represents a link element - whose hreflang attribute is exactly "fr".

- -
link[hreflang=fr]
- -

The following selector represents a link element for - which the values of the hreflang attribute begins with - "en", including "en", "en-US", and "en-cockney":

- -
link[hreflang|="en"]
- -

Similarly, the following selectors represents a - DIALOGUE element whenever it has one of two different - values for an attribute character:

- -
DIALOGUE[character=romeo]
-DIALOGUE[character=juliet]
- -
- -

6.3.2. Substring matching attribute -selectors

- -

Three additional attribute selectors are provided for matching -substrings in the value of an attribute:

- -
-
[att^=val]
-
Represents an element with the att attribute whose value begins - with the prefix "val".
-
[att$=val] -
Represents an element with the att attribute whose value ends with - the suffix "val".
-
[att*=val] -
Represents an element with the att attribute whose value contains - at least one instance of the substring "val".
-
- -

Attribute values must be identifiers or strings. The -case-sensitivity of attribute names in selectors depends on the -document language.

- -
-

Examples:

-

The following selector represents an HTML object, referencing an - image:

-
object[type^="image/"]
-

The following selector represents an HTML anchor a with an - href attribute whose value ends with ".html".

-
a[href$=".html"]
-

The following selector represents an HTML paragraph with a title - attribute whose value contains the substring "hello"

-
p[title*="hello"]
-
- -

6.3.3. Attribute selectors and namespaces

- -

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" (|). 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 "|attr"). 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. - -

An attribute selector with an attribute name containing a namespace -prefix that has not been previously declared is an invalid 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. - -

-

CSS examples:

-
@namespace foo "http://www.example.com";
-[foo|att=val] { color: blue }
-[*|att] { color: yellow }
-[|att] { color: green }
-[att] { color: green }
- -

The first rule will match only elements with the attribute - att in the "http://www.example.com" namespace with the - value "val".

- -

The second rule will match only elements with the attribute - att regardless of the namespace of the attribute - (including no declared namespace).

- -

The last two rules are equivalent and will match only elements - with the attribute att where the attribute is not - declared to be in a namespace.

- -
- -

6.3.4. Default attribute values in DTDs

- -

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.

- -

More precisely, a UA is not required to read an "external -subset" of the DTD but is required to look for default -attribute values in the document's "internal subset." (See [XML10] for definitions of these subsets.)

- -

A UA that recognizes an XML namespace [XMLNAMES] 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.)

- -

Note: Typically, implementations -choose to ignore external subsets.

- -
-

Example:

- -

Consider an element EXAMPLE with an attribute "notation" that has a -default value of "decimal". The DTD fragment might be

- -
<!ATTLIST EXAMPLE notation (decimal,octal) "decimal">
- -

If the style sheet contains the rules

- -
EXAMPLE[notation=decimal] { /*... default property settings ...*/ }
-EXAMPLE[notation=octal]   { /*... other settings...*/ }
- -

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:

- -
EXAMPLE                   { /*... default property settings ...*/ }
-EXAMPLE[notation=octal]   { /*... other settings...*/ }
- -

Here, because the selector EXAMPLE[notation=octal] 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.

- -
- -

6.4. Class selectors

- -

Working with HTML, authors may use the period (U+002E, -.) notation as an alternative to the ~= -notation when representing the class attribute. Thus, for -HTML, div.value and div[class~=value] have -the same meaning. The attribute value must immediately follow the -"period" (.).

- -

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 [SVG] describes the SVG -"class" attribute and how a UA should interpret it, and -similarly MathML 1.01 [MATH] describes the MathML -"class" attribute.)

- -
-

CSS examples:

- -

We can assign style information to all elements with - class~="pastoral" as follows:

- -
*.pastoral { color: green }  /* all elements with class~=pastoral */
- -

or just

- -
.pastoral { color: green }  /* all elements with class~=pastoral */
- -

The following assigns style only to H1 elements with - class~="pastoral":

- -
H1.pastoral { color: green }  /* H1 elements with class~=pastoral */
- -

Given these rules, the first H1 instance below would not have - green text, while the second would:

- -
<H1>Not green</H1>
-<H1 class="pastoral">Very green</H1>
- -
- -

To represent a subset of "class" values, each value must be preceded -by a ".", in any order.

- -
- -

CSS example:

- -

The following rule matches any P element whose "class" attribute - has been assigned a list of whitespace-separated values that includes - "pastoral" and "marine":

- -
p.pastoral.marine { color: green }
- -

This rule matches when class="pastoral blue aqua - marine" but does not match for class="pastoral - blue".

- -
- -

Note: 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.

- -

Note: 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.

- -

6.5. ID selectors

- -

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.

- -

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, -#) immediately followed by the ID value, which must be an -identifier.

- -

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. - -

-

Examples:

-

The following ID selector represents an h1 element - whose ID-typed attribute has the value "chapter1":

-
h1#chapter1
-

The following ID selector represents any element whose ID-typed - attribute has the value "chapter1":

-
#chapter1
-

The following selector represents any element whose ID-typed - attribute has the value "z98y".

-
*#z98y
-
- -

Note. In XML 1.0 [XML10], 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: -[name=p371] instead of #p371. Elements in -XML 1.0 documents without a DTD do not have IDs at all.

- -

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.

- -

6.6. Pseudo-classes

- -

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.

- -

A pseudo-class always consists of a "colon" -(:) followed by the name of the pseudo-class and -optionally by a value between parentheses.

- -

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.

- - -

6.6.1. Dynamic pseudo-classes

- -

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.

- -

Dynamic pseudo-classes do not appear in the document source or -document tree.

- - -
The link pseudo-classes: :link and :visited
- -

User agents commonly display unvisited links differently from -previously visited ones. Selectors -provides the pseudo-classes :link and -:visited to distinguish them:

- -
    -
  • The :link pseudo-class applies to links that have - not yet been visited.
  • -
  • The :visited pseudo-class applies once the link has - been visited by the user.
  • -
- -

After some amount of time, user agents may choose to return a -visited link to the (unvisited) ':link' state.

- -

The two states are mutually exclusive.

- -
- -

Example:

- -

The following selector represents links carrying class - external and already visited:

- -
a.external:visited
- -
- -

Note: 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. - -

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.

- -
The user action pseudo-classes -:hover, :active, and :focus
- -

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.

- -
    - -
  • The :hover 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 interactive - media do not have to support this pseudo-class. Some conforming - user agents that support interactive - media may not be able to support this pseudo-class (e.g., a pen - device that does not detect hovering).
  • - -
  • The :active 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.
  • - -
  • The :focus pseudo-class applies while an element - has the focus (accepts keyboard or mouse events, or other forms of - input).
  • - -
- -

There may be document language or implementation specific limits on -which elements can become :active or acquire -:focus.

- -

These pseudo-classes are not mutually exclusive. An element may -match several pseudo-classes at the same time.

- -

Selectors doesn't define if the parent of an element that is -':active' or ':hover' is also in that state.

- -
-

Examples:

-
a:link    /* unvisited links */
-a:visited /* visited links */
-a:hover   /* user hovers */
-a:active  /* active links */
-

An example of combining dynamic pseudo-classes:

-
a:focus
-a:focus:hover
-

The last selector matches a elements that are in - the pseudo-class :focus and in the pseudo-class :hover.

-
- -

Note: An element can be both ':visited' -and ':active' (or ':link' and ':active').

- -

6.6.2. The target pseudo-class :target

- -

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).

- -

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 section_2 in an HTML -document:

- -
http://example.com/html/top.html#section_2
- -

A target element can be represented by the :target -pseudo-class. If the document's URI has no fragment identifier, then -the document has no target element.

- -
-

Example:

-
p.note:target
-

This selector represents a p element of class - note that is the target element of the referring - URI.

-
- -
-

CSS example:

-

Here, the :target pseudo-class is used to make the - target element red and place an image before it, if there is one:

-
*:target { color : red }
-*:target::before { content : url(target.png) }
-
- -

6.6.3. The language pseudo-class :lang

- -

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 [HTML4], the language is determined by a -combination of the lang attribute, the meta -element, and possibly by information from the protocol (such as HTTP -headers). XML uses an attribute called xml:lang, and -there may be other document language-specific methods for determining -the language.

- -

The pseudo-class :lang(C) represents an element that -is in language C. Whether an element is represented by a -:lang() 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 '|=' operator in attribute -selectors. The identifier C does not have to be a valid language -name.

- -

C must not be empty. (If it is, the selector is invalid.)

- -

Note: It is recommended that -documents and protocols indicate language using codes from RFC 3066 [RFC3066] or its successor, and by means of -"xml:lang" attributes in the case of XML-based documents [XML10]. See -"FAQ: Two-letter or three-letter language codes."

- -
-

Examples:

-

The two following selectors represent an HTML document that is in - Belgian, French, or German. The two next selectors represent - q quotations in an arbitrary element in Belgian, French, - or German.

-
html:lang(fr-be)
-html:lang(de)
-:lang(fr-be) > q
-:lang(de) > q
-
- -

6.6.4. The UI element states pseudo-classes

- -
The :enabled and :disabled pseudo-classes
- -

The :enabled 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 input element without also specifying what it -would look like when it was disabled.

- -

Similar to :enabled, :disabled allows the -author to specify precisely how a disabled or inactive user interface -element should look.

- -

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.

- - -
The :checked pseudo-class
- -

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 :checked pseudo-class applies. The -:checked pseudo-class initially applies to such elements -that have the HTML4 selected and checked -attributes as described in Section -17.2.1 of HTML4, but of course the user can toggle "off" such -elements in which case the :checked pseudo-class would no -longer apply. While the :checked 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 selected and -checked attributes, it applies to all media. - - -

The :indeterminate pseudo-class
- -
- -

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.

- -

A future version of this specification may introduce an -:indeterminate pseudo-class that applies to such elements. -

- -
- - -

6.6.5. Structural pseudo-classes

- -

Selectors introduces the concept of structural -pseudo-classes to permit selection based on extra information that lies in -the document tree but cannot be represented by other simple selectors or -combinators. - -

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. - - -

:root pseudo-class
- -

The :root pseudo-class represents an element that is -the root of the document. In HTML 4, this is always the -HTML element. - - -

:nth-child() pseudo-class
- -

The -:nth-child(an+b) -pseudo-class notation represents an element that has -an+b-1 siblings -before it in the document tree, for a given positive -integer or zero value of n, and has a parent element. In -other words, this matches the bth child of an element after -all the children have been split into groups of a 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 a and -b values must be zero, negative integers or positive -integers. The index of the first child of an element is 1. - -

In addition to this, :nth-child() can take -'odd' and 'even' as arguments instead. -'odd' has the same signification as 2n+1, -and 'even' has the same signification as 2n. - - -

-

Examples:

-
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; }
-
- -

When a=0, no repeating is used, so for example -:nth-child(0n+5) matches only the fifth child. When -a=0, the an part need not be -included, so the syntax simplifies to -:nth-child(b) and the last example simplifies -to :nth-child(5). - -

-

Examples:

-
foo:nth-child(0n+1)   /* represents an element foo, first child of its parent element */
-foo:nth-child(1)      /* same */
-
- -

When a=1, the number may be omitted from the rule. - -

-

Examples:

-

The following selectors are therefore equivalent:

-
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) */
-
- -

If b=0, then every ath element is picked. In -such a case, the b part may be omitted. - -

-

Examples:

-
tr:nth-child(2n+0) /* represents every even row of an HTML table */
-tr:nth-child(2n) /* same */
-
- -

If both a and b are equal to zero, the -pseudo-class represents no element in the document tree.

- -

The value a can be negative, but only the positive -values of an+b, for -n≥0, may represent an element in the document -tree.

- -
-

Example:

-
html|tr:nth-child(-n+6)  /* represents the 6 first rows of XHTML tables */
-
- -

When the value b is negative, the "+" character in the -expression must be removed (it is effectively replaced by the "-" -character indicating the negative value of b).

- -
-

Examples:

-
: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 */
-
- - -
:nth-last-child() pseudo-class
- -

The :nth-last-child(an+b) -pseudo-class notation represents an element that has -an+b-1 siblings -after it in the document tree, for a given positive -integer or zero value of n, and has a parent element. See -:nth-child() pseudo-class for the syntax of its argument. -It also accepts the 'even' and 'odd' values -as arguments. - - -

-

Examples:

-
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 */
-
- - -
:nth-of-type() pseudo-class
- -

The :nth-of-type(an+b) -pseudo-class notation represents an element that has -an+b-1 siblings with the same -element name before it in the document tree, for a -given zero or positive integer value of n, and has a -parent element. In other words, this matches the bth child -of that type after all the children of that type have been split into -groups of a elements each. See :nth-child() pseudo-class -for the syntax of its argument. It also accepts the -'even' and 'odd' values. - - -

-

CSS example:

-

This allows an author to alternate the position of floated images:

-
img:nth-of-type(2n+1) { float: right; }
-img:nth-of-type(2n) { float: left; }
-
- - -
:nth-last-of-type() pseudo-class
- -

The :nth-last-of-type(an+b) -pseudo-class notation represents an element that has -an+b-1 siblings with the same -element name after it in the document tree, for a -given zero or positive integer value of n, and has a -parent element. See :nth-child() pseudo-class for the -syntax of its argument. It also accepts the 'even' and 'odd' values. - - -

-

Example:

-

To represent all h2 children of an XHTML - body except the first and last, one could use the - following selector:

-
body > h2:nth-of-type(n+2):nth-last-of-type(n+2)
-

In this case, one could also use :not(), although the - selector ends up being just as long:

-
body > h2:not(:first-of-type):not(:last-of-type)
-
- - -
:first-child pseudo-class
- -

Same as :nth-child(1). The :first-child pseudo-class -represents an element that is the first child of some other element. - - -

-

Examples:

-

The following selector represents a p element that is - the first child of a div element:

-
div > p:first-child
-

This selector can represent the p inside the - div of the following fragment:

-
<p> The last P before the note.</p>
-<div class="note">
-   <p> The first P inside the note.</p>
-</div>
but cannot represent the second p in the following -fragment: -
<p> The last P before the note.</p>
-<div class="note">
-   <h2> Note </h2>
-   <p> The first P inside the note.</p>
-</div>
-

The following two selectors are usually equivalent:

-
* > a:first-child /* a is first child of any element */
-a:first-child /* Same (assuming a is not the root element) */
-
- -
:last-child pseudo-class
- -

Same as :nth-last-child(1). The :last-child pseudo-class -represents an element that is the last child of some other element. - -

-

Example:

-

The following selector represents a list item li that - is the last child of an ordered list ol. -

ol > li:last-child
-
- -
:first-of-type pseudo-class
- -

Same as :nth-of-type(1). The :first-of-type pseudo-class -represents an element that is the first sibling of its type in the list of -children of its parent element. - -

-

Example:

-

The following selector represents a definition title -dt inside a definition list dl, this -dt being the first of its type in the list of children of -its parent element.

-
dl dt:first-of-type
-

It is a valid description for the first two dt -elements in the following example but not for the third one:

-
<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>
-
- -
:last-of-type pseudo-class
- -

Same as :nth-last-of-type(1). The -:last-of-type pseudo-class represents an element that is -the last sibling of its type in the list of children of its parent -element.

- -
-

Example:

-

The following selector represents the last data cell - td of a table row.

-
tr > td:last-of-type
-
- -
:only-child pseudo-class
- -

Represents an element that has a parent element and whose parent -element has no other element children. Same as -:first-child:last-child or -:nth-child(1):nth-last-child(1), but with a lower -specificity.

- -
:only-of-type pseudo-class
- -

Represents an element that has a parent element and whose parent -element has no other element children with the same element name. Same -as :first-of-type:last-of-type or -:nth-of-type(1):nth-last-of-type(1), but with a lower -specificity.

- - -
:empty pseudo-class
- -

The :empty 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.

- -
-

Examples:

-

p:empty is a valid representation of the following fragment:

-
<p></p>
-

foo:empty is not a valid representation for the - following fragments:

-
<foo>bar</foo>
-
<foo><bar>bla</bar></foo>
-
<foo>this is not <bar>:empty</bar></foo>
-
- -

6.6.6. Blank

- -

This section intentionally left blank.

- - -

6.6.7. The negation pseudo-class

- -

The negation pseudo-class, :not(X), is a -functional notation taking a simple -selector (excluding the negation pseudo-class itself and -pseudo-elements) as an argument. It represents an element that is not -represented by the argument. - - - -

-

Examples:

-

The following CSS selector matches all button - elements in an HTML document that are not disabled.

-
button:not([DISABLED])
-

The following selector represents all but FOO - elements.

-
*:not(FOO)
-

The following group of selectors represents all HTML elements - except links.

-
html|*:not(:link):not(:visited)
-
- -

Default namespace declarations do not affect the argument of the -negation pseudo-class unless the argument is a universal selector or a -type selector.

- -
-

Examples:

-

Assuming that the default namespace is bound to - "http://example.com/", the following selector represents all - elements that are not in that namespace:

-
*|*:not(*)
-

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 are being hovered.

-
*|*:not(:hover)
-
- -

Note: the :not() pseudo allows -useless selectors to be written. For instance :not(*|*), -which represents no element at all, or foo:not(bar), -which is equivalent to foo but with a higher -specificity.

- -

7. Pseudo-elements

- -

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 ::before and -::after pseudo-elements give access to generated -content).

- -

A pseudo-element is made of two colons (::) followed -by the name of the pseudo-element.

- -

This :: 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, -:first-line, :first-letter, -:before and :after). This compatibility is -not allowed for the new pseudo-elements introduced in CSS level 3.

- -

Only one pseudo-element may appear per selector, and if present it -must appear after the sequence of simple selectors that represents the -subjects of the selector. A -future version of this specification may allow multiple -pesudo-elements per selector.

- -

7.1. The ::first-line pseudo-element

- -

The ::first-line pseudo-element describes the contents -of the first formatted line of an element. - -

-

CSS example:

-
p::first-line { text-transform: uppercase }
-

The above rule means "change the letters of the first line of every -paragraph to uppercase".

-
- -

The selector p::first-line 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.

- -

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>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>
-
- -

the lines of which happen to be broken as follows: - -

-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.
-
- -

This paragraph might be "rewritten" by user agents to include the -fictional tag sequence for ::first-line. This -fictional tag sequence helps to show how properties are inherited.

- -
-<P><P::first-line> This is a somewhat long HTML 
-paragraph that </P::first-line> 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>
-
- -

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 span element:

- -
-<P><SPAN class="test"> This is a somewhat long HTML
-paragraph that will be broken into several
-lines.</SPAN> The first line will be identified
-by a fictional tag sequence. The other lines 
-will be treated as ordinary lines in the 
-paragraph.</P>
-
- -

the user agent could simulate start and end tags for -span when inserting the fictional tag sequence for -::first-line. - -

-<P><P::first-line><SPAN class="test"> This is a
-somewhat long HTML
-paragraph that will </SPAN></P::first-line><SPAN class="test"> be
-broken into several
-lines.</SPAN> The first line will be identified
-by a fictional tag sequence. The other lines
-will be treated as ordinary lines in the 
-paragraph.</P>
-
- -

In CSS, the ::first-line pseudo-element can only be -attached to a block-level element, an inline-block, a table-caption, -or a table-cell.

- -

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 div in <DIV><P>This -line...</P></DIV> is the first line of the p (assuming -that both p and div are block-level). - -

The first line of a table-cell or inline-block cannot be the first -formatted line of an ancestor element. Thus, in <DIV><P -STYLE="display: inline-block">Hello<BR>Goodbye</P> -etcetera</DIV> the first formatted line of the -div is not the line "Hello". - -

Note that the first line of the p in this -fragment: <p><br>First... doesn't contain any -letters (assuming the default style for br in HTML -4). The word "First" is not on the first formatted line. - -

A UA should act as if the fictional start tags of the -::first-line 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

- -
-<DIV>
-  <P>First paragraph</P>
-  <P>Second paragraph</P>
-</DIV>
-
- -

is

- -
-<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>
-
- -

The ::first-line pseudo-element is similar to an -inline-level element, but with certain restrictions. In CSS, the -following properties apply to a ::first-line -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.

- - -

7.2. The ::first-letter pseudo-element

- -

The ::first-letter 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.

- -

In CSS, these are the properties that apply to ::first-letter -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.

- -
-

Example:

-

This example shows a possible rendering of an initial cap. Note -that the 'line-height' that is inherited by the ::first-letter -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, and thus -the font weight of the first letter is normal, not bold as the span: -

-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.
-
-
-

Image illustrating the ::first-letter pseudo-element -

-
- -
-

The following CSS will make a drop cap initial letter span about two lines:

- -
-<!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>
-
- -

This example might be formatted as follows:

- -
-

Image illustrating the combined effect of the ::first-letter and ::first-line pseudo-elements

-
- -

The fictional tag sequence is:

- -
-<P>
-<SPAN>
-<P::first-letter>
-T
-</P::first-letter>he first
-</SPAN> 
-few words of an article in the Economist.
-</P>
-
- -

Note that the ::first-letter 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.

- -

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.

- -

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. [UNICODE]

- -
-

Quotes that precede the
-first letter should be included.

-
- -

The ::first-letter also applies if the first letter is -in fact a digit, e.g., the "6" in "67 million dollars is a lot of -money."

- -

In CSS, the ::first-letter pseudo-element applies to -block, list-item, table-cell, table-caption, and inline-block -elements. A future version of this specification -may allow this pesudo-element to apply to more element -types.

- -

The ::first-letter 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.

- -
-

Example:

-

The fictional tag sequence for this HTMLfragment: -

<div>
-<p>The first text.
-

is: -

<div>
-<p><div::first-letter><p::first-letter>T</...></...>he first text.
-
- -

The first letter of a table-cell or inline-block cannot be the -first letter of an ancestor element. Thus, in <DIV><P -STYLE="display: inline-block">Hello<BR>Goodbye</P> -etcetera</DIV> the first letter of the div is not the -letter "H". In fact, the div doesn't have a first letter. - -

The first letter must occur on the first formatted line. For example, in -this fragment: <p><br>First... the first line -doesn't contain any letters and ::first-letter doesn't -match anything (assuming the default style for br in HTML -4). In particular, it does not match the "F" of "First." - -

In CSS, if an element is a list item ('display: list-item'), the -::first-letter applies to the first letter in the -principal box after the marker. UAs may ignore -::first-letter on list items with 'list-style-position: -inside'. If an element has ::before or -::after content, the ::first-letter applies -to the first letter of the element including that content. - -

-

Example:

-

After the rule 'p::before {content: "Note: "}', the selector -'p::first-letter' matches the "N" of "Note".

-
- -

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 ::first-letter pseudo-element. - -

If the letters that would form the ::first-letter are not in the -same element, such as "'T" in <p>'<em>T..., the UA -may create a ::first-letter pseudo-element from one of the elements, -both elements, or simply not create a pseudo-element.

- -

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). - -

-

Example:

-

The following example 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 { 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>
- -

Assuming that a line break will occur before the word "ends", the -fictional tag -sequence for this fragment might be:

- -
<P>
-<P::first-line>
-<P::first-letter> 
-S 
-</P::first-letter>ome text that 
-</P::first-line> 
-ends up on two lines 
-</P>
- -

Note that the ::first-letter element is inside the ::first-line -element. Properties set on ::first-line are inherited by -::first-letter, but are overridden if the same property is set on -::first-letter.

-
- - -

7.3. The ::selection pseudo-element

- -

The ::selection 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 :checked pseudo-class (which used to be -named :selected) - -

Although the ::selection 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 -[CSS21]) which was originally rendered to a -dynamic medium (like screen), the UA may wish to transfer the current -::selection 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 ::selection -pseudo-element for static media. - -

These are the CSS properties that apply to ::selection -pseudo-elements: color, background, cursor (optional), outline -(optional). The computed value of the 'background-image' property on -::selection may be ignored. - - -

7.4. The ::before and ::after pseudo-elements

- -

The ::before and ::after pseudo-elements -can be used to describe generated content before or after an element's -content. They are explained in CSS 2.1 [CSS21].

- -

When the ::first-letter and ::first-line -pseudo-elements are combined with ::before and -::after, they apply to the first letter or line of the -element including the inserted text.

- -

8. Combinators

- -

8.1. Descendant combinator

- -

At times, authors may want selectors to describe an element that is -the descendant of another element in the document tree (e.g., "an -EM element that is contained within an H1 -element"). Descendant combinators express such a relationship. A -descendant combinator is white space that -separates two sequences of simple selectors. A selector of the form -"A B" represents an element B that is an -arbitrary descendant of some ancestor element A. - -

-

Examples:

-

For example, consider the following selector:

-
h1 em
-

It represents an em element being the descendant of - an h1 element. It is a correct and valid, but partial, - description of the following fragment:

-
<h1>This <span class="myclass">headline
-is <em>very</em> important</span></h1>
-

The following selector:

-
div * p
-

represents a p element that is a grandchild or later - descendant of a div 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.

-

The following selector, which combines descendant combinators and - attribute selectors, represents an - element that (1) has the href attribute set and (2) is - inside a p that is itself inside a div:

-
div p *[href]
-
- -

8.2. Child combinators

- -

A child combinator describes a childhood relationship -between two elements. A child combinator is made of the -"greater-than sign" (>) character and -separates two sequences of simple selectors. - - -

-

Examples:

-

The following selector represents a p element that is - child of body:

-
body > p
-

The following example combines descendant combinators and child - combinators.

-
div ol>li p
-

It represents a p element that is a descendant of an - li element; the li element must be the - child of an ol element; the ol element must - be a descendant of a div. Notice that the optional white - space around the ">" combinator has been left out.

-
- -

For information on selecting the first child of an element, please -see the section on the :first-child pseudo-class -above.

- -

8.3. Sibling combinators

- -

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.

- -

8.3.1. Adjacent sibling combinator

- -

The adjacent sibling combinator is made of the "plus -sign" (U+002B, +) 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.

- -
-

Examples:

-

The following selector represents a p element - immediately following a math element:

-
math + 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 h1 element, that it must have - class="opener":

-
h1.opener + h2
-
- - -

8.3.2. General sibling combinator

- -

The general sibling combinator is made of the "tilde" -(U+007E, ~) 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.

- -
-

Example:

-
h1 ~ pre
-

represents a pre element following an h1. It - is a correct and valid, but partial, description of:

-
<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>
-
- -

9. Calculating a selector's specificity

- -

A selector's specificity is calculated as follows:

- -
    -
  • count the number of ID selectors in the selector (= a)
  • -
  • count the number of class selectors, attributes selectors, and pseudo-classes in the selector (= b)
  • -
  • count the number of element names in the selector (= c)
  • -
  • ignore pseudo-elements
  • -
- -

Selectors inside the negation pseudo-class -are counted like any other, but the negation itself does not count as -a pseudo-class.

- -

Concatenating the three numbers a-b-c (in a number system with a -large base) gives the specificity.

- -
-

Examples:

-
*               /* 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 */
-
-
- -

Note: the specificity of the styles -specified in an HTML style attribute is described in CSS -2.1. [CSS21].

- -

10. The grammar of Selectors

- -

10.1. Grammar

- -

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 [YACC]) -are used:

- -
    -
  • *: 0 or more -
  • +: 1 or more -
  • ?: 0 or 1 -
  • |: separates alternatives -
  • [ ]: grouping
  • -
- -

The productions are:

- -
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
-  ;
- - -

10.2. Lexical scanner

- -

The following is the tokenizer, written in Flex (see -[FLEX]) notation. The tokenizer is -case-insensitive.

- -

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. [UNICODE]

- -
%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;
- - - -

11. Namespaces and down-level clients

- -

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.

- -

It should be noted that a down-level CSS client will (if it -properly conforms to CSS forward compatible parsing rules) ignore all -@namespace 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.

- -

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.

- -

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.

- -
    -
  1. - -

    The XML document does not use namespaces.

    - -
      - -
    • 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.
    • - -
    • 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 ("|name") - will guarantee that selectors will match only XML elements that do - not have a declared namespace.
    • - -
    - -
  2. - -
  3. - -

    The XML document defines a single, default namespace used - throughout the document. No namespace prefixes are used in element - names.

    - -
      - -
    • 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.
    • - -
    - -
  4. - -
  5. - -

    The XML document does not 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).

    - -
      - -
    • 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 Type selectors and Namespaces section. CSS - selectors may be declared using an escaped colon "\:" - to describe the fully qualified names, e.g. - "html\:h1" will match - <html:h1>. 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.
    • - -
    • Note that selectors declared in this fashion will - only 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).
    • - -
    - -
  6. - -
- -

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 -different 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.

- -

12. Profiles

- -

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.

- -

Non normative examples: - -

- - - - - - - - - - - - - - - -
Selectors profile
SpecificationCSS level 1
Acceptstype selectors
class selectors
ID selectors
:link, - :visited and :active pseudo-classes
descendant combinator -
::first-line and ::first-letter pseudo-elements
Excludes - -

universal selector
attribute selectors
:hover and :focus - pseudo-classes
:target pseudo-class
:lang() pseudo-class
all UI - element states pseudo-classes
all structural - pseudo-classes
negation pseudo-class
all - UI element fragments pseudo-elements
::before and ::after - pseudo-elements
child combinators
sibling combinators - -

namespaces

Extra constraintsonly one class selector allowed per sequence of simple - selectors


- - - - - - - - - - - - - - - -
Selectors profile
SpecificationCSS level 2
Acceptstype selectors
universal selector
attribute presence and - values selectors
class selectors
ID selectors
:link, :visited, - :active, :hover, :focus, :lang() and :first-child pseudo-classes -
descendant combinator
child combinator
adjacent sibling - combinator
::first-line and ::first-letter pseudo-elements
::before - and ::after pseudo-elements
Excludes - -

content selectors
substring matching attribute - selectors
:target pseudo-classes
all UI element - states pseudo-classes
all structural pseudo-classes other - than :first-child
negation pseudo-class
all UI element - fragments pseudo-elements
general sibling combinators - -

namespaces

Extra constraintsmore than one class selector per sequence of simple selectors (CSS1 - constraint) allowed
- -

In CSS, selectors express pattern matching rules that determine which style -rules apply to elements in the document tree. - -

The following selector (CSS level 2) will match all anchors a -with attribute name set inside a section 1 header h1: -

h1 a[name]
- -

All CSS declarations attached to such a selector are applied to elements -matching it.

- -
- - - - - - - - - - - - - - - - -
Selectors profile
SpecificationSTTS 3
Accepts - -

type selectors
universal selectors
attribute selectors
class - selectors
ID selectors
all structural pseudo-classes
- all combinators - -

namespaces

Excludesnon-accepted pseudo-classes
pseudo-elements
Extra constraintssome selectors and combinators are not allowed in fragment - descriptions on the right side of STTS declarations.
-
- - - - - - - - - - - - - - - - - - - - - - - - - -
- -

Selectors can be used in STTS 3 in two different - manners: -

    -
  1. a selection mechanism equivalent to CSS selection mechanism: declarations - attached to a given selector are applied to elements matching that selector, -
  2. fragment descriptions that appear on the right side of declarations. -
- -

13. Conformance and requirements

- -

This section defines conformance with the present specification only. - -

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. - -

All specifications reusing Selectors must contain a Profile listing the -subset of Selectors it accepts or excludes, and describing the constraints -it adds to the current specification. - -

Invalidity is caused by a parsing error, e.g. an unrecognized token or a token -which is not allowed at the current parsing point. - -

User agents must observe the rules for handling parsing errors: -

    -
  • a simple selector containing an undeclared namespace prefix is invalid
  • -
  • a selector containing an invalid simple selector, an invalid combinator - or an invalid token is invalid.
  • -
  • a group of selectors containing an invalid selector is invalid.
  • -
- -

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.)

- - - -

14. Tests

- -

This specification has a test -suite 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.

- -

15. Acknowledgements

- -

The CSS working group would like to thank everyone who has sent -comments on this specification over the years.

- -

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.

- -

16. References

- -
- -
[CSS1] -
Bert Bos, Håkon Wium Lie; "Cascading Style Sheets, level 1", W3C Recommendation, 17 Dec 1996, revised 11 Jan 1999 -
(http://www.w3.org/TR/REC-CSS1) - -
[CSS21] -
Bert Bos, Tantek Çelik, Ian Hickson, Håkon Wium Lie, editors; "Cascading Style Sheets, level 2 revision 1", W3C Working Draft, 13 June 2005 -
(http://www.w3.org/TR/CSS21) - -
[CWWW] -
Martin J. Dürst, François Yergeau, Misha Wolf, Asmus Freytag, Tex Texin, editors; "Character Model for the World Wide Web", W3C Recommendation, 15 February 2005 -
(http://www.w3.org/TR/charmod/) - -
[FLEX] -
"Flex: The Lexical Scanner Generator", Version 2.3.7, ISBN 1882114213 - -
[HTML4] -
Dave Ragget, Arnaud Le Hors, Ian Jacobs, editors; "HTML 4.01 Specification", W3C Recommendation, 24 December 1999 -
(http://www.w3.org/TR/html4/) - -
[MATH] -
Patrick Ion, Robert Miner, editors; "Mathematical Markup Language (MathML) 1.01", W3C Recommendation, revision of 7 July 1999 -
(http://www.w3.org/TR/REC-MathML/) - -
[RFC3066] -
H. Alvestrand; "Tags for the Identification of Languages", Request for Comments 3066, January 2001 -
(http://www.ietf.org/rfc/rfc3066.txt) - -
[STTS] -
Daniel Glazman; "Simple Tree Transformation Sheets 3", Electricité de France, submission to the W3C, 11 November 1998 -
(http://www.w3.org/TR/NOTE-STTS3) - -
[SVG] -
Jon Ferraiolo, 藤沢 淳, Dean Jackson, editors; "Scalable Vector Graphics (SVG) 1.1 Specification", W3C Recommendation, 14 January 2003 -
(http://www.w3.org/TR/SVG/) - -
[UNICODE]
-
The Unicode Standard, Version 4.1, The Unicode Consortium. Boston, MA, Addison-Wesley, March 2005. ISBN 0-321-18578-1, as amended by Unicode 4.0.1 and Unicode 4.1.0. -
(http://www.unicode.org/versions/)
- -
[XML10] -
Tim Bray, Jean Paoli, C. M. Sperberg-McQueen, Eve Maler, François Yergeau, editors; "Extensible Markup Language (XML) 1.0 (Third Edition)", W3C Recommendation, 4 February 2004 -
(http://www.w3.org/TR/REC-xml/) - -
[XMLNAMES] -
Tim Bray, Dave Hollander, Andrew Layman, editors; "Namespaces in XML", W3C Recommendation, 14 January 1999 -
(http://www.w3.org/TR/REC-xml-names/) - -
[YACC] -
S. C. Johnson; "YACC — Yet another compiler compiler", Technical Report, Murray Hill, 1975 - -
- - diff --git a/samples/third_party/dromaeo/web/tests/dom-modify.html b/samples/third_party/dromaeo/web/tests/dom-modify.html deleted file mode 100644 index 02298927e97..00000000000 --- a/samples/third_party/dromaeo/web/tests/dom-modify.html +++ /dev/null @@ -1,2973 +0,0 @@ - - - - - - -
-

W3C - -

Selectors

- -

W3C Working Draft 15 December 2005

- -
- -
This version: - -
- http://www.w3.org/TR/2005/WD-css3-selectors-20051215 - -
Latest version: - -
- http://www.w3.org/TR/css3-selectors - -
Previous version: - -
- http://www.w3.org/TR/2001/CR-css3-selectors-20011113 - -
Editors: - -
Daniel Glazman (Invited Expert)
- -
Tantek Çelik (Invited Expert) - -
Ian Hickson (Google) - -
Peter Linss (former editor, Netscape/AOL) - -
John Williams (former editor, Quark, Inc.) - -
- -
- -
- -

Abstract

- -

Selectors 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.

- -

CSS (Cascading - Style Sheets) is a language for describing the rendering of HTML and XML 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. - -

Selectors define the following function:

- -
expression ∗ element → boolean
- -

That is, given an element and a selector, this specification - defines whether that element matches the selector.

- -

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. STTS (Simple Tree Transformation Sheets), a - language for transforming XML trees, uses this mechanism. [STTS]

- -

Status of this document

- -

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 W3C technical reports index at - http://www.w3.org/TR/.

- -

This document describes the selectors that already exist in CSS1 and CSS2, and - also proposes new selectors for CSS3 and other languages that may need them.

- -

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.

- -

This specification is a last call working draft for the the CSS Working Group - (Style Activity). This - document is a revision of the Candidate - Recommendation dated 2001 November 13, 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.

- -

All persons are encouraged to review and implement this - specification and return comments to the (archived) - public mailing list www-style - (see instructions). W3C - Members can also send comments directly to the CSS Working - Group. - The deadline for comments is 14 January 2006.

- -

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". - -

This document may be available in translation. - The English version of this specification is the only normative - version. - -

- -

Table of contents

- - - -
- -

1. Introduction

- -

1.1. Dependencies

- -

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. [CSS21]

- -

1.2. Terminology

- -

All of the text of this specification is normative except - examples, notes, and sections explicitly marked as - non-normative.

- -

1.3. Changes from CSS2

- -

This section is non-normative.

- -

The main differences between the selectors in CSS2 and those in - Selectors are: - -

    - -
  • 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
  • - -
  • an optional namespace component is now allowed in type element - selectors, the universal selector and attribute selectors
  • - -
  • a new combinator has been introduced
  • - -
  • new simple selectors including substring matching attribute - selectors, and new pseudo-classes
  • - -
  • new pseudo-elements, and introduction of the "::" convention - for pseudo-elements
  • - -
  • the grammar has been rewritten
  • - -
  • profiles to be added to specifications integrating Selectors - and defining the set of selectors which is actually supported by - each specification
  • - -
  • Selectors are now a CSS3 Module and an independent - specification; other specifications can now refer to this document - independently of CSS
  • - -
  • the specification now has its own test suite
  • - -
- -

2. Selectors

- -

This section is non-normative, as it merely summarizes the -following sections.

- -

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.

- -

Selectors may range from simple element names to rich contextual -representations.

- -

The following table summarizes the Selector syntax:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PatternMeaningDescribed in sectionFirst defined in CSS level
*any elementUniversal - selector2
Ean element of type EType selector1
E[foo]an E element with a "foo" attributeAttribute - selectors2
E[foo="bar"]an E element whose "foo" attribute value is exactly - equal to "bar"Attribute - selectors2
E[foo~="bar"]an E element whose "foo" attribute value is a list of - space-separated values, one of which is exactly equal to "bar"Attribute - selectors2
E[foo^="bar"]an E element whose "foo" attribute value begins exactly - with the string "bar"Attribute - selectors3
E[foo$="bar"]an E element whose "foo" attribute value ends exactly - with the string "bar"Attribute - selectors3
E[foo*="bar"]an E element whose "foo" attribute value contains the - substring "bar"Attribute - selectors3
E[hreflang|="en"]an E element whose "hreflang" attribute has a hyphen-separated - list of values beginning (from the left) with "en"Attribute - selectors2
E:rootan E element, root of the documentStructural - pseudo-classes3
E:nth-child(n)an E element, the n-th child of its parentStructural - pseudo-classes3
E:nth-last-child(n)an E element, the n-th child of its parent, counting - from the last oneStructural - pseudo-classes3
E:nth-of-type(n)an E element, the n-th sibling of its typeStructural - pseudo-classes3
E:nth-last-of-type(n)an E element, the n-th sibling of its type, counting - from the last oneStructural - pseudo-classes3
E:first-childan E element, first child of its parentStructural - pseudo-classes2
E:last-childan E element, last child of its parentStructural - pseudo-classes3
E:first-of-typean E element, first sibling of its typeStructural - pseudo-classes3
E:last-of-typean E element, last sibling of its typeStructural - pseudo-classes3
E:only-childan E element, only child of its parentStructural - pseudo-classes3
E:only-of-typean E element, only sibling of its typeStructural - pseudo-classes3
E:emptyan E element that has no children (including text - nodes)Structural - pseudo-classes3
E:link
E:visited
an E element being the source anchor of a hyperlink of - which the target is not yet visited (:link) or already visited - (:visited)The link - pseudo-classes1
E:active
E:hover
E:focus
an E element during certain user actionsThe user - action pseudo-classes1 and 2
E:targetan E element being the target of the referring URIThe target - pseudo-class3
E:lang(fr)an element of type E in language "fr" (the document - language specifies how language is determined)The :lang() - pseudo-class2
E:enabled
E:disabled
a user interface element E which is enabled or - disabledThe UI element states - pseudo-classes3
E:checkeda user interface element E which is checked (for instance a radio-button or checkbox)The UI element states - pseudo-classes3
E::first-linethe first formatted line of an E elementThe ::first-line - pseudo-element1
E::first-letterthe first formatted letter of an E elementThe ::first-letter - pseudo-element1
E::selectionthe portion of an E element that is currently - selected/highlighted by the userThe UI element - fragments pseudo-elements3
E::beforegenerated content before an E elementThe ::before - pseudo-element2
E::aftergenerated content after an E elementThe ::after - pseudo-element2
E.warningan E element whose class is -"warning" (the document language specifies how class is determined).Class - selectors1
E#myidan E element with ID equal to "myid".ID - selectors1
E:not(s)an E element that does not match simple selector sNegation - pseudo-class3
E Fan F element descendant of an E elementDescendant - combinator1
E > Fan F element child of an E elementChild - combinator2
E + Fan F element immediately preceded by an E elementAdjacent sibling combinator2
E ~ Fan F element preceded by an E elementGeneral sibling combinator3
- -

The meaning of each selector is derived from the table above by -prepending "matches" to the contents of each cell in the "Meaning" -column.

- -

3. Case sensitivity

- -

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.

- -

4. Selector syntax

- -

A selector is a chain of one -or more sequences of simple selectors -separated by combinators.

- -

A sequence of simple selectors -is a chain of simple selectors -that are not separated by a combinator. It -always begins with a type selector or a -universal selector. No other type -selector or universal selector is allowed in the sequence.

- -

A simple selector is either a type selector, universal selector, attribute selector, class selector, ID selector, content selector, or pseudo-class. One pseudo-element may be appended to the last -sequence of simple selectors.

- -

Combinators are: white space, "greater-than -sign" (U+003E, >), "plus sign" (U+002B, -+) and "tilde" (U+007E, ~). White -space may appear between a combinator and the simple selectors around -it. 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.

- -

The elements of a document tree that are represented by a selector -are the subjects of the selector. 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.

- -

An empty selector, containing no sequence of simple selectors and -no pseudo-element, is an invalid -selector.

- -

5. Groups of selectors

- -

When several selectors share the same declarations, they may be -grouped into a comma-separated list. (A comma is U+002C.)

- -
-

CSS examples:

-

In this example, we condense three rules with identical -declarations into one. Thus,

-
h1 { font-family: sans-serif }
-h2 { font-family: sans-serif }
-h3 { font-family: sans-serif }
-

is equivalent to:

-
h1, h2, h3 { font-family: sans-serif }
-
- -

Warning: 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.

- - -

6. Simple selectors

- -

6.1. Type selector

- -

A type selector is the name of a document language -element type. A type selector represents an instance of the element -type in the document tree.

- -
-

Example:

-

The following selector represents an h1 element in the document tree:

-
h1
-
- - -

6.1.1. Type selectors and namespaces

- -

Type selectors allow an optional namespace ([XMLNAMES]) 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, |).

- -

The namespace component may be left empty to indicate that the -selector is only to represent elements with no declared namespace.

- -

An asterisk may be used for the namespace prefix, indicating that -the selector represents elements in any namespace (including elements -with no namespace).

- -

Element type selectors that have no namespace component (no -namespace separator), represent elements without regard to the -element's namespace (equivalent to "*|") unless a default -namespace has been declared. If a default namespace has been declared, -the selector will represent only elements in the default -namespace.

- -

A type selector containing a namespace prefix that has not been -previously declared is an invalid 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.

- -

In a namespace-aware client, element type selectors will only match -against the local part -of the element's qualified -name. See below for notes about matching -behaviors in down-level clients.

- -

In summary:

- -
-
ns|E
-
elements with name E in namespace ns
-
*|E
-
elements with name E in any namespace, including those without any - declared namespace
-
|E
-
elements with name E without any declared namespace
-
E
-
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.
-
- -
-

CSS examples:

- -
@namespace foo url(http://www.example.com);
- foo|h1 { color: blue }
- foo|* { color: yellow }
- |h1 { color: red }
- *|h1 { color: green }
- h1 { color: green }
- -

The first rule will match only h1 elements in the - "http://www.example.com" namespace.

- -

The second rule will match all elements in the - "http://www.example.com" namespace.

- -

The third rule will match only h1 elements without - any declared namespace.

- -

The fourth rule will match h1 elements in any - namespace (including those without any declared namespace).

- -

The last rule is equivalent to the fourth rule because no default - namespace has been defined.

- -
- -

6.2. Universal selector

- -

The universal selector, written "asterisk" -(*), 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 Universal selector and -Namespaces below.

- -

If the universal selector is not the only component of a sequence -of simple selectors, the * may be omitted.

- -
-

Examples:

-
    -
  • *[hreflang|=en] and [hreflang|=en] are equivalent,
  • -
  • *.warning and .warning are equivalent,
  • -
  • *#myid and #myid are equivalent.
  • -
-
- -

Note: it is recommended that the -*, representing the universal selector, not be -omitted.

- -

6.2.1. Universal selector and namespaces

- -

The universal selector allows an optional namespace component. It -is used as follows:

- -
-
ns|*
-
all elements in namespace ns
-
*|*
-
all elements
-
|*
-
all elements without any declared namespace
-
*
-
if no default namespace has been specified, this is equivalent to *|*. - Otherwise it is equivalent to ns|* where ns is the default namespace.
-
- -

A universal selector containing a namespace prefix that has not -been previously declared is an invalid -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.

- - -

6.3. Attribute selectors

- -

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.

- -

6.3.1. Attribute presence and values -selectors

- -

CSS2 introduced four attribute selectors:

- -
-
[att] -
Represents an element with the att attribute, whatever the value of - the attribute.
-
[att=val]
-
Represents an element with the att attribute whose value is exactly - "val".
-
[att~=val]
-
Represents an element with the att attribute whose value is a whitespace-separated list of words, one of - which is exactly "val". If "val" contains whitespace, it will never - represent anything (since the words are separated by - spaces).
-
[att|=val] -
Represents an element with the att 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 hreflang attribute on the - link element in HTML) as described in RFC 3066 ([RFC3066]). For lang (or - xml:lang) language subcode matching, please see the :lang pseudo-class.
-
- -

Attribute values must be identifiers or strings. The -case-sensitivity of attribute names and values in selectors depends on -the document language.

- -
- -

Examples:

- -

The following attribute selector represents an h1 - element that carries the title attribute, whatever its - value:

- -
h1[title]
- -

In the following example, the selector represents a - span element whose class attribute has - exactly the value "example":

- -
span[class="example"]
- -

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 span element - whose hello attribute has exactly the value "Cleveland" - and whose goodbye attribute has exactly the value - "Columbus":

- -
span[hello="Cleveland"][goodbye="Columbus"]
- -

The following selectors illustrate the differences between "=" - and "~=". The first selector will represent, for example, the value - "copyright copyleft copyeditor" on a rel attribute. The - second selector will only represent an a element with - an href attribute having the exact value - "http://www.w3.org/".

- -
a[rel~="copyright"]
-a[href="http://www.w3.org/"]
- -

The following selector represents a link element - whose hreflang attribute is exactly "fr".

- -
link[hreflang=fr]
- -

The following selector represents a link element for - which the values of the hreflang attribute begins with - "en", including "en", "en-US", and "en-cockney":

- -
link[hreflang|="en"]
- -

Similarly, the following selectors represents a - DIALOGUE element whenever it has one of two different - values for an attribute character:

- -
DIALOGUE[character=romeo]
-DIALOGUE[character=juliet]
- -
- -

6.3.2. Substring matching attribute -selectors

- -

Three additional attribute selectors are provided for matching -substrings in the value of an attribute:

- -
-
[att^=val]
-
Represents an element with the att attribute whose value begins - with the prefix "val".
-
[att$=val] -
Represents an element with the att attribute whose value ends with - the suffix "val".
-
[att*=val] -
Represents an element with the att attribute whose value contains - at least one instance of the substring "val".
-
- -

Attribute values must be identifiers or strings. The -case-sensitivity of attribute names in selectors depends on the -document language.

- -
-

Examples:

-

The following selector represents an HTML object, referencing an - image:

-
object[type^="image/"]
-

The following selector represents an HTML anchor a with an - href attribute whose value ends with ".html".

-
a[href$=".html"]
-

The following selector represents an HTML paragraph with a title - attribute whose value contains the substring "hello"

-
p[title*="hello"]
-
- -

6.3.3. Attribute selectors and namespaces

- -

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" (|). 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 "|attr"). 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. - -

An attribute selector with an attribute name containing a namespace -prefix that has not been previously declared is an invalid 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. - -

-

CSS examples:

-
@namespace foo "http://www.example.com";
-[foo|att=val] { color: blue }
-[*|att] { color: yellow }
-[|att] { color: green }
-[att] { color: green }
- -

The first rule will match only elements with the attribute - att in the "http://www.example.com" namespace with the - value "val".

- -

The second rule will match only elements with the attribute - att regardless of the namespace of the attribute - (including no declared namespace).

- -

The last two rules are equivalent and will match only elements - with the attribute att where the attribute is not - declared to be in a namespace.

- -
- -

6.3.4. Default attribute values in DTDs

- -

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.

- -

More precisely, a UA is not required to read an "external -subset" of the DTD but is required to look for default -attribute values in the document's "internal subset." (See [XML10] for definitions of these subsets.)

- -

A UA that recognizes an XML namespace [XMLNAMES] 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.)

- -

Note: Typically, implementations -choose to ignore external subsets.

- -
-

Example:

- -

Consider an element EXAMPLE with an attribute "notation" that has a -default value of "decimal". The DTD fragment might be

- -
<!ATTLIST EXAMPLE notation (decimal,octal) "decimal">
- -

If the style sheet contains the rules

- -
EXAMPLE[notation=decimal] { /*... default property settings ...*/ }
-EXAMPLE[notation=octal]   { /*... other settings...*/ }
- -

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:

- -
EXAMPLE                   { /*... default property settings ...*/ }
-EXAMPLE[notation=octal]   { /*... other settings...*/ }
- -

Here, because the selector EXAMPLE[notation=octal] 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.

- -
- -

6.4. Class selectors

- -

Working with HTML, authors may use the period (U+002E, -.) notation as an alternative to the ~= -notation when representing the class attribute. Thus, for -HTML, div.value and div[class~=value] have -the same meaning. The attribute value must immediately follow the -"period" (.).

- -

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 [SVG] describes the SVG -"class" attribute and how a UA should interpret it, and -similarly MathML 1.01 [MATH] describes the MathML -"class" attribute.)

- -
-

CSS examples:

- -

We can assign style information to all elements with - class~="pastoral" as follows:

- -
*.pastoral { color: green }  /* all elements with class~=pastoral */
- -

or just

- -
.pastoral { color: green }  /* all elements with class~=pastoral */
- -

The following assigns style only to H1 elements with - class~="pastoral":

- -
H1.pastoral { color: green }  /* H1 elements with class~=pastoral */
- -

Given these rules, the first H1 instance below would not have - green text, while the second would:

- -
<H1>Not green</H1>
-<H1 class="pastoral">Very green</H1>
- -
- -

To represent a subset of "class" values, each value must be preceded -by a ".", in any order.

- -
- -

CSS example:

- -

The following rule matches any P element whose "class" attribute - has been assigned a list of whitespace-separated values that includes - "pastoral" and "marine":

- -
p.pastoral.marine { color: green }
- -

This rule matches when class="pastoral blue aqua - marine" but does not match for class="pastoral - blue".

- -
- -

Note: 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.

- -

Note: 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.

- -

6.5. ID selectors

- -

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.

- -

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, -#) immediately followed by the ID value, which must be an -identifier.

- -

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. - -

-

Examples:

-

The following ID selector represents an h1 element - whose ID-typed attribute has the value "chapter1":

-
h1#chapter1
-

The following ID selector represents any element whose ID-typed - attribute has the value "chapter1":

-
#chapter1
-

The following selector represents any element whose ID-typed - attribute has the value "z98y".

-
*#z98y
-
- -

Note. In XML 1.0 [XML10], 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: -[name=p371] instead of #p371. Elements in -XML 1.0 documents without a DTD do not have IDs at all.

- -

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.

- -

6.6. Pseudo-classes

- -

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.

- -

A pseudo-class always consists of a "colon" -(:) followed by the name of the pseudo-class and -optionally by a value between parentheses.

- -

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.

- - -

6.6.1. Dynamic pseudo-classes

- -

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.

- -

Dynamic pseudo-classes do not appear in the document source or -document tree.

- - -
The link pseudo-classes: :link and :visited
- -

User agents commonly display unvisited links differently from -previously visited ones. Selectors -provides the pseudo-classes :link and -:visited to distinguish them:

- -
    -
  • The :link pseudo-class applies to links that have - not yet been visited.
  • -
  • The :visited pseudo-class applies once the link has - been visited by the user.
  • -
- -

After some amount of time, user agents may choose to return a -visited link to the (unvisited) ':link' state.

- -

The two states are mutually exclusive.

- -
- -

Example:

- -

The following selector represents links carrying class - external and already visited:

- -
a.external:visited
- -
- -

Note: 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. - -

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.

- -
The user action pseudo-classes -:hover, :active, and :focus
- -

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.

- -
    - -
  • The :hover 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 interactive - media do not have to support this pseudo-class. Some conforming - user agents that support interactive - media may not be able to support this pseudo-class (e.g., a pen - device that does not detect hovering).
  • - -
  • The :active 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.
  • - -
  • The :focus pseudo-class applies while an element - has the focus (accepts keyboard or mouse events, or other forms of - input).
  • - -
- -

There may be document language or implementation specific limits on -which elements can become :active or acquire -:focus.

- -

These pseudo-classes are not mutually exclusive. An element may -match several pseudo-classes at the same time.

- -

Selectors doesn't define if the parent of an element that is -':active' or ':hover' is also in that state.

- -
-

Examples:

-
a:link    /* unvisited links */
-a:visited /* visited links */
-a:hover   /* user hovers */
-a:active  /* active links */
-

An example of combining dynamic pseudo-classes:

-
a:focus
-a:focus:hover
-

The last selector matches a elements that are in - the pseudo-class :focus and in the pseudo-class :hover.

-
- -

Note: An element can be both ':visited' -and ':active' (or ':link' and ':active').

- -

6.6.2. The target pseudo-class :target

- -

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).

- -

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 section_2 in an HTML -document:

- -
http://example.com/html/top.html#section_2
- -

A target element can be represented by the :target -pseudo-class. If the document's URI has no fragment identifier, then -the document has no target element.

- -
-

Example:

-
p.note:target
-

This selector represents a p element of class - note that is the target element of the referring - URI.

-
- -
-

CSS example:

-

Here, the :target pseudo-class is used to make the - target element red and place an image before it, if there is one:

-
*:target { color : red }
-*:target::before { content : url(target.png) }
-
- -

6.6.3. The language pseudo-class :lang

- -

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 [HTML4], the language is determined by a -combination of the lang attribute, the meta -element, and possibly by information from the protocol (such as HTTP -headers). XML uses an attribute called xml:lang, and -there may be other document language-specific methods for determining -the language.

- -

The pseudo-class :lang(C) represents an element that -is in language C. Whether an element is represented by a -:lang() 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 '|=' operator in attribute -selectors. The identifier C does not have to be a valid language -name.

- -

C must not be empty. (If it is, the selector is invalid.)

- -

Note: It is recommended that -documents and protocols indicate language using codes from RFC 3066 [RFC3066] or its successor, and by means of -"xml:lang" attributes in the case of XML-based documents [XML10]. See -"FAQ: Two-letter or three-letter language codes."

- -
-

Examples:

-

The two following selectors represent an HTML document that is in - Belgian, French, or German. The two next selectors represent - q quotations in an arbitrary element in Belgian, French, - or German.

-
html:lang(fr-be)
-html:lang(de)
-:lang(fr-be) > q
-:lang(de) > q
-
- -

6.6.4. The UI element states pseudo-classes

- -
The :enabled and :disabled pseudo-classes
- -

The :enabled 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 input element without also specifying what it -would look like when it was disabled.

- -

Similar to :enabled, :disabled allows the -author to specify precisely how a disabled or inactive user interface -element should look.

- -

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.

- - -
The :checked pseudo-class
- -

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 :checked pseudo-class applies. The -:checked pseudo-class initially applies to such elements -that have the HTML4 selected and checked -attributes as described in Section -17.2.1 of HTML4, but of course the user can toggle "off" such -elements in which case the :checked pseudo-class would no -longer apply. While the :checked 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 selected and -checked attributes, it applies to all media. - - -

The :indeterminate pseudo-class
- -
- -

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.

- -

A future version of this specification may introduce an -:indeterminate pseudo-class that applies to such elements. -

- -
- - -

6.6.5. Structural pseudo-classes

- -

Selectors introduces the concept of structural -pseudo-classes to permit selection based on extra information that lies in -the document tree but cannot be represented by other simple selectors or -combinators. - -

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. - - -

:root pseudo-class
- -

The :root pseudo-class represents an element that is -the root of the document. In HTML 4, this is always the -HTML element. - - -

:nth-child() pseudo-class
- -

The -:nth-child(an+b) -pseudo-class notation represents an element that has -an+b-1 siblings -before it in the document tree, for a given positive -integer or zero value of n, and has a parent element. In -other words, this matches the bth child of an element after -all the children have been split into groups of a 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 a and -b values must be zero, negative integers or positive -integers. The index of the first child of an element is 1. - -

In addition to this, :nth-child() can take -'odd' and 'even' as arguments instead. -'odd' has the same signification as 2n+1, -and 'even' has the same signification as 2n. - - -

-

Examples:

-
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; }
-
- -

When a=0, no repeating is used, so for example -:nth-child(0n+5) matches only the fifth child. When -a=0, the an part need not be -included, so the syntax simplifies to -:nth-child(b) and the last example simplifies -to :nth-child(5). - -

-

Examples:

-
foo:nth-child(0n+1)   /* represents an element foo, first child of its parent element */
-foo:nth-child(1)      /* same */
-
- -

When a=1, the number may be omitted from the rule. - -

-

Examples:

-

The following selectors are therefore equivalent:

-
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) */
-
- -

If b=0, then every ath element is picked. In -such a case, the b part may be omitted. - -

-

Examples:

-
tr:nth-child(2n+0) /* represents every even row of an HTML table */
-tr:nth-child(2n) /* same */
-
- -

If both a and b are equal to zero, the -pseudo-class represents no element in the document tree.

- -

The value a can be negative, but only the positive -values of an+b, for -n≥0, may represent an element in the document -tree.

- -
-

Example:

-
html|tr:nth-child(-n+6)  /* represents the 6 first rows of XHTML tables */
-
- -

When the value b is negative, the "+" character in the -expression must be removed (it is effectively replaced by the "-" -character indicating the negative value of b).

- -
-

Examples:

-
: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 */
-
- - -
:nth-last-child() pseudo-class
- -

The :nth-last-child(an+b) -pseudo-class notation represents an element that has -an+b-1 siblings -after it in the document tree, for a given positive -integer or zero value of n, and has a parent element. See -:nth-child() pseudo-class for the syntax of its argument. -It also accepts the 'even' and 'odd' values -as arguments. - - -

-

Examples:

-
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 */
-
- - -
:nth-of-type() pseudo-class
- -

The :nth-of-type(an+b) -pseudo-class notation represents an element that has -an+b-1 siblings with the same -element name before it in the document tree, for a -given zero or positive integer value of n, and has a -parent element. In other words, this matches the bth child -of that type after all the children of that type have been split into -groups of a elements each. See :nth-child() pseudo-class -for the syntax of its argument. It also accepts the -'even' and 'odd' values. - - -

-

CSS example:

-

This allows an author to alternate the position of floated images:

-
img:nth-of-type(2n+1) { float: right; }
-img:nth-of-type(2n) { float: left; }
-
- - -
:nth-last-of-type() pseudo-class
- -

The :nth-last-of-type(an+b) -pseudo-class notation represents an element that has -an+b-1 siblings with the same -element name after it in the document tree, for a -given zero or positive integer value of n, and has a -parent element. See :nth-child() pseudo-class for the -syntax of its argument. It also accepts the 'even' and 'odd' values. - - -

-

Example:

-

To represent all h2 children of an XHTML - body except the first and last, one could use the - following selector:

-
body > h2:nth-of-type(n+2):nth-last-of-type(n+2)
-

In this case, one could also use :not(), although the - selector ends up being just as long:

-
body > h2:not(:first-of-type):not(:last-of-type)
-
- - -
:first-child pseudo-class
- -

Same as :nth-child(1). The :first-child pseudo-class -represents an element that is the first child of some other element. - - -

-

Examples:

-

The following selector represents a p element that is - the first child of a div element:

-
div > p:first-child
-

This selector can represent the p inside the - div of the following fragment:

-
<p> The last P before the note.</p>
-<div class="note">
-   <p> The first P inside the note.</p>
-</div>
but cannot represent the second p in the following -fragment: -
<p> The last P before the note.</p>
-<div class="note">
-   <h2> Note </h2>
-   <p> The first P inside the note.</p>
-</div>
-

The following two selectors are usually equivalent:

-
* > a:first-child /* a is first child of any element */
-a:first-child /* Same (assuming a is not the root element) */
-
- -
:last-child pseudo-class
- -

Same as :nth-last-child(1). The :last-child pseudo-class -represents an element that is the last child of some other element. - -

-

Example:

-

The following selector represents a list item li that - is the last child of an ordered list ol. -

ol > li:last-child
-
- -
:first-of-type pseudo-class
- -

Same as :nth-of-type(1). The :first-of-type pseudo-class -represents an element that is the first sibling of its type in the list of -children of its parent element. - -

-

Example:

-

The following selector represents a definition title -dt inside a definition list dl, this -dt being the first of its type in the list of children of -its parent element.

-
dl dt:first-of-type
-

It is a valid description for the first two dt -elements in the following example but not for the third one:

-
<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>
-
- -
:last-of-type pseudo-class
- -

Same as :nth-last-of-type(1). The -:last-of-type pseudo-class represents an element that is -the last sibling of its type in the list of children of its parent -element.

- -
-

Example:

-

The following selector represents the last data cell - td of a table row.

-
tr > td:last-of-type
-
- -
:only-child pseudo-class
- -

Represents an element that has a parent element and whose parent -element has no other element children. Same as -:first-child:last-child or -:nth-child(1):nth-last-child(1), but with a lower -specificity.

- -
:only-of-type pseudo-class
- -

Represents an element that has a parent element and whose parent -element has no other element children with the same element name. Same -as :first-of-type:last-of-type or -:nth-of-type(1):nth-last-of-type(1), but with a lower -specificity.

- - -
:empty pseudo-class
- -

The :empty 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.

- -
-

Examples:

-

p:empty is a valid representation of the following fragment:

-
<p></p>
-

foo:empty is not a valid representation for the - following fragments:

-
<foo>bar</foo>
-
<foo><bar>bla</bar></foo>
-
<foo>this is not <bar>:empty</bar></foo>
-
- -

6.6.6. Blank

- -

This section intentionally left blank.

- - -

6.6.7. The negation pseudo-class

- -

The negation pseudo-class, :not(X), is a -functional notation taking a simple -selector (excluding the negation pseudo-class itself and -pseudo-elements) as an argument. It represents an element that is not -represented by the argument. - - - -

-

Examples:

-

The following CSS selector matches all button - elements in an HTML document that are not disabled.

-
button:not([DISABLED])
-

The following selector represents all but FOO - elements.

-
*:not(FOO)
-

The following group of selectors represents all HTML elements - except links.

-
html|*:not(:link):not(:visited)
-
- -

Default namespace declarations do not affect the argument of the -negation pseudo-class unless the argument is a universal selector or a -type selector.

- -
-

Examples:

-

Assuming that the default namespace is bound to - "http://example.com/", the following selector represents all - elements that are not in that namespace:

-
*|*:not(*)
-

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 are being hovered.

-
*|*:not(:hover)
-
- -

Note: the :not() pseudo allows -useless selectors to be written. For instance :not(*|*), -which represents no element at all, or foo:not(bar), -which is equivalent to foo but with a higher -specificity.

- -

7. Pseudo-elements

- -

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 ::before and -::after pseudo-elements give access to generated -content).

- -

A pseudo-element is made of two colons (::) followed -by the name of the pseudo-element.

- -

This :: 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, -:first-line, :first-letter, -:before and :after). This compatibility is -not allowed for the new pseudo-elements introduced in CSS level 3.

- -

Only one pseudo-element may appear per selector, and if present it -must appear after the sequence of simple selectors that represents the -subjects of the selector. A -future version of this specification may allow multiple -pesudo-elements per selector.

- -

7.1. The ::first-line pseudo-element

- -

The ::first-line pseudo-element describes the contents -of the first formatted line of an element. - -

-

CSS example:

-
p::first-line { text-transform: uppercase }
-

The above rule means "change the letters of the first line of every -paragraph to uppercase".

-
- -

The selector p::first-line 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.

- -

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>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>
-
- -

the lines of which happen to be broken as follows: - -

-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.
-
- -

This paragraph might be "rewritten" by user agents to include the -fictional tag sequence for ::first-line. This -fictional tag sequence helps to show how properties are inherited.

- -
-<P><P::first-line> This is a somewhat long HTML
-paragraph that </P::first-line> 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>
-
- -

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 span element:

- -
-<P><SPAN class="test"> This is a somewhat long HTML
-paragraph that will be broken into several
-lines.</SPAN> The first line will be identified
-by a fictional tag sequence. The other lines
-will be treated as ordinary lines in the
-paragraph.</P>
-
- -

the user agent could simulate start and end tags for -span when inserting the fictional tag sequence for -::first-line. - -

-<P><P::first-line><SPAN class="test"> This is a
-somewhat long HTML
-paragraph that will </SPAN></P::first-line><SPAN class="test"> be
-broken into several
-lines.</SPAN> The first line will be identified
-by a fictional tag sequence. The other lines
-will be treated as ordinary lines in the
-paragraph.</P>
-
- -

In CSS, the ::first-line pseudo-element can only be -attached to a block-level element, an inline-block, a table-caption, -or a table-cell.

- -

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 div in <DIV><P>This -line...</P></DIV> is the first line of the p (assuming -that both p and div are block-level). - -

The first line of a table-cell or inline-block cannot be the first -formatted line of an ancestor element. Thus, in <DIV><P -STYLE="display: inline-block">Hello<BR>Goodbye</P> -etcetera</DIV> the first formatted line of the -div is not the line "Hello". - -

Note that the first line of the p in this -fragment: <p><br>First... doesn't contain any -letters (assuming the default style for br in HTML -4). The word "First" is not on the first formatted line. - -

A UA should act as if the fictional start tags of the -::first-line 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

- -
-<DIV>
-  <P>First paragraph</P>
-  <P>Second paragraph</P>
-</DIV>
-
- -

is

- -
-<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>
-
- -

The ::first-line pseudo-element is similar to an -inline-level element, but with certain restrictions. In CSS, the -following properties apply to a ::first-line -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.

- - -

7.2. The ::first-letter pseudo-element

- -

The ::first-letter 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.

- -

In CSS, these are the properties that apply to ::first-letter -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.

- -
-

Example:

-

This example shows a possible rendering of an initial cap. Note -that the 'line-height' that is inherited by the ::first-letter -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, and thus -the font weight of the first letter is normal, not bold as the span: -

-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.
-
-
-

Image illustrating the ::first-letter pseudo-element -

-
- -
-

The following CSS will make a drop cap initial letter span about two lines:

- -
-<!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>
-
- -

This example might be formatted as follows:

- -
-

Image illustrating the combined effect of the ::first-letter and ::first-line pseudo-elements

-
- -

The fictional tag sequence is:

- -
-<P>
-<SPAN>
-<P::first-letter>
-T
-</P::first-letter>he first
-</SPAN>
-few words of an article in the Economist.
-</P>
-
- -

Note that the ::first-letter 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.

- -

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.

- -

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. [UNICODE]

- -
-

Quotes that precede the
-first letter should be included.

-
- -

The ::first-letter also applies if the first letter is -in fact a digit, e.g., the "6" in "67 million dollars is a lot of -money."

- -

In CSS, the ::first-letter pseudo-element applies to -block, list-item, table-cell, table-caption, and inline-block -elements. A future version of this specification -may allow this pesudo-element to apply to more element -types.

- -

The ::first-letter 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.

- -
-

Example:

-

The fictional tag sequence for this HTMLfragment: -

<div>
-<p>The first text.
-

is: -

<div>
-<p><div::first-letter><p::first-letter>T</...></...>he first text.
-
- -

The first letter of a table-cell or inline-block cannot be the -first letter of an ancestor element. Thus, in <DIV><P -STYLE="display: inline-block">Hello<BR>Goodbye</P> -etcetera</DIV> the first letter of the div is not the -letter "H". In fact, the div doesn't have a first letter. - -

The first letter must occur on the first formatted line. For example, in -this fragment: <p><br>First... the first line -doesn't contain any letters and ::first-letter doesn't -match anything (assuming the default style for br in HTML -4). In particular, it does not match the "F" of "First." - -

In CSS, if an element is a list item ('display: list-item'), the -::first-letter applies to the first letter in the -principal box after the marker. UAs may ignore -::first-letter on list items with 'list-style-position: -inside'. If an element has ::before or -::after content, the ::first-letter applies -to the first letter of the element including that content. - -

-

Example:

-

After the rule 'p::before {content: "Note: "}', the selector -'p::first-letter' matches the "N" of "Note".

-
- -

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 ::first-letter pseudo-element. - -

If the letters that would form the ::first-letter are not in the -same element, such as "'T" in <p>'<em>T..., the UA -may create a ::first-letter pseudo-element from one of the elements, -both elements, or simply not create a pseudo-element.

- -

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). - -

-

Example:

-

The following example 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 { 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>
- -

Assuming that a line break will occur before the word "ends", the -fictional tag -sequence for this fragment might be:

- -
<P>
-<P::first-line>
-<P::first-letter>
-S
-</P::first-letter>ome text that
-</P::first-line>
-ends up on two lines
-</P>
- -

Note that the ::first-letter element is inside the ::first-line -element. Properties set on ::first-line are inherited by -::first-letter, but are overridden if the same property is set on -::first-letter.

-
- - -

7.3. The ::selection pseudo-element

- -

The ::selection 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 :checked pseudo-class (which used to be -named :selected) - -

Although the ::selection 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 -[CSS21]) which was originally rendered to a -dynamic medium (like screen), the UA may wish to transfer the current -::selection 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 ::selection -pseudo-element for static media. - -

These are the CSS properties that apply to ::selection -pseudo-elements: color, background, cursor (optional), outline -(optional). The computed value of the 'background-image' property on -::selection may be ignored. - - -

7.4. The ::before and ::after pseudo-elements

- -

The ::before and ::after pseudo-elements -can be used to describe generated content before or after an element's -content. They are explained in CSS 2.1 [CSS21].

- -

When the ::first-letter and ::first-line -pseudo-elements are combined with ::before and -::after, they apply to the first letter or line of the -element including the inserted text.

- -

8. Combinators

- -

8.1. Descendant combinator

- -

At times, authors may want selectors to describe an element that is -the descendant of another element in the document tree (e.g., "an -EM element that is contained within an H1 -element"). Descendant combinators express such a relationship. A -descendant combinator is white space that -separates two sequences of simple selectors. A selector of the form -"A B" represents an element B that is an -arbitrary descendant of some ancestor element A. - -

-

Examples:

-

For example, consider the following selector:

-
h1 em
-

It represents an em element being the descendant of - an h1 element. It is a correct and valid, but partial, - description of the following fragment:

-
<h1>This <span class="myclass">headline
-is <em>very</em> important</span></h1>
-

The following selector:

-
div * p
-

represents a p element that is a grandchild or later - descendant of a div 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.

-

The following selector, which combines descendant combinators and - attribute selectors, represents an - element that (1) has the href attribute set and (2) is - inside a p that is itself inside a div:

-
div p *[href]
-
- -

8.2. Child combinators

- -

A child combinator describes a childhood relationship -between two elements. A child combinator is made of the -"greater-than sign" (>) character and -separates two sequences of simple selectors. - - -

-

Examples:

-

The following selector represents a p element that is - child of body:

-
body > p
-

The following example combines descendant combinators and child - combinators.

-
div ol>li p
-

It represents a p element that is a descendant of an - li element; the li element must be the - child of an ol element; the ol element must - be a descendant of a div. Notice that the optional white - space around the ">" combinator has been left out.

-
- -

For information on selecting the first child of an element, please -see the section on the :first-child pseudo-class -above.

- -

8.3. Sibling combinators

- -

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.

- -

8.3.1. Adjacent sibling combinator

- -

The adjacent sibling combinator is made of the "plus -sign" (U+002B, +) 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.

- -
-

Examples:

-

The following selector represents a p element - immediately following a math element:

-
math + 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 h1 element, that it must have - class="opener":

-
h1.opener + h2
-
- - -

8.3.2. General sibling combinator

- -

The general sibling combinator is made of the "tilde" -(U+007E, ~) 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.

- -
-

Example:

-
h1 ~ pre
-

represents a pre element following an h1. It - is a correct and valid, but partial, description of:

-
<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>
-
- -

9. Calculating a selector's specificity

- -

A selector's specificity is calculated as follows:

- -
    -
  • count the number of ID selectors in the selector (= a)
  • -
  • count the number of class selectors, attributes selectors, and pseudo-classes in the selector (= b)
  • -
  • count the number of element names in the selector (= c)
  • -
  • ignore pseudo-elements
  • -
- -

Selectors inside the negation pseudo-class -are counted like any other, but the negation itself does not count as -a pseudo-class.

- -

Concatenating the three numbers a-b-c (in a number system with a -large base) gives the specificity.

- -
-

Examples:

-
*               /* 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 */
-
-
- -

Note: the specificity of the styles -specified in an HTML style attribute is described in CSS -2.1. [CSS21].

- -

10. The grammar of Selectors

- -

10.1. Grammar

- -

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 [YACC]) -are used:

- -
    -
  • *: 0 or more -
  • +: 1 or more -
  • ?: 0 or 1 -
  • |: separates alternatives -
  • [ ]: grouping
  • -
- -

The productions are:

- -
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
-  ;
- - -

10.2. Lexical scanner

- -

The following is the tokenizer, written in Flex (see -[FLEX]) notation. The tokenizer is -case-insensitive.

- -

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. [UNICODE]

- -
%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;
- - - -

11. Namespaces and down-level clients

- -

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.

- -

It should be noted that a down-level CSS client will (if it -properly conforms to CSS forward compatible parsing rules) ignore all -@namespace 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.

- -

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.

- -

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.

- -
    -
  1. - -

    The XML document does not use namespaces.

    - -
      - -
    • 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.
    • - -
    • 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 ("|name") - will guarantee that selectors will match only XML elements that do - not have a declared namespace.
    • - -
    - -
  2. - -
  3. - -

    The XML document defines a single, default namespace used - throughout the document. No namespace prefixes are used in element - names.

    - -
      - -
    • 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.
    • - -
    - -
  4. - -
  5. - -

    The XML document does not 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).

    - -
      - -
    • 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 Type selectors and Namespaces section. CSS - selectors may be declared using an escaped colon "\:" - to describe the fully qualified names, e.g. - "html\:h1" will match - <html:h1>. 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.
    • - -
    • Note that selectors declared in this fashion will - only 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).
    • - -
    - -
  6. - -
- -

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 -different 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.

- -

12. Profiles

- -

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.

- -

Non normative examples: - -

- - - - - - - - - - - - - - - -
Selectors profile
SpecificationCSS level 1
Acceptstype selectors
class selectors
ID selectors
:link, - :visited and :active pseudo-classes
descendant combinator -
::first-line and ::first-letter pseudo-elements
Excludes - -

universal selector
attribute selectors
:hover and :focus - pseudo-classes
:target pseudo-class
:lang() pseudo-class
all UI - element states pseudo-classes
all structural - pseudo-classes
negation pseudo-class
all - UI element fragments pseudo-elements
::before and ::after - pseudo-elements
child combinators
sibling combinators - -

namespaces

Extra constraintsonly one class selector allowed per sequence of simple - selectors


- - - - - - - - - - - - - - - -
Selectors profile
SpecificationCSS level 2
Acceptstype selectors
universal selector
attribute presence and - values selectors
class selectors
ID selectors
:link, :visited, - :active, :hover, :focus, :lang() and :first-child pseudo-classes -
descendant combinator
child combinator
adjacent sibling - combinator
::first-line and ::first-letter pseudo-elements
::before - and ::after pseudo-elements
Excludes - -

content selectors
substring matching attribute - selectors
:target pseudo-classes
all UI element - states pseudo-classes
all structural pseudo-classes other - than :first-child
negation pseudo-class
all UI element - fragments pseudo-elements
general sibling combinators - -

namespaces

Extra constraintsmore than one class selector per sequence of simple selectors (CSS1 - constraint) allowed
- -

In CSS, selectors express pattern matching rules that determine which style -rules apply to elements in the document tree. - -

The following selector (CSS level 2) will match all anchors a -with attribute name set inside a section 1 header h1: -

h1 a[name]
- -

All CSS declarations attached to such a selector are applied to elements -matching it.

- -
- - - - - - - - - - - - - - - - -
Selectors profile
SpecificationSTTS 3
Accepts - -

type selectors
universal selectors
attribute selectors
class - selectors
ID selectors
all structural pseudo-classes
- all combinators - -

namespaces

Excludesnon-accepted pseudo-classes
pseudo-elements
Extra constraintssome selectors and combinators are not allowed in fragment - descriptions on the right side of STTS declarations.
-
- - - - - - - - - - - - - - - - - - - - - - - - - -
- -

Selectors can be used in STTS 3 in two different - manners: -

    -
  1. a selection mechanism equivalent to CSS selection mechanism: declarations - attached to a given selector are applied to elements matching that selector, -
  2. fragment descriptions that appear on the right side of declarations. -
- -

13. Conformance and requirements

- -

This section defines conformance with the present specification only. - -

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. - -

All specifications reusing Selectors must contain a Profile listing the -subset of Selectors it accepts or excludes, and describing the constraints -it adds to the current specification. - -

Invalidity is caused by a parsing error, e.g. an unrecognized token or a token -which is not allowed at the current parsing point. - -

User agents must observe the rules for handling parsing errors: -

    -
  • a simple selector containing an undeclared namespace prefix is invalid
  • -
  • a selector containing an invalid simple selector, an invalid combinator - or an invalid token is invalid.
  • -
  • a group of selectors containing an invalid selector is invalid.
  • -
- -

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.)

- - - -

14. Tests

- -

This specification has a test -suite 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.

- -

15. Acknowledgements

- -

The CSS working group would like to thank everyone who has sent -comments on this specification over the years.

- -

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.

- -

16. References

- -
- -
[CSS1] -
Bert Bos, Håkon Wium Lie; "Cascading Style Sheets, level 1", W3C Recommendation, 17 Dec 1996, revised 11 Jan 1999 -
(http://www.w3.org/TR/REC-CSS1) - -
[CSS21] -
Bert Bos, Tantek Çelik, Ian Hickson, Håkon Wium Lie, editors; "Cascading Style Sheets, level 2 revision 1", W3C Working Draft, 13 June 2005 -
(http://www.w3.org/TR/CSS21) - -
[CWWW] -
Martin J. Dürst, François Yergeau, Misha Wolf, Asmus Freytag, Tex Texin, editors; "Character Model for the World Wide Web", W3C Recommendation, 15 February 2005 -
(http://www.w3.org/TR/charmod/) - -
[FLEX] -
"Flex: The Lexical Scanner Generator", Version 2.3.7, ISBN 1882114213 - -
[HTML4] -
Dave Ragget, Arnaud Le Hors, Ian Jacobs, editors; "HTML 4.01 Specification", W3C Recommendation, 24 December 1999 -
(http://www.w3.org/TR/html4/) - -
[MATH] -
Patrick Ion, Robert Miner, editors; "Mathematical Markup Language (MathML) 1.01", W3C Recommendation, revision of 7 July 1999 -
(http://www.w3.org/TR/REC-MathML/) - -
[RFC3066] -
H. Alvestrand; "Tags for the Identification of Languages", Request for Comments 3066, January 2001 -
(http://www.ietf.org/rfc/rfc3066.txt) - -
[STTS] -
Daniel Glazman; "Simple Tree Transformation Sheets 3", Electricité de France, submission to the W3C, 11 November 1998 -
(http://www.w3.org/TR/NOTE-STTS3) - -
[SVG] -
Jon Ferraiolo, 藤沢 淳, Dean Jackson, editors; "Scalable Vector Graphics (SVG) 1.1 Specification", W3C Recommendation, 14 January 2003 -
(http://www.w3.org/TR/SVG/) - -
[UNICODE]
-
The Unicode Standard, Version 4.1, The Unicode Consortium. Boston, MA, Addison-Wesley, March 2005. ISBN 0-321-18578-1, as amended by Unicode 4.0.1 and Unicode 4.1.0. -
(http://www.unicode.org/versions/)
- -
[XML10] -
Tim Bray, Jean Paoli, C. M. Sperberg-McQueen, Eve Maler, François Yergeau, editors; "Extensible Markup Language (XML) 1.0 (Third Edition)", W3C Recommendation, 4 February 2004 -
(http://www.w3.org/TR/REC-xml/) - -
[XMLNAMES] -
Tim Bray, Dave Hollander, Andrew Layman, editors; "Namespaces in XML", W3C Recommendation, 14 January 1999 -
(http://www.w3.org/TR/REC-xml-names/) - -
[YACC] -
S. C. Johnson; "YACC — Yet another compiler compiler", Technical Report, Murray Hill, 1975 - -
- - diff --git a/samples/third_party/dromaeo/web/tests/dom-query-html.dart b/samples/third_party/dromaeo/web/tests/dom-query-html.dart deleted file mode 100644 index cd587820306..00000000000 --- a/samples/third_party/dromaeo/web/tests/dom-query-html.dart +++ /dev/null @@ -1,106 +0,0 @@ -library dromaeo; -import 'dart:async'; -import 'dart:html'; -import '../common/common.dart'; -import "dart:convert"; -import 'dart:math' as Math; -part 'Common.dart'; -part 'RunnerSuite.dart'; - -void main() { - final int num = 40; - - // Try to force real results. - var ret; - - String html = document.body.innerHtml; - - new Suite(window, 'dom-query') - .prep(() { - html = BenchUtil.replaceAll(html, 'id="test(\\w).*?"', (Match match) { - final group = match.group(1); - return 'id="test${group}${num}"'; - }); - html = BenchUtil.replaceAll(html, 'name="test.*?"', (Match match) { - return 'name="test${num}"'; - }); - html = BenchUtil.replaceAll(html, 'class="foo.*?"', (Match match) { - return 'class="foo test${num} bar"'; - }); - final div = new Element.tag('div'); - div.innerHtml = html; - document.body.append(div); - }) - .test('getElementById', () { - for (int i = 0; i < num * 30; i++) { - ret = document.getElementById('testA$num').nodeType; - ret = document.getElementById('testB$num').nodeType; - ret = document.getElementById('testC$num').nodeType; - ret = document.getElementById('testD$num').nodeType; - ret = document.getElementById('testE$num').nodeType; - ret = document.getElementById('testF$num').nodeType; - } - }) - .test('getElementById (not in document)', () { - for (int i = 0; i < num * 30; i++) { - ret = document.getElementById('testA'); - ret = document.getElementById('testB'); - ret = document.getElementById('testC'); - ret = document.getElementById('testD'); - ret = document.getElementById('testE'); - ret = document.getElementById('testF'); - } - }) - .test('getElementsByTagName(div)', () { - for (int i = 0; i < num; i++) { - List elems = document.getElementsByTagName('div'); - ret = elems.last.nodeType; - } - }) - .test('getElementsByTagName(p)', () { - for (int i = 0; i < num; i++) { - List elems = document.getElementsByTagName('p'); - ret = elems.last.nodeType; - } - }) - .test('getElementsByTagName(a)', () { - for (int i = 0; i < num; i++) { - List elems = document.getElementsByTagName('a'); - ret = elems.last.nodeType; - } - }) - .test('getElementsByTagName(*)', () { - for (int i = 0; i < num; i++) { - List elems = document.getElementsByTagName('*'); - ret = elems.last.nodeType; - } - }) - .test('getElementsByTagName (not in document)', () { - for (int i = 0; i < num; i++) { - List elems = document.getElementsByTagName('strong'); - ret = elems.length == 0; - } - }) - .test('getElementsByName', () { - for (int i = 0; i < num * 20; i++) { - List elems = document.getElementsByName('test$num'); - ret = elems[elems.length-1].nodeType; - elems = document.getElementsByName('test$num'); - ret = elems[elems.length-1].nodeType; - elems = document.getElementsByName('test$num'); - ret = elems[elems.length-1].nodeType; - elems = document.getElementsByName('test$num'); - ret = elems[elems.length-1].nodeType; - } - }) - .test('getElementsByName (not in document)', () { - for (int i = 0; i < num * 20; i++) { - ret = document.getElementsByName('test').length == 0; - ret = document.getElementsByName('test').length == 0; - ret = document.getElementsByName('test').length == 0; - ret = document.getElementsByName('test').length == 0; - ret = document.getElementsByName('test').length == 0; - } - }) - .end(); -} diff --git a/samples/third_party/dromaeo/web/tests/dom-query-html.html b/samples/third_party/dromaeo/web/tests/dom-query-html.html deleted file mode 100644 index 27f93333a2c..00000000000 --- a/samples/third_party/dromaeo/web/tests/dom-query-html.html +++ /dev/null @@ -1,2900 +0,0 @@ - - - - - - -
-

W3C - -

Selectors

- -

W3C Working Draft 15 December 2005

- -
- -
This version: - -
- http://www.w3.org/TR/2005/WD-css3-selectors-20051215 - -
Latest version: - -
- http://www.w3.org/TR/css3-selectors - -
Previous version: - -
- http://www.w3.org/TR/2001/CR-css3-selectors-20011113 - -
Editors: - -
Daniel Glazman (Invited Expert)
- -
Tantek Çelik (Invited Expert) - -
Ian Hickson (Google) - -
Peter Linss (former editor, Netscape/AOL) - -
John Williams (former editor, Quark, Inc.) - -
- -
- -
- -

Abstract

- -

Selectors 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.

- -

CSS (Cascading - Style Sheets) is a language for describing the rendering of HTML and XML 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. - -

Selectors define the following function:

- -
expression ∗ element → boolean
- -

That is, given an element and a selector, this specification - defines whether that element matches the selector.

- -

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. STTS (Simple Tree Transformation Sheets), a - language for transforming XML trees, uses this mechanism. [STTS]

- -

Status of this document

- -

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 W3C technical reports index at - http://www.w3.org/TR/.

- -

This document describes the selectors that already exist in CSS1 and CSS2, and - also proposes new selectors for CSS3 and other languages that may need them.

- -

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.

- -

This specification is a last call working draft for the the CSS Working Group - (Style Activity). This - document is a revision of the Candidate - Recommendation dated 2001 November 13, 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.

- -

All persons are encouraged to review and implement this - specification and return comments to the (archived) - public mailing list www-style - (see instructions). W3C - Members can also send comments directly to the CSS Working - Group. - The deadline for comments is 14 January 2006.

- -

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". - -

This document may be available in translation. - The English version of this specification is the only normative - version. - -

- -

Table of contents

- - - -
- -

1. Introduction

- -

1.1. Dependencies

- -

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. [CSS21]

- -

1.2. Terminology

- -

All of the text of this specification is normative except - examples, notes, and sections explicitly marked as - non-normative.

- -

1.3. Changes from CSS2

- -

This section is non-normative.

- -

The main differences between the selectors in CSS2 and those in - Selectors are: - -

    - -
  • 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
  • - -
  • an optional namespace component is now allowed in type element - selectors, the universal selector and attribute selectors
  • - -
  • a new combinator has been introduced
  • - -
  • new simple selectors including substring matching attribute - selectors, and new pseudo-classes
  • - -
  • new pseudo-elements, and introduction of the "::" convention - for pseudo-elements
  • - -
  • the grammar has been rewritten
  • - -
  • profiles to be added to specifications integrating Selectors - and defining the set of selectors which is actually supported by - each specification
  • - -
  • Selectors are now a CSS3 Module and an independent - specification; other specifications can now refer to this document - independently of CSS
  • - -
  • the specification now has its own test suite
  • - -
- -

2. Selectors

- -

This section is non-normative, as it merely summarizes the -following sections.

- -

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.

- -

Selectors may range from simple element names to rich contextual -representations.

- -

The following table summarizes the Selector syntax:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PatternMeaningDescribed in sectionFirst defined in CSS level
*any elementUniversal - selector2
Ean element of type EType selector1
E[foo]an E element with a "foo" attributeAttribute - selectors2
E[foo="bar"]an E element whose "foo" attribute value is exactly - equal to "bar"Attribute - selectors2
E[foo~="bar"]an E element whose "foo" attribute value is a list of - space-separated values, one of which is exactly equal to "bar"Attribute - selectors2
E[foo^="bar"]an E element whose "foo" attribute value begins exactly - with the string "bar"Attribute - selectors3
E[foo$="bar"]an E element whose "foo" attribute value ends exactly - with the string "bar"Attribute - selectors3
E[foo*="bar"]an E element whose "foo" attribute value contains the - substring "bar"Attribute - selectors3
E[hreflang|="en"]an E element whose "hreflang" attribute has a hyphen-separated - list of values beginning (from the left) with "en"Attribute - selectors2
E:rootan E element, root of the documentStructural - pseudo-classes3
E:nth-child(n)an E element, the n-th child of its parentStructural - pseudo-classes3
E:nth-last-child(n)an E element, the n-th child of its parent, counting - from the last oneStructural - pseudo-classes3
E:nth-of-type(n)an E element, the n-th sibling of its typeStructural - pseudo-classes3
E:nth-last-of-type(n)an E element, the n-th sibling of its type, counting - from the last oneStructural - pseudo-classes3
E:first-childan E element, first child of its parentStructural - pseudo-classes2
E:last-childan E element, last child of its parentStructural - pseudo-classes3
E:first-of-typean E element, first sibling of its typeStructural - pseudo-classes3
E:last-of-typean E element, last sibling of its typeStructural - pseudo-classes3
E:only-childan E element, only child of its parentStructural - pseudo-classes3
E:only-of-typean E element, only sibling of its typeStructural - pseudo-classes3
E:emptyan E element that has no children (including text - nodes)Structural - pseudo-classes3
E:link
E:visited
an E element being the source anchor of a hyperlink of - which the target is not yet visited (:link) or already visited - (:visited)The link - pseudo-classes1
E:active
E:hover
E:focus
an E element during certain user actionsThe user - action pseudo-classes1 and 2
E:targetan E element being the target of the referring URIThe target - pseudo-class3
E:lang(fr)an element of type E in language "fr" (the document - language specifies how language is determined)The :lang() - pseudo-class2
E:enabled
E:disabled
a user interface element E which is enabled or - disabledThe UI element states - pseudo-classes3
E:checkeda user interface element E which is checked (for instance a radio-button or checkbox)The UI element states - pseudo-classes3
E::first-linethe first formatted line of an E elementThe ::first-line - pseudo-element1
E::first-letterthe first formatted letter of an E elementThe ::first-letter - pseudo-element1
E::selectionthe portion of an E element that is currently - selected/highlighted by the userThe UI element - fragments pseudo-elements3
E::beforegenerated content before an E elementThe ::before - pseudo-element2
E::aftergenerated content after an E elementThe ::after - pseudo-element2
E.warningan E element whose class is -"warning" (the document language specifies how class is determined).Class - selectors1
E#myidan E element with ID equal to "myid".ID - selectors1
E:not(s)an E element that does not match simple selector sNegation - pseudo-class3
E Fan F element descendant of an E elementDescendant - combinator1
E > Fan F element child of an E elementChild - combinator2
E + Fan F element immediately preceded by an E elementAdjacent sibling combinator2
E ~ Fan F element preceded by an E elementGeneral sibling combinator3
- -

The meaning of each selector is derived from the table above by -prepending "matches" to the contents of each cell in the "Meaning" -column.

- -

3. Case sensitivity

- -

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.

- -

4. Selector syntax

- -

A selector is a chain of one -or more sequences of simple selectors -separated by combinators.

- -

A sequence of simple selectors -is a chain of simple selectors -that are not separated by a combinator. It -always begins with a type selector or a -universal selector. No other type -selector or universal selector is allowed in the sequence.

- -

A simple selector is either a type selector, universal selector, attribute selector, class selector, ID selector, content selector, or pseudo-class. One pseudo-element may be appended to the last -sequence of simple selectors.

- -

Combinators are: white space, "greater-than -sign" (U+003E, >), "plus sign" (U+002B, -+) and "tilde" (U+007E, ~). White -space may appear between a combinator and the simple selectors around -it. 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.

- -

The elements of a document tree that are represented by a selector -are the subjects of the selector. 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.

- -

An empty selector, containing no sequence of simple selectors and -no pseudo-element, is an invalid -selector.

- -

5. Groups of selectors

- -

When several selectors share the same declarations, they may be -grouped into a comma-separated list. (A comma is U+002C.)

- -
-

CSS examples:

-

In this example, we condense three rules with identical -declarations into one. Thus,

-
h1 { font-family: sans-serif }
-h2 { font-family: sans-serif }
-h3 { font-family: sans-serif }
-

is equivalent to:

-
h1, h2, h3 { font-family: sans-serif }
-
- -

Warning: 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.

- - -

6. Simple selectors

- -

6.1. Type selector

- -

A type selector is the name of a document language -element type. A type selector represents an instance of the element -type in the document tree.

- -
-

Example:

-

The following selector represents an h1 element in the document tree:

-
h1
-
- - -

6.1.1. Type selectors and namespaces

- -

Type selectors allow an optional namespace ([XMLNAMES]) 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, |).

- -

The namespace component may be left empty to indicate that the -selector is only to represent elements with no declared namespace.

- -

An asterisk may be used for the namespace prefix, indicating that -the selector represents elements in any namespace (including elements -with no namespace).

- -

Element type selectors that have no namespace component (no -namespace separator), represent elements without regard to the -element's namespace (equivalent to "*|") unless a default -namespace has been declared. If a default namespace has been declared, -the selector will represent only elements in the default -namespace.

- -

A type selector containing a namespace prefix that has not been -previously declared is an invalid 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.

- -

In a namespace-aware client, element type selectors will only match -against the local part -of the element's qualified -name. See below for notes about matching -behaviors in down-level clients.

- -

In summary:

- -
-
ns|E
-
elements with name E in namespace ns
-
*|E
-
elements with name E in any namespace, including those without any - declared namespace
-
|E
-
elements with name E without any declared namespace
-
E
-
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.
-
- -
-

CSS examples:

- -
@namespace foo url(http://www.example.com);
- foo|h1 { color: blue }
- foo|* { color: yellow }
- |h1 { color: red }
- *|h1 { color: green }
- h1 { color: green }
- -

The first rule will match only h1 elements in the - "http://www.example.com" namespace.

- -

The second rule will match all elements in the - "http://www.example.com" namespace.

- -

The third rule will match only h1 elements without - any declared namespace.

- -

The fourth rule will match h1 elements in any - namespace (including those without any declared namespace).

- -

The last rule is equivalent to the fourth rule because no default - namespace has been defined.

- -
- -

6.2. Universal selector

- -

The universal selector, written "asterisk" -(*), 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 Universal selector and -Namespaces below.

- -

If the universal selector is not the only component of a sequence -of simple selectors, the * may be omitted.

- -
-

Examples:

-
    -
  • *[hreflang|=en] and [hreflang|=en] are equivalent,
  • -
  • *.warning and .warning are equivalent,
  • -
  • *#myid and #myid are equivalent.
  • -
-
- -

Note: it is recommended that the -*, representing the universal selector, not be -omitted.

- -

6.2.1. Universal selector and namespaces

- -

The universal selector allows an optional namespace component. It -is used as follows:

- -
-
ns|*
-
all elements in namespace ns
-
*|*
-
all elements
-
|*
-
all elements without any declared namespace
-
*
-
if no default namespace has been specified, this is equivalent to *|*. - Otherwise it is equivalent to ns|* where ns is the default namespace.
-
- -

A universal selector containing a namespace prefix that has not -been previously declared is an invalid -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.

- - -

6.3. Attribute selectors

- -

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.

- -

6.3.1. Attribute presence and values -selectors

- -

CSS2 introduced four attribute selectors:

- -
-
[att] -
Represents an element with the att attribute, whatever the value of - the attribute.
-
[att=val]
-
Represents an element with the att attribute whose value is exactly - "val".
-
[att~=val]
-
Represents an element with the att attribute whose value is a whitespace-separated list of words, one of - which is exactly "val". If "val" contains whitespace, it will never - represent anything (since the words are separated by - spaces).
-
[att|=val] -
Represents an element with the att 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 hreflang attribute on the - link element in HTML) as described in RFC 3066 ([RFC3066]). For lang (or - xml:lang) language subcode matching, please see the :lang pseudo-class.
-
- -

Attribute values must be identifiers or strings. The -case-sensitivity of attribute names and values in selectors depends on -the document language.

- -
- -

Examples:

- -

The following attribute selector represents an h1 - element that carries the title attribute, whatever its - value:

- -
h1[title]
- -

In the following example, the selector represents a - span element whose class attribute has - exactly the value "example":

- -
span[class="example"]
- -

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 span element - whose hello attribute has exactly the value "Cleveland" - and whose goodbye attribute has exactly the value - "Columbus":

- -
span[hello="Cleveland"][goodbye="Columbus"]
- -

The following selectors illustrate the differences between "=" - and "~=". The first selector will represent, for example, the value - "copyright copyleft copyeditor" on a rel attribute. The - second selector will only represent an a element with - an href attribute having the exact value - "http://www.w3.org/".

- -
a[rel~="copyright"]
-a[href="http://www.w3.org/"]
- -

The following selector represents a link element - whose hreflang attribute is exactly "fr".

- -
link[hreflang=fr]
- -

The following selector represents a link element for - which the values of the hreflang attribute begins with - "en", including "en", "en-US", and "en-cockney":

- -
link[hreflang|="en"]
- -

Similarly, the following selectors represents a - DIALOGUE element whenever it has one of two different - values for an attribute character:

- -
DIALOGUE[character=romeo]
-DIALOGUE[character=juliet]
- -
- -

6.3.2. Substring matching attribute -selectors

- -

Three additional attribute selectors are provided for matching -substrings in the value of an attribute:

- -
-
[att^=val]
-
Represents an element with the att attribute whose value begins - with the prefix "val".
-
[att$=val] -
Represents an element with the att attribute whose value ends with - the suffix "val".
-
[att*=val] -
Represents an element with the att attribute whose value contains - at least one instance of the substring "val".
-
- -

Attribute values must be identifiers or strings. The -case-sensitivity of attribute names in selectors depends on the -document language.

- -
-

Examples:

-

The following selector represents an HTML object, referencing an - image:

-
object[type^="image/"]
-

The following selector represents an HTML anchor a with an - href attribute whose value ends with ".html".

-
a[href$=".html"]
-

The following selector represents an HTML paragraph with a title - attribute whose value contains the substring "hello"

-
p[title*="hello"]
-
- -

6.3.3. Attribute selectors and namespaces

- -

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" (|). 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 "|attr"). 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. - -

An attribute selector with an attribute name containing a namespace -prefix that has not been previously declared is an invalid 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. - -

-

CSS examples:

-
@namespace foo "http://www.example.com";
-[foo|att=val] { color: blue }
-[*|att] { color: yellow }
-[|att] { color: green }
-[att] { color: green }
- -

The first rule will match only elements with the attribute - att in the "http://www.example.com" namespace with the - value "val".

- -

The second rule will match only elements with the attribute - att regardless of the namespace of the attribute - (including no declared namespace).

- -

The last two rules are equivalent and will match only elements - with the attribute att where the attribute is not - declared to be in a namespace.

- -
- -

6.3.4. Default attribute values in DTDs

- -

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.

- -

More precisely, a UA is not required to read an "external -subset" of the DTD but is required to look for default -attribute values in the document's "internal subset." (See [XML10] for definitions of these subsets.)

- -

A UA that recognizes an XML namespace [XMLNAMES] 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.)

- -

Note: Typically, implementations -choose to ignore external subsets.

- -
-

Example:

- -

Consider an element EXAMPLE with an attribute "notation" that has a -default value of "decimal". The DTD fragment might be

- -
<!ATTLIST EXAMPLE notation (decimal,octal) "decimal">
- -

If the style sheet contains the rules

- -
EXAMPLE[notation=decimal] { /*... default property settings ...*/ }
-EXAMPLE[notation=octal]   { /*... other settings...*/ }
- -

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:

- -
EXAMPLE                   { /*... default property settings ...*/ }
-EXAMPLE[notation=octal]   { /*... other settings...*/ }
- -

Here, because the selector EXAMPLE[notation=octal] 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.

- -
- -

6.4. Class selectors

- -

Working with HTML, authors may use the period (U+002E, -.) notation as an alternative to the ~= -notation when representing the class attribute. Thus, for -HTML, div.value and div[class~=value] have -the same meaning. The attribute value must immediately follow the -"period" (.).

- -

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 [SVG] describes the SVG -"class" attribute and how a UA should interpret it, and -similarly MathML 1.01 [MATH] describes the MathML -"class" attribute.)

- -
-

CSS examples:

- -

We can assign style information to all elements with - class~="pastoral" as follows:

- -
*.pastoral { color: green }  /* all elements with class~=pastoral */
- -

or just

- -
.pastoral { color: green }  /* all elements with class~=pastoral */
- -

The following assigns style only to H1 elements with - class~="pastoral":

- -
H1.pastoral { color: green }  /* H1 elements with class~=pastoral */
- -

Given these rules, the first H1 instance below would not have - green text, while the second would:

- -
<H1>Not green</H1>
-<H1 class="pastoral">Very green</H1>
- -
- -

To represent a subset of "class" values, each value must be preceded -by a ".", in any order.

- -
- -

CSS example:

- -

The following rule matches any P element whose "class" attribute - has been assigned a list of whitespace-separated values that includes - "pastoral" and "marine":

- -
p.pastoral.marine { color: green }
- -

This rule matches when class="pastoral blue aqua - marine" but does not match for class="pastoral - blue".

- -
- -

Note: 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.

- -

Note: 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.

- -

6.5. ID selectors

- -

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.

- -

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, -#) immediately followed by the ID value, which must be an -identifier.

- -

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. - -

-

Examples:

-

The following ID selector represents an h1 element - whose ID-typed attribute has the value "chapter1":

-
h1#chapter1
-

The following ID selector represents any element whose ID-typed - attribute has the value "chapter1":

-
#chapter1
-

The following selector represents any element whose ID-typed - attribute has the value "z98y".

-
*#z98y
-
- -

Note. In XML 1.0 [XML10], 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: -[name=p371] instead of #p371. Elements in -XML 1.0 documents without a DTD do not have IDs at all.

- -

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.

- -

6.6. Pseudo-classes

- -

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.

- -

A pseudo-class always consists of a "colon" -(:) followed by the name of the pseudo-class and -optionally by a value between parentheses.

- -

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.

- - -

6.6.1. Dynamic pseudo-classes

- -

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.

- -

Dynamic pseudo-classes do not appear in the document source or -document tree.

- - -
The link pseudo-classes: :link and :visited
- -

User agents commonly display unvisited links differently from -previously visited ones. Selectors -provides the pseudo-classes :link and -:visited to distinguish them:

- -
    -
  • The :link pseudo-class applies to links that have - not yet been visited.
  • -
  • The :visited pseudo-class applies once the link has - been visited by the user.
  • -
- -

After some amount of time, user agents may choose to return a -visited link to the (unvisited) ':link' state.

- -

The two states are mutually exclusive.

- -
- -

Example:

- -

The following selector represents links carrying class - external and already visited:

- -
a.external:visited
- -
- -

Note: 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. - -

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.

- -
The user action pseudo-classes -:hover, :active, and :focus
- -

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.

- -
    - -
  • The :hover 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 interactive - media do not have to support this pseudo-class. Some conforming - user agents that support interactive - media may not be able to support this pseudo-class (e.g., a pen - device that does not detect hovering).
  • - -
  • The :active 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.
  • - -
  • The :focus pseudo-class applies while an element - has the focus (accepts keyboard or mouse events, or other forms of - input).
  • - -
- -

There may be document language or implementation specific limits on -which elements can become :active or acquire -:focus.

- -

These pseudo-classes are not mutually exclusive. An element may -match several pseudo-classes at the same time.

- -

Selectors doesn't define if the parent of an element that is -':active' or ':hover' is also in that state.

- -
-

Examples:

-
a:link    /* unvisited links */
-a:visited /* visited links */
-a:hover   /* user hovers */
-a:active  /* active links */
-

An example of combining dynamic pseudo-classes:

-
a:focus
-a:focus:hover
-

The last selector matches a elements that are in - the pseudo-class :focus and in the pseudo-class :hover.

-
- -

Note: An element can be both ':visited' -and ':active' (or ':link' and ':active').

- -

6.6.2. The target pseudo-class :target

- -

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).

- -

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 section_2 in an HTML -document:

- -
http://example.com/html/top.html#section_2
- -

A target element can be represented by the :target -pseudo-class. If the document's URI has no fragment identifier, then -the document has no target element.

- -
-

Example:

-
p.note:target
-

This selector represents a p element of class - note that is the target element of the referring - URI.

-
- -
-

CSS example:

-

Here, the :target pseudo-class is used to make the - target element red and place an image before it, if there is one:

-
*:target { color : red }
-*:target::before { content : url(target.png) }
-
- -

6.6.3. The language pseudo-class :lang

- -

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 [HTML4], the language is determined by a -combination of the lang attribute, the meta -element, and possibly by information from the protocol (such as HTTP -headers). XML uses an attribute called xml:lang, and -there may be other document language-specific methods for determining -the language.

- -

The pseudo-class :lang(C) represents an element that -is in language C. Whether an element is represented by a -:lang() 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 '|=' operator in attribute -selectors. The identifier C does not have to be a valid language -name.

- -

C must not be empty. (If it is, the selector is invalid.)

- -

Note: It is recommended that -documents and protocols indicate language using codes from RFC 3066 [RFC3066] or its successor, and by means of -"xml:lang" attributes in the case of XML-based documents [XML10]. See -"FAQ: Two-letter or three-letter language codes."

- -
-

Examples:

-

The two following selectors represent an HTML document that is in - Belgian, French, or German. The two next selectors represent - q quotations in an arbitrary element in Belgian, French, - or German.

-
html:lang(fr-be)
-html:lang(de)
-:lang(fr-be) > q
-:lang(de) > q
-
- -

6.6.4. The UI element states pseudo-classes

- -
The :enabled and :disabled pseudo-classes
- -

The :enabled 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 input element without also specifying what it -would look like when it was disabled.

- -

Similar to :enabled, :disabled allows the -author to specify precisely how a disabled or inactive user interface -element should look.

- -

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.

- - -
The :checked pseudo-class
- -

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 :checked pseudo-class applies. The -:checked pseudo-class initially applies to such elements -that have the HTML4 selected and checked -attributes as described in Section -17.2.1 of HTML4, but of course the user can toggle "off" such -elements in which case the :checked pseudo-class would no -longer apply. While the :checked 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 selected and -checked attributes, it applies to all media. - - -

The :indeterminate pseudo-class
- -
- -

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.

- -

A future version of this specification may introduce an -:indeterminate pseudo-class that applies to such elements. -

- -
- - -

6.6.5. Structural pseudo-classes

- -

Selectors introduces the concept of structural -pseudo-classes to permit selection based on extra information that lies in -the document tree but cannot be represented by other simple selectors or -combinators. - -

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. - - -

:root pseudo-class
- -

The :root pseudo-class represents an element that is -the root of the document. In HTML 4, this is always the -HTML element. - - -

:nth-child() pseudo-class
- -

The -:nth-child(an+b) -pseudo-class notation represents an element that has -an+b-1 siblings -before it in the document tree, for a given positive -integer or zero value of n, and has a parent element. In -other words, this matches the bth child of an element after -all the children have been split into groups of a 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 a and -b values must be zero, negative integers or positive -integers. The index of the first child of an element is 1. - -

In addition to this, :nth-child() can take -'odd' and 'even' as arguments instead. -'odd' has the same signification as 2n+1, -and 'even' has the same signification as 2n. - - -

-

Examples:

-
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; }
-
- -

When a=0, no repeating is used, so for example -:nth-child(0n+5) matches only the fifth child. When -a=0, the an part need not be -included, so the syntax simplifies to -:nth-child(b) and the last example simplifies -to :nth-child(5). - -

-

Examples:

-
foo:nth-child(0n+1)   /* represents an element foo, first child of its parent element */
-foo:nth-child(1)      /* same */
-
- -

When a=1, the number may be omitted from the rule. - -

-

Examples:

-

The following selectors are therefore equivalent:

-
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) */
-
- -

If b=0, then every ath element is picked. In -such a case, the b part may be omitted. - -

-

Examples:

-
tr:nth-child(2n+0) /* represents every even row of an HTML table */
-tr:nth-child(2n) /* same */
-
- -

If both a and b are equal to zero, the -pseudo-class represents no element in the document tree.

- -

The value a can be negative, but only the positive -values of an+b, for -n≥0, may represent an element in the document -tree.

- -
-

Example:

-
html|tr:nth-child(-n+6)  /* represents the 6 first rows of XHTML tables */
-
- -

When the value b is negative, the "+" character in the -expression must be removed (it is effectively replaced by the "-" -character indicating the negative value of b).

- -
-

Examples:

-
: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 */
-
- - -
:nth-last-child() pseudo-class
- -

The :nth-last-child(an+b) -pseudo-class notation represents an element that has -an+b-1 siblings -after it in the document tree, for a given positive -integer or zero value of n, and has a parent element. See -:nth-child() pseudo-class for the syntax of its argument. -It also accepts the 'even' and 'odd' values -as arguments. - - -

-

Examples:

-
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 */
-
- - -
:nth-of-type() pseudo-class
- -

The :nth-of-type(an+b) -pseudo-class notation represents an element that has -an+b-1 siblings with the same -element name before it in the document tree, for a -given zero or positive integer value of n, and has a -parent element. In other words, this matches the bth child -of that type after all the children of that type have been split into -groups of a elements each. See :nth-child() pseudo-class -for the syntax of its argument. It also accepts the -'even' and 'odd' values. - - -

-

CSS example:

-

This allows an author to alternate the position of floated images:

-
img:nth-of-type(2n+1) { float: right; }
-img:nth-of-type(2n) { float: left; }
-
- - -
:nth-last-of-type() pseudo-class
- -

The :nth-last-of-type(an+b) -pseudo-class notation represents an element that has -an+b-1 siblings with the same -element name after it in the document tree, for a -given zero or positive integer value of n, and has a -parent element. See :nth-child() pseudo-class for the -syntax of its argument. It also accepts the 'even' and 'odd' values. - - -

-

Example:

-

To represent all h2 children of an XHTML - body except the first and last, one could use the - following selector:

-
body > h2:nth-of-type(n+2):nth-last-of-type(n+2)
-

In this case, one could also use :not(), although the - selector ends up being just as long:

-
body > h2:not(:first-of-type):not(:last-of-type)
-
- - -
:first-child pseudo-class
- -

Same as :nth-child(1). The :first-child pseudo-class -represents an element that is the first child of some other element. - - -

-

Examples:

-

The following selector represents a p element that is - the first child of a div element:

-
div > p:first-child
-

This selector can represent the p inside the - div of the following fragment:

-
<p> The last P before the note.</p>
-<div class="note">
-   <p> The first P inside the note.</p>
-</div>
but cannot represent the second p in the following -fragment: -
<p> The last P before the note.</p>
-<div class="note">
-   <h2> Note </h2>
-   <p> The first P inside the note.</p>
-</div>
-

The following two selectors are usually equivalent:

-
* > a:first-child /* a is first child of any element */
-a:first-child /* Same (assuming a is not the root element) */
-
- -
:last-child pseudo-class
- -

Same as :nth-last-child(1). The :last-child pseudo-class -represents an element that is the last child of some other element. - -

-

Example:

-

The following selector represents a list item li that - is the last child of an ordered list ol. -

ol > li:last-child
-
- -
:first-of-type pseudo-class
- -

Same as :nth-of-type(1). The :first-of-type pseudo-class -represents an element that is the first sibling of its type in the list of -children of its parent element. - -

-

Example:

-

The following selector represents a definition title -dt inside a definition list dl, this -dt being the first of its type in the list of children of -its parent element.

-
dl dt:first-of-type
-

It is a valid description for the first two dt -elements in the following example but not for the third one:

-
<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>
-
- -
:last-of-type pseudo-class
- -

Same as :nth-last-of-type(1). The -:last-of-type pseudo-class represents an element that is -the last sibling of its type in the list of children of its parent -element.

- -
-

Example:

-

The following selector represents the last data cell - td of a table row.

-
tr > td:last-of-type
-
- -
:only-child pseudo-class
- -

Represents an element that has a parent element and whose parent -element has no other element children. Same as -:first-child:last-child or -:nth-child(1):nth-last-child(1), but with a lower -specificity.

- -
:only-of-type pseudo-class
- -

Represents an element that has a parent element and whose parent -element has no other element children with the same element name. Same -as :first-of-type:last-of-type or -:nth-of-type(1):nth-last-of-type(1), but with a lower -specificity.

- - -
:empty pseudo-class
- -

The :empty 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.

- -
-

Examples:

-

p:empty is a valid representation of the following fragment:

-
<p></p>
-

foo:empty is not a valid representation for the - following fragments:

-
<foo>bar</foo>
-
<foo><bar>bla</bar></foo>
-
<foo>this is not <bar>:empty</bar></foo>
-
- -

6.6.6. Blank

- -

This section intentionally left blank.

- - -

6.6.7. The negation pseudo-class

- -

The negation pseudo-class, :not(X), is a -functional notation taking a simple -selector (excluding the negation pseudo-class itself and -pseudo-elements) as an argument. It represents an element that is not -represented by the argument. - - - -

-

Examples:

-

The following CSS selector matches all button - elements in an HTML document that are not disabled.

-
button:not([DISABLED])
-

The following selector represents all but FOO - elements.

-
*:not(FOO)
-

The following group of selectors represents all HTML elements - except links.

-
html|*:not(:link):not(:visited)
-
- -

Default namespace declarations do not affect the argument of the -negation pseudo-class unless the argument is a universal selector or a -type selector.

- -
-

Examples:

-

Assuming that the default namespace is bound to - "http://example.com/", the following selector represents all - elements that are not in that namespace:

-
*|*:not(*)
-

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 are being hovered.

-
*|*:not(:hover)
-
- -

Note: the :not() pseudo allows -useless selectors to be written. For instance :not(*|*), -which represents no element at all, or foo:not(bar), -which is equivalent to foo but with a higher -specificity.

- -

7. Pseudo-elements

- -

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 ::before and -::after pseudo-elements give access to generated -content).

- -

A pseudo-element is made of two colons (::) followed -by the name of the pseudo-element.

- -

This :: 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, -:first-line, :first-letter, -:before and :after). This compatibility is -not allowed for the new pseudo-elements introduced in CSS level 3.

- -

Only one pseudo-element may appear per selector, and if present it -must appear after the sequence of simple selectors that represents the -subjects of the selector. A -future version of this specification may allow multiple -pesudo-elements per selector.

- -

7.1. The ::first-line pseudo-element

- -

The ::first-line pseudo-element describes the contents -of the first formatted line of an element. - -

-

CSS example:

-
p::first-line { text-transform: uppercase }
-

The above rule means "change the letters of the first line of every -paragraph to uppercase".

-
- -

The selector p::first-line 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.

- -

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>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>
-
- -

the lines of which happen to be broken as follows: - -

-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.
-
- -

This paragraph might be "rewritten" by user agents to include the -fictional tag sequence for ::first-line. This -fictional tag sequence helps to show how properties are inherited.

- -
-<P><P::first-line> This is a somewhat long HTML 
-paragraph that </P::first-line> 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>
-
- -

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 span element:

- -
-<P><SPAN class="test"> This is a somewhat long HTML
-paragraph that will be broken into several
-lines.</SPAN> The first line will be identified
-by a fictional tag sequence. The other lines 
-will be treated as ordinary lines in the 
-paragraph.</P>
-
- -

the user agent could simulate start and end tags for -span when inserting the fictional tag sequence for -::first-line. - -

-<P><P::first-line><SPAN class="test"> This is a
-somewhat long HTML
-paragraph that will </SPAN></P::first-line><SPAN class="test"> be
-broken into several
-lines.</SPAN> The first line will be identified
-by a fictional tag sequence. The other lines
-will be treated as ordinary lines in the 
-paragraph.</P>
-
- -

In CSS, the ::first-line pseudo-element can only be -attached to a block-level element, an inline-block, a table-caption, -or a table-cell.

- -

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 div in <DIV><P>This -line...</P></DIV> is the first line of the p (assuming -that both p and div are block-level). - -

The first line of a table-cell or inline-block cannot be the first -formatted line of an ancestor element. Thus, in <DIV><P -STYLE="display: inline-block">Hello<BR>Goodbye</P> -etcetera</DIV> the first formatted line of the -div is not the line "Hello". - -

Note that the first line of the p in this -fragment: <p><br>First... doesn't contain any -letters (assuming the default style for br in HTML -4). The word "First" is not on the first formatted line. - -

A UA should act as if the fictional start tags of the -::first-line 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

- -
-<DIV>
-  <P>First paragraph</P>
-  <P>Second paragraph</P>
-</DIV>
-
- -

is

- -
-<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>
-
- -

The ::first-line pseudo-element is similar to an -inline-level element, but with certain restrictions. In CSS, the -following properties apply to a ::first-line -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.

- - -

7.2. The ::first-letter pseudo-element

- -

The ::first-letter 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.

- -

In CSS, these are the properties that apply to ::first-letter -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.

- -
-

Example:

-

This example shows a possible rendering of an initial cap. Note -that the 'line-height' that is inherited by the ::first-letter -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, and thus -the font weight of the first letter is normal, not bold as the span: -

-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.
-
-
-

Image illustrating the ::first-letter pseudo-element -

-
- -
-

The following CSS will make a drop cap initial letter span about two lines:

- -
-<!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>
-
- -

This example might be formatted as follows:

- -
-

Image illustrating the combined effect of the ::first-letter and ::first-line pseudo-elements

-
- -

The fictional tag sequence is:

- -
-<P>
-<SPAN>
-<P::first-letter>
-T
-</P::first-letter>he first
-</SPAN> 
-few words of an article in the Economist.
-</P>
-
- -

Note that the ::first-letter 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.

- -

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.

- -

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. [UNICODE]

- -
-

Quotes that precede the
-first letter should be included.

-
- -

The ::first-letter also applies if the first letter is -in fact a digit, e.g., the "6" in "67 million dollars is a lot of -money."

- -

In CSS, the ::first-letter pseudo-element applies to -block, list-item, table-cell, table-caption, and inline-block -elements. A future version of this specification -may allow this pesudo-element to apply to more element -types.

- -

The ::first-letter 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.

- -
-

Example:

-

The fictional tag sequence for this HTMLfragment: -

<div>
-<p>The first text.
-

is: -

<div>
-<p><div::first-letter><p::first-letter>T</...></...>he first text.
-
- -

The first letter of a table-cell or inline-block cannot be the -first letter of an ancestor element. Thus, in <DIV><P -STYLE="display: inline-block">Hello<BR>Goodbye</P> -etcetera</DIV> the first letter of the div is not the -letter "H". In fact, the div doesn't have a first letter. - -

The first letter must occur on the first formatted line. For example, in -this fragment: <p><br>First... the first line -doesn't contain any letters and ::first-letter doesn't -match anything (assuming the default style for br in HTML -4). In particular, it does not match the "F" of "First." - -

In CSS, if an element is a list item ('display: list-item'), the -::first-letter applies to the first letter in the -principal box after the marker. UAs may ignore -::first-letter on list items with 'list-style-position: -inside'. If an element has ::before or -::after content, the ::first-letter applies -to the first letter of the element including that content. - -

-

Example:

-

After the rule 'p::before {content: "Note: "}', the selector -'p::first-letter' matches the "N" of "Note".

-
- -

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 ::first-letter pseudo-element. - -

If the letters that would form the ::first-letter are not in the -same element, such as "'T" in <p>'<em>T..., the UA -may create a ::first-letter pseudo-element from one of the elements, -both elements, or simply not create a pseudo-element.

- -

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). - -

-

Example:

-

The following example 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 { 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>
- -

Assuming that a line break will occur before the word "ends", the -fictional tag -sequence for this fragment might be:

- -
<P>
-<P::first-line>
-<P::first-letter> 
-S 
-</P::first-letter>ome text that 
-</P::first-line> 
-ends up on two lines 
-</P>
- -

Note that the ::first-letter element is inside the ::first-line -element. Properties set on ::first-line are inherited by -::first-letter, but are overridden if the same property is set on -::first-letter.

-
- - -

7.3. The ::selection pseudo-element

- -

The ::selection 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 :checked pseudo-class (which used to be -named :selected) - -

Although the ::selection 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 -[CSS21]) which was originally rendered to a -dynamic medium (like screen), the UA may wish to transfer the current -::selection 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 ::selection -pseudo-element for static media. - -

These are the CSS properties that apply to ::selection -pseudo-elements: color, background, cursor (optional), outline -(optional). The computed value of the 'background-image' property on -::selection may be ignored. - - -

7.4. The ::before and ::after pseudo-elements

- -

The ::before and ::after pseudo-elements -can be used to describe generated content before or after an element's -content. They are explained in CSS 2.1 [CSS21].

- -

When the ::first-letter and ::first-line -pseudo-elements are combined with ::before and -::after, they apply to the first letter or line of the -element including the inserted text.

- -

8. Combinators

- -

8.1. Descendant combinator

- -

At times, authors may want selectors to describe an element that is -the descendant of another element in the document tree (e.g., "an -EM element that is contained within an H1 -element"). Descendant combinators express such a relationship. A -descendant combinator is white space that -separates two sequences of simple selectors. A selector of the form -"A B" represents an element B that is an -arbitrary descendant of some ancestor element A. - -

-

Examples:

-

For example, consider the following selector:

-
h1 em
-

It represents an em element being the descendant of - an h1 element. It is a correct and valid, but partial, - description of the following fragment:

-
<h1>This <span class="myclass">headline
-is <em>very</em> important</span></h1>
-

The following selector:

-
div * p
-

represents a p element that is a grandchild or later - descendant of a div 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.

-

The following selector, which combines descendant combinators and - attribute selectors, represents an - element that (1) has the href attribute set and (2) is - inside a p that is itself inside a div:

-
div p *[href]
-
- -

8.2. Child combinators

- -

A child combinator describes a childhood relationship -between two elements. A child combinator is made of the -"greater-than sign" (>) character and -separates two sequences of simple selectors. - - -

-

Examples:

-

The following selector represents a p element that is - child of body:

-
body > p
-

The following example combines descendant combinators and child - combinators.

-
div ol>li p
-

It represents a p element that is a descendant of an - li element; the li element must be the - child of an ol element; the ol element must - be a descendant of a div. Notice that the optional white - space around the ">" combinator has been left out.

-
- -

For information on selecting the first child of an element, please -see the section on the :first-child pseudo-class -above.

- -

8.3. Sibling combinators

- -

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.

- -

8.3.1. Adjacent sibling combinator

- -

The adjacent sibling combinator is made of the "plus -sign" (U+002B, +) 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.

- -
-

Examples:

-

The following selector represents a p element - immediately following a math element:

-
math + 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 h1 element, that it must have - class="opener":

-
h1.opener + h2
-
- - -

8.3.2. General sibling combinator

- -

The general sibling combinator is made of the "tilde" -(U+007E, ~) 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.

- -
-

Example:

-
h1 ~ pre
-

represents a pre element following an h1. It - is a correct and valid, but partial, description of:

-
<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>
-
- -

9. Calculating a selector's specificity

- -

A selector's specificity is calculated as follows:

- -
    -
  • count the number of ID selectors in the selector (= a)
  • -
  • count the number of class selectors, attributes selectors, and pseudo-classes in the selector (= b)
  • -
  • count the number of element names in the selector (= c)
  • -
  • ignore pseudo-elements
  • -
- -

Selectors inside the negation pseudo-class -are counted like any other, but the negation itself does not count as -a pseudo-class.

- -

Concatenating the three numbers a-b-c (in a number system with a -large base) gives the specificity.

- -
-

Examples:

-
*               /* 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 */
-
-
- -

Note: the specificity of the styles -specified in an HTML style attribute is described in CSS -2.1. [CSS21].

- -

10. The grammar of Selectors

- -

10.1. Grammar

- -

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 [YACC]) -are used:

- -
    -
  • *: 0 or more -
  • +: 1 or more -
  • ?: 0 or 1 -
  • |: separates alternatives -
  • [ ]: grouping
  • -
- -

The productions are:

- -
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
-  ;
- - -

10.2. Lexical scanner

- -

The following is the tokenizer, written in Flex (see -[FLEX]) notation. The tokenizer is -case-insensitive.

- -

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. [UNICODE]

- -
%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;
- - - -

11. Namespaces and down-level clients

- -

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.

- -

It should be noted that a down-level CSS client will (if it -properly conforms to CSS forward compatible parsing rules) ignore all -@namespace 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.

- -

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.

- -

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.

- -
    -
  1. - -

    The XML document does not use namespaces.

    - -
      - -
    • 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.
    • - -
    • 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 ("|name") - will guarantee that selectors will match only XML elements that do - not have a declared namespace.
    • - -
    - -
  2. - -
  3. - -

    The XML document defines a single, default namespace used - throughout the document. No namespace prefixes are used in element - names.

    - -
      - -
    • 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.
    • - -
    - -
  4. - -
  5. - -

    The XML document does not 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).

    - -
      - -
    • 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 Type selectors and Namespaces section. CSS - selectors may be declared using an escaped colon "\:" - to describe the fully qualified names, e.g. - "html\:h1" will match - <html:h1>. 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.
    • - -
    • Note that selectors declared in this fashion will - only 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).
    • - -
    - -
  6. - -
- -

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 -different 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.

- -

12. Profiles

- -

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.

- -

Non normative examples: - -

- - - - - - - - - - - - - - - -
Selectors profile
SpecificationCSS level 1
Acceptstype selectors
class selectors
ID selectors
:link, - :visited and :active pseudo-classes
descendant combinator -
::first-line and ::first-letter pseudo-elements
Excludes - -

universal selector
attribute selectors
:hover and :focus - pseudo-classes
:target pseudo-class
:lang() pseudo-class
all UI - element states pseudo-classes
all structural - pseudo-classes
negation pseudo-class
all - UI element fragments pseudo-elements
::before and ::after - pseudo-elements
child combinators
sibling combinators - -

namespaces

Extra constraintsonly one class selector allowed per sequence of simple - selectors


- - - - - - - - - - - - - - - -
Selectors profile
SpecificationCSS level 2
Acceptstype selectors
universal selector
attribute presence and - values selectors
class selectors
ID selectors
:link, :visited, - :active, :hover, :focus, :lang() and :first-child pseudo-classes -
descendant combinator
child combinator
adjacent sibling - combinator
::first-line and ::first-letter pseudo-elements
::before - and ::after pseudo-elements
Excludes - -

content selectors
substring matching attribute - selectors
:target pseudo-classes
all UI element - states pseudo-classes
all structural pseudo-classes other - than :first-child
negation pseudo-class
all UI element - fragments pseudo-elements
general sibling combinators - -

namespaces

Extra constraintsmore than one class selector per sequence of simple selectors (CSS1 - constraint) allowed
- -

In CSS, selectors express pattern matching rules that determine which style -rules apply to elements in the document tree. - -

The following selector (CSS level 2) will match all anchors a -with attribute name set inside a section 1 header h1: -

h1 a[name]
- -

All CSS declarations attached to such a selector are applied to elements -matching it.

- -
- - - - - - - - - - - - - - - - -
Selectors profile
SpecificationSTTS 3
Accepts - -

type selectors
universal selectors
attribute selectors
class - selectors
ID selectors
all structural pseudo-classes
- all combinators - -

namespaces

Excludesnon-accepted pseudo-classes
pseudo-elements
Extra constraintssome selectors and combinators are not allowed in fragment - descriptions on the right side of STTS declarations.
-
- - - - - - - - - - - - - - - - - - - - - - - - - -
- -

Selectors can be used in STTS 3 in two different - manners: -

    -
  1. a selection mechanism equivalent to CSS selection mechanism: declarations - attached to a given selector are applied to elements matching that selector, -
  2. fragment descriptions that appear on the right side of declarations. -
- -

13. Conformance and requirements

- -

This section defines conformance with the present specification only. - -

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. - -

All specifications reusing Selectors must contain a Profile listing the -subset of Selectors it accepts or excludes, and describing the constraints -it adds to the current specification. - -

Invalidity is caused by a parsing error, e.g. an unrecognized token or a token -which is not allowed at the current parsing point. - -

User agents must observe the rules for handling parsing errors: -

    -
  • a simple selector containing an undeclared namespace prefix is invalid
  • -
  • a selector containing an invalid simple selector, an invalid combinator - or an invalid token is invalid.
  • -
  • a group of selectors containing an invalid selector is invalid.
  • -
- -

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.)

- - - -

14. Tests

- -

This specification has a test -suite 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.

- -

15. Acknowledgements

- -

The CSS working group would like to thank everyone who has sent -comments on this specification over the years.

- -

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.

- -

16. References

- -
- -
[CSS1] -
Bert Bos, Håkon Wium Lie; "Cascading Style Sheets, level 1", W3C Recommendation, 17 Dec 1996, revised 11 Jan 1999 -
(http://www.w3.org/TR/REC-CSS1) - -
[CSS21] -
Bert Bos, Tantek Çelik, Ian Hickson, Håkon Wium Lie, editors; "Cascading Style Sheets, level 2 revision 1", W3C Working Draft, 13 June 2005 -
(http://www.w3.org/TR/CSS21) - -
[CWWW] -
Martin J. Dürst, François Yergeau, Misha Wolf, Asmus Freytag, Tex Texin, editors; "Character Model for the World Wide Web", W3C Recommendation, 15 February 2005 -
(http://www.w3.org/TR/charmod/) - -
[FLEX] -
"Flex: The Lexical Scanner Generator", Version 2.3.7, ISBN 1882114213 - -
[HTML4] -
Dave Ragget, Arnaud Le Hors, Ian Jacobs, editors; "HTML 4.01 Specification", W3C Recommendation, 24 December 1999 -
(http://www.w3.org/TR/html4/) - -
[MATH] -
Patrick Ion, Robert Miner, editors; "Mathematical Markup Language (MathML) 1.01", W3C Recommendation, revision of 7 July 1999 -
(http://www.w3.org/TR/REC-MathML/) - -
[RFC3066] -
H. Alvestrand; "Tags for the Identification of Languages", Request for Comments 3066, January 2001 -
(http://www.ietf.org/rfc/rfc3066.txt) - -
[STTS] -
Daniel Glazman; "Simple Tree Transformation Sheets 3", Electricité de France, submission to the W3C, 11 November 1998 -
(http://www.w3.org/TR/NOTE-STTS3) - -
[SVG] -
Jon Ferraiolo, 藤沢 淳, Dean Jackson, editors; "Scalable Vector Graphics (SVG) 1.1 Specification", W3C Recommendation, 14 January 2003 -
(http://www.w3.org/TR/SVG/) - -
[UNICODE]
-
The Unicode Standard, Version 4.1, The Unicode Consortium. Boston, MA, Addison-Wesley, March 2005. ISBN 0-321-18578-1, as amended by Unicode 4.0.1 and Unicode 4.1.0. -
(http://www.unicode.org/versions/)
- -
[XML10] -
Tim Bray, Jean Paoli, C. M. Sperberg-McQueen, Eve Maler, François Yergeau, editors; "Extensible Markup Language (XML) 1.0 (Third Edition)", W3C Recommendation, 4 February 2004 -
(http://www.w3.org/TR/REC-xml/) - -
[XMLNAMES] -
Tim Bray, Dave Hollander, Andrew Layman, editors; "Namespaces in XML", W3C Recommendation, 14 January 1999 -
(http://www.w3.org/TR/REC-xml-names/) - -
[YACC] -
S. C. Johnson; "YACC — Yet another compiler compiler", Technical Report, Murray Hill, 1975 - -
- - diff --git a/samples/third_party/dromaeo/web/tests/dom-query.html b/samples/third_party/dromaeo/web/tests/dom-query.html deleted file mode 100644 index 07acf16cbb3..00000000000 --- a/samples/third_party/dromaeo/web/tests/dom-query.html +++ /dev/null @@ -1,3000 +0,0 @@ - - - - - - -
-

W3C - -

Selectors

- -

W3C Working Draft 15 December 2005

- -
- -
This version: - -
- http://www.w3.org/TR/2005/WD-css3-selectors-20051215 - -
Latest version: - -
- http://www.w3.org/TR/css3-selectors - -
Previous version: - -
- http://www.w3.org/TR/2001/CR-css3-selectors-20011113 - -
Editors: - -
Daniel Glazman (Invited Expert)
- -
Tantek Çelik (Invited Expert) - -
Ian Hickson (Google) - -
Peter Linss (former editor, Netscape/AOL) - -
John Williams (former editor, Quark, Inc.) - -
- -
- -
- -

Abstract

- -

Selectors 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.

- -

CSS (Cascading - Style Sheets) is a language for describing the rendering of HTML and XML 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. - -

Selectors define the following function:

- -
expression ∗ element → boolean
- -

That is, given an element and a selector, this specification - defines whether that element matches the selector.

- -

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. STTS (Simple Tree Transformation Sheets), a - language for transforming XML trees, uses this mechanism. [STTS]

- -

Status of this document

- -

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 W3C technical reports index at - http://www.w3.org/TR/.

- -

This document describes the selectors that already exist in CSS1 and CSS2, and - also proposes new selectors for CSS3 and other languages that may need them.

- -

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.

- -

This specification is a last call working draft for the the CSS Working Group - (Style Activity). This - document is a revision of the Candidate - Recommendation dated 2001 November 13, 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.

- -

All persons are encouraged to review and implement this - specification and return comments to the (archived) - public mailing list www-style - (see instructions). W3C - Members can also send comments directly to the CSS Working - Group. - The deadline for comments is 14 January 2006.

- -

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". - -

This document may be available in translation. - The English version of this specification is the only normative - version. - -

- -

Table of contents

- - - -
- -

1. Introduction

- -

1.1. Dependencies

- -

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. [CSS21]

- -

1.2. Terminology

- -

All of the text of this specification is normative except - examples, notes, and sections explicitly marked as - non-normative.

- -

1.3. Changes from CSS2

- -

This section is non-normative.

- -

The main differences between the selectors in CSS2 and those in - Selectors are: - -

    - -
  • 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
  • - -
  • an optional namespace component is now allowed in type element - selectors, the universal selector and attribute selectors
  • - -
  • a new combinator has been introduced
  • - -
  • new simple selectors including substring matching attribute - selectors, and new pseudo-classes
  • - -
  • new pseudo-elements, and introduction of the "::" convention - for pseudo-elements
  • - -
  • the grammar has been rewritten
  • - -
  • profiles to be added to specifications integrating Selectors - and defining the set of selectors which is actually supported by - each specification
  • - -
  • Selectors are now a CSS3 Module and an independent - specification; other specifications can now refer to this document - independently of CSS
  • - -
  • the specification now has its own test suite
  • - -
- -

2. Selectors

- -

This section is non-normative, as it merely summarizes the -following sections.

- -

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.

- -

Selectors may range from simple element names to rich contextual -representations.

- -

The following table summarizes the Selector syntax:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PatternMeaningDescribed in sectionFirst defined in CSS level
*any elementUniversal - selector2
Ean element of type EType selector1
E[foo]an E element with a "foo" attributeAttribute - selectors2
E[foo="bar"]an E element whose "foo" attribute value is exactly - equal to "bar"Attribute - selectors2
E[foo~="bar"]an E element whose "foo" attribute value is a list of - space-separated values, one of which is exactly equal to "bar"Attribute - selectors2
E[foo^="bar"]an E element whose "foo" attribute value begins exactly - with the string "bar"Attribute - selectors3
E[foo$="bar"]an E element whose "foo" attribute value ends exactly - with the string "bar"Attribute - selectors3
E[foo*="bar"]an E element whose "foo" attribute value contains the - substring "bar"Attribute - selectors3
E[hreflang|="en"]an E element whose "hreflang" attribute has a hyphen-separated - list of values beginning (from the left) with "en"Attribute - selectors2
E:rootan E element, root of the documentStructural - pseudo-classes3
E:nth-child(n)an E element, the n-th child of its parentStructural - pseudo-classes3
E:nth-last-child(n)an E element, the n-th child of its parent, counting - from the last oneStructural - pseudo-classes3
E:nth-of-type(n)an E element, the n-th sibling of its typeStructural - pseudo-classes3
E:nth-last-of-type(n)an E element, the n-th sibling of its type, counting - from the last oneStructural - pseudo-classes3
E:first-childan E element, first child of its parentStructural - pseudo-classes2
E:last-childan E element, last child of its parentStructural - pseudo-classes3
E:first-of-typean E element, first sibling of its typeStructural - pseudo-classes3
E:last-of-typean E element, last sibling of its typeStructural - pseudo-classes3
E:only-childan E element, only child of its parentStructural - pseudo-classes3
E:only-of-typean E element, only sibling of its typeStructural - pseudo-classes3
E:emptyan E element that has no children (including text - nodes)Structural - pseudo-classes3
E:link
E:visited
an E element being the source anchor of a hyperlink of - which the target is not yet visited (:link) or already visited - (:visited)The link - pseudo-classes1
E:active
E:hover
E:focus
an E element during certain user actionsThe user - action pseudo-classes1 and 2
E:targetan E element being the target of the referring URIThe target - pseudo-class3
E:lang(fr)an element of type E in language "fr" (the document - language specifies how language is determined)The :lang() - pseudo-class2
E:enabled
E:disabled
a user interface element E which is enabled or - disabledThe UI element states - pseudo-classes3
E:checkeda user interface element E which is checked (for instance a radio-button or checkbox)The UI element states - pseudo-classes3
E::first-linethe first formatted line of an E elementThe ::first-line - pseudo-element1
E::first-letterthe first formatted letter of an E elementThe ::first-letter - pseudo-element1
E::selectionthe portion of an E element that is currently - selected/highlighted by the userThe UI element - fragments pseudo-elements3
E::beforegenerated content before an E elementThe ::before - pseudo-element2
E::aftergenerated content after an E elementThe ::after - pseudo-element2
E.warningan E element whose class is -"warning" (the document language specifies how class is determined).Class - selectors1
E#myidan E element with ID equal to "myid".ID - selectors1
E:not(s)an E element that does not match simple selector sNegation - pseudo-class3
E Fan F element descendant of an E elementDescendant - combinator1
E > Fan F element child of an E elementChild - combinator2
E + Fan F element immediately preceded by an E elementAdjacent sibling combinator2
E ~ Fan F element preceded by an E elementGeneral sibling combinator3
- -

The meaning of each selector is derived from the table above by -prepending "matches" to the contents of each cell in the "Meaning" -column.

- -

3. Case sensitivity

- -

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.

- -

4. Selector syntax

- -

A selector is a chain of one -or more sequences of simple selectors -separated by combinators.

- -

A sequence of simple selectors -is a chain of simple selectors -that are not separated by a combinator. It -always begins with a type selector or a -universal selector. No other type -selector or universal selector is allowed in the sequence.

- -

A simple selector is either a type selector, universal selector, attribute selector, class selector, ID selector, content selector, or pseudo-class. One pseudo-element may be appended to the last -sequence of simple selectors.

- -

Combinators are: white space, "greater-than -sign" (U+003E, >), "plus sign" (U+002B, -+) and "tilde" (U+007E, ~). White -space may appear between a combinator and the simple selectors around -it. 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.

- -

The elements of a document tree that are represented by a selector -are the subjects of the selector. 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.

- -

An empty selector, containing no sequence of simple selectors and -no pseudo-element, is an invalid -selector.

- -

5. Groups of selectors

- -

When several selectors share the same declarations, they may be -grouped into a comma-separated list. (A comma is U+002C.)

- -
-

CSS examples:

-

In this example, we condense three rules with identical -declarations into one. Thus,

-
h1 { font-family: sans-serif }
-h2 { font-family: sans-serif }
-h3 { font-family: sans-serif }
-

is equivalent to:

-
h1, h2, h3 { font-family: sans-serif }
-
- -

Warning: 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.

- - -

6. Simple selectors

- -

6.1. Type selector

- -

A type selector is the name of a document language -element type. A type selector represents an instance of the element -type in the document tree.

- -
-

Example:

-

The following selector represents an h1 element in the document tree:

-
h1
-
- - -

6.1.1. Type selectors and namespaces

- -

Type selectors allow an optional namespace ([XMLNAMES]) 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, |).

- -

The namespace component may be left empty to indicate that the -selector is only to represent elements with no declared namespace.

- -

An asterisk may be used for the namespace prefix, indicating that -the selector represents elements in any namespace (including elements -with no namespace).

- -

Element type selectors that have no namespace component (no -namespace separator), represent elements without regard to the -element's namespace (equivalent to "*|") unless a default -namespace has been declared. If a default namespace has been declared, -the selector will represent only elements in the default -namespace.

- -

A type selector containing a namespace prefix that has not been -previously declared is an invalid 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.

- -

In a namespace-aware client, element type selectors will only match -against the local part -of the element's qualified -name. See below for notes about matching -behaviors in down-level clients.

- -

In summary:

- -
-
ns|E
-
elements with name E in namespace ns
-
*|E
-
elements with name E in any namespace, including those without any - declared namespace
-
|E
-
elements with name E without any declared namespace
-
E
-
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.
-
- -
-

CSS examples:

- -
@namespace foo url(http://www.example.com);
- foo|h1 { color: blue }
- foo|* { color: yellow }
- |h1 { color: red }
- *|h1 { color: green }
- h1 { color: green }
- -

The first rule will match only h1 elements in the - "http://www.example.com" namespace.

- -

The second rule will match all elements in the - "http://www.example.com" namespace.

- -

The third rule will match only h1 elements without - any declared namespace.

- -

The fourth rule will match h1 elements in any - namespace (including those without any declared namespace).

- -

The last rule is equivalent to the fourth rule because no default - namespace has been defined.

- -
- -

6.2. Universal selector

- -

The universal selector, written "asterisk" -(*), 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 Universal selector and -Namespaces below.

- -

If the universal selector is not the only component of a sequence -of simple selectors, the * may be omitted.

- -
-

Examples:

-
    -
  • *[hreflang|=en] and [hreflang|=en] are equivalent,
  • -
  • *.warning and .warning are equivalent,
  • -
  • *#myid and #myid are equivalent.
  • -
-
- -

Note: it is recommended that the -*, representing the universal selector, not be -omitted.

- -

6.2.1. Universal selector and namespaces

- -

The universal selector allows an optional namespace component. It -is used as follows:

- -
-
ns|*
-
all elements in namespace ns
-
*|*
-
all elements
-
|*
-
all elements without any declared namespace
-
*
-
if no default namespace has been specified, this is equivalent to *|*. - Otherwise it is equivalent to ns|* where ns is the default namespace.
-
- -

A universal selector containing a namespace prefix that has not -been previously declared is an invalid -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.

- - -

6.3. Attribute selectors

- -

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.

- -

6.3.1. Attribute presence and values -selectors

- -

CSS2 introduced four attribute selectors:

- -
-
[att] -
Represents an element with the att attribute, whatever the value of - the attribute.
-
[att=val]
-
Represents an element with the att attribute whose value is exactly - "val".
-
[att~=val]
-
Represents an element with the att attribute whose value is a whitespace-separated list of words, one of - which is exactly "val". If "val" contains whitespace, it will never - represent anything (since the words are separated by - spaces).
-
[att|=val] -
Represents an element with the att 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 hreflang attribute on the - link element in HTML) as described in RFC 3066 ([RFC3066]). For lang (or - xml:lang) language subcode matching, please see the :lang pseudo-class.
-
- -

Attribute values must be identifiers or strings. The -case-sensitivity of attribute names and values in selectors depends on -the document language.

- -
- -

Examples:

- -

The following attribute selector represents an h1 - element that carries the title attribute, whatever its - value:

- -
h1[title]
- -

In the following example, the selector represents a - span element whose class attribute has - exactly the value "example":

- -
span[class="example"]
- -

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 span element - whose hello attribute has exactly the value "Cleveland" - and whose goodbye attribute has exactly the value - "Columbus":

- -
span[hello="Cleveland"][goodbye="Columbus"]
- -

The following selectors illustrate the differences between "=" - and "~=". The first selector will represent, for example, the value - "copyright copyleft copyeditor" on a rel attribute. The - second selector will only represent an a element with - an href attribute having the exact value - "http://www.w3.org/".

- -
a[rel~="copyright"]
-a[href="http://www.w3.org/"]
- -

The following selector represents a link element - whose hreflang attribute is exactly "fr".

- -
link[hreflang=fr]
- -

The following selector represents a link element for - which the values of the hreflang attribute begins with - "en", including "en", "en-US", and "en-cockney":

- -
link[hreflang|="en"]
- -

Similarly, the following selectors represents a - DIALOGUE element whenever it has one of two different - values for an attribute character:

- -
DIALOGUE[character=romeo]
-DIALOGUE[character=juliet]
- -
- -

6.3.2. Substring matching attribute -selectors

- -

Three additional attribute selectors are provided for matching -substrings in the value of an attribute:

- -
-
[att^=val]
-
Represents an element with the att attribute whose value begins - with the prefix "val".
-
[att$=val] -
Represents an element with the att attribute whose value ends with - the suffix "val".
-
[att*=val] -
Represents an element with the att attribute whose value contains - at least one instance of the substring "val".
-
- -

Attribute values must be identifiers or strings. The -case-sensitivity of attribute names in selectors depends on the -document language.

- -
-

Examples:

-

The following selector represents an HTML object, referencing an - image:

-
object[type^="image/"]
-

The following selector represents an HTML anchor a with an - href attribute whose value ends with ".html".

-
a[href$=".html"]
-

The following selector represents an HTML paragraph with a title - attribute whose value contains the substring "hello"

-
p[title*="hello"]
-
- -

6.3.3. Attribute selectors and namespaces

- -

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" (|). 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 "|attr"). 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. - -

An attribute selector with an attribute name containing a namespace -prefix that has not been previously declared is an invalid 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. - -

-

CSS examples:

-
@namespace foo "http://www.example.com";
-[foo|att=val] { color: blue }
-[*|att] { color: yellow }
-[|att] { color: green }
-[att] { color: green }
- -

The first rule will match only elements with the attribute - att in the "http://www.example.com" namespace with the - value "val".

- -

The second rule will match only elements with the attribute - att regardless of the namespace of the attribute - (including no declared namespace).

- -

The last two rules are equivalent and will match only elements - with the attribute att where the attribute is not - declared to be in a namespace.

- -
- -

6.3.4. Default attribute values in DTDs

- -

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.

- -

More precisely, a UA is not required to read an "external -subset" of the DTD but is required to look for default -attribute values in the document's "internal subset." (See [XML10] for definitions of these subsets.)

- -

A UA that recognizes an XML namespace [XMLNAMES] 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.)

- -

Note: Typically, implementations -choose to ignore external subsets.

- -
-

Example:

- -

Consider an element EXAMPLE with an attribute "notation" that has a -default value of "decimal". The DTD fragment might be

- -
<!ATTLIST EXAMPLE notation (decimal,octal) "decimal">
- -

If the style sheet contains the rules

- -
EXAMPLE[notation=decimal] { /*... default property settings ...*/ }
-EXAMPLE[notation=octal]   { /*... other settings...*/ }
- -

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:

- -
EXAMPLE                   { /*... default property settings ...*/ }
-EXAMPLE[notation=octal]   { /*... other settings...*/ }
- -

Here, because the selector EXAMPLE[notation=octal] 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.

- -
- -

6.4. Class selectors

- -

Working with HTML, authors may use the period (U+002E, -.) notation as an alternative to the ~= -notation when representing the class attribute. Thus, for -HTML, div.value and div[class~=value] have -the same meaning. The attribute value must immediately follow the -"period" (.).

- -

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 [SVG] describes the SVG -"class" attribute and how a UA should interpret it, and -similarly MathML 1.01 [MATH] describes the MathML -"class" attribute.)

- -
-

CSS examples:

- -

We can assign style information to all elements with - class~="pastoral" as follows:

- -
*.pastoral { color: green }  /* all elements with class~=pastoral */
- -

or just

- -
.pastoral { color: green }  /* all elements with class~=pastoral */
- -

The following assigns style only to H1 elements with - class~="pastoral":

- -
H1.pastoral { color: green }  /* H1 elements with class~=pastoral */
- -

Given these rules, the first H1 instance below would not have - green text, while the second would:

- -
<H1>Not green</H1>
-<H1 class="pastoral">Very green</H1>
- -
- -

To represent a subset of "class" values, each value must be preceded -by a ".", in any order.

- -
- -

CSS example:

- -

The following rule matches any P element whose "class" attribute - has been assigned a list of whitespace-separated values that includes - "pastoral" and "marine":

- -
p.pastoral.marine { color: green }
- -

This rule matches when class="pastoral blue aqua - marine" but does not match for class="pastoral - blue".

- -
- -

Note: 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.

- -

Note: 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.

- -

6.5. ID selectors

- -

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.

- -

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, -#) immediately followed by the ID value, which must be an -identifier.

- -

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. - -

-

Examples:

-

The following ID selector represents an h1 element - whose ID-typed attribute has the value "chapter1":

-
h1#chapter1
-

The following ID selector represents any element whose ID-typed - attribute has the value "chapter1":

-
#chapter1
-

The following selector represents any element whose ID-typed - attribute has the value "z98y".

-
*#z98y
-
- -

Note. In XML 1.0 [XML10], 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: -[name=p371] instead of #p371. Elements in -XML 1.0 documents without a DTD do not have IDs at all.

- -

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.

- -

6.6. Pseudo-classes

- -

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.

- -

A pseudo-class always consists of a "colon" -(:) followed by the name of the pseudo-class and -optionally by a value between parentheses.

- -

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.

- - -

6.6.1. Dynamic pseudo-classes

- -

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.

- -

Dynamic pseudo-classes do not appear in the document source or -document tree.

- - -
The link pseudo-classes: :link and :visited
- -

User agents commonly display unvisited links differently from -previously visited ones. Selectors -provides the pseudo-classes :link and -:visited to distinguish them:

- -
    -
  • The :link pseudo-class applies to links that have - not yet been visited.
  • -
  • The :visited pseudo-class applies once the link has - been visited by the user.
  • -
- -

After some amount of time, user agents may choose to return a -visited link to the (unvisited) ':link' state.

- -

The two states are mutually exclusive.

- -
- -

Example:

- -

The following selector represents links carrying class - external and already visited:

- -
a.external:visited
- -
- -

Note: 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. - -

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.

- -
The user action pseudo-classes -:hover, :active, and :focus
- -

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.

- -
    - -
  • The :hover 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 interactive - media do not have to support this pseudo-class. Some conforming - user agents that support interactive - media may not be able to support this pseudo-class (e.g., a pen - device that does not detect hovering).
  • - -
  • The :active 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.
  • - -
  • The :focus pseudo-class applies while an element - has the focus (accepts keyboard or mouse events, or other forms of - input).
  • - -
- -

There may be document language or implementation specific limits on -which elements can become :active or acquire -:focus.

- -

These pseudo-classes are not mutually exclusive. An element may -match several pseudo-classes at the same time.

- -

Selectors doesn't define if the parent of an element that is -':active' or ':hover' is also in that state.

- -
-

Examples:

-
a:link    /* unvisited links */
-a:visited /* visited links */
-a:hover   /* user hovers */
-a:active  /* active links */
-

An example of combining dynamic pseudo-classes:

-
a:focus
-a:focus:hover
-

The last selector matches a elements that are in - the pseudo-class :focus and in the pseudo-class :hover.

-
- -

Note: An element can be both ':visited' -and ':active' (or ':link' and ':active').

- -

6.6.2. The target pseudo-class :target

- -

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).

- -

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 section_2 in an HTML -document:

- -
http://example.com/html/top.html#section_2
- -

A target element can be represented by the :target -pseudo-class. If the document's URI has no fragment identifier, then -the document has no target element.

- -
-

Example:

-
p.note:target
-

This selector represents a p element of class - note that is the target element of the referring - URI.

-
- -
-

CSS example:

-

Here, the :target pseudo-class is used to make the - target element red and place an image before it, if there is one:

-
*:target { color : red }
-*:target::before { content : url(target.png) }
-
- -

6.6.3. The language pseudo-class :lang

- -

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 [HTML4], the language is determined by a -combination of the lang attribute, the meta -element, and possibly by information from the protocol (such as HTTP -headers). XML uses an attribute called xml:lang, and -there may be other document language-specific methods for determining -the language.

- -

The pseudo-class :lang(C) represents an element that -is in language C. Whether an element is represented by a -:lang() 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 '|=' operator in attribute -selectors. The identifier C does not have to be a valid language -name.

- -

C must not be empty. (If it is, the selector is invalid.)

- -

Note: It is recommended that -documents and protocols indicate language using codes from RFC 3066 [RFC3066] or its successor, and by means of -"xml:lang" attributes in the case of XML-based documents [XML10]. See -"FAQ: Two-letter or three-letter language codes."

- -
-

Examples:

-

The two following selectors represent an HTML document that is in - Belgian, French, or German. The two next selectors represent - q quotations in an arbitrary element in Belgian, French, - or German.

-
html:lang(fr-be)
-html:lang(de)
-:lang(fr-be) > q
-:lang(de) > q
-
- -

6.6.4. The UI element states pseudo-classes

- -
The :enabled and :disabled pseudo-classes
- -

The :enabled 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 input element without also specifying what it -would look like when it was disabled.

- -

Similar to :enabled, :disabled allows the -author to specify precisely how a disabled or inactive user interface -element should look.

- -

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.

- - -
The :checked pseudo-class
- -

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 :checked pseudo-class applies. The -:checked pseudo-class initially applies to such elements -that have the HTML4 selected and checked -attributes as described in Section -17.2.1 of HTML4, but of course the user can toggle "off" such -elements in which case the :checked pseudo-class would no -longer apply. While the :checked 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 selected and -checked attributes, it applies to all media. - - -

The :indeterminate pseudo-class
- -
- -

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.

- -

A future version of this specification may introduce an -:indeterminate pseudo-class that applies to such elements. -

- -
- - -

6.6.5. Structural pseudo-classes

- -

Selectors introduces the concept of structural -pseudo-classes to permit selection based on extra information that lies in -the document tree but cannot be represented by other simple selectors or -combinators. - -

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. - - -

:root pseudo-class
- -

The :root pseudo-class represents an element that is -the root of the document. In HTML 4, this is always the -HTML element. - - -

:nth-child() pseudo-class
- -

The -:nth-child(an+b) -pseudo-class notation represents an element that has -an+b-1 siblings -before it in the document tree, for a given positive -integer or zero value of n, and has a parent element. In -other words, this matches the bth child of an element after -all the children have been split into groups of a 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 a and -b values must be zero, negative integers or positive -integers. The index of the first child of an element is 1. - -

In addition to this, :nth-child() can take -'odd' and 'even' as arguments instead. -'odd' has the same signification as 2n+1, -and 'even' has the same signification as 2n. - - -

-

Examples:

-
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; }
-
- -

When a=0, no repeating is used, so for example -:nth-child(0n+5) matches only the fifth child. When -a=0, the an part need not be -included, so the syntax simplifies to -:nth-child(b) and the last example simplifies -to :nth-child(5). - -

-

Examples:

-
foo:nth-child(0n+1)   /* represents an element foo, first child of its parent element */
-foo:nth-child(1)      /* same */
-
- -

When a=1, the number may be omitted from the rule. - -

-

Examples:

-

The following selectors are therefore equivalent:

-
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) */
-
- -

If b=0, then every ath element is picked. In -such a case, the b part may be omitted. - -

-

Examples:

-
tr:nth-child(2n+0) /* represents every even row of an HTML table */
-tr:nth-child(2n) /* same */
-
- -

If both a and b are equal to zero, the -pseudo-class represents no element in the document tree.

- -

The value a can be negative, but only the positive -values of an+b, for -n≥0, may represent an element in the document -tree.

- -
-

Example:

-
html|tr:nth-child(-n+6)  /* represents the 6 first rows of XHTML tables */
-
- -

When the value b is negative, the "+" character in the -expression must be removed (it is effectively replaced by the "-" -character indicating the negative value of b).

- -
-

Examples:

-
: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 */
-
- - -
:nth-last-child() pseudo-class
- -

The :nth-last-child(an+b) -pseudo-class notation represents an element that has -an+b-1 siblings -after it in the document tree, for a given positive -integer or zero value of n, and has a parent element. See -:nth-child() pseudo-class for the syntax of its argument. -It also accepts the 'even' and 'odd' values -as arguments. - - -

-

Examples:

-
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 */
-
- - -
:nth-of-type() pseudo-class
- -

The :nth-of-type(an+b) -pseudo-class notation represents an element that has -an+b-1 siblings with the same -element name before it in the document tree, for a -given zero or positive integer value of n, and has a -parent element. In other words, this matches the bth child -of that type after all the children of that type have been split into -groups of a elements each. See :nth-child() pseudo-class -for the syntax of its argument. It also accepts the -'even' and 'odd' values. - - -

-

CSS example:

-

This allows an author to alternate the position of floated images:

-
img:nth-of-type(2n+1) { float: right; }
-img:nth-of-type(2n) { float: left; }
-
- - -
:nth-last-of-type() pseudo-class
- -

The :nth-last-of-type(an+b) -pseudo-class notation represents an element that has -an+b-1 siblings with the same -element name after it in the document tree, for a -given zero or positive integer value of n, and has a -parent element. See :nth-child() pseudo-class for the -syntax of its argument. It also accepts the 'even' and 'odd' values. - - -

-

Example:

-

To represent all h2 children of an XHTML - body except the first and last, one could use the - following selector:

-
body > h2:nth-of-type(n+2):nth-last-of-type(n+2)
-

In this case, one could also use :not(), although the - selector ends up being just as long:

-
body > h2:not(:first-of-type):not(:last-of-type)
-
- - -
:first-child pseudo-class
- -

Same as :nth-child(1). The :first-child pseudo-class -represents an element that is the first child of some other element. - - -

-

Examples:

-

The following selector represents a p element that is - the first child of a div element:

-
div > p:first-child
-

This selector can represent the p inside the - div of the following fragment:

-
<p> The last P before the note.</p>
-<div class="note">
-   <p> The first P inside the note.</p>
-</div>
but cannot represent the second p in the following -fragment: -
<p> The last P before the note.</p>
-<div class="note">
-   <h2> Note </h2>
-   <p> The first P inside the note.</p>
-</div>
-

The following two selectors are usually equivalent:

-
* > a:first-child /* a is first child of any element */
-a:first-child /* Same (assuming a is not the root element) */
-
- -
:last-child pseudo-class
- -

Same as :nth-last-child(1). The :last-child pseudo-class -represents an element that is the last child of some other element. - -

-

Example:

-

The following selector represents a list item li that - is the last child of an ordered list ol. -

ol > li:last-child
-
- -
:first-of-type pseudo-class
- -

Same as :nth-of-type(1). The :first-of-type pseudo-class -represents an element that is the first sibling of its type in the list of -children of its parent element. - -

-

Example:

-

The following selector represents a definition title -dt inside a definition list dl, this -dt being the first of its type in the list of children of -its parent element.

-
dl dt:first-of-type
-

It is a valid description for the first two dt -elements in the following example but not for the third one:

-
<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>
-
- -
:last-of-type pseudo-class
- -

Same as :nth-last-of-type(1). The -:last-of-type pseudo-class represents an element that is -the last sibling of its type in the list of children of its parent -element.

- -
-

Example:

-

The following selector represents the last data cell - td of a table row.

-
tr > td:last-of-type
-
- -
:only-child pseudo-class
- -

Represents an element that has a parent element and whose parent -element has no other element children. Same as -:first-child:last-child or -:nth-child(1):nth-last-child(1), but with a lower -specificity.

- -
:only-of-type pseudo-class
- -

Represents an element that has a parent element and whose parent -element has no other element children with the same element name. Same -as :first-of-type:last-of-type or -:nth-of-type(1):nth-last-of-type(1), but with a lower -specificity.

- - -
:empty pseudo-class
- -

The :empty 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.

- -
-

Examples:

-

p:empty is a valid representation of the following fragment:

-
<p></p>
-

foo:empty is not a valid representation for the - following fragments:

-
<foo>bar</foo>
-
<foo><bar>bla</bar></foo>
-
<foo>this is not <bar>:empty</bar></foo>
-
- -

6.6.6. Blank

- -

This section intentionally left blank.

- - -

6.6.7. The negation pseudo-class

- -

The negation pseudo-class, :not(X), is a -functional notation taking a simple -selector (excluding the negation pseudo-class itself and -pseudo-elements) as an argument. It represents an element that is not -represented by the argument. - - - -

-

Examples:

-

The following CSS selector matches all button - elements in an HTML document that are not disabled.

-
button:not([DISABLED])
-

The following selector represents all but FOO - elements.

-
*:not(FOO)
-

The following group of selectors represents all HTML elements - except links.

-
html|*:not(:link):not(:visited)
-
- -

Default namespace declarations do not affect the argument of the -negation pseudo-class unless the argument is a universal selector or a -type selector.

- -
-

Examples:

-

Assuming that the default namespace is bound to - "http://example.com/", the following selector represents all - elements that are not in that namespace:

-
*|*:not(*)
-

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 are being hovered.

-
*|*:not(:hover)
-
- -

Note: the :not() pseudo allows -useless selectors to be written. For instance :not(*|*), -which represents no element at all, or foo:not(bar), -which is equivalent to foo but with a higher -specificity.

- -

7. Pseudo-elements

- -

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 ::before and -::after pseudo-elements give access to generated -content).

- -

A pseudo-element is made of two colons (::) followed -by the name of the pseudo-element.

- -

This :: 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, -:first-line, :first-letter, -:before and :after). This compatibility is -not allowed for the new pseudo-elements introduced in CSS level 3.

- -

Only one pseudo-element may appear per selector, and if present it -must appear after the sequence of simple selectors that represents the -subjects of the selector. A -future version of this specification may allow multiple -pesudo-elements per selector.

- -

7.1. The ::first-line pseudo-element

- -

The ::first-line pseudo-element describes the contents -of the first formatted line of an element. - -

-

CSS example:

-
p::first-line { text-transform: uppercase }
-

The above rule means "change the letters of the first line of every -paragraph to uppercase".

-
- -

The selector p::first-line 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.

- -

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>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>
-
- -

the lines of which happen to be broken as follows: - -

-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.
-
- -

This paragraph might be "rewritten" by user agents to include the -fictional tag sequence for ::first-line. This -fictional tag sequence helps to show how properties are inherited.

- -
-<P><P::first-line> This is a somewhat long HTML
-paragraph that </P::first-line> 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>
-
- -

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 span element:

- -
-<P><SPAN class="test"> This is a somewhat long HTML
-paragraph that will be broken into several
-lines.</SPAN> The first line will be identified
-by a fictional tag sequence. The other lines
-will be treated as ordinary lines in the
-paragraph.</P>
-
- -

the user agent could simulate start and end tags for -span when inserting the fictional tag sequence for -::first-line. - -

-<P><P::first-line><SPAN class="test"> This is a
-somewhat long HTML
-paragraph that will </SPAN></P::first-line><SPAN class="test"> be
-broken into several
-lines.</SPAN> The first line will be identified
-by a fictional tag sequence. The other lines
-will be treated as ordinary lines in the
-paragraph.</P>
-
- -

In CSS, the ::first-line pseudo-element can only be -attached to a block-level element, an inline-block, a table-caption, -or a table-cell.

- -

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 div in <DIV><P>This -line...</P></DIV> is the first line of the p (assuming -that both p and div are block-level). - -

The first line of a table-cell or inline-block cannot be the first -formatted line of an ancestor element. Thus, in <DIV><P -STYLE="display: inline-block">Hello<BR>Goodbye</P> -etcetera</DIV> the first formatted line of the -div is not the line "Hello". - -

Note that the first line of the p in this -fragment: <p><br>First... doesn't contain any -letters (assuming the default style for br in HTML -4). The word "First" is not on the first formatted line. - -

A UA should act as if the fictional start tags of the -::first-line 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

- -
-<DIV>
-  <P>First paragraph</P>
-  <P>Second paragraph</P>
-</DIV>
-
- -

is

- -
-<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>
-
- -

The ::first-line pseudo-element is similar to an -inline-level element, but with certain restrictions. In CSS, the -following properties apply to a ::first-line -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.

- - -

7.2. The ::first-letter pseudo-element

- -

The ::first-letter 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.

- -

In CSS, these are the properties that apply to ::first-letter -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.

- -
-

Example:

-

This example shows a possible rendering of an initial cap. Note -that the 'line-height' that is inherited by the ::first-letter -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, and thus -the font weight of the first letter is normal, not bold as the span: -

-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.
-
-
-

Image illustrating the ::first-letter pseudo-element -

-
- -
-

The following CSS will make a drop cap initial letter span about two lines:

- -
-<!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>
-
- -

This example might be formatted as follows:

- -
-

Image illustrating the combined effect of the ::first-letter and ::first-line pseudo-elements

-
- -

The fictional tag sequence is:

- -
-<P>
-<SPAN>
-<P::first-letter>
-T
-</P::first-letter>he first
-</SPAN>
-few words of an article in the Economist.
-</P>
-
- -

Note that the ::first-letter 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.

- -

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.

- -

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. [UNICODE]

- -
-

Quotes that precede the
-first letter should be included.

-
- -

The ::first-letter also applies if the first letter is -in fact a digit, e.g., the "6" in "67 million dollars is a lot of -money."

- -

In CSS, the ::first-letter pseudo-element applies to -block, list-item, table-cell, table-caption, and inline-block -elements. A future version of this specification -may allow this pesudo-element to apply to more element -types.

- -

The ::first-letter 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.

- -
-

Example:

-

The fictional tag sequence for this HTMLfragment: -

<div>
-<p>The first text.
-

is: -

<div>
-<p><div::first-letter><p::first-letter>T</...></...>he first text.
-
- -

The first letter of a table-cell or inline-block cannot be the -first letter of an ancestor element. Thus, in <DIV><P -STYLE="display: inline-block">Hello<BR>Goodbye</P> -etcetera</DIV> the first letter of the div is not the -letter "H". In fact, the div doesn't have a first letter. - -

The first letter must occur on the first formatted line. For example, in -this fragment: <p><br>First... the first line -doesn't contain any letters and ::first-letter doesn't -match anything (assuming the default style for br in HTML -4). In particular, it does not match the "F" of "First." - -

In CSS, if an element is a list item ('display: list-item'), the -::first-letter applies to the first letter in the -principal box after the marker. UAs may ignore -::first-letter on list items with 'list-style-position: -inside'. If an element has ::before or -::after content, the ::first-letter applies -to the first letter of the element including that content. - -

-

Example:

-

After the rule 'p::before {content: "Note: "}', the selector -'p::first-letter' matches the "N" of "Note".

-
- -

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 ::first-letter pseudo-element. - -

If the letters that would form the ::first-letter are not in the -same element, such as "'T" in <p>'<em>T..., the UA -may create a ::first-letter pseudo-element from one of the elements, -both elements, or simply not create a pseudo-element.

- -

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). - -

-

Example:

-

The following example 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 { 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>
- -

Assuming that a line break will occur before the word "ends", the -fictional tag -sequence for this fragment might be:

- -
<P>
-<P::first-line>
-<P::first-letter>
-S
-</P::first-letter>ome text that
-</P::first-line>
-ends up on two lines
-</P>
- -

Note that the ::first-letter element is inside the ::first-line -element. Properties set on ::first-line are inherited by -::first-letter, but are overridden if the same property is set on -::first-letter.

-
- - -

7.3. The ::selection pseudo-element

- -

The ::selection 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 :checked pseudo-class (which used to be -named :selected) - -

Although the ::selection 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 -[CSS21]) which was originally rendered to a -dynamic medium (like screen), the UA may wish to transfer the current -::selection 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 ::selection -pseudo-element for static media. - -

These are the CSS properties that apply to ::selection -pseudo-elements: color, background, cursor (optional), outline -(optional). The computed value of the 'background-image' property on -::selection may be ignored. - - -

7.4. The ::before and ::after pseudo-elements

- -

The ::before and ::after pseudo-elements -can be used to describe generated content before or after an element's -content. They are explained in CSS 2.1 [CSS21].

- -

When the ::first-letter and ::first-line -pseudo-elements are combined with ::before and -::after, they apply to the first letter or line of the -element including the inserted text.

- -

8. Combinators

- -

8.1. Descendant combinator

- -

At times, authors may want selectors to describe an element that is -the descendant of another element in the document tree (e.g., "an -EM element that is contained within an H1 -element"). Descendant combinators express such a relationship. A -descendant combinator is white space that -separates two sequences of simple selectors. A selector of the form -"A B" represents an element B that is an -arbitrary descendant of some ancestor element A. - -

-

Examples:

-

For example, consider the following selector:

-
h1 em
-

It represents an em element being the descendant of - an h1 element. It is a correct and valid, but partial, - description of the following fragment:

-
<h1>This <span class="myclass">headline
-is <em>very</em> important</span></h1>
-

The following selector:

-
div * p
-

represents a p element that is a grandchild or later - descendant of a div 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.

-

The following selector, which combines descendant combinators and - attribute selectors, represents an - element that (1) has the href attribute set and (2) is - inside a p that is itself inside a div:

-
div p *[href]
-
- -

8.2. Child combinators

- -

A child combinator describes a childhood relationship -between two elements. A child combinator is made of the -"greater-than sign" (>) character and -separates two sequences of simple selectors. - - -

-

Examples:

-

The following selector represents a p element that is - child of body:

-
body > p
-

The following example combines descendant combinators and child - combinators.

-
div ol>li p
-

It represents a p element that is a descendant of an - li element; the li element must be the - child of an ol element; the ol element must - be a descendant of a div. Notice that the optional white - space around the ">" combinator has been left out.

-
- -

For information on selecting the first child of an element, please -see the section on the :first-child pseudo-class -above.

- -

8.3. Sibling combinators

- -

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.

- -

8.3.1. Adjacent sibling combinator

- -

The adjacent sibling combinator is made of the "plus -sign" (U+002B, +) 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.

- -
-

Examples:

-

The following selector represents a p element - immediately following a math element:

-
math + 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 h1 element, that it must have - class="opener":

-
h1.opener + h2
-
- - -

8.3.2. General sibling combinator

- -

The general sibling combinator is made of the "tilde" -(U+007E, ~) 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.

- -
-

Example:

-
h1 ~ pre
-

represents a pre element following an h1. It - is a correct and valid, but partial, description of:

-
<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>
-
- -

9. Calculating a selector's specificity

- -

A selector's specificity is calculated as follows:

- -
    -
  • count the number of ID selectors in the selector (= a)
  • -
  • count the number of class selectors, attributes selectors, and pseudo-classes in the selector (= b)
  • -
  • count the number of element names in the selector (= c)
  • -
  • ignore pseudo-elements
  • -
- -

Selectors inside the negation pseudo-class -are counted like any other, but the negation itself does not count as -a pseudo-class.

- -

Concatenating the three numbers a-b-c (in a number system with a -large base) gives the specificity.

- -
-

Examples:

-
*               /* 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 */
-
-
- -

Note: the specificity of the styles -specified in an HTML style attribute is described in CSS -2.1. [CSS21].

- -

10. The grammar of Selectors

- -

10.1. Grammar

- -

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 [YACC]) -are used:

- -
    -
  • *: 0 or more -
  • +: 1 or more -
  • ?: 0 or 1 -
  • |: separates alternatives -
  • [ ]: grouping
  • -
- -

The productions are:

- -
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
-  ;
- - -

10.2. Lexical scanner

- -

The following is the tokenizer, written in Flex (see -[FLEX]) notation. The tokenizer is -case-insensitive.

- -

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. [UNICODE]

- -
%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;
- - - -

11. Namespaces and down-level clients

- -

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.

- -

It should be noted that a down-level CSS client will (if it -properly conforms to CSS forward compatible parsing rules) ignore all -@namespace 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.

- -

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.

- -

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.

- -
    -
  1. - -

    The XML document does not use namespaces.

    - -
      - -
    • 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.
    • - -
    • 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 ("|name") - will guarantee that selectors will match only XML elements that do - not have a declared namespace.
    • - -
    - -
  2. - -
  3. - -

    The XML document defines a single, default namespace used - throughout the document. No namespace prefixes are used in element - names.

    - -
      - -
    • 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.
    • - -
    - -
  4. - -
  5. - -

    The XML document does not 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).

    - -
      - -
    • 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 Type selectors and Namespaces section. CSS - selectors may be declared using an escaped colon "\:" - to describe the fully qualified names, e.g. - "html\:h1" will match - <html:h1>. 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.
    • - -
    • Note that selectors declared in this fashion will - only 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).
    • - -
    - -
  6. - -
- -

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 -different 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.

- -

12. Profiles

- -

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.

- -

Non normative examples: - -

- - - - - - - - - - - - - - - -
Selectors profile
SpecificationCSS level 1
Acceptstype selectors
class selectors
ID selectors
:link, - :visited and :active pseudo-classes
descendant combinator -
::first-line and ::first-letter pseudo-elements
Excludes - -

universal selector
attribute selectors
:hover and :focus - pseudo-classes
:target pseudo-class
:lang() pseudo-class
all UI - element states pseudo-classes
all structural - pseudo-classes
negation pseudo-class
all - UI element fragments pseudo-elements
::before and ::after - pseudo-elements
child combinators
sibling combinators - -

namespaces

Extra constraintsonly one class selector allowed per sequence of simple - selectors


- - - - - - - - - - - - - - - -
Selectors profile
SpecificationCSS level 2
Acceptstype selectors
universal selector
attribute presence and - values selectors
class selectors
ID selectors
:link, :visited, - :active, :hover, :focus, :lang() and :first-child pseudo-classes -
descendant combinator
child combinator
adjacent sibling - combinator
::first-line and ::first-letter pseudo-elements
::before - and ::after pseudo-elements
Excludes - -

content selectors
substring matching attribute - selectors
:target pseudo-classes
all UI element - states pseudo-classes
all structural pseudo-classes other - than :first-child
negation pseudo-class
all UI element - fragments pseudo-elements
general sibling combinators - -

namespaces

Extra constraintsmore than one class selector per sequence of simple selectors (CSS1 - constraint) allowed
- -

In CSS, selectors express pattern matching rules that determine which style -rules apply to elements in the document tree. - -

The following selector (CSS level 2) will match all anchors a -with attribute name set inside a section 1 header h1: -

h1 a[name]
- -

All CSS declarations attached to such a selector are applied to elements -matching it.

- -
- - - - - - - - - - - - - - - - -
Selectors profile
SpecificationSTTS 3
Accepts - -

type selectors
universal selectors
attribute selectors
class - selectors
ID selectors
all structural pseudo-classes
- all combinators - -

namespaces

Excludesnon-accepted pseudo-classes
pseudo-elements
Extra constraintssome selectors and combinators are not allowed in fragment - descriptions on the right side of STTS declarations.
-
- - - - - - - - - - - - - - - - - - - - - - - - - -
- -

Selectors can be used in STTS 3 in two different - manners: -

    -
  1. a selection mechanism equivalent to CSS selection mechanism: declarations - attached to a given selector are applied to elements matching that selector, -
  2. fragment descriptions that appear on the right side of declarations. -
- -

13. Conformance and requirements

- -

This section defines conformance with the present specification only. - -

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. - -

All specifications reusing Selectors must contain a Profile listing the -subset of Selectors it accepts or excludes, and describing the constraints -it adds to the current specification. - -

Invalidity is caused by a parsing error, e.g. an unrecognized token or a token -which is not allowed at the current parsing point. - -

User agents must observe the rules for handling parsing errors: -

    -
  • a simple selector containing an undeclared namespace prefix is invalid
  • -
  • a selector containing an invalid simple selector, an invalid combinator - or an invalid token is invalid.
  • -
  • a group of selectors containing an invalid selector is invalid.
  • -
- -

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.)

- - - -

14. Tests

- -

This specification has a test -suite 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.

- -

15. Acknowledgements

- -

The CSS working group would like to thank everyone who has sent -comments on this specification over the years.

- -

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.

- -

16. References

- -
- -
[CSS1] -
Bert Bos, Håkon Wium Lie; "Cascading Style Sheets, level 1", W3C Recommendation, 17 Dec 1996, revised 11 Jan 1999 -
(http://www.w3.org/TR/REC-CSS1) - -
[CSS21] -
Bert Bos, Tantek Çelik, Ian Hickson, Håkon Wium Lie, editors; "Cascading Style Sheets, level 2 revision 1", W3C Working Draft, 13 June 2005 -
(http://www.w3.org/TR/CSS21) - -
[CWWW] -
Martin J. Dürst, François Yergeau, Misha Wolf, Asmus Freytag, Tex Texin, editors; "Character Model for the World Wide Web", W3C Recommendation, 15 February 2005 -
(http://www.w3.org/TR/charmod/) - -
[FLEX] -
"Flex: The Lexical Scanner Generator", Version 2.3.7, ISBN 1882114213 - -
[HTML4] -
Dave Ragget, Arnaud Le Hors, Ian Jacobs, editors; "HTML 4.01 Specification", W3C Recommendation, 24 December 1999 -
(http://www.w3.org/TR/html4/) - -
[MATH] -
Patrick Ion, Robert Miner, editors; "Mathematical Markup Language (MathML) 1.01", W3C Recommendation, revision of 7 July 1999 -
(http://www.w3.org/TR/REC-MathML/) - -
[RFC3066] -
H. Alvestrand; "Tags for the Identification of Languages", Request for Comments 3066, January 2001 -
(http://www.ietf.org/rfc/rfc3066.txt) - -
[STTS] -
Daniel Glazman; "Simple Tree Transformation Sheets 3", Electricité de France, submission to the W3C, 11 November 1998 -
(http://www.w3.org/TR/NOTE-STTS3) - -
[SVG] -
Jon Ferraiolo, 藤沢 淳, Dean Jackson, editors; "Scalable Vector Graphics (SVG) 1.1 Specification", W3C Recommendation, 14 January 2003 -
(http://www.w3.org/TR/SVG/) - -
[UNICODE]
-
The Unicode Standard, Version 4.1, The Unicode Consortium. Boston, MA, Addison-Wesley, March 2005. ISBN 0-321-18578-1, as amended by Unicode 4.0.1 and Unicode 4.1.0. -
(http://www.unicode.org/versions/)
- -
[XML10] -
Tim Bray, Jean Paoli, C. M. Sperberg-McQueen, Eve Maler, François Yergeau, editors; "Extensible Markup Language (XML) 1.0 (Third Edition)", W3C Recommendation, 4 February 2004 -
(http://www.w3.org/TR/REC-xml/) - -
[XMLNAMES] -
Tim Bray, Dave Hollander, Andrew Layman, editors; "Namespaces in XML", W3C Recommendation, 14 January 1999 -
(http://www.w3.org/TR/REC-xml-names/) - -
[YACC] -
S. C. Johnson; "YACC — Yet another compiler compiler", Technical Report, Murray Hill, 1975 - -
- - diff --git a/samples/third_party/dromaeo/web/tests/dom-traverse-html.dart b/samples/third_party/dromaeo/web/tests/dom-traverse-html.dart deleted file mode 100644 index 19fb3e5e907..00000000000 --- a/samples/third_party/dromaeo/web/tests/dom-traverse-html.dart +++ /dev/null @@ -1,91 +0,0 @@ -library dromaeo; -import 'dart:async'; -import 'dart:html'; -import "dart:convert"; -import '../common/common.dart'; -import 'dart:math' as Math; -part 'Common.dart'; -part 'RunnerSuite.dart'; - - -void main() { - final int num = 40; - - // Try to force real results. - var ret; - - String html = document.body.innerHtml; - - new Suite(window, 'dom-traverse') - .prep(() { - html = BenchUtil.replaceAll(html, 'id="test(\\w).*?"', (Match match) { - final group = match.group(1); - return 'id="test${group}${num}"'; - }); - html = BenchUtil.replaceAll(html, 'name="test.*?"', (Match match) { - return 'name="test${num}"'; - }); - html = BenchUtil.replaceAll(html, 'class="foo.*?"', (Match match) { - return 'class="foo test${num} bar"'; - }); - - final div = new Element.tag('div'); - div.innerHtml = html; - document.body.append(div); - }) - .test('firstChild', () { - final nodes = document.body.childNodes; - final nl = nodes.length; - - for (int i = 0; i < num; i++) { - for (int j = 0; j < nl; j++) { - Node cur = nodes[j]; - while (cur != null) { - cur = cur.firstChild; - } - ret = cur; - } - } - }) - .test('lastChild', () { - final nodes = document.body.childNodes; - final nl = nodes.length; - - for (int i = 0; i < num; i++) { - for (int j = 0; j < nl; j++) { - Node cur = nodes[j]; - while (cur != null) { - cur = cur.lastChild; - } - ret = cur; - } - } - }) - .test('nextSibling', () { - for (int i = 0; i < num * 2; i++) { - Node cur = document.body.firstChild; - while (cur != null) { - cur = cur.nextNode; - } - ret = cur; - } - }) - .test('previousSibling', () { - for (int i = 0; i < num * 2; i++) { - Node cur = document.body.lastChild; - while (cur != null) { - cur = cur.previousNode; - } - ret = cur; - } - }) - .test('childNodes', () { - for (int i = 0; i < num; i++) { - final nodes = document.body.childNodes; - for (int j = 0; j < nodes.length; j++) { - ret = nodes[j]; - } - } - }) - .end(); -} diff --git a/samples/third_party/dromaeo/web/tests/dom-traverse-html.html b/samples/third_party/dromaeo/web/tests/dom-traverse-html.html deleted file mode 100644 index ed139767360..00000000000 --- a/samples/third_party/dromaeo/web/tests/dom-traverse-html.html +++ /dev/null @@ -1,2900 +0,0 @@ - - - - - - -
-

W3C - -

Selectors

- -

W3C Working Draft 15 December 2005

- -
- -
This version: - -
- http://www.w3.org/TR/2005/WD-css3-selectors-20051215 - -
Latest version: - -
- http://www.w3.org/TR/css3-selectors - -
Previous version: - -
- http://www.w3.org/TR/2001/CR-css3-selectors-20011113 - -
Editors: - -
Daniel Glazman (Invited Expert)
- -
Tantek Çelik (Invited Expert) - -
Ian Hickson (Google) - -
Peter Linss (former editor, Netscape/AOL) - -
John Williams (former editor, Quark, Inc.) - -
- -
- -
- -

Abstract

- -

Selectors 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.

- -

CSS (Cascading - Style Sheets) is a language for describing the rendering of HTML and XML 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. - -

Selectors define the following function:

- -
expression ∗ element → boolean
- -

That is, given an element and a selector, this specification - defines whether that element matches the selector.

- -

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. STTS (Simple Tree Transformation Sheets), a - language for transforming XML trees, uses this mechanism. [STTS]

- -

Status of this document

- -

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 W3C technical reports index at - http://www.w3.org/TR/.

- -

This document describes the selectors that already exist in CSS1 and CSS2, and - also proposes new selectors for CSS3 and other languages that may need them.

- -

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.

- -

This specification is a last call working draft for the the CSS Working Group - (Style Activity). This - document is a revision of the Candidate - Recommendation dated 2001 November 13, 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.

- -

All persons are encouraged to review and implement this - specification and return comments to the (archived) - public mailing list www-style - (see instructions). W3C - Members can also send comments directly to the CSS Working - Group. - The deadline for comments is 14 January 2006.

- -

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". - -

This document may be available in translation. - The English version of this specification is the only normative - version. - -

- -

Table of contents

- - - -
- -

1. Introduction

- -

1.1. Dependencies

- -

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. [CSS21]

- -

1.2. Terminology

- -

All of the text of this specification is normative except - examples, notes, and sections explicitly marked as - non-normative.

- -

1.3. Changes from CSS2

- -

This section is non-normative.

- -

The main differences between the selectors in CSS2 and those in - Selectors are: - -

    - -
  • 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
  • - -
  • an optional namespace component is now allowed in type element - selectors, the universal selector and attribute selectors
  • - -
  • a new combinator has been introduced
  • - -
  • new simple selectors including substring matching attribute - selectors, and new pseudo-classes
  • - -
  • new pseudo-elements, and introduction of the "::" convention - for pseudo-elements
  • - -
  • the grammar has been rewritten
  • - -
  • profiles to be added to specifications integrating Selectors - and defining the set of selectors which is actually supported by - each specification
  • - -
  • Selectors are now a CSS3 Module and an independent - specification; other specifications can now refer to this document - independently of CSS
  • - -
  • the specification now has its own test suite
  • - -
- -

2. Selectors

- -

This section is non-normative, as it merely summarizes the -following sections.

- -

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.

- -

Selectors may range from simple element names to rich contextual -representations.

- -

The following table summarizes the Selector syntax:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PatternMeaningDescribed in sectionFirst defined in CSS level
*any elementUniversal - selector2
Ean element of type EType selector1
E[foo]an E element with a "foo" attributeAttribute - selectors2
E[foo="bar"]an E element whose "foo" attribute value is exactly - equal to "bar"Attribute - selectors2
E[foo~="bar"]an E element whose "foo" attribute value is a list of - space-separated values, one of which is exactly equal to "bar"Attribute - selectors2
E[foo^="bar"]an E element whose "foo" attribute value begins exactly - with the string "bar"Attribute - selectors3
E[foo$="bar"]an E element whose "foo" attribute value ends exactly - with the string "bar"Attribute - selectors3
E[foo*="bar"]an E element whose "foo" attribute value contains the - substring "bar"Attribute - selectors3
E[hreflang|="en"]an E element whose "hreflang" attribute has a hyphen-separated - list of values beginning (from the left) with "en"Attribute - selectors2
E:rootan E element, root of the documentStructural - pseudo-classes3
E:nth-child(n)an E element, the n-th child of its parentStructural - pseudo-classes3
E:nth-last-child(n)an E element, the n-th child of its parent, counting - from the last oneStructural - pseudo-classes3
E:nth-of-type(n)an E element, the n-th sibling of its typeStructural - pseudo-classes3
E:nth-last-of-type(n)an E element, the n-th sibling of its type, counting - from the last oneStructural - pseudo-classes3
E:first-childan E element, first child of its parentStructural - pseudo-classes2
E:last-childan E element, last child of its parentStructural - pseudo-classes3
E:first-of-typean E element, first sibling of its typeStructural - pseudo-classes3
E:last-of-typean E element, last sibling of its typeStructural - pseudo-classes3
E:only-childan E element, only child of its parentStructural - pseudo-classes3
E:only-of-typean E element, only sibling of its typeStructural - pseudo-classes3
E:emptyan E element that has no children (including text - nodes)Structural - pseudo-classes3
E:link
E:visited
an E element being the source anchor of a hyperlink of - which the target is not yet visited (:link) or already visited - (:visited)The link - pseudo-classes1
E:active
E:hover
E:focus
an E element during certain user actionsThe user - action pseudo-classes1 and 2
E:targetan E element being the target of the referring URIThe target - pseudo-class3
E:lang(fr)an element of type E in language "fr" (the document - language specifies how language is determined)The :lang() - pseudo-class2
E:enabled
E:disabled
a user interface element E which is enabled or - disabledThe UI element states - pseudo-classes3
E:checkeda user interface element E which is checked (for instance a radio-button or checkbox)The UI element states - pseudo-classes3
E::first-linethe first formatted line of an E elementThe ::first-line - pseudo-element1
E::first-letterthe first formatted letter of an E elementThe ::first-letter - pseudo-element1
E::selectionthe portion of an E element that is currently - selected/highlighted by the userThe UI element - fragments pseudo-elements3
E::beforegenerated content before an E elementThe ::before - pseudo-element2
E::aftergenerated content after an E elementThe ::after - pseudo-element2
E.warningan E element whose class is -"warning" (the document language specifies how class is determined).Class - selectors1
E#myidan E element with ID equal to "myid".ID - selectors1
E:not(s)an E element that does not match simple selector sNegation - pseudo-class3
E Fan F element descendant of an E elementDescendant - combinator1
E > Fan F element child of an E elementChild - combinator2
E + Fan F element immediately preceded by an E elementAdjacent sibling combinator2
E ~ Fan F element preceded by an E elementGeneral sibling combinator3
- -

The meaning of each selector is derived from the table above by -prepending "matches" to the contents of each cell in the "Meaning" -column.

- -

3. Case sensitivity

- -

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.

- -

4. Selector syntax

- -

A selector is a chain of one -or more sequences of simple selectors -separated by combinators.

- -

A sequence of simple selectors -is a chain of simple selectors -that are not separated by a combinator. It -always begins with a type selector or a -universal selector. No other type -selector or universal selector is allowed in the sequence.

- -

A simple selector is either a type selector, universal selector, attribute selector, class selector, ID selector, content selector, or pseudo-class. One pseudo-element may be appended to the last -sequence of simple selectors.

- -

Combinators are: white space, "greater-than -sign" (U+003E, >), "plus sign" (U+002B, -+) and "tilde" (U+007E, ~). White -space may appear between a combinator and the simple selectors around -it. 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.

- -

The elements of a document tree that are represented by a selector -are the subjects of the selector. 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.

- -

An empty selector, containing no sequence of simple selectors and -no pseudo-element, is an invalid -selector.

- -

5. Groups of selectors

- -

When several selectors share the same declarations, they may be -grouped into a comma-separated list. (A comma is U+002C.)

- -
-

CSS examples:

-

In this example, we condense three rules with identical -declarations into one. Thus,

-
h1 { font-family: sans-serif }
-h2 { font-family: sans-serif }
-h3 { font-family: sans-serif }
-

is equivalent to:

-
h1, h2, h3 { font-family: sans-serif }
-
- -

Warning: 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.

- - -

6. Simple selectors

- -

6.1. Type selector

- -

A type selector is the name of a document language -element type. A type selector represents an instance of the element -type in the document tree.

- -
-

Example:

-

The following selector represents an h1 element in the document tree:

-
h1
-
- - -

6.1.1. Type selectors and namespaces

- -

Type selectors allow an optional namespace ([XMLNAMES]) 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, |).

- -

The namespace component may be left empty to indicate that the -selector is only to represent elements with no declared namespace.

- -

An asterisk may be used for the namespace prefix, indicating that -the selector represents elements in any namespace (including elements -with no namespace).

- -

Element type selectors that have no namespace component (no -namespace separator), represent elements without regard to the -element's namespace (equivalent to "*|") unless a default -namespace has been declared. If a default namespace has been declared, -the selector will represent only elements in the default -namespace.

- -

A type selector containing a namespace prefix that has not been -previously declared is an invalid 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.

- -

In a namespace-aware client, element type selectors will only match -against the local part -of the element's qualified -name. See below for notes about matching -behaviors in down-level clients.

- -

In summary:

- -
-
ns|E
-
elements with name E in namespace ns
-
*|E
-
elements with name E in any namespace, including those without any - declared namespace
-
|E
-
elements with name E without any declared namespace
-
E
-
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.
-
- -
-

CSS examples:

- -
@namespace foo url(http://www.example.com);
- foo|h1 { color: blue }
- foo|* { color: yellow }
- |h1 { color: red }
- *|h1 { color: green }
- h1 { color: green }
- -

The first rule will match only h1 elements in the - "http://www.example.com" namespace.

- -

The second rule will match all elements in the - "http://www.example.com" namespace.

- -

The third rule will match only h1 elements without - any declared namespace.

- -

The fourth rule will match h1 elements in any - namespace (including those without any declared namespace).

- -

The last rule is equivalent to the fourth rule because no default - namespace has been defined.

- -
- -

6.2. Universal selector

- -

The universal selector, written "asterisk" -(*), 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 Universal selector and -Namespaces below.

- -

If the universal selector is not the only component of a sequence -of simple selectors, the * may be omitted.

- -
-

Examples:

-
    -
  • *[hreflang|=en] and [hreflang|=en] are equivalent,
  • -
  • *.warning and .warning are equivalent,
  • -
  • *#myid and #myid are equivalent.
  • -
-
- -

Note: it is recommended that the -*, representing the universal selector, not be -omitted.

- -

6.2.1. Universal selector and namespaces

- -

The universal selector allows an optional namespace component. It -is used as follows:

- -
-
ns|*
-
all elements in namespace ns
-
*|*
-
all elements
-
|*
-
all elements without any declared namespace
-
*
-
if no default namespace has been specified, this is equivalent to *|*. - Otherwise it is equivalent to ns|* where ns is the default namespace.
-
- -

A universal selector containing a namespace prefix that has not -been previously declared is an invalid -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.

- - -

6.3. Attribute selectors

- -

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.

- -

6.3.1. Attribute presence and values -selectors

- -

CSS2 introduced four attribute selectors:

- -
-
[att] -
Represents an element with the att attribute, whatever the value of - the attribute.
-
[att=val]
-
Represents an element with the att attribute whose value is exactly - "val".
-
[att~=val]
-
Represents an element with the att attribute whose value is a whitespace-separated list of words, one of - which is exactly "val". If "val" contains whitespace, it will never - represent anything (since the words are separated by - spaces).
-
[att|=val] -
Represents an element with the att 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 hreflang attribute on the - link element in HTML) as described in RFC 3066 ([RFC3066]). For lang (or - xml:lang) language subcode matching, please see the :lang pseudo-class.
-
- -

Attribute values must be identifiers or strings. The -case-sensitivity of attribute names and values in selectors depends on -the document language.

- -
- -

Examples:

- -

The following attribute selector represents an h1 - element that carries the title attribute, whatever its - value:

- -
h1[title]
- -

In the following example, the selector represents a - span element whose class attribute has - exactly the value "example":

- -
span[class="example"]
- -

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 span element - whose hello attribute has exactly the value "Cleveland" - and whose goodbye attribute has exactly the value - "Columbus":

- -
span[hello="Cleveland"][goodbye="Columbus"]
- -

The following selectors illustrate the differences between "=" - and "~=". The first selector will represent, for example, the value - "copyright copyleft copyeditor" on a rel attribute. The - second selector will only represent an a element with - an href attribute having the exact value - "http://www.w3.org/".

- -
a[rel~="copyright"]
-a[href="http://www.w3.org/"]
- -

The following selector represents a link element - whose hreflang attribute is exactly "fr".

- -
link[hreflang=fr]
- -

The following selector represents a link element for - which the values of the hreflang attribute begins with - "en", including "en", "en-US", and "en-cockney":

- -
link[hreflang|="en"]
- -

Similarly, the following selectors represents a - DIALOGUE element whenever it has one of two different - values for an attribute character:

- -
DIALOGUE[character=romeo]
-DIALOGUE[character=juliet]
- -
- -

6.3.2. Substring matching attribute -selectors

- -

Three additional attribute selectors are provided for matching -substrings in the value of an attribute:

- -
-
[att^=val]
-
Represents an element with the att attribute whose value begins - with the prefix "val".
-
[att$=val] -
Represents an element with the att attribute whose value ends with - the suffix "val".
-
[att*=val] -
Represents an element with the att attribute whose value contains - at least one instance of the substring "val".
-
- -

Attribute values must be identifiers or strings. The -case-sensitivity of attribute names in selectors depends on the -document language.

- -
-

Examples:

-

The following selector represents an HTML object, referencing an - image:

-
object[type^="image/"]
-

The following selector represents an HTML anchor a with an - href attribute whose value ends with ".html".

-
a[href$=".html"]
-

The following selector represents an HTML paragraph with a title - attribute whose value contains the substring "hello"

-
p[title*="hello"]
-
- -

6.3.3. Attribute selectors and namespaces

- -

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" (|). 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 "|attr"). 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. - -

An attribute selector with an attribute name containing a namespace -prefix that has not been previously declared is an invalid 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. - -

-

CSS examples:

-
@namespace foo "http://www.example.com";
-[foo|att=val] { color: blue }
-[*|att] { color: yellow }
-[|att] { color: green }
-[att] { color: green }
- -

The first rule will match only elements with the attribute - att in the "http://www.example.com" namespace with the - value "val".

- -

The second rule will match only elements with the attribute - att regardless of the namespace of the attribute - (including no declared namespace).

- -

The last two rules are equivalent and will match only elements - with the attribute att where the attribute is not - declared to be in a namespace.

- -
- -

6.3.4. Default attribute values in DTDs

- -

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.

- -

More precisely, a UA is not required to read an "external -subset" of the DTD but is required to look for default -attribute values in the document's "internal subset." (See [XML10] for definitions of these subsets.)

- -

A UA that recognizes an XML namespace [XMLNAMES] 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.)

- -

Note: Typically, implementations -choose to ignore external subsets.

- -
-

Example:

- -

Consider an element EXAMPLE with an attribute "notation" that has a -default value of "decimal". The DTD fragment might be

- -
<!ATTLIST EXAMPLE notation (decimal,octal) "decimal">
- -

If the style sheet contains the rules

- -
EXAMPLE[notation=decimal] { /*... default property settings ...*/ }
-EXAMPLE[notation=octal]   { /*... other settings...*/ }
- -

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:

- -
EXAMPLE                   { /*... default property settings ...*/ }
-EXAMPLE[notation=octal]   { /*... other settings...*/ }
- -

Here, because the selector EXAMPLE[notation=octal] 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.

- -
- -

6.4. Class selectors

- -

Working with HTML, authors may use the period (U+002E, -.) notation as an alternative to the ~= -notation when representing the class attribute. Thus, for -HTML, div.value and div[class~=value] have -the same meaning. The attribute value must immediately follow the -"period" (.).

- -

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 [SVG] describes the SVG -"class" attribute and how a UA should interpret it, and -similarly MathML 1.01 [MATH] describes the MathML -"class" attribute.)

- -
-

CSS examples:

- -

We can assign style information to all elements with - class~="pastoral" as follows:

- -
*.pastoral { color: green }  /* all elements with class~=pastoral */
- -

or just

- -
.pastoral { color: green }  /* all elements with class~=pastoral */
- -

The following assigns style only to H1 elements with - class~="pastoral":

- -
H1.pastoral { color: green }  /* H1 elements with class~=pastoral */
- -

Given these rules, the first H1 instance below would not have - green text, while the second would:

- -
<H1>Not green</H1>
-<H1 class="pastoral">Very green</H1>
- -
- -

To represent a subset of "class" values, each value must be preceded -by a ".", in any order.

- -
- -

CSS example:

- -

The following rule matches any P element whose "class" attribute - has been assigned a list of whitespace-separated values that includes - "pastoral" and "marine":

- -
p.pastoral.marine { color: green }
- -

This rule matches when class="pastoral blue aqua - marine" but does not match for class="pastoral - blue".

- -
- -

Note: 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.

- -

Note: 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.

- -

6.5. ID selectors

- -

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.

- -

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, -#) immediately followed by the ID value, which must be an -identifier.

- -

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. - -

-

Examples:

-

The following ID selector represents an h1 element - whose ID-typed attribute has the value "chapter1":

-
h1#chapter1
-

The following ID selector represents any element whose ID-typed - attribute has the value "chapter1":

-
#chapter1
-

The following selector represents any element whose ID-typed - attribute has the value "z98y".

-
*#z98y
-
- -

Note. In XML 1.0 [XML10], 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: -[name=p371] instead of #p371. Elements in -XML 1.0 documents without a DTD do not have IDs at all.

- -

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.

- -

6.6. Pseudo-classes

- -

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.

- -

A pseudo-class always consists of a "colon" -(:) followed by the name of the pseudo-class and -optionally by a value between parentheses.

- -

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.

- - -

6.6.1. Dynamic pseudo-classes

- -

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.

- -

Dynamic pseudo-classes do not appear in the document source or -document tree.

- - -
The link pseudo-classes: :link and :visited
- -

User agents commonly display unvisited links differently from -previously visited ones. Selectors -provides the pseudo-classes :link and -:visited to distinguish them:

- -
    -
  • The :link pseudo-class applies to links that have - not yet been visited.
  • -
  • The :visited pseudo-class applies once the link has - been visited by the user.
  • -
- -

After some amount of time, user agents may choose to return a -visited link to the (unvisited) ':link' state.

- -

The two states are mutually exclusive.

- -
- -

Example:

- -

The following selector represents links carrying class - external and already visited:

- -
a.external:visited
- -
- -

Note: 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. - -

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.

- -
The user action pseudo-classes -:hover, :active, and :focus
- -

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.

- -
    - -
  • The :hover 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 interactive - media do not have to support this pseudo-class. Some conforming - user agents that support interactive - media may not be able to support this pseudo-class (e.g., a pen - device that does not detect hovering).
  • - -
  • The :active 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.
  • - -
  • The :focus pseudo-class applies while an element - has the focus (accepts keyboard or mouse events, or other forms of - input).
  • - -
- -

There may be document language or implementation specific limits on -which elements can become :active or acquire -:focus.

- -

These pseudo-classes are not mutually exclusive. An element may -match several pseudo-classes at the same time.

- -

Selectors doesn't define if the parent of an element that is -':active' or ':hover' is also in that state.

- -
-

Examples:

-
a:link    /* unvisited links */
-a:visited /* visited links */
-a:hover   /* user hovers */
-a:active  /* active links */
-

An example of combining dynamic pseudo-classes:

-
a:focus
-a:focus:hover
-

The last selector matches a elements that are in - the pseudo-class :focus and in the pseudo-class :hover.

-
- -

Note: An element can be both ':visited' -and ':active' (or ':link' and ':active').

- -

6.6.2. The target pseudo-class :target

- -

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).

- -

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 section_2 in an HTML -document:

- -
http://example.com/html/top.html#section_2
- -

A target element can be represented by the :target -pseudo-class. If the document's URI has no fragment identifier, then -the document has no target element.

- -
-

Example:

-
p.note:target
-

This selector represents a p element of class - note that is the target element of the referring - URI.

-
- -
-

CSS example:

-

Here, the :target pseudo-class is used to make the - target element red and place an image before it, if there is one:

-
*:target { color : red }
-*:target::before { content : url(target.png) }
-
- -

6.6.3. The language pseudo-class :lang

- -

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 [HTML4], the language is determined by a -combination of the lang attribute, the meta -element, and possibly by information from the protocol (such as HTTP -headers). XML uses an attribute called xml:lang, and -there may be other document language-specific methods for determining -the language.

- -

The pseudo-class :lang(C) represents an element that -is in language C. Whether an element is represented by a -:lang() 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 '|=' operator in attribute -selectors. The identifier C does not have to be a valid language -name.

- -

C must not be empty. (If it is, the selector is invalid.)

- -

Note: It is recommended that -documents and protocols indicate language using codes from RFC 3066 [RFC3066] or its successor, and by means of -"xml:lang" attributes in the case of XML-based documents [XML10]. See -"FAQ: Two-letter or three-letter language codes."

- -
-

Examples:

-

The two following selectors represent an HTML document that is in - Belgian, French, or German. The two next selectors represent - q quotations in an arbitrary element in Belgian, French, - or German.

-
html:lang(fr-be)
-html:lang(de)
-:lang(fr-be) > q
-:lang(de) > q
-
- -

6.6.4. The UI element states pseudo-classes

- -
The :enabled and :disabled pseudo-classes
- -

The :enabled 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 input element without also specifying what it -would look like when it was disabled.

- -

Similar to :enabled, :disabled allows the -author to specify precisely how a disabled or inactive user interface -element should look.

- -

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.

- - -
The :checked pseudo-class
- -

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 :checked pseudo-class applies. The -:checked pseudo-class initially applies to such elements -that have the HTML4 selected and checked -attributes as described in Section -17.2.1 of HTML4, but of course the user can toggle "off" such -elements in which case the :checked pseudo-class would no -longer apply. While the :checked 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 selected and -checked attributes, it applies to all media. - - -

The :indeterminate pseudo-class
- -
- -

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.

- -

A future version of this specification may introduce an -:indeterminate pseudo-class that applies to such elements. -

- -
- - -

6.6.5. Structural pseudo-classes

- -

Selectors introduces the concept of structural -pseudo-classes to permit selection based on extra information that lies in -the document tree but cannot be represented by other simple selectors or -combinators. - -

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. - - -

:root pseudo-class
- -

The :root pseudo-class represents an element that is -the root of the document. In HTML 4, this is always the -HTML element. - - -

:nth-child() pseudo-class
- -

The -:nth-child(an+b) -pseudo-class notation represents an element that has -an+b-1 siblings -before it in the document tree, for a given positive -integer or zero value of n, and has a parent element. In -other words, this matches the bth child of an element after -all the children have been split into groups of a 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 a and -b values must be zero, negative integers or positive -integers. The index of the first child of an element is 1. - -

In addition to this, :nth-child() can take -'odd' and 'even' as arguments instead. -'odd' has the same signification as 2n+1, -and 'even' has the same signification as 2n. - - -

-

Examples:

-
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; }
-
- -

When a=0, no repeating is used, so for example -:nth-child(0n+5) matches only the fifth child. When -a=0, the an part need not be -included, so the syntax simplifies to -:nth-child(b) and the last example simplifies -to :nth-child(5). - -

-

Examples:

-
foo:nth-child(0n+1)   /* represents an element foo, first child of its parent element */
-foo:nth-child(1)      /* same */
-
- -

When a=1, the number may be omitted from the rule. - -

-

Examples:

-

The following selectors are therefore equivalent:

-
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) */
-
- -

If b=0, then every ath element is picked. In -such a case, the b part may be omitted. - -

-

Examples:

-
tr:nth-child(2n+0) /* represents every even row of an HTML table */
-tr:nth-child(2n) /* same */
-
- -

If both a and b are equal to zero, the -pseudo-class represents no element in the document tree.

- -

The value a can be negative, but only the positive -values of an+b, for -n≥0, may represent an element in the document -tree.

- -
-

Example:

-
html|tr:nth-child(-n+6)  /* represents the 6 first rows of XHTML tables */
-
- -

When the value b is negative, the "+" character in the -expression must be removed (it is effectively replaced by the "-" -character indicating the negative value of b).

- -
-

Examples:

-
: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 */
-
- - -
:nth-last-child() pseudo-class
- -

The :nth-last-child(an+b) -pseudo-class notation represents an element that has -an+b-1 siblings -after it in the document tree, for a given positive -integer or zero value of n, and has a parent element. See -:nth-child() pseudo-class for the syntax of its argument. -It also accepts the 'even' and 'odd' values -as arguments. - - -

-

Examples:

-
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 */
-
- - -
:nth-of-type() pseudo-class
- -

The :nth-of-type(an+b) -pseudo-class notation represents an element that has -an+b-1 siblings with the same -element name before it in the document tree, for a -given zero or positive integer value of n, and has a -parent element. In other words, this matches the bth child -of that type after all the children of that type have been split into -groups of a elements each. See :nth-child() pseudo-class -for the syntax of its argument. It also accepts the -'even' and 'odd' values. - - -

-

CSS example:

-

This allows an author to alternate the position of floated images:

-
img:nth-of-type(2n+1) { float: right; }
-img:nth-of-type(2n) { float: left; }
-
- - -
:nth-last-of-type() pseudo-class
- -

The :nth-last-of-type(an+b) -pseudo-class notation represents an element that has -an+b-1 siblings with the same -element name after it in the document tree, for a -given zero or positive integer value of n, and has a -parent element. See :nth-child() pseudo-class for the -syntax of its argument. It also accepts the 'even' and 'odd' values. - - -

-

Example:

-

To represent all h2 children of an XHTML - body except the first and last, one could use the - following selector:

-
body > h2:nth-of-type(n+2):nth-last-of-type(n+2)
-

In this case, one could also use :not(), although the - selector ends up being just as long:

-
body > h2:not(:first-of-type):not(:last-of-type)
-
- - -
:first-child pseudo-class
- -

Same as :nth-child(1). The :first-child pseudo-class -represents an element that is the first child of some other element. - - -

-

Examples:

-

The following selector represents a p element that is - the first child of a div element:

-
div > p:first-child
-

This selector can represent the p inside the - div of the following fragment:

-
<p> The last P before the note.</p>
-<div class="note">
-   <p> The first P inside the note.</p>
-</div>
but cannot represent the second p in the following -fragment: -
<p> The last P before the note.</p>
-<div class="note">
-   <h2> Note </h2>
-   <p> The first P inside the note.</p>
-</div>
-

The following two selectors are usually equivalent:

-
* > a:first-child /* a is first child of any element */
-a:first-child /* Same (assuming a is not the root element) */
-
- -
:last-child pseudo-class
- -

Same as :nth-last-child(1). The :last-child pseudo-class -represents an element that is the last child of some other element. - -

-

Example:

-

The following selector represents a list item li that - is the last child of an ordered list ol. -

ol > li:last-child
-
- -
:first-of-type pseudo-class
- -

Same as :nth-of-type(1). The :first-of-type pseudo-class -represents an element that is the first sibling of its type in the list of -children of its parent element. - -

-

Example:

-

The following selector represents a definition title -dt inside a definition list dl, this -dt being the first of its type in the list of children of -its parent element.

-
dl dt:first-of-type
-

It is a valid description for the first two dt -elements in the following example but not for the third one:

-
<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>
-
- -
:last-of-type pseudo-class
- -

Same as :nth-last-of-type(1). The -:last-of-type pseudo-class represents an element that is -the last sibling of its type in the list of children of its parent -element.

- -
-

Example:

-

The following selector represents the last data cell - td of a table row.

-
tr > td:last-of-type
-
- -
:only-child pseudo-class
- -

Represents an element that has a parent element and whose parent -element has no other element children. Same as -:first-child:last-child or -:nth-child(1):nth-last-child(1), but with a lower -specificity.

- -
:only-of-type pseudo-class
- -

Represents an element that has a parent element and whose parent -element has no other element children with the same element name. Same -as :first-of-type:last-of-type or -:nth-of-type(1):nth-last-of-type(1), but with a lower -specificity.

- - -
:empty pseudo-class
- -

The :empty 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.

- -
-

Examples:

-

p:empty is a valid representation of the following fragment:

-
<p></p>
-

foo:empty is not a valid representation for the - following fragments:

-
<foo>bar</foo>
-
<foo><bar>bla</bar></foo>
-
<foo>this is not <bar>:empty</bar></foo>
-
- -

6.6.6. Blank

- -

This section intentionally left blank.

- - -

6.6.7. The negation pseudo-class

- -

The negation pseudo-class, :not(X), is a -functional notation taking a simple -selector (excluding the negation pseudo-class itself and -pseudo-elements) as an argument. It represents an element that is not -represented by the argument. - - - -

-

Examples:

-

The following CSS selector matches all button - elements in an HTML document that are not disabled.

-
button:not([DISABLED])
-

The following selector represents all but FOO - elements.

-
*:not(FOO)
-

The following group of selectors represents all HTML elements - except links.

-
html|*:not(:link):not(:visited)
-
- -

Default namespace declarations do not affect the argument of the -negation pseudo-class unless the argument is a universal selector or a -type selector.

- -
-

Examples:

-

Assuming that the default namespace is bound to - "http://example.com/", the following selector represents all - elements that are not in that namespace:

-
*|*:not(*)
-

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 are being hovered.

-
*|*:not(:hover)
-
- -

Note: the :not() pseudo allows -useless selectors to be written. For instance :not(*|*), -which represents no element at all, or foo:not(bar), -which is equivalent to foo but with a higher -specificity.

- -

7. Pseudo-elements

- -

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 ::before and -::after pseudo-elements give access to generated -content).

- -

A pseudo-element is made of two colons (::) followed -by the name of the pseudo-element.

- -

This :: 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, -:first-line, :first-letter, -:before and :after). This compatibility is -not allowed for the new pseudo-elements introduced in CSS level 3.

- -

Only one pseudo-element may appear per selector, and if present it -must appear after the sequence of simple selectors that represents the -subjects of the selector. A -future version of this specification may allow multiple -pesudo-elements per selector.

- -

7.1. The ::first-line pseudo-element

- -

The ::first-line pseudo-element describes the contents -of the first formatted line of an element. - -

-

CSS example:

-
p::first-line { text-transform: uppercase }
-

The above rule means "change the letters of the first line of every -paragraph to uppercase".

-
- -

The selector p::first-line 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.

- -

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>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>
-
- -

the lines of which happen to be broken as follows: - -

-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.
-
- -

This paragraph might be "rewritten" by user agents to include the -fictional tag sequence for ::first-line. This -fictional tag sequence helps to show how properties are inherited.

- -
-<P><P::first-line> This is a somewhat long HTML 
-paragraph that </P::first-line> 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>
-
- -

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 span element:

- -
-<P><SPAN class="test"> This is a somewhat long HTML
-paragraph that will be broken into several
-lines.</SPAN> The first line will be identified
-by a fictional tag sequence. The other lines 
-will be treated as ordinary lines in the 
-paragraph.</P>
-
- -

the user agent could simulate start and end tags for -span when inserting the fictional tag sequence for -::first-line. - -

-<P><P::first-line><SPAN class="test"> This is a
-somewhat long HTML
-paragraph that will </SPAN></P::first-line><SPAN class="test"> be
-broken into several
-lines.</SPAN> The first line will be identified
-by a fictional tag sequence. The other lines
-will be treated as ordinary lines in the 
-paragraph.</P>
-
- -

In CSS, the ::first-line pseudo-element can only be -attached to a block-level element, an inline-block, a table-caption, -or a table-cell.

- -

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 div in <DIV><P>This -line...</P></DIV> is the first line of the p (assuming -that both p and div are block-level). - -

The first line of a table-cell or inline-block cannot be the first -formatted line of an ancestor element. Thus, in <DIV><P -STYLE="display: inline-block">Hello<BR>Goodbye</P> -etcetera</DIV> the first formatted line of the -div is not the line "Hello". - -

Note that the first line of the p in this -fragment: <p><br>First... doesn't contain any -letters (assuming the default style for br in HTML -4). The word "First" is not on the first formatted line. - -

A UA should act as if the fictional start tags of the -::first-line 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

- -
-<DIV>
-  <P>First paragraph</P>
-  <P>Second paragraph</P>
-</DIV>
-
- -

is

- -
-<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>
-
- -

The ::first-line pseudo-element is similar to an -inline-level element, but with certain restrictions. In CSS, the -following properties apply to a ::first-line -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.

- - -

7.2. The ::first-letter pseudo-element

- -

The ::first-letter 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.

- -

In CSS, these are the properties that apply to ::first-letter -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.

- -
-

Example:

-

This example shows a possible rendering of an initial cap. Note -that the 'line-height' that is inherited by the ::first-letter -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, and thus -the font weight of the first letter is normal, not bold as the span: -

-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.
-
-
-

Image illustrating the ::first-letter pseudo-element -

-
- -
-

The following CSS will make a drop cap initial letter span about two lines:

- -
-<!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>
-
- -

This example might be formatted as follows:

- -
-

Image illustrating the combined effect of the ::first-letter and ::first-line pseudo-elements

-
- -

The fictional tag sequence is:

- -
-<P>
-<SPAN>
-<P::first-letter>
-T
-</P::first-letter>he first
-</SPAN> 
-few words of an article in the Economist.
-</P>
-
- -

Note that the ::first-letter 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.

- -

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.

- -

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. [UNICODE]

- -
-

Quotes that precede the
-first letter should be included.

-
- -

The ::first-letter also applies if the first letter is -in fact a digit, e.g., the "6" in "67 million dollars is a lot of -money."

- -

In CSS, the ::first-letter pseudo-element applies to -block, list-item, table-cell, table-caption, and inline-block -elements. A future version of this specification -may allow this pesudo-element to apply to more element -types.

- -

The ::first-letter 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.

- -
-

Example:

-

The fictional tag sequence for this HTMLfragment: -

<div>
-<p>The first text.
-

is: -

<div>
-<p><div::first-letter><p::first-letter>T</...></...>he first text.
-
- -

The first letter of a table-cell or inline-block cannot be the -first letter of an ancestor element. Thus, in <DIV><P -STYLE="display: inline-block">Hello<BR>Goodbye</P> -etcetera</DIV> the first letter of the div is not the -letter "H". In fact, the div doesn't have a first letter. - -

The first letter must occur on the first formatted line. For example, in -this fragment: <p><br>First... the first line -doesn't contain any letters and ::first-letter doesn't -match anything (assuming the default style for br in HTML -4). In particular, it does not match the "F" of "First." - -

In CSS, if an element is a list item ('display: list-item'), the -::first-letter applies to the first letter in the -principal box after the marker. UAs may ignore -::first-letter on list items with 'list-style-position: -inside'. If an element has ::before or -::after content, the ::first-letter applies -to the first letter of the element including that content. - -

-

Example:

-

After the rule 'p::before {content: "Note: "}', the selector -'p::first-letter' matches the "N" of "Note".

-
- -

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 ::first-letter pseudo-element. - -

If the letters that would form the ::first-letter are not in the -same element, such as "'T" in <p>'<em>T..., the UA -may create a ::first-letter pseudo-element from one of the elements, -both elements, or simply not create a pseudo-element.

- -

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). - -

-

Example:

-

The following example 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 { 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>
- -

Assuming that a line break will occur before the word "ends", the -fictional tag -sequence for this fragment might be:

- -
<P>
-<P::first-line>
-<P::first-letter> 
-S 
-</P::first-letter>ome text that 
-</P::first-line> 
-ends up on two lines 
-</P>
- -

Note that the ::first-letter element is inside the ::first-line -element. Properties set on ::first-line are inherited by -::first-letter, but are overridden if the same property is set on -::first-letter.

-
- - -

7.3. The ::selection pseudo-element

- -

The ::selection 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 :checked pseudo-class (which used to be -named :selected) - -

Although the ::selection 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 -[CSS21]) which was originally rendered to a -dynamic medium (like screen), the UA may wish to transfer the current -::selection 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 ::selection -pseudo-element for static media. - -

These are the CSS properties that apply to ::selection -pseudo-elements: color, background, cursor (optional), outline -(optional). The computed value of the 'background-image' property on -::selection may be ignored. - - -

7.4. The ::before and ::after pseudo-elements

- -

The ::before and ::after pseudo-elements -can be used to describe generated content before or after an element's -content. They are explained in CSS 2.1 [CSS21].

- -

When the ::first-letter and ::first-line -pseudo-elements are combined with ::before and -::after, they apply to the first letter or line of the -element including the inserted text.

- -

8. Combinators

- -

8.1. Descendant combinator

- -

At times, authors may want selectors to describe an element that is -the descendant of another element in the document tree (e.g., "an -EM element that is contained within an H1 -element"). Descendant combinators express such a relationship. A -descendant combinator is white space that -separates two sequences of simple selectors. A selector of the form -"A B" represents an element B that is an -arbitrary descendant of some ancestor element A. - -

-

Examples:

-

For example, consider the following selector:

-
h1 em
-

It represents an em element being the descendant of - an h1 element. It is a correct and valid, but partial, - description of the following fragment:

-
<h1>This <span class="myclass">headline
-is <em>very</em> important</span></h1>
-

The following selector:

-
div * p
-

represents a p element that is a grandchild or later - descendant of a div 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.

-

The following selector, which combines descendant combinators and - attribute selectors, represents an - element that (1) has the href attribute set and (2) is - inside a p that is itself inside a div:

-
div p *[href]
-
- -

8.2. Child combinators

- -

A child combinator describes a childhood relationship -between two elements. A child combinator is made of the -"greater-than sign" (>) character and -separates two sequences of simple selectors. - - -

-

Examples:

-

The following selector represents a p element that is - child of body:

-
body > p
-

The following example combines descendant combinators and child - combinators.

-
div ol>li p
-

It represents a p element that is a descendant of an - li element; the li element must be the - child of an ol element; the ol element must - be a descendant of a div. Notice that the optional white - space around the ">" combinator has been left out.

-
- -

For information on selecting the first child of an element, please -see the section on the :first-child pseudo-class -above.

- -

8.3. Sibling combinators

- -

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.

- -

8.3.1. Adjacent sibling combinator

- -

The adjacent sibling combinator is made of the "plus -sign" (U+002B, +) 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.

- -
-

Examples:

-

The following selector represents a p element - immediately following a math element:

-
math + 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 h1 element, that it must have - class="opener":

-
h1.opener + h2
-
- - -

8.3.2. General sibling combinator

- -

The general sibling combinator is made of the "tilde" -(U+007E, ~) 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.

- -
-

Example:

-
h1 ~ pre
-

represents a pre element following an h1. It - is a correct and valid, but partial, description of:

-
<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>
-
- -

9. Calculating a selector's specificity

- -

A selector's specificity is calculated as follows:

- -
    -
  • count the number of ID selectors in the selector (= a)
  • -
  • count the number of class selectors, attributes selectors, and pseudo-classes in the selector (= b)
  • -
  • count the number of element names in the selector (= c)
  • -
  • ignore pseudo-elements
  • -
- -

Selectors inside the negation pseudo-class -are counted like any other, but the negation itself does not count as -a pseudo-class.

- -

Concatenating the three numbers a-b-c (in a number system with a -large base) gives the specificity.

- -
-

Examples:

-
*               /* 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 */
-
-
- -

Note: the specificity of the styles -specified in an HTML style attribute is described in CSS -2.1. [CSS21].

- -

10. The grammar of Selectors

- -

10.1. Grammar

- -

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 [YACC]) -are used:

- -
    -
  • *: 0 or more -
  • +: 1 or more -
  • ?: 0 or 1 -
  • |: separates alternatives -
  • [ ]: grouping
  • -
- -

The productions are:

- -
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
-  ;
- - -

10.2. Lexical scanner

- -

The following is the tokenizer, written in Flex (see -[FLEX]) notation. The tokenizer is -case-insensitive.

- -

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. [UNICODE]

- -
%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;
- - - -

11. Namespaces and down-level clients

- -

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.

- -

It should be noted that a down-level CSS client will (if it -properly conforms to CSS forward compatible parsing rules) ignore all -@namespace 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.

- -

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.

- -

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.

- -
    -
  1. - -

    The XML document does not use namespaces.

    - -
      - -
    • 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.
    • - -
    • 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 ("|name") - will guarantee that selectors will match only XML elements that do - not have a declared namespace.
    • - -
    - -
  2. - -
  3. - -

    The XML document defines a single, default namespace used - throughout the document. No namespace prefixes are used in element - names.

    - -
      - -
    • 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.
    • - -
    - -
  4. - -
  5. - -

    The XML document does not 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).

    - -
      - -
    • 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 Type selectors and Namespaces section. CSS - selectors may be declared using an escaped colon "\:" - to describe the fully qualified names, e.g. - "html\:h1" will match - <html:h1>. 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.
    • - -
    • Note that selectors declared in this fashion will - only 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).
    • - -
    - -
  6. - -
- -

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 -different 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.

- -

12. Profiles

- -

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.

- -

Non normative examples: - -

- - - - - - - - - - - - - - - -
Selectors profile
SpecificationCSS level 1
Acceptstype selectors
class selectors
ID selectors
:link, - :visited and :active pseudo-classes
descendant combinator -
::first-line and ::first-letter pseudo-elements
Excludes - -

universal selector
attribute selectors
:hover and :focus - pseudo-classes
:target pseudo-class
:lang() pseudo-class
all UI - element states pseudo-classes
all structural - pseudo-classes
negation pseudo-class
all - UI element fragments pseudo-elements
::before and ::after - pseudo-elements
child combinators
sibling combinators - -

namespaces

Extra constraintsonly one class selector allowed per sequence of simple - selectors


- - - - - - - - - - - - - - - -
Selectors profile
SpecificationCSS level 2
Acceptstype selectors
universal selector
attribute presence and - values selectors
class selectors
ID selectors
:link, :visited, - :active, :hover, :focus, :lang() and :first-child pseudo-classes -
descendant combinator
child combinator
adjacent sibling - combinator
::first-line and ::first-letter pseudo-elements
::before - and ::after pseudo-elements
Excludes - -

content selectors
substring matching attribute - selectors
:target pseudo-classes
all UI element - states pseudo-classes
all structural pseudo-classes other - than :first-child
negation pseudo-class
all UI element - fragments pseudo-elements
general sibling combinators - -

namespaces

Extra constraintsmore than one class selector per sequence of simple selectors (CSS1 - constraint) allowed
- -

In CSS, selectors express pattern matching rules that determine which style -rules apply to elements in the document tree. - -

The following selector (CSS level 2) will match all anchors a -with attribute name set inside a section 1 header h1: -

h1 a[name]
- -

All CSS declarations attached to such a selector are applied to elements -matching it.

- -
- - - - - - - - - - - - - - - - -
Selectors profile
SpecificationSTTS 3
Accepts - -

type selectors
universal selectors
attribute selectors
class - selectors
ID selectors
all structural pseudo-classes
- all combinators - -

namespaces

Excludesnon-accepted pseudo-classes
pseudo-elements
Extra constraintssome selectors and combinators are not allowed in fragment - descriptions on the right side of STTS declarations.
-
- - - - - - - - - - - - - - - - - - - - - - - - - -
- -

Selectors can be used in STTS 3 in two different - manners: -

    -
  1. a selection mechanism equivalent to CSS selection mechanism: declarations - attached to a given selector are applied to elements matching that selector, -
  2. fragment descriptions that appear on the right side of declarations. -
- -

13. Conformance and requirements

- -

This section defines conformance with the present specification only. - -

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. - -

All specifications reusing Selectors must contain a Profile listing the -subset of Selectors it accepts or excludes, and describing the constraints -it adds to the current specification. - -

Invalidity is caused by a parsing error, e.g. an unrecognized token or a token -which is not allowed at the current parsing point. - -

User agents must observe the rules for handling parsing errors: -

    -
  • a simple selector containing an undeclared namespace prefix is invalid
  • -
  • a selector containing an invalid simple selector, an invalid combinator - or an invalid token is invalid.
  • -
  • a group of selectors containing an invalid selector is invalid.
  • -
- -

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.)

- - - -

14. Tests

- -

This specification has a test -suite 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.

- -

15. Acknowledgements

- -

The CSS working group would like to thank everyone who has sent -comments on this specification over the years.

- -

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.

- -

16. References

- -
- -
[CSS1] -
Bert Bos, Håkon Wium Lie; "Cascading Style Sheets, level 1", W3C Recommendation, 17 Dec 1996, revised 11 Jan 1999 -
(http://www.w3.org/TR/REC-CSS1) - -
[CSS21] -
Bert Bos, Tantek Çelik, Ian Hickson, Håkon Wium Lie, editors; "Cascading Style Sheets, level 2 revision 1", W3C Working Draft, 13 June 2005 -
(http://www.w3.org/TR/CSS21) - -
[CWWW] -
Martin J. Dürst, François Yergeau, Misha Wolf, Asmus Freytag, Tex Texin, editors; "Character Model for the World Wide Web", W3C Recommendation, 15 February 2005 -
(http://www.w3.org/TR/charmod/) - -
[FLEX] -
"Flex: The Lexical Scanner Generator", Version 2.3.7, ISBN 1882114213 - -
[HTML4] -
Dave Ragget, Arnaud Le Hors, Ian Jacobs, editors; "HTML 4.01 Specification", W3C Recommendation, 24 December 1999 -
(http://www.w3.org/TR/html4/) - -
[MATH] -
Patrick Ion, Robert Miner, editors; "Mathematical Markup Language (MathML) 1.01", W3C Recommendation, revision of 7 July 1999 -
(http://www.w3.org/TR/REC-MathML/) - -
[RFC3066] -
H. Alvestrand; "Tags for the Identification of Languages", Request for Comments 3066, January 2001 -
(http://www.ietf.org/rfc/rfc3066.txt) - -
[STTS] -
Daniel Glazman; "Simple Tree Transformation Sheets 3", Electricité de France, submission to the W3C, 11 November 1998 -
(http://www.w3.org/TR/NOTE-STTS3) - -
[SVG] -
Jon Ferraiolo, 藤沢 淳, Dean Jackson, editors; "Scalable Vector Graphics (SVG) 1.1 Specification", W3C Recommendation, 14 January 2003 -
(http://www.w3.org/TR/SVG/) - -
[UNICODE]
-
The Unicode Standard, Version 4.1, The Unicode Consortium. Boston, MA, Addison-Wesley, March 2005. ISBN 0-321-18578-1, as amended by Unicode 4.0.1 and Unicode 4.1.0. -
(http://www.unicode.org/versions/)
- -
[XML10] -
Tim Bray, Jean Paoli, C. M. Sperberg-McQueen, Eve Maler, François Yergeau, editors; "Extensible Markup Language (XML) 1.0 (Third Edition)", W3C Recommendation, 4 February 2004 -
(http://www.w3.org/TR/REC-xml/) - -
[XMLNAMES] -
Tim Bray, Dave Hollander, Andrew Layman, editors; "Namespaces in XML", W3C Recommendation, 14 January 1999 -
(http://www.w3.org/TR/REC-xml-names/) - -
[YACC] -
S. C. Johnson; "YACC — Yet another compiler compiler", Technical Report, Murray Hill, 1975 - -
- - diff --git a/samples/third_party/dromaeo/web/tests/dom-traverse.html b/samples/third_party/dromaeo/web/tests/dom-traverse.html deleted file mode 100644 index 9b0a098755a..00000000000 --- a/samples/third_party/dromaeo/web/tests/dom-traverse.html +++ /dev/null @@ -1,2972 +0,0 @@ - - - - - - -
-

W3C - -

Selectors

- -

W3C Working Draft 15 December 2005

- -
- -
This version: - -
- http://www.w3.org/TR/2005/WD-css3-selectors-20051215 - -
Latest version: - -
- http://www.w3.org/TR/css3-selectors - -
Previous version: - -
- http://www.w3.org/TR/2001/CR-css3-selectors-20011113 - -
Editors: - -
Daniel Glazman (Invited Expert)
- -
Tantek Çelik (Invited Expert) - -
Ian Hickson (Google) - -
Peter Linss (former editor, Netscape/AOL) - -
John Williams (former editor, Quark, Inc.) - -
- -
- -
- -

Abstract

- -

Selectors 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.

- -

CSS (Cascading - Style Sheets) is a language for describing the rendering of HTML and XML 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. - -

Selectors define the following function:

- -
expression ∗ element → boolean
- -

That is, given an element and a selector, this specification - defines whether that element matches the selector.

- -

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. STTS (Simple Tree Transformation Sheets), a - language for transforming XML trees, uses this mechanism. [STTS]

- -

Status of this document

- -

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 W3C technical reports index at - http://www.w3.org/TR/.

- -

This document describes the selectors that already exist in CSS1 and CSS2, and - also proposes new selectors for CSS3 and other languages that may need them.

- -

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.

- -

This specification is a last call working draft for the the CSS Working Group - (Style Activity). This - document is a revision of the Candidate - Recommendation dated 2001 November 13, 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.

- -

All persons are encouraged to review and implement this - specification and return comments to the (archived) - public mailing list www-style - (see instructions). W3C - Members can also send comments directly to the CSS Working - Group. - The deadline for comments is 14 January 2006.

- -

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". - -

This document may be available in translation. - The English version of this specification is the only normative - version. - -

- -

Table of contents

- - - -
- -

1. Introduction

- -

1.1. Dependencies

- -

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. [CSS21]

- -

1.2. Terminology

- -

All of the text of this specification is normative except - examples, notes, and sections explicitly marked as - non-normative.

- -

1.3. Changes from CSS2

- -

This section is non-normative.

- -

The main differences between the selectors in CSS2 and those in - Selectors are: - -

    - -
  • 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
  • - -
  • an optional namespace component is now allowed in type element - selectors, the universal selector and attribute selectors
  • - -
  • a new combinator has been introduced
  • - -
  • new simple selectors including substring matching attribute - selectors, and new pseudo-classes
  • - -
  • new pseudo-elements, and introduction of the "::" convention - for pseudo-elements
  • - -
  • the grammar has been rewritten
  • - -
  • profiles to be added to specifications integrating Selectors - and defining the set of selectors which is actually supported by - each specification
  • - -
  • Selectors are now a CSS3 Module and an independent - specification; other specifications can now refer to this document - independently of CSS
  • - -
  • the specification now has its own test suite
  • - -
- -

2. Selectors

- -

This section is non-normative, as it merely summarizes the -following sections.

- -

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.

- -

Selectors may range from simple element names to rich contextual -representations.

- -

The following table summarizes the Selector syntax:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PatternMeaningDescribed in sectionFirst defined in CSS level
*any elementUniversal - selector2
Ean element of type EType selector1
E[foo]an E element with a "foo" attributeAttribute - selectors2
E[foo="bar"]an E element whose "foo" attribute value is exactly - equal to "bar"Attribute - selectors2
E[foo~="bar"]an E element whose "foo" attribute value is a list of - space-separated values, one of which is exactly equal to "bar"Attribute - selectors2
E[foo^="bar"]an E element whose "foo" attribute value begins exactly - with the string "bar"Attribute - selectors3
E[foo$="bar"]an E element whose "foo" attribute value ends exactly - with the string "bar"Attribute - selectors3
E[foo*="bar"]an E element whose "foo" attribute value contains the - substring "bar"Attribute - selectors3
E[hreflang|="en"]an E element whose "hreflang" attribute has a hyphen-separated - list of values beginning (from the left) with "en"Attribute - selectors2
E:rootan E element, root of the documentStructural - pseudo-classes3
E:nth-child(n)an E element, the n-th child of its parentStructural - pseudo-classes3
E:nth-last-child(n)an E element, the n-th child of its parent, counting - from the last oneStructural - pseudo-classes3
E:nth-of-type(n)an E element, the n-th sibling of its typeStructural - pseudo-classes3
E:nth-last-of-type(n)an E element, the n-th sibling of its type, counting - from the last oneStructural - pseudo-classes3
E:first-childan E element, first child of its parentStructural - pseudo-classes2
E:last-childan E element, last child of its parentStructural - pseudo-classes3
E:first-of-typean E element, first sibling of its typeStructural - pseudo-classes3
E:last-of-typean E element, last sibling of its typeStructural - pseudo-classes3
E:only-childan E element, only child of its parentStructural - pseudo-classes3
E:only-of-typean E element, only sibling of its typeStructural - pseudo-classes3
E:emptyan E element that has no children (including text - nodes)Structural - pseudo-classes3
E:link
E:visited
an E element being the source anchor of a hyperlink of - which the target is not yet visited (:link) or already visited - (:visited)The link - pseudo-classes1
E:active
E:hover
E:focus
an E element during certain user actionsThe user - action pseudo-classes1 and 2
E:targetan E element being the target of the referring URIThe target - pseudo-class3
E:lang(fr)an element of type E in language "fr" (the document - language specifies how language is determined)The :lang() - pseudo-class2
E:enabled
E:disabled
a user interface element E which is enabled or - disabledThe UI element states - pseudo-classes3
E:checkeda user interface element E which is checked (for instance a radio-button or checkbox)The UI element states - pseudo-classes3
E::first-linethe first formatted line of an E elementThe ::first-line - pseudo-element1
E::first-letterthe first formatted letter of an E elementThe ::first-letter - pseudo-element1
E::selectionthe portion of an E element that is currently - selected/highlighted by the userThe UI element - fragments pseudo-elements3
E::beforegenerated content before an E elementThe ::before - pseudo-element2
E::aftergenerated content after an E elementThe ::after - pseudo-element2
E.warningan E element whose class is -"warning" (the document language specifies how class is determined).Class - selectors1
E#myidan E element with ID equal to "myid".ID - selectors1
E:not(s)an E element that does not match simple selector sNegation - pseudo-class3
E Fan F element descendant of an E elementDescendant - combinator1
E > Fan F element child of an E elementChild - combinator2
E + Fan F element immediately preceded by an E elementAdjacent sibling combinator2
E ~ Fan F element preceded by an E elementGeneral sibling combinator3
- -

The meaning of each selector is derived from the table above by -prepending "matches" to the contents of each cell in the "Meaning" -column.

- -

3. Case sensitivity

- -

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.

- -

4. Selector syntax

- -

A selector is a chain of one -or more sequences of simple selectors -separated by combinators.

- -

A sequence of simple selectors -is a chain of simple selectors -that are not separated by a combinator. It -always begins with a type selector or a -universal selector. No other type -selector or universal selector is allowed in the sequence.

- -

A simple selector is either a type selector, universal selector, attribute selector, class selector, ID selector, content selector, or pseudo-class. One pseudo-element may be appended to the last -sequence of simple selectors.

- -

Combinators are: white space, "greater-than -sign" (U+003E, >), "plus sign" (U+002B, -+) and "tilde" (U+007E, ~). White -space may appear between a combinator and the simple selectors around -it. 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.

- -

The elements of a document tree that are represented by a selector -are the subjects of the selector. 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.

- -

An empty selector, containing no sequence of simple selectors and -no pseudo-element, is an invalid -selector.

- -

5. Groups of selectors

- -

When several selectors share the same declarations, they may be -grouped into a comma-separated list. (A comma is U+002C.)

- -
-

CSS examples:

-

In this example, we condense three rules with identical -declarations into one. Thus,

-
h1 { font-family: sans-serif }
-h2 { font-family: sans-serif }
-h3 { font-family: sans-serif }
-

is equivalent to:

-
h1, h2, h3 { font-family: sans-serif }
-
- -

Warning: 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.

- - -

6. Simple selectors

- -

6.1. Type selector

- -

A type selector is the name of a document language -element type. A type selector represents an instance of the element -type in the document tree.

- -
-

Example:

-

The following selector represents an h1 element in the document tree:

-
h1
-
- - -

6.1.1. Type selectors and namespaces

- -

Type selectors allow an optional namespace ([XMLNAMES]) 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, |).

- -

The namespace component may be left empty to indicate that the -selector is only to represent elements with no declared namespace.

- -

An asterisk may be used for the namespace prefix, indicating that -the selector represents elements in any namespace (including elements -with no namespace).

- -

Element type selectors that have no namespace component (no -namespace separator), represent elements without regard to the -element's namespace (equivalent to "*|") unless a default -namespace has been declared. If a default namespace has been declared, -the selector will represent only elements in the default -namespace.

- -

A type selector containing a namespace prefix that has not been -previously declared is an invalid 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.

- -

In a namespace-aware client, element type selectors will only match -against the local part -of the element's qualified -name. See below for notes about matching -behaviors in down-level clients.

- -

In summary:

- -
-
ns|E
-
elements with name E in namespace ns
-
*|E
-
elements with name E in any namespace, including those without any - declared namespace
-
|E
-
elements with name E without any declared namespace
-
E
-
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.
-
- -
-

CSS examples:

- -
@namespace foo url(http://www.example.com);
- foo|h1 { color: blue }
- foo|* { color: yellow }
- |h1 { color: red }
- *|h1 { color: green }
- h1 { color: green }
- -

The first rule will match only h1 elements in the - "http://www.example.com" namespace.

- -

The second rule will match all elements in the - "http://www.example.com" namespace.

- -

The third rule will match only h1 elements without - any declared namespace.

- -

The fourth rule will match h1 elements in any - namespace (including those without any declared namespace).

- -

The last rule is equivalent to the fourth rule because no default - namespace has been defined.

- -
- -

6.2. Universal selector

- -

The universal selector, written "asterisk" -(*), 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 Universal selector and -Namespaces below.

- -

If the universal selector is not the only component of a sequence -of simple selectors, the * may be omitted.

- -
-

Examples:

-
    -
  • *[hreflang|=en] and [hreflang|=en] are equivalent,
  • -
  • *.warning and .warning are equivalent,
  • -
  • *#myid and #myid are equivalent.
  • -
-
- -

Note: it is recommended that the -*, representing the universal selector, not be -omitted.

- -

6.2.1. Universal selector and namespaces

- -

The universal selector allows an optional namespace component. It -is used as follows:

- -
-
ns|*
-
all elements in namespace ns
-
*|*
-
all elements
-
|*
-
all elements without any declared namespace
-
*
-
if no default namespace has been specified, this is equivalent to *|*. - Otherwise it is equivalent to ns|* where ns is the default namespace.
-
- -

A universal selector containing a namespace prefix that has not -been previously declared is an invalid -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.

- - -

6.3. Attribute selectors

- -

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.

- -

6.3.1. Attribute presence and values -selectors

- -

CSS2 introduced four attribute selectors:

- -
-
[att] -
Represents an element with the att attribute, whatever the value of - the attribute.
-
[att=val]
-
Represents an element with the att attribute whose value is exactly - "val".
-
[att~=val]
-
Represents an element with the att attribute whose value is a whitespace-separated list of words, one of - which is exactly "val". If "val" contains whitespace, it will never - represent anything (since the words are separated by - spaces).
-
[att|=val] -
Represents an element with the att 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 hreflang attribute on the - link element in HTML) as described in RFC 3066 ([RFC3066]). For lang (or - xml:lang) language subcode matching, please see the :lang pseudo-class.
-
- -

Attribute values must be identifiers or strings. The -case-sensitivity of attribute names and values in selectors depends on -the document language.

- -
- -

Examples:

- -

The following attribute selector represents an h1 - element that carries the title attribute, whatever its - value:

- -
h1[title]
- -

In the following example, the selector represents a - span element whose class attribute has - exactly the value "example":

- -
span[class="example"]
- -

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 span element - whose hello attribute has exactly the value "Cleveland" - and whose goodbye attribute has exactly the value - "Columbus":

- -
span[hello="Cleveland"][goodbye="Columbus"]
- -

The following selectors illustrate the differences between "=" - and "~=". The first selector will represent, for example, the value - "copyright copyleft copyeditor" on a rel attribute. The - second selector will only represent an a element with - an href attribute having the exact value - "http://www.w3.org/".

- -
a[rel~="copyright"]
-a[href="http://www.w3.org/"]
- -

The following selector represents a link element - whose hreflang attribute is exactly "fr".

- -
link[hreflang=fr]
- -

The following selector represents a link element for - which the values of the hreflang attribute begins with - "en", including "en", "en-US", and "en-cockney":

- -
link[hreflang|="en"]
- -

Similarly, the following selectors represents a - DIALOGUE element whenever it has one of two different - values for an attribute character:

- -
DIALOGUE[character=romeo]
-DIALOGUE[character=juliet]
- -
- -

6.3.2. Substring matching attribute -selectors

- -

Three additional attribute selectors are provided for matching -substrings in the value of an attribute:

- -
-
[att^=val]
-
Represents an element with the att attribute whose value begins - with the prefix "val".
-
[att$=val] -
Represents an element with the att attribute whose value ends with - the suffix "val".
-
[att*=val] -
Represents an element with the att attribute whose value contains - at least one instance of the substring "val".
-
- -

Attribute values must be identifiers or strings. The -case-sensitivity of attribute names in selectors depends on the -document language.

- -
-

Examples:

-

The following selector represents an HTML object, referencing an - image:

-
object[type^="image/"]
-

The following selector represents an HTML anchor a with an - href attribute whose value ends with ".html".

-
a[href$=".html"]
-

The following selector represents an HTML paragraph with a title - attribute whose value contains the substring "hello"

-
p[title*="hello"]
-
- -

6.3.3. Attribute selectors and namespaces

- -

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" (|). 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 "|attr"). 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. - -

An attribute selector with an attribute name containing a namespace -prefix that has not been previously declared is an invalid 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. - -

-

CSS examples:

-
@namespace foo "http://www.example.com";
-[foo|att=val] { color: blue }
-[*|att] { color: yellow }
-[|att] { color: green }
-[att] { color: green }
- -

The first rule will match only elements with the attribute - att in the "http://www.example.com" namespace with the - value "val".

- -

The second rule will match only elements with the attribute - att regardless of the namespace of the attribute - (including no declared namespace).

- -

The last two rules are equivalent and will match only elements - with the attribute att where the attribute is not - declared to be in a namespace.

- -
- -

6.3.4. Default attribute values in DTDs

- -

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.

- -

More precisely, a UA is not required to read an "external -subset" of the DTD but is required to look for default -attribute values in the document's "internal subset." (See [XML10] for definitions of these subsets.)

- -

A UA that recognizes an XML namespace [XMLNAMES] 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.)

- -

Note: Typically, implementations -choose to ignore external subsets.

- -
-

Example:

- -

Consider an element EXAMPLE with an attribute "notation" that has a -default value of "decimal". The DTD fragment might be

- -
<!ATTLIST EXAMPLE notation (decimal,octal) "decimal">
- -

If the style sheet contains the rules

- -
EXAMPLE[notation=decimal] { /*... default property settings ...*/ }
-EXAMPLE[notation=octal]   { /*... other settings...*/ }
- -

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:

- -
EXAMPLE                   { /*... default property settings ...*/ }
-EXAMPLE[notation=octal]   { /*... other settings...*/ }
- -

Here, because the selector EXAMPLE[notation=octal] 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.

- -
- -

6.4. Class selectors

- -

Working with HTML, authors may use the period (U+002E, -.) notation as an alternative to the ~= -notation when representing the class attribute. Thus, for -HTML, div.value and div[class~=value] have -the same meaning. The attribute value must immediately follow the -"period" (.).

- -

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 [SVG] describes the SVG -"class" attribute and how a UA should interpret it, and -similarly MathML 1.01 [MATH] describes the MathML -"class" attribute.)

- -
-

CSS examples:

- -

We can assign style information to all elements with - class~="pastoral" as follows:

- -
*.pastoral { color: green }  /* all elements with class~=pastoral */
- -

or just

- -
.pastoral { color: green }  /* all elements with class~=pastoral */
- -

The following assigns style only to H1 elements with - class~="pastoral":

- -
H1.pastoral { color: green }  /* H1 elements with class~=pastoral */
- -

Given these rules, the first H1 instance below would not have - green text, while the second would:

- -
<H1>Not green</H1>
-<H1 class="pastoral">Very green</H1>
- -
- -

To represent a subset of "class" values, each value must be preceded -by a ".", in any order.

- -
- -

CSS example:

- -

The following rule matches any P element whose "class" attribute - has been assigned a list of whitespace-separated values that includes - "pastoral" and "marine":

- -
p.pastoral.marine { color: green }
- -

This rule matches when class="pastoral blue aqua - marine" but does not match for class="pastoral - blue".

- -
- -

Note: 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.

- -

Note: 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.

- -

6.5. ID selectors

- -

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.

- -

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, -#) immediately followed by the ID value, which must be an -identifier.

- -

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. - -

-

Examples:

-

The following ID selector represents an h1 element - whose ID-typed attribute has the value "chapter1":

-
h1#chapter1
-

The following ID selector represents any element whose ID-typed - attribute has the value "chapter1":

-
#chapter1
-

The following selector represents any element whose ID-typed - attribute has the value "z98y".

-
*#z98y
-
- -

Note. In XML 1.0 [XML10], 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: -[name=p371] instead of #p371. Elements in -XML 1.0 documents without a DTD do not have IDs at all.

- -

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.

- -

6.6. Pseudo-classes

- -

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.

- -

A pseudo-class always consists of a "colon" -(:) followed by the name of the pseudo-class and -optionally by a value between parentheses.

- -

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.

- - -

6.6.1. Dynamic pseudo-classes

- -

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.

- -

Dynamic pseudo-classes do not appear in the document source or -document tree.

- - -
The link pseudo-classes: :link and :visited
- -

User agents commonly display unvisited links differently from -previously visited ones. Selectors -provides the pseudo-classes :link and -:visited to distinguish them:

- -
    -
  • The :link pseudo-class applies to links that have - not yet been visited.
  • -
  • The :visited pseudo-class applies once the link has - been visited by the user.
  • -
- -

After some amount of time, user agents may choose to return a -visited link to the (unvisited) ':link' state.

- -

The two states are mutually exclusive.

- -
- -

Example:

- -

The following selector represents links carrying class - external and already visited:

- -
a.external:visited
- -
- -

Note: 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. - -

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.

- -
The user action pseudo-classes -:hover, :active, and :focus
- -

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.

- -
    - -
  • The :hover 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 interactive - media do not have to support this pseudo-class. Some conforming - user agents that support interactive - media may not be able to support this pseudo-class (e.g., a pen - device that does not detect hovering).
  • - -
  • The :active 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.
  • - -
  • The :focus pseudo-class applies while an element - has the focus (accepts keyboard or mouse events, or other forms of - input).
  • - -
- -

There may be document language or implementation specific limits on -which elements can become :active or acquire -:focus.

- -

These pseudo-classes are not mutually exclusive. An element may -match several pseudo-classes at the same time.

- -

Selectors doesn't define if the parent of an element that is -':active' or ':hover' is also in that state.

- -
-

Examples:

-
a:link    /* unvisited links */
-a:visited /* visited links */
-a:hover   /* user hovers */
-a:active  /* active links */
-

An example of combining dynamic pseudo-classes:

-
a:focus
-a:focus:hover
-

The last selector matches a elements that are in - the pseudo-class :focus and in the pseudo-class :hover.

-
- -

Note: An element can be both ':visited' -and ':active' (or ':link' and ':active').

- -

6.6.2. The target pseudo-class :target

- -

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).

- -

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 section_2 in an HTML -document:

- -
http://example.com/html/top.html#section_2
- -

A target element can be represented by the :target -pseudo-class. If the document's URI has no fragment identifier, then -the document has no target element.

- -
-

Example:

-
p.note:target
-

This selector represents a p element of class - note that is the target element of the referring - URI.

-
- -
-

CSS example:

-

Here, the :target pseudo-class is used to make the - target element red and place an image before it, if there is one:

-
*:target { color : red }
-*:target::before { content : url(target.png) }
-
- -

6.6.3. The language pseudo-class :lang

- -

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 [HTML4], the language is determined by a -combination of the lang attribute, the meta -element, and possibly by information from the protocol (such as HTTP -headers). XML uses an attribute called xml:lang, and -there may be other document language-specific methods for determining -the language.

- -

The pseudo-class :lang(C) represents an element that -is in language C. Whether an element is represented by a -:lang() 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 '|=' operator in attribute -selectors. The identifier C does not have to be a valid language -name.

- -

C must not be empty. (If it is, the selector is invalid.)

- -

Note: It is recommended that -documents and protocols indicate language using codes from RFC 3066 [RFC3066] or its successor, and by means of -"xml:lang" attributes in the case of XML-based documents [XML10]. See -"FAQ: Two-letter or three-letter language codes."

- -
-

Examples:

-

The two following selectors represent an HTML document that is in - Belgian, French, or German. The two next selectors represent - q quotations in an arbitrary element in Belgian, French, - or German.

-
html:lang(fr-be)
-html:lang(de)
-:lang(fr-be) > q
-:lang(de) > q
-
- -

6.6.4. The UI element states pseudo-classes

- -
The :enabled and :disabled pseudo-classes
- -

The :enabled 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 input element without also specifying what it -would look like when it was disabled.

- -

Similar to :enabled, :disabled allows the -author to specify precisely how a disabled or inactive user interface -element should look.

- -

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.

- - -
The :checked pseudo-class
- -

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 :checked pseudo-class applies. The -:checked pseudo-class initially applies to such elements -that have the HTML4 selected and checked -attributes as described in Section -17.2.1 of HTML4, but of course the user can toggle "off" such -elements in which case the :checked pseudo-class would no -longer apply. While the :checked 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 selected and -checked attributes, it applies to all media. - - -

The :indeterminate pseudo-class
- -
- -

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.

- -

A future version of this specification may introduce an -:indeterminate pseudo-class that applies to such elements. -

- -
- - -

6.6.5. Structural pseudo-classes

- -

Selectors introduces the concept of structural -pseudo-classes to permit selection based on extra information that lies in -the document tree but cannot be represented by other simple selectors or -combinators. - -

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. - - -

:root pseudo-class
- -

The :root pseudo-class represents an element that is -the root of the document. In HTML 4, this is always the -HTML element. - - -

:nth-child() pseudo-class
- -

The -:nth-child(an+b) -pseudo-class notation represents an element that has -an+b-1 siblings -before it in the document tree, for a given positive -integer or zero value of n, and has a parent element. In -other words, this matches the bth child of an element after -all the children have been split into groups of a 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 a and -b values must be zero, negative integers or positive -integers. The index of the first child of an element is 1. - -

In addition to this, :nth-child() can take -'odd' and 'even' as arguments instead. -'odd' has the same signification as 2n+1, -and 'even' has the same signification as 2n. - - -

-

Examples:

-
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; }
-
- -

When a=0, no repeating is used, so for example -:nth-child(0n+5) matches only the fifth child. When -a=0, the an part need not be -included, so the syntax simplifies to -:nth-child(b) and the last example simplifies -to :nth-child(5). - -

-

Examples:

-
foo:nth-child(0n+1)   /* represents an element foo, first child of its parent element */
-foo:nth-child(1)      /* same */
-
- -

When a=1, the number may be omitted from the rule. - -

-

Examples:

-

The following selectors are therefore equivalent:

-
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) */
-
- -

If b=0, then every ath element is picked. In -such a case, the b part may be omitted. - -

-

Examples:

-
tr:nth-child(2n+0) /* represents every even row of an HTML table */
-tr:nth-child(2n) /* same */
-
- -

If both a and b are equal to zero, the -pseudo-class represents no element in the document tree.

- -

The value a can be negative, but only the positive -values of an+b, for -n≥0, may represent an element in the document -tree.

- -
-

Example:

-
html|tr:nth-child(-n+6)  /* represents the 6 first rows of XHTML tables */
-
- -

When the value b is negative, the "+" character in the -expression must be removed (it is effectively replaced by the "-" -character indicating the negative value of b).

- -
-

Examples:

-
: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 */
-
- - -
:nth-last-child() pseudo-class
- -

The :nth-last-child(an+b) -pseudo-class notation represents an element that has -an+b-1 siblings -after it in the document tree, for a given positive -integer or zero value of n, and has a parent element. See -:nth-child() pseudo-class for the syntax of its argument. -It also accepts the 'even' and 'odd' values -as arguments. - - -

-

Examples:

-
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 */
-
- - -
:nth-of-type() pseudo-class
- -

The :nth-of-type(an+b) -pseudo-class notation represents an element that has -an+b-1 siblings with the same -element name before it in the document tree, for a -given zero or positive integer value of n, and has a -parent element. In other words, this matches the bth child -of that type after all the children of that type have been split into -groups of a elements each. See :nth-child() pseudo-class -for the syntax of its argument. It also accepts the -'even' and 'odd' values. - - -

-

CSS example:

-

This allows an author to alternate the position of floated images:

-
img:nth-of-type(2n+1) { float: right; }
-img:nth-of-type(2n) { float: left; }
-
- - -
:nth-last-of-type() pseudo-class
- -

The :nth-last-of-type(an+b) -pseudo-class notation represents an element that has -an+b-1 siblings with the same -element name after it in the document tree, for a -given zero or positive integer value of n, and has a -parent element. See :nth-child() pseudo-class for the -syntax of its argument. It also accepts the 'even' and 'odd' values. - - -

-

Example:

-

To represent all h2 children of an XHTML - body except the first and last, one could use the - following selector:

-
body > h2:nth-of-type(n+2):nth-last-of-type(n+2)
-

In this case, one could also use :not(), although the - selector ends up being just as long:

-
body > h2:not(:first-of-type):not(:last-of-type)
-
- - -
:first-child pseudo-class
- -

Same as :nth-child(1). The :first-child pseudo-class -represents an element that is the first child of some other element. - - -

-

Examples:

-

The following selector represents a p element that is - the first child of a div element:

-
div > p:first-child
-

This selector can represent the p inside the - div of the following fragment:

-
<p> The last P before the note.</p>
-<div class="note">
-   <p> The first P inside the note.</p>
-</div>
but cannot represent the second p in the following -fragment: -
<p> The last P before the note.</p>
-<div class="note">
-   <h2> Note </h2>
-   <p> The first P inside the note.</p>
-</div>
-

The following two selectors are usually equivalent:

-
* > a:first-child /* a is first child of any element */
-a:first-child /* Same (assuming a is not the root element) */
-
- -
:last-child pseudo-class
- -

Same as :nth-last-child(1). The :last-child pseudo-class -represents an element that is the last child of some other element. - -

-

Example:

-

The following selector represents a list item li that - is the last child of an ordered list ol. -

ol > li:last-child
-
- -
:first-of-type pseudo-class
- -

Same as :nth-of-type(1). The :first-of-type pseudo-class -represents an element that is the first sibling of its type in the list of -children of its parent element. - -

-

Example:

-

The following selector represents a definition title -dt inside a definition list dl, this -dt being the first of its type in the list of children of -its parent element.

-
dl dt:first-of-type
-

It is a valid description for the first two dt -elements in the following example but not for the third one:

-
<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>
-
- -
:last-of-type pseudo-class
- -

Same as :nth-last-of-type(1). The -:last-of-type pseudo-class represents an element that is -the last sibling of its type in the list of children of its parent -element.

- -
-

Example:

-

The following selector represents the last data cell - td of a table row.

-
tr > td:last-of-type
-
- -
:only-child pseudo-class
- -

Represents an element that has a parent element and whose parent -element has no other element children. Same as -:first-child:last-child or -:nth-child(1):nth-last-child(1), but with a lower -specificity.

- -
:only-of-type pseudo-class
- -

Represents an element that has a parent element and whose parent -element has no other element children with the same element name. Same -as :first-of-type:last-of-type or -:nth-of-type(1):nth-last-of-type(1), but with a lower -specificity.

- - -
:empty pseudo-class
- -

The :empty 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.

- -
-

Examples:

-

p:empty is a valid representation of the following fragment:

-
<p></p>
-

foo:empty is not a valid representation for the - following fragments:

-
<foo>bar</foo>
-
<foo><bar>bla</bar></foo>
-
<foo>this is not <bar>:empty</bar></foo>
-
- -

6.6.6. Blank

- -

This section intentionally left blank.

- - -

6.6.7. The negation pseudo-class

- -

The negation pseudo-class, :not(X), is a -functional notation taking a simple -selector (excluding the negation pseudo-class itself and -pseudo-elements) as an argument. It represents an element that is not -represented by the argument. - - - -

-

Examples:

-

The following CSS selector matches all button - elements in an HTML document that are not disabled.

-
button:not([DISABLED])
-

The following selector represents all but FOO - elements.

-
*:not(FOO)
-

The following group of selectors represents all HTML elements - except links.

-
html|*:not(:link):not(:visited)
-
- -

Default namespace declarations do not affect the argument of the -negation pseudo-class unless the argument is a universal selector or a -type selector.

- -
-

Examples:

-

Assuming that the default namespace is bound to - "http://example.com/", the following selector represents all - elements that are not in that namespace:

-
*|*:not(*)
-

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 are being hovered.

-
*|*:not(:hover)
-
- -

Note: the :not() pseudo allows -useless selectors to be written. For instance :not(*|*), -which represents no element at all, or foo:not(bar), -which is equivalent to foo but with a higher -specificity.

- -

7. Pseudo-elements

- -

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 ::before and -::after pseudo-elements give access to generated -content).

- -

A pseudo-element is made of two colons (::) followed -by the name of the pseudo-element.

- -

This :: 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, -:first-line, :first-letter, -:before and :after). This compatibility is -not allowed for the new pseudo-elements introduced in CSS level 3.

- -

Only one pseudo-element may appear per selector, and if present it -must appear after the sequence of simple selectors that represents the -subjects of the selector. A -future version of this specification may allow multiple -pesudo-elements per selector.

- -

7.1. The ::first-line pseudo-element

- -

The ::first-line pseudo-element describes the contents -of the first formatted line of an element. - -

-

CSS example:

-
p::first-line { text-transform: uppercase }
-

The above rule means "change the letters of the first line of every -paragraph to uppercase".

-
- -

The selector p::first-line 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.

- -

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>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>
-
- -

the lines of which happen to be broken as follows: - -

-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.
-
- -

This paragraph might be "rewritten" by user agents to include the -fictional tag sequence for ::first-line. This -fictional tag sequence helps to show how properties are inherited.

- -
-<P><P::first-line> This is a somewhat long HTML
-paragraph that </P::first-line> 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>
-
- -

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 span element:

- -
-<P><SPAN class="test"> This is a somewhat long HTML
-paragraph that will be broken into several
-lines.</SPAN> The first line will be identified
-by a fictional tag sequence. The other lines
-will be treated as ordinary lines in the
-paragraph.</P>
-
- -

the user agent could simulate start and end tags for -span when inserting the fictional tag sequence for -::first-line. - -

-<P><P::first-line><SPAN class="test"> This is a
-somewhat long HTML
-paragraph that will </SPAN></P::first-line><SPAN class="test"> be
-broken into several
-lines.</SPAN> The first line will be identified
-by a fictional tag sequence. The other lines
-will be treated as ordinary lines in the
-paragraph.</P>
-
- -

In CSS, the ::first-line pseudo-element can only be -attached to a block-level element, an inline-block, a table-caption, -or a table-cell.

- -

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 div in <DIV><P>This -line...</P></DIV> is the first line of the p (assuming -that both p and div are block-level). - -

The first line of a table-cell or inline-block cannot be the first -formatted line of an ancestor element. Thus, in <DIV><P -STYLE="display: inline-block">Hello<BR>Goodbye</P> -etcetera</DIV> the first formatted line of the -div is not the line "Hello". - -

Note that the first line of the p in this -fragment: <p><br>First... doesn't contain any -letters (assuming the default style for br in HTML -4). The word "First" is not on the first formatted line. - -

A UA should act as if the fictional start tags of the -::first-line 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

- -
-<DIV>
-  <P>First paragraph</P>
-  <P>Second paragraph</P>
-</DIV>
-
- -

is

- -
-<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>
-
- -

The ::first-line pseudo-element is similar to an -inline-level element, but with certain restrictions. In CSS, the -following properties apply to a ::first-line -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.

- - -

7.2. The ::first-letter pseudo-element

- -

The ::first-letter 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.

- -

In CSS, these are the properties that apply to ::first-letter -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.

- -
-

Example:

-

This example shows a possible rendering of an initial cap. Note -that the 'line-height' that is inherited by the ::first-letter -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, and thus -the font weight of the first letter is normal, not bold as the span: -

-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.
-
-
-

Image illustrating the ::first-letter pseudo-element -

-
- -
-

The following CSS will make a drop cap initial letter span about two lines:

- -
-<!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>
-
- -

This example might be formatted as follows:

- -
-

Image illustrating the combined effect of the ::first-letter and ::first-line pseudo-elements

-
- -

The fictional tag sequence is:

- -
-<P>
-<SPAN>
-<P::first-letter>
-T
-</P::first-letter>he first
-</SPAN>
-few words of an article in the Economist.
-</P>
-
- -

Note that the ::first-letter 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.

- -

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.

- -

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. [UNICODE]

- -
-

Quotes that precede the
-first letter should be included.

-
- -

The ::first-letter also applies if the first letter is -in fact a digit, e.g., the "6" in "67 million dollars is a lot of -money."

- -

In CSS, the ::first-letter pseudo-element applies to -block, list-item, table-cell, table-caption, and inline-block -elements. A future version of this specification -may allow this pesudo-element to apply to more element -types.

- -

The ::first-letter 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.

- -
-

Example:

-

The fictional tag sequence for this HTMLfragment: -

<div>
-<p>The first text.
-

is: -

<div>
-<p><div::first-letter><p::first-letter>T</...></...>he first text.
-
- -

The first letter of a table-cell or inline-block cannot be the -first letter of an ancestor element. Thus, in <DIV><P -STYLE="display: inline-block">Hello<BR>Goodbye</P> -etcetera</DIV> the first letter of the div is not the -letter "H". In fact, the div doesn't have a first letter. - -

The first letter must occur on the first formatted line. For example, in -this fragment: <p><br>First... the first line -doesn't contain any letters and ::first-letter doesn't -match anything (assuming the default style for br in HTML -4). In particular, it does not match the "F" of "First." - -

In CSS, if an element is a list item ('display: list-item'), the -::first-letter applies to the first letter in the -principal box after the marker. UAs may ignore -::first-letter on list items with 'list-style-position: -inside'. If an element has ::before or -::after content, the ::first-letter applies -to the first letter of the element including that content. - -

-

Example:

-

After the rule 'p::before {content: "Note: "}', the selector -'p::first-letter' matches the "N" of "Note".

-
- -

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 ::first-letter pseudo-element. - -

If the letters that would form the ::first-letter are not in the -same element, such as "'T" in <p>'<em>T..., the UA -may create a ::first-letter pseudo-element from one of the elements, -both elements, or simply not create a pseudo-element.

- -

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). - -

-

Example:

-

The following example 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 { 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>
- -

Assuming that a line break will occur before the word "ends", the -fictional tag -sequence for this fragment might be:

- -
<P>
-<P::first-line>
-<P::first-letter>
-S
-</P::first-letter>ome text that
-</P::first-line>
-ends up on two lines
-</P>
- -

Note that the ::first-letter element is inside the ::first-line -element. Properties set on ::first-line are inherited by -::first-letter, but are overridden if the same property is set on -::first-letter.

-
- - -

7.3. The ::selection pseudo-element

- -

The ::selection 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 :checked pseudo-class (which used to be -named :selected) - -

Although the ::selection 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 -[CSS21]) which was originally rendered to a -dynamic medium (like screen), the UA may wish to transfer the current -::selection 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 ::selection -pseudo-element for static media. - -

These are the CSS properties that apply to ::selection -pseudo-elements: color, background, cursor (optional), outline -(optional). The computed value of the 'background-image' property on -::selection may be ignored. - - -

7.4. The ::before and ::after pseudo-elements

- -

The ::before and ::after pseudo-elements -can be used to describe generated content before or after an element's -content. They are explained in CSS 2.1 [CSS21].

- -

When the ::first-letter and ::first-line -pseudo-elements are combined with ::before and -::after, they apply to the first letter or line of the -element including the inserted text.

- -

8. Combinators

- -

8.1. Descendant combinator

- -

At times, authors may want selectors to describe an element that is -the descendant of another element in the document tree (e.g., "an -EM element that is contained within an H1 -element"). Descendant combinators express such a relationship. A -descendant combinator is white space that -separates two sequences of simple selectors. A selector of the form -"A B" represents an element B that is an -arbitrary descendant of some ancestor element A. - -

-

Examples:

-

For example, consider the following selector:

-
h1 em
-

It represents an em element being the descendant of - an h1 element. It is a correct and valid, but partial, - description of the following fragment:

-
<h1>This <span class="myclass">headline
-is <em>very</em> important</span></h1>
-

The following selector:

-
div * p
-

represents a p element that is a grandchild or later - descendant of a div 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.

-

The following selector, which combines descendant combinators and - attribute selectors, represents an - element that (1) has the href attribute set and (2) is - inside a p that is itself inside a div:

-
div p *[href]
-
- -

8.2. Child combinators

- -

A child combinator describes a childhood relationship -between two elements. A child combinator is made of the -"greater-than sign" (>) character and -separates two sequences of simple selectors. - - -

-

Examples:

-

The following selector represents a p element that is - child of body:

-
body > p
-

The following example combines descendant combinators and child - combinators.

-
div ol>li p
-

It represents a p element that is a descendant of an - li element; the li element must be the - child of an ol element; the ol element must - be a descendant of a div. Notice that the optional white - space around the ">" combinator has been left out.

-
- -

For information on selecting the first child of an element, please -see the section on the :first-child pseudo-class -above.

- -

8.3. Sibling combinators

- -

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.

- -

8.3.1. Adjacent sibling combinator

- -

The adjacent sibling combinator is made of the "plus -sign" (U+002B, +) 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.

- -
-

Examples:

-

The following selector represents a p element - immediately following a math element:

-
math + 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 h1 element, that it must have - class="opener":

-
h1.opener + h2
-
- - -

8.3.2. General sibling combinator

- -

The general sibling combinator is made of the "tilde" -(U+007E, ~) 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.

- -
-

Example:

-
h1 ~ pre
-

represents a pre element following an h1. It - is a correct and valid, but partial, description of:

-
<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>
-
- -

9. Calculating a selector's specificity

- -

A selector's specificity is calculated as follows:

- -
    -
  • count the number of ID selectors in the selector (= a)
  • -
  • count the number of class selectors, attributes selectors, and pseudo-classes in the selector (= b)
  • -
  • count the number of element names in the selector (= c)
  • -
  • ignore pseudo-elements
  • -
- -

Selectors inside the negation pseudo-class -are counted like any other, but the negation itself does not count as -a pseudo-class.

- -

Concatenating the three numbers a-b-c (in a number system with a -large base) gives the specificity.

- -
-

Examples:

-
*               /* 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 */
-
-
- -

Note: the specificity of the styles -specified in an HTML style attribute is described in CSS -2.1. [CSS21].

- -

10. The grammar of Selectors

- -

10.1. Grammar

- -

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 [YACC]) -are used:

- -
    -
  • *: 0 or more -
  • +: 1 or more -
  • ?: 0 or 1 -
  • |: separates alternatives -
  • [ ]: grouping
  • -
- -

The productions are:

- -
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
-  ;
- - -

10.2. Lexical scanner

- -

The following is the tokenizer, written in Flex (see -[FLEX]) notation. The tokenizer is -case-insensitive.

- -

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. [UNICODE]

- -
%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;
- - - -

11. Namespaces and down-level clients

- -

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.

- -

It should be noted that a down-level CSS client will (if it -properly conforms to CSS forward compatible parsing rules) ignore all -@namespace 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.

- -

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.

- -

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.

- -
    -
  1. - -

    The XML document does not use namespaces.

    - -
      - -
    • 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.
    • - -
    • 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 ("|name") - will guarantee that selectors will match only XML elements that do - not have a declared namespace.
    • - -
    - -
  2. - -
  3. - -

    The XML document defines a single, default namespace used - throughout the document. No namespace prefixes are used in element - names.

    - -
      - -
    • 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.
    • - -
    - -
  4. - -
  5. - -

    The XML document does not 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).

    - -
      - -
    • 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 Type selectors and Namespaces section. CSS - selectors may be declared using an escaped colon "\:" - to describe the fully qualified names, e.g. - "html\:h1" will match - <html:h1>. 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.
    • - -
    • Note that selectors declared in this fashion will - only 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).
    • - -
    - -
  6. - -
- -

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 -different 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.

- -

12. Profiles

- -

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.

- -

Non normative examples: - -

- - - - - - - - - - - - - - - -
Selectors profile
SpecificationCSS level 1
Acceptstype selectors
class selectors
ID selectors
:link, - :visited and :active pseudo-classes
descendant combinator -
::first-line and ::first-letter pseudo-elements
Excludes - -

universal selector
attribute selectors
:hover and :focus - pseudo-classes
:target pseudo-class
:lang() pseudo-class
all UI - element states pseudo-classes
all structural - pseudo-classes
negation pseudo-class
all - UI element fragments pseudo-elements
::before and ::after - pseudo-elements
child combinators
sibling combinators - -

namespaces

Extra constraintsonly one class selector allowed per sequence of simple - selectors


- - - - - - - - - - - - - - - -
Selectors profile
SpecificationCSS level 2
Acceptstype selectors
universal selector
attribute presence and - values selectors
class selectors
ID selectors
:link, :visited, - :active, :hover, :focus, :lang() and :first-child pseudo-classes -
descendant combinator
child combinator
adjacent sibling - combinator
::first-line and ::first-letter pseudo-elements
::before - and ::after pseudo-elements
Excludes - -

content selectors
substring matching attribute - selectors
:target pseudo-classes
all UI element - states pseudo-classes
all structural pseudo-classes other - than :first-child
negation pseudo-class
all UI element - fragments pseudo-elements
general sibling combinators - -

namespaces

Extra constraintsmore than one class selector per sequence of simple selectors (CSS1 - constraint) allowed
- -

In CSS, selectors express pattern matching rules that determine which style -rules apply to elements in the document tree. - -

The following selector (CSS level 2) will match all anchors a -with attribute name set inside a section 1 header h1: -

h1 a[name]
- -

All CSS declarations attached to such a selector are applied to elements -matching it.

- -
- - - - - - - - - - - - - - - - -
Selectors profile
SpecificationSTTS 3
Accepts - -

type selectors
universal selectors
attribute selectors
class - selectors
ID selectors
all structural pseudo-classes
- all combinators - -

namespaces

Excludesnon-accepted pseudo-classes
pseudo-elements
Extra constraintssome selectors and combinators are not allowed in fragment - descriptions on the right side of STTS declarations.
-
- - - - - - - - - - - - - - - - - - - - - - - - - -
- -

Selectors can be used in STTS 3 in two different - manners: -

    -
  1. a selection mechanism equivalent to CSS selection mechanism: declarations - attached to a given selector are applied to elements matching that selector, -
  2. fragment descriptions that appear on the right side of declarations. -
- -

13. Conformance and requirements

- -

This section defines conformance with the present specification only. - -

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. - -

All specifications reusing Selectors must contain a Profile listing the -subset of Selectors it accepts or excludes, and describing the constraints -it adds to the current specification. - -

Invalidity is caused by a parsing error, e.g. an unrecognized token or a token -which is not allowed at the current parsing point. - -

User agents must observe the rules for handling parsing errors: -

    -
  • a simple selector containing an undeclared namespace prefix is invalid
  • -
  • a selector containing an invalid simple selector, an invalid combinator - or an invalid token is invalid.
  • -
  • a group of selectors containing an invalid selector is invalid.
  • -
- -

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.)

- - - -

14. Tests

- -

This specification has a test -suite 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.

- -

15. Acknowledgements

- -

The CSS working group would like to thank everyone who has sent -comments on this specification over the years.

- -

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.

- -

16. References

- -
- -
[CSS1] -
Bert Bos, Håkon Wium Lie; "Cascading Style Sheets, level 1", W3C Recommendation, 17 Dec 1996, revised 11 Jan 1999 -
(http://www.w3.org/TR/REC-CSS1) - -
[CSS21] -
Bert Bos, Tantek Çelik, Ian Hickson, Håkon Wium Lie, editors; "Cascading Style Sheets, level 2 revision 1", W3C Working Draft, 13 June 2005 -
(http://www.w3.org/TR/CSS21) - -
[CWWW] -
Martin J. Dürst, François Yergeau, Misha Wolf, Asmus Freytag, Tex Texin, editors; "Character Model for the World Wide Web", W3C Recommendation, 15 February 2005 -
(http://www.w3.org/TR/charmod/) - -
[FLEX] -
"Flex: The Lexical Scanner Generator", Version 2.3.7, ISBN 1882114213 - -
[HTML4] -
Dave Ragget, Arnaud Le Hors, Ian Jacobs, editors; "HTML 4.01 Specification", W3C Recommendation, 24 December 1999 -
(http://www.w3.org/TR/html4/) - -
[MATH] -
Patrick Ion, Robert Miner, editors; "Mathematical Markup Language (MathML) 1.01", W3C Recommendation, revision of 7 July 1999 -
(http://www.w3.org/TR/REC-MathML/) - -
[RFC3066] -
H. Alvestrand; "Tags for the Identification of Languages", Request for Comments 3066, January 2001 -
(http://www.ietf.org/rfc/rfc3066.txt) - -
[STTS] -
Daniel Glazman; "Simple Tree Transformation Sheets 3", Electricité de France, submission to the W3C, 11 November 1998 -
(http://www.w3.org/TR/NOTE-STTS3) - -
[SVG] -
Jon Ferraiolo, 藤沢 淳, Dean Jackson, editors; "Scalable Vector Graphics (SVG) 1.1 Specification", W3C Recommendation, 14 January 2003 -
(http://www.w3.org/TR/SVG/) - -
[UNICODE]
-
The Unicode Standard, Version 4.1, The Unicode Consortium. Boston, MA, Addison-Wesley, March 2005. ISBN 0-321-18578-1, as amended by Unicode 4.0.1 and Unicode 4.1.0. -
(http://www.unicode.org/versions/)
- -
[XML10] -
Tim Bray, Jean Paoli, C. M. Sperberg-McQueen, Eve Maler, François Yergeau, editors; "Extensible Markup Language (XML) 1.0 (Third Edition)", W3C Recommendation, 4 February 2004 -
(http://www.w3.org/TR/REC-xml/) - -
[XMLNAMES] -
Tim Bray, Dave Hollander, Andrew Layman, editors; "Namespaces in XML", W3C Recommendation, 14 January 1999 -
(http://www.w3.org/TR/REC-xml-names/) - -
[YACC] -
S. C. Johnson; "YACC — Yet another compiler compiler", Technical Report, Murray Hill, 1975 - -
- - diff --git a/samples/third_party/dromaeo/web/web-style.css b/samples/third_party/dromaeo/web/web-style.css deleted file mode 100644 index c439dc0ec88..00000000000 --- a/samples/third_party/dromaeo/web/web-style.css +++ /dev/null @@ -1,24 +0,0 @@ - -a { color: orange; } -div.test { overflow: hidden; margin: 4px; } -div.test b { display: block; float: left; width: 150px; text-align: right; margin-right: 10px; } -div.bar { float: left; width: 400px; border: 1px inset; text-align: left; } -div.bar div { height: 1em; background: url(orange-stripe.png); } -div.bar span { padding-left: 5px; padding-right: 5px; } -body { font-family: Arial; font-size: 12px; background: url(gray-stripe.png); text-align: center; } - -/*#main { margin: 0 auto; width: 600px; padding: 10px; background: #FFF; }*/ - -ol.results { text-align: left; display: none; font-size: 10px; margin-left: 120px; list-style: none; } -ol.results li { clear: both; overflow: auto; } -ol.results b { display: block; width: 200px; float: left; text-align: right; padding-right: 15px; } -#info, div.results { clear:both;width:420px;margin:10 auto;text-align:left; padding: 10px 10px 10px 110px; } -#info span { background: #FFF; color: #000; padding: 8px 4px 4px 4px; } -h1 { text-align: left; } -h1 img { float:left;margin-right: 15px;margin-top: -10px; border: 0; } -h1 small { font-weight:normal; } -iframe { display: none; } -div.resultwrap { text-align: center; } -table.results { font-size: 12px; margin: 0 auto; } -table.results td, table.results th.name { text-align: right; } -table.results .winner { background-color: #c7331d; } diff --git a/samples/third_party/todomvc_performance/.gitignore b/samples/third_party/todomvc_performance/.gitignore deleted file mode 100644 index 378eac25d31..00000000000 --- a/samples/third_party/todomvc_performance/.gitignore +++ /dev/null @@ -1 +0,0 @@ -build diff --git a/samples/third_party/todomvc_performance/AUTHORS b/samples/third_party/todomvc_performance/AUTHORS deleted file mode 100644 index 06177657564..00000000000 --- a/samples/third_party/todomvc_performance/AUTHORS +++ /dev/null @@ -1,9 +0,0 @@ -# Names should be added to this file with this pattern: -# -# For individuals: -# Name -# -# For organizations: -# Organization -# -Google Inc. <*@google.com> diff --git a/samples/third_party/todomvc_performance/LICENSE b/samples/third_party/todomvc_performance/LICENSE deleted file mode 100644 index 92d60b019fd..00000000000 --- a/samples/third_party/todomvc_performance/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2012 The Polymer Authors. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/samples/third_party/todomvc_performance/PATENTS b/samples/third_party/todomvc_performance/PATENTS deleted file mode 100644 index e120963325b..00000000000 --- a/samples/third_party/todomvc_performance/PATENTS +++ /dev/null @@ -1,23 +0,0 @@ -Additional IP Rights Grant (Patents) - -"This implementation" means the copyrightable works distributed by -Google as part of the Polymer project. - -Google hereby grants to You a perpetual, worldwide, non-exclusive, -no-charge, royalty-free, irrevocable (except as stated in this section) -patent license to make, have made, use, offer to sell, sell, import, -transfer and otherwise run, modify and propagate the contents of this -implementation of Polymer, where such license applies only to those -patent claims, both currently owned or controlled by Google and acquired -in the future, licensable by Google that are necessarily infringed by -this implementation of Polymer. This grant does not include claims -that would be infringed only as a consequence of further modification of -this implementation. If you or your agent or exclusive licensee -institute or order or agree to the institution of patent litigation -against any entity (including a cross-claim or counterclaim in a -lawsuit) alleging that this implementation of Polymer or any code -incorporated within this implementation of Polymer constitutes -direct or contributory patent infringement, or inducement of patent -infringement, then any patent rights granted to you under this License -for this implementation of Polymer shall terminate as of the date -such litigation is filed. diff --git a/samples/third_party/todomvc_performance/README.md b/samples/third_party/todomvc_performance/README.md deleted file mode 100644 index c7a053fa72c..00000000000 --- a/samples/third_party/todomvc_performance/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Polymer TodoMVC Performance Test - -This directory is a copy of samples/third_party/todomvc with some modifications -to make a performance test and added a pure JS implementation for comparison. diff --git a/samples/third_party/todomvc_performance/js_todomvc/AUTHORS b/samples/third_party/todomvc_performance/js_todomvc/AUTHORS deleted file mode 100755 index 06177657564..00000000000 --- a/samples/third_party/todomvc_performance/js_todomvc/AUTHORS +++ /dev/null @@ -1,9 +0,0 @@ -# Names should be added to this file with this pattern: -# -# For individuals: -# Name -# -# For organizations: -# Organization -# -Google Inc. <*@google.com> diff --git a/samples/third_party/todomvc_performance/js_todomvc/CONTRIBUTING.md b/samples/third_party/todomvc_performance/js_todomvc/CONTRIBUTING.md deleted file mode 100755 index 6f3aca954cf..00000000000 --- a/samples/third_party/todomvc_performance/js_todomvc/CONTRIBUTING.md +++ /dev/null @@ -1 +0,0 @@ -See https://github.com/Polymer/polymer/blob/master/CONTRIBUTING.md diff --git a/samples/third_party/todomvc_performance/js_todomvc/LICENSE b/samples/third_party/todomvc_performance/js_todomvc/LICENSE deleted file mode 100755 index 92d60b019fd..00000000000 --- a/samples/third_party/todomvc_performance/js_todomvc/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2012 The Polymer Authors. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/samples/third_party/todomvc_performance/js_todomvc/PATENTS b/samples/third_party/todomvc_performance/js_todomvc/PATENTS deleted file mode 100755 index e120963325b..00000000000 --- a/samples/third_party/todomvc_performance/js_todomvc/PATENTS +++ /dev/null @@ -1,23 +0,0 @@ -Additional IP Rights Grant (Patents) - -"This implementation" means the copyrightable works distributed by -Google as part of the Polymer project. - -Google hereby grants to You a perpetual, worldwide, non-exclusive, -no-charge, royalty-free, irrevocable (except as stated in this section) -patent license to make, have made, use, offer to sell, sell, import, -transfer and otherwise run, modify and propagate the contents of this -implementation of Polymer, where such license applies only to those -patent claims, both currently owned or controlled by Google and acquired -in the future, licensable by Google that are necessarily infringed by -this implementation of Polymer. This grant does not include claims -that would be infringed only as a consequence of further modification of -this implementation. If you or your agent or exclusive licensee -institute or order or agree to the institution of patent litigation -against any entity (including a cross-claim or counterclaim in a -lawsuit) alleging that this implementation of Polymer or any code -incorporated within this implementation of Polymer constitutes -direct or contributory patent infringement, or inducement of patent -infringement, then any patent rights granted to you under this License -for this implementation of Polymer shall terminate as of the date -such litigation is filed. diff --git a/samples/third_party/todomvc_performance/js_todomvc/README.md b/samples/third_party/todomvc_performance/js_todomvc/README.md deleted file mode 100755 index da3d1bc9eec..00000000000 --- a/samples/third_party/todomvc_performance/js_todomvc/README.md +++ /dev/null @@ -1,46 +0,0 @@ -This is a snapshot of https://github.com/Polymer/todomvc taken on 3-14-14. - -# Polymer TodoMVC Example - -> Polymer is a new type of library for the web, built on top of Web Components, and designed to leverage the evolving web platform on modern browsers. - -> _[Polymer - www.polymer-project.org](http://www.polymer-project.org/)_ - -## Learning Polymer - -The [Polymer website](http://www.polymer-project.org) is a great resource for getting started. - -Here are some links you may find helpful: - -* [Getting Started](http://www.polymer-project.org/docs/start/everything.html) -* [FAQ](http://www.polymer-project.org/resources/faq.html) -* [Browser Compatibility](http://www.polymer-project.org/resources/compatibility.html) - -Get help from Polymer devs and users: - -* Find us on IRC on __#polymer__ at freenode. -* Join the high-traffic [polymer-dev](https://groups.google.com/forum/?fromgroups=#!forum/polymer-dev) Google group or the announcement-only [polymer-announce](https://groups.google.com/forum/?fromgroups=#!forum/polymer-announce) Google group. - -## Implementation - -The Polymer implementation of TodoMVC has a few key differences with other implementations: - -* Since [Web Components](http://w3c.github.io/webcomponents/explainer/) allow you to create new types of DOM elements, the DOM tree is very different from other implementations. -* The template, styling, and behavior are fully encapsulated in each custom element. Instead of having an overall stylesheet (`base.css` or `app.css`), each element that needs styling has its own stylesheet. -* Non-visual elements such as the router and the model are also implemented as custom elements and appear in the DOM. Implementing them as custom elements instead of plain objects allows you to take advantage of Polymer data binding and event handling throughout the app. - -## Compatibility - -Polymer and its polyfills are intended to work in the latest version of [evergreen browsers](http://tomdale.net/2013/05/evergreen-browsers/). IE9 is not supported. Please refer to [Browser Compatibility](http://www.polymer-project.org/resources/compatibility.html) for more details. - -## Running this sample - -1. Install [node.js](nodejs.org) (required for `bower` client-side package management) -1. Install bower: `npm install -g bower` - -1. From the `todomvc\` folder, run `bower update` -1. Start a web server in the `todomvc\` folder. Hint: if you have python installed, you can just run: - - `python -m SimpleHTTPServer` - -1. Browse to the server root diff --git a/samples/third_party/todomvc_performance/js_todomvc/app/app.css b/samples/third_party/todomvc_performance/js_todomvc/app/app.css deleted file mode 100755 index 12f3666b85f..00000000000 --- a/samples/third_party/todomvc_performance/js_todomvc/app/app.css +++ /dev/null @@ -1,206 +0,0 @@ -/* base.css overrides */ - -html, -body { - margin: 0; - padding: 0; -} - -body { - font: 14px 'Helvetica Neue', Helvetica, Arial, sans-serif; - line-height: 1.4em; - background: #eaeaea url('../components/todomvc-common/bg.png'); - color: #4d4d4d; - width: 550px; - margin: 0 auto; - -webkit-font-smoothing: antialiased; - -moz-font-smoothing: antialiased; - -ms-font-smoothing: antialiased; - -o-font-smoothing: antialiased; - font-smoothing: antialiased; -} - -body > header { - padding-top: 22px; - margin-bottom: -5px; -} - -h1 { - /* position: absolute; - top: -120px;*/ - width: 100%; - font-size: 70px; - font-weight: bold; - text-align: center; - color: #b3b3b3; - color: rgba(255, 255, 255, 0.3); - text-shadow: -1px -1px rgba(0, 0, 0, 0.2); - -webkit-text-rendering: optimizeLegibility; - -moz-text-rendering: optimizeLegibility; - -ms-text-rendering: optimizeLegibility; - -o-text-rendering: optimizeLegibility; - text-rendering: optimizeLegibility; -} - -#info { - margin: 65px auto 0; - color: #a6a6a6; - font-size: 12px; - text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7); - text-align: center; -} - -#info a { - color: inherit; -} - -.hidden{ - display:none; -} - -hr { - margin: 20px 0; - border: 0; - border-top: 1px dashed #C5C5C5; - border-bottom: 1px dashed #F7F7F7; -} - -.learn a { - font-weight: normal; - text-decoration: none; - color: #b83f45; -} - -.learn a:hover { - text-decoration: underline; - color: #787e7e; -} - -.learn h3, -.learn h4, -.learn h5 { - margin: 10px 0; - font-weight: 500; - line-height: 1.2; - color: #000; -} - -.learn h3 { - font-size: 24px; -} - -.learn h4 { - font-size: 18px; -} - -.learn h5 { - margin-bottom: 0; - font-size: 14px; -} - -.learn ul { - padding: 0; - margin: 0 0 30px 25px; -} - -.learn li { - line-height: 20px; -} - -.learn p { - font-size: 15px; - font-weight: 300; - line-height: 1.3; - margin-top: 0; - margin-bottom: 0; -} - -.quote { - border: none; - margin: 20px 0 60px 0; -} - -.quote p { - font-style: italic; -} - -.quote p:before { - content: '“'; - font-size: 50px; - opacity: .15; - position: absolute; - top: -20px; - left: 3px; -} - -.quote p:after { - content: '”'; - font-size: 50px; - opacity: .15; - position: absolute; - bottom: -42px; - right: 3px; -} - -.quote footer { - position: absolute; - bottom: -40px; - right: 0; -} - -.quote footer img { - border-radius: 3px; -} - -.quote footer a { - margin-left: 5px; - vertical-align: middle; -} - -.speech-bubble { - position: relative; - padding: 10px; - background: rgba(0, 0, 0, .04); - border-radius: 5px; -} - -.speech-bubble:after { - content: ''; - position: absolute; - top: 100%; - right: 30px; - border: 13px solid transparent; - border-top-color: rgba(0, 0, 0, .04); -} - -/**body*/.learn-bar > .learn { - position: absolute; - width: 272px; - top: 8px; - left: -300px; - padding: 10px; - border-radius: 5px; - background-color: rgba(255, 255, 255, .6); - transition-property: left; - transition-duration: 500ms; -} - - -/* IE doesn't support the hidden attribute */ -[hidden] { - display: none; -} - -@media (min-width: 899px) { - /**body*/.learn-bar { - width: auto; - margin: 0 0 0 300px; - } - /**body*/.learn-bar > .learn { - left: 8px; - } - /**body*/.learn-bar #todoapp { - width: 550px; - margin: 130px auto 40px auto; - } -} diff --git a/samples/third_party/todomvc_performance/js_todomvc/bower.json b/samples/third_party/todomvc_performance/js_todomvc/bower.json deleted file mode 100755 index c67d0d184ce..00000000000 --- a/samples/third_party/todomvc_performance/js_todomvc/bower.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "todomvc-template", - "version": "0.0.0", - "dependencies": { - "todomvc-common": "~0.1.4", - "polymer-selector": "Polymer/polymer-selector", - "flatiron-director": "Polymer/flatiron-director", - "polymer-localstorage": "Polymer/polymer-localstorage" - } -} diff --git a/samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/.bower.json b/samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/.bower.json deleted file mode 100644 index f221bdec664..00000000000 --- a/samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/.bower.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "flatiron-director", - "private": true, - "dependencies": { - "polymer": "Polymer/polymer#0.2.1" - }, - "version": "0.2.1", - "homepage": "https://github.com/Polymer/flatiron-director", - "_release": "0.2.1", - "_resolution": { - "type": "version", - "tag": "0.2.1", - "commit": "d01427ec016607908f939aad6b7ab4164b355a73" - }, - "_source": "git://github.com/Polymer/flatiron-director.git", - "_target": "*", - "_originalSource": "Polymer/flatiron-director" -} \ No newline at end of file diff --git a/samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/AUTHORS b/samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/AUTHORS deleted file mode 100644 index 06177657564..00000000000 --- a/samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/AUTHORS +++ /dev/null @@ -1,9 +0,0 @@ -# Names should be added to this file with this pattern: -# -# For individuals: -# Name -# -# For organizations: -# Organization -# -Google Inc. <*@google.com> diff --git a/samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/CONTRIBUTING.md b/samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/CONTRIBUTING.md deleted file mode 100644 index 6f3aca954cf..00000000000 --- a/samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/CONTRIBUTING.md +++ /dev/null @@ -1 +0,0 @@ -See https://github.com/Polymer/polymer/blob/master/CONTRIBUTING.md diff --git a/samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/LICENSE b/samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/LICENSE deleted file mode 100644 index a9bb4ebeccd..00000000000 --- a/samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/LICENSE +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2011 Nodejitsu Inc. -// Copyright (c) 2012 The Polymer Authors. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/PATENTS b/samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/PATENTS deleted file mode 100644 index e120963325b..00000000000 --- a/samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/PATENTS +++ /dev/null @@ -1,23 +0,0 @@ -Additional IP Rights Grant (Patents) - -"This implementation" means the copyrightable works distributed by -Google as part of the Polymer project. - -Google hereby grants to You a perpetual, worldwide, non-exclusive, -no-charge, royalty-free, irrevocable (except as stated in this section) -patent license to make, have made, use, offer to sell, sell, import, -transfer and otherwise run, modify and propagate the contents of this -implementation of Polymer, where such license applies only to those -patent claims, both currently owned or controlled by Google and acquired -in the future, licensable by Google that are necessarily infringed by -this implementation of Polymer. This grant does not include claims -that would be infringed only as a consequence of further modification of -this implementation. If you or your agent or exclusive licensee -institute or order or agree to the institution of patent litigation -against any entity (including a cross-claim or counterclaim in a -lawsuit) alleging that this implementation of Polymer or any code -incorporated within this implementation of Polymer constitutes -direct or contributory patent infringement, or inducement of patent -infringement, then any patent rights granted to you under this License -for this implementation of Polymer shall terminate as of the date -such litigation is filed. diff --git a/samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/bower.json b/samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/bower.json deleted file mode 100644 index f12cefafde4..00000000000 --- a/samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/bower.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "flatiron-director", - "private": true, - "dependencies": { - "polymer": "Polymer/polymer#0.2.1" - }, - "version": "0.2.1" -} \ No newline at end of file diff --git a/samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/demo.html b/samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/demo.html deleted file mode 100644 index ea77ba65f27..00000000000 --- a/samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/demo.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - Director - - - - - - - - - - - - diff --git a/samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/director/LICENSE b/samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/director/LICENSE deleted file mode 100644 index 1f01e2b36c6..00000000000 --- a/samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/director/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2011 Nodejitsu Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file diff --git a/samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/director/director.min.js b/samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/director/director.min.js deleted file mode 100644 index 55a8e64989d..00000000000 --- a/samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/director/director.min.js +++ /dev/null @@ -1,7 +0,0 @@ - - -// -// Generated on Fri Dec 27 2013 12:02:11 GMT-0500 (EST) by Nodejitsu, Inc (Using Codesurgeon). -// Version 1.2.2 -// -(function(a){function k(a,b,c,d){var e=0,f=0,g=0,c=(c||"(").toString(),d=(d||")").toString(),h;for(h=0;hi.indexOf(d,e)||~i.indexOf(c,e)&&!~i.indexOf(d,e)||!~i.indexOf(c,e)&&~i.indexOf(d,e)){f=i.indexOf(c,e),g=i.indexOf(d,e);if(~f&&!~g||!~f&&~g){var j=a.slice(0,(h||1)+1).join(b);a=[j].concat(a.slice((h||1)+1))}e=(g>f?g:f)+1,h=0}else e=0}return a}function j(a,b){var c,d=0,e="";while(c=a.substr(d).match(/[^\w\d\- %@&]*\*[^\w\d\- %@&]*/))d=c.index+c[0].length,c[0]=c[0].replace(/^\*/,"([_.()!\\ %@&a-zA-Z0-9-]+)"),e+=a.substr(0,c.index)+c[0];a=e+=a.substr(d);var f=a.match(/:([^\/]+)/ig),g,h;if(f){h=f.length;for(var j=0;j7))this.history===!0?setTimeout(function(){window.onpopstate=d},500):window.onhashchange=d,this.mode="modern";else{var f=document.createElement("iframe");f.id="state-frame",f.style.display="none",document.body.appendChild(f),this.writeFrame(""),"onpropertychange"in document&&"attachEvent"in document&&document.attachEvent("onpropertychange",function(){event.propertyName==="location"&&c.check()}),window.setInterval(function(){c.check()},50),this.onHashChanged=d,this.mode="legacy"}e.listeners.push(a);return this.mode},destroy:function(a){if(!!e&&!!e.listeners){var b=e.listeners;for(var c=b.length-1;c>=0;c--)b[c]===a&&b.splice(c,1)}},setHash:function(a){this.mode==="legacy"&&this.writeFrame(a),this.history===!0?(window.history.pushState({},document.title,a),this.fire()):b.hash=a[0]==="/"?a:"/"+a;return this},writeFrame:function(a){var b=document.getElementById("state-frame"),c=b.contentDocument||b.contentWindow.document;c.open(),c.write(" - - - - diff --git a/samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/index.html b/samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/index.html deleted file mode 100644 index 9bb2721c008..00000000000 --- a/samples/third_party/todomvc_performance/js_todomvc/components/flatiron-director/index.html +++ /dev/null @@ -1,64 +0,0 @@ - - - - polymer api - - - - - - - -
- [remote] - -
- - - - \ No newline at end of file diff --git a/samples/third_party/todomvc_performance/js_todomvc/components/platform/.bower.json b/samples/third_party/todomvc_performance/js_todomvc/components/platform/.bower.json deleted file mode 100644 index 6aa570ed1c6..00000000000 --- a/samples/third_party/todomvc_performance/js_todomvc/components/platform/.bower.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "platform", - "main": "platform.js", - "homepage": "https://github.com/Polymer/platform", - "authors": [ - "The Polymer Authors" - ], - "description": "Integrate platform polyfills: load, build, test", - "keywords": [ - "polymer", - "web", - "components" - ], - "license": "BSD", - "private": true, - "version": "0.2.1", - "_release": "0.2.1", - "_resolution": { - "type": "version", - "tag": "0.2.1", - "commit": "961d6f68848b9479d4d778466c37c0835837bc1c" - }, - "_source": "git://github.com/Polymer/platform.git", - "_target": "0.2.1", - "_originalSource": "Polymer/platform" -} \ No newline at end of file diff --git a/samples/third_party/todomvc_performance/js_todomvc/components/platform/AUTHORS b/samples/third_party/todomvc_performance/js_todomvc/components/platform/AUTHORS deleted file mode 100644 index 06177657564..00000000000 --- a/samples/third_party/todomvc_performance/js_todomvc/components/platform/AUTHORS +++ /dev/null @@ -1,9 +0,0 @@ -# Names should be added to this file with this pattern: -# -# For individuals: -# Name -# -# For organizations: -# Organization -# -Google Inc. <*@google.com> diff --git a/samples/third_party/todomvc_performance/js_todomvc/components/platform/CONTRIBUTING.md b/samples/third_party/todomvc_performance/js_todomvc/components/platform/CONTRIBUTING.md deleted file mode 100644 index 1de2f3418e3..00000000000 --- a/samples/third_party/todomvc_performance/js_todomvc/components/platform/CONTRIBUTING.md +++ /dev/null @@ -1,73 +0,0 @@ -# Contributing - -Want to contribute to Polymer? Great! - -We are more than happy to accept external contributions to the project in the form of [feedback](https://groups.google.com/forum/?fromgroups=#!forum/polymer-dev), [bug reports](../../issues), and pull requests. - -## Contributor License Agreement - -Before we can accept patches, there's a quick web form you need to fill out. - -- If you're contributing as an individual (e.g. you own the intellectual property), fill out [this form](http://code.google.com/legal/individual-cla-v1.0.html). -- If you're contributing under a company, fill out [this form](http://code.google.com/legal/corporate-cla-v1.0.html) instead. - -This CLA asserts that contributions are owned by you and that we can license all work under our [license](LICENSE). - -Other projects require a similar agreement: jQuery, Firefox, Apache, Node, and many more. - -[More about CLAs](https://www.google.com/search?q=Contributor%20License%20Agreement) - -## Initial setup - -Here's an easy guide that should get you up and running: - -1. Setup Grunt: `sudo npm install -g grunt-cli` -1. Fork the project on github and pull down your copy. - > replace the {{ username }} with your username and {{ repository }} with the repository name - - git clone git@github.com:{{ username }}/{{ repository }}.git --recursive - - Note the `--recursive`. This is necessary for submodules to initialize properly. If you don't do a recursive clone, you'll have to init them manually: - - git submodule init - git submodule update - - Download and run the `pull-all.sh` script to install the sibling dependencies. - - git clone git://github.com/Polymer/tools.git && tools/bin/pull-all.sh - -1. Test your change - > in the repo you've made changes to, run the tests: - - cd $REPO - npm install - grunt test - -1. Commit your code and make a pull request. - -That's it for the one time setup. Now you're ready to make a change. - -## Submitting a pull request - -We iterate fast! To avoid potential merge conflicts, it's a good idea to pull from the main project before making a change and submitting a pull request. The easiest way to do this is setup a remote called `upstream` and do a pull before working on a change: - - git remote add upstream git://github.com/Polymer/{{ repository }}.git - -Then before making a change, do a pull from the upstream `master` branch: - - git pull upstream master - -To make life easier, add a "pull upstream" alias in your `.gitconfig`: - - [alias] - pu = !"git fetch origin -v; git fetch upstream -v; git merge upstream/master" - -That will pull in changes from your forked repo, the main (upstream) repo, and merge the two. Then it's just a matter of running `git pu` before a change and pushing to your repo: - - git checkout master - git pu - # make change - git commit -a -m 'Awesome things.' - git push - -Lastly, don't forget to submit the pull request. diff --git a/samples/third_party/todomvc_performance/js_todomvc/components/platform/LICENSE b/samples/third_party/todomvc_performance/js_todomvc/components/platform/LICENSE deleted file mode 100644 index 92d60b019fd..00000000000 --- a/samples/third_party/todomvc_performance/js_todomvc/components/platform/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2012 The Polymer Authors. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/samples/third_party/todomvc_performance/js_todomvc/components/platform/PATENTS b/samples/third_party/todomvc_performance/js_todomvc/components/platform/PATENTS deleted file mode 100644 index e120963325b..00000000000 --- a/samples/third_party/todomvc_performance/js_todomvc/components/platform/PATENTS +++ /dev/null @@ -1,23 +0,0 @@ -Additional IP Rights Grant (Patents) - -"This implementation" means the copyrightable works distributed by -Google as part of the Polymer project. - -Google hereby grants to You a perpetual, worldwide, non-exclusive, -no-charge, royalty-free, irrevocable (except as stated in this section) -patent license to make, have made, use, offer to sell, sell, import, -transfer and otherwise run, modify and propagate the contents of this -implementation of Polymer, where such license applies only to those -patent claims, both currently owned or controlled by Google and acquired -in the future, licensable by Google that are necessarily infringed by -this implementation of Polymer. This grant does not include claims -that would be infringed only as a consequence of further modification of -this implementation. If you or your agent or exclusive licensee -institute or order or agree to the institution of patent litigation -against any entity (including a cross-claim or counterclaim in a -lawsuit) alleging that this implementation of Polymer or any code -incorporated within this implementation of Polymer constitutes -direct or contributory patent infringement, or inducement of patent -infringement, then any patent rights granted to you under this License -for this implementation of Polymer shall terminate as of the date -such litigation is filed. diff --git a/samples/third_party/todomvc_performance/js_todomvc/components/platform/README.md b/samples/third_party/todomvc_performance/js_todomvc/components/platform/README.md deleted file mode 100644 index 65b661ed159..00000000000 --- a/samples/third_party/todomvc_performance/js_todomvc/components/platform/README.md +++ /dev/null @@ -1,6 +0,0 @@ -Platform -======== - -Aggregated polyfills the Polymer platform. - -[![Analytics](https://ga-beacon.appspot.com/UA-39334307-2/Polymer/platform/README)](https://github.com/igrigorik/ga-beacon) diff --git a/samples/third_party/todomvc_performance/js_todomvc/components/platform/bower.json b/samples/third_party/todomvc_performance/js_todomvc/components/platform/bower.json deleted file mode 100644 index cc029b992eb..00000000000 --- a/samples/third_party/todomvc_performance/js_todomvc/components/platform/bower.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "platform", - "main": "platform.js", - "homepage": "https://github.com/Polymer/platform", - "authors": [ - "The Polymer Authors" - ], - "description": "Integrate platform polyfills: load, build, test", - "keywords": [ - "polymer", - "web", - "components" - ], - "license": "BSD", - "private": true, - "version": "0.2.1" -} \ No newline at end of file diff --git a/samples/third_party/todomvc_performance/js_todomvc/components/platform/platform.js b/samples/third_party/todomvc_performance/js_todomvc/components/platform/platform.js deleted file mode 100644 index 57f1b106517..00000000000 --- a/samples/third_party/todomvc_performance/js_todomvc/components/platform/platform.js +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * Copyright (c) 2012-2014 The Polymer Authors. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -// @version: 0.2.1 -function PointerGestureEvent(a,b){var c=b||{},d=document.createEvent("Event"),e={bubbles:Boolean(c.bubbles)===c.bubbles||!0,cancelable:Boolean(c.cancelable)===c.cancelable||!0};d.initEvent(a,e.bubbles,e.cancelable);for(var f,g=Object.keys(c),h=0;h>>0)+(b++ +"__")};c.prototype={set:function(b,c){var d=b[this.name];d&&d[0]===b?d[1]=c:a(b,this.name,{value:[b,c],writable:!0})},get:function(a){var b;return(b=a[this.name])&&b[0]===a?b[1]:void 0},"delete":function(a){this.set(a,void 0)}},window.WeakMap=c}(),function(a){"use strict";function b(){function a(a){b=a}if("function"!=typeof Object.observe||"function"!=typeof Array.observe)return!1;var b=[],c={};if(Object.observe(c,a),c.id=1,c.id=2,delete c.id,Object.deliverChangeRecords(a),3!==b.length)return!1;if("new"==b[0].type&&"updated"==b[1].type&&"deleted"==b[2].type)L="new",M="updated",N="reconfigured",O="deleted";else if("add"!=b[0].type||"update"!=b[1].type||"delete"!=b[2].type)return console.error("Unexpected change record names for Object.observe. Using dirty-checking instead"),!1;return Object.unobserve(c,a),c=[0],Array.observe(c,a),c[1]=1,c.length=0,Object.deliverChangeRecords(a),2!=b.length?!1:b[0].type!=P||b[1].type!=P?!1:(Array.unobserve(c,a),!0)}function c(){if(a.document&&"securityPolicy"in a.document&&!a.document.securityPolicy.allowsEval)return!1;try{var b=new Function("","return true;");return b()}catch(c){return!1}}function d(a){return+a===a>>>0}function e(a){return+a}function f(a){return a===Object(a)}function g(a,b){return a===b?0!==a||1/a===1/b:S(a)&&S(b)?!0:a!==a&&b!==b}function h(a){return"string"!=typeof a?!1:(a=a.trim(),""==a?!0:"."==a[0]?!1:$.test(a))}function i(a,b){if(b!==_)throw Error("Use Path.get to retrieve path objects");return""==a.trim()?this:d(a)?(this.push(a),this):(a.split(/\s*\.\s*/).filter(function(a){return a}).forEach(function(a){this.push(a)},this),void(R&&this.length&&(this.getValueFrom=this.compiledGetValueFromFn())))}function j(a){if(a instanceof i)return a;null==a&&(a=""),"string"!=typeof a&&(a=String(a));var b=ab[a];if(b)return b;if(!h(a))return bb;var b=new i(a,_);return ab[a]=b,b}function k(b){for(var c=0;db>c&&b.check_();)c++;return a.testingExposeCycleCount&&(a.dirtyCheckCycleCount=c),c>0}function l(a){for(var b in a)return!1;return!0}function m(a){return l(a.added)&&l(a.removed)&&l(a.changed)}function n(a,b){var c={},d={},e={};for(var f in b){var g=a[f];(void 0===g||g!==b[f])&&(f in a?g!==b[f]&&(e[f]=g):d[f]=void 0)}for(var f in a)f in b||(c[f]=a[f]);return Array.isArray(a)&&a.length!==b.length&&(e.length=a.length),{added:c,removed:d,changed:e}}function o(){if(!eb.length)return!1;for(var a=0;a=0?(j[c]=void 0,i.push(b)):i.indexOf(b)<0&&(i.push(b),Object.observe(b,e)),a(Object.getPrototypeOf(b))}}function b(){var b=j===hb?[]:j;j=i,i=b;var c;for(var d in g)c=g[d],c&&c.state_==kb&&c.iterateObjects_(a);for(var f=0;fb||a>d?-1:b==c||d==a?0:c>a?d>b?b-c:d-c:b>d?d-a:b-a}function I(a,b,c,d){for(var e=E(b,c,d),f=!1,g=0,h=0;h=0){a.splice(h,1),h--,g-=i.addedCount-i.removed.length,e.addedCount+=i.addedCount-j;var k=e.removed.length+i.removed.length-j;if(e.addedCount||k){var c=i.removed;if(e.indexi.index+i.addedCount){var m=e.removed.slice(i.index+i.addedCount-e.index);Array.prototype.push.apply(c,m)}e.removed=c,i.indexh)continue;I(c,h,[g.oldValue],1);break;default:console.error("Unexpected record type: "+JSON.stringify(g))}}return c}function K(a,b){var c=[];return J(a,b).forEach(function(b){return 1==b.addedCount&&1==b.removed.length?void(b.removed[0]!==a[b.index]&&c.push(b)):void(c=c.concat(G(a,b.index,b.index+b.addedCount,b.removed,0,b.removed.length)))}),c}var L="add",M="update",N="reconfigure",O="delete",P="splice",Q=b(),R=c(),S=a.Number.isNaN||function(b){return"number"==typeof b&&a.isNaN(b)},T="__proto__"in{}?function(a){return a}:function(a){var b=a.__proto__;if(!b)return a;var c=Object.create(b);return Object.getOwnPropertyNames(a).forEach(function(b){Object.defineProperty(c,b,Object.getOwnPropertyDescriptor(a,b))}),c},U="[$_a-zA-Z]",V="[$_a-zA-Z0-9]",W=U+"+"+V+"*",X="(?:[0-9]|[1-9]+[0-9]+)",Y="(?:"+W+"|"+X+")",Z="(?:"+Y+")(?:\\s*\\.\\s*"+Y+")*",$=new RegExp("^"+Z+"$"),_={},ab={};i.get=j,i.prototype=T({__proto__:[],valid:!0,toString:function(){return this.join(".")},getValueFrom:function(a){for(var b=0;bd&&b);a.testingExposeCycleCount&&(a.dirtyCheckCycleCount=d),qb=!1}}},pb&&(a.Platform.clearObservers=function(){ob=[]}),w.prototype=T({__proto__:t.prototype,arrayObserve:!1,connect_:function(){Q?this.directObserver_=q(this,this.value_,this.arrayObserve):this.oldObject_=this.copyObject(this.value_)},copyObject:function(a){var b=Array.isArray(a)?[]:{};for(var c in a)b[c]=a[c];return Array.isArray(a)&&(b.length=a.length),b},check_:function(a){var b,c;if(Q){if(!a)return!1;c={},b=D(this.value_,a,c)}else c=this.oldObject_,b=n(this.value_,this.oldObject_);return m(b)?!1:(Q||(this.oldObject_=this.copyObject(this.value_)),this.report_([b.added||{},b.removed||{},b.changed||{},function(a){return c[a]}]),!0)},disconnect_:function(){Q?(this.directObserver_.close(),this.directObserver_=void 0):this.oldObject_=void 0},deliver:function(){this.state_==kb&&(Q?this.directObserver_.deliver(!1):k(this))},discardChanges:function(){return this.directObserver_?this.directObserver_.deliver(!0):this.oldObject_=this.copyObject(this.value_),this.value_}}),x.prototype=T({__proto__:w.prototype,arrayObserve:!0,copyObject:function(a){return a.slice()},check_:function(a){var b;if(Q){if(!a)return!1;b=K(this.value_,a)}else b=G(this.value_,0,this.value_.length,this.oldObject_,0,this.oldObject_.length);return b&&b.length?(Q||(this.oldObject_=this.copyObject(this.value_)),this.report_([b]),!0):!1}}),x.applySplices=function(a,b,c){c.forEach(function(c){for(var d=[c.index,c.removed.length],e=c.index;ej;j++)i[j]=new Array(h),i[j][0]=j;for(var k=0;h>k;k++)i[0][k]=k;for(var j=1;g>j;j++)for(var k=1;h>k;k++)if(this.equals(a[b+k-1],d[e+j-1]))i[j][k]=i[j-1][k-1];else{var l=i[j-1][k]+1,m=i[j][k-1]+1;i[j][k]=m>l?l:m}return i},spliceOperationsFromEditDistances:function(a){for(var b=a.length-1,c=a[0].length-1,d=a[b][c],e=[];b>0||c>0;)if(0!=b)if(0!=c){var f,g=a[b-1][c-1],h=a[b-1][c],i=a[b][c-1];f=i>h?g>h?h:g:g>i?i:g,f==g?(g==d?e.push(ub):(e.push(vb),d=g),b--,c--):f==h?(e.push(xb),b--,d=h):(e.push(wb),c--,d=i)}else e.push(xb),b--;else e.push(wb),c--;return e.reverse(),e},calcSplices:function(a,b,c,d,e,f){var g=0,h=0,i=Math.min(c-b,f-e);if(0==b&&0==e&&(g=this.sharedPrefix(a,d,i)),c==a.length&&f==d.length&&(h=this.sharedSuffix(a,d,i-g)),b+=g,e+=g,c-=h,f-=h,c-b==0&&f-e==0)return[];if(b==c){for(var j=E(b,[],0);f>e;)j.removed.push(d[e++]);return[j]}if(e==f)return[E(b,[],c-b)];for(var k=this.spliceOperationsFromEditDistances(this.calcEditDistances(a,b,c,d,e,f)),j=void 0,l=[],m=b,n=e,o=0;od;d++)if(!this.equals(a[d],b[d]))return d;return c},sharedSuffix:function(a,b,c){for(var d=a.length,e=b.length,f=0;c>f&&this.equals(a[--d],b[--e]);)f++;return f},calculateSplices:function(a,b){return this.calcSplices(a,0,a.length,b,0,b.length)},equals:function(a,b){return a===b}};var yb=new F;a.Observer=t,a.Observer.runEOM_=fb,a.Observer.hasObjectObserve=Q,a.ArrayObserver=x,a.ArrayObserver.calculateSplices=function(a,b){return yb.calculateSplices(a,b)},a.ArraySplice=F,a.ObjectObserver=w,a.PathObserver=y,a.CompoundObserver=z,a.Path=i,a.ObserverTransform=B,a.Observer.changeRecordTypes={add:L,update:M,reconfigure:N,"delete":O,splice:P}}("undefined"!=typeof global&&global&&"undefined"!=typeof module&&module?global:this||window),window.Platform=window.Platform||{},window.logFlags=window.logFlags||{},function(a){var b=a.flags||{};location.search.slice(1).split("&").forEach(function(a){a=a.split("="),a[0]&&(b[a[0]]=a[1]||!0)});var c=document.currentScript||document.querySelector('script[src*="platform.js"]');if(c)for(var d,e=c.attributes,f=0;f=0;b--)if(!c(a[b]))return a[b];return null}function i(a,d){for(var e=[];a;){for(var g=[],i=d,j=void 0;i;){var m=null;if(g.length){if(c(i)&&(m=h(g),k(j))){var n=g[g.length-1];g.push(n)}}else g.push(i);if(l(i,a))return g[g.length-1];b(i)&&g.pop(),j=i,i=f(i,m,e)}a=b(a)?a.host:a.parentNode}}function j(b){return a.insertionParentTable.get(b)}function k(a){return j(a)}function l(a,b){return K(a)===K(b)}function m(a){return R.get(a)?void 0:(R.set(a,!0),n(O(a),O(a.target)))}function n(b,c){if(S.get(b))throw new Error("InvalidStateError");S.set(b,!0),a.renderAllPending();var d=g(c);return"load"===b.type&&2===d.length&&d[0].target instanceof P.Document&&d.shift(),$.set(b,d),o(b,d)&&p(b,d)&&q(b,d),W.set(b,t.NONE),U.delete(b,null),S.delete(b),b.defaultPrevented}function o(a,b){for(var c,d=b.length-1;d>0;d--){var e=b[d].target,f=b[d].currentTarget;if(e!==f&&(c=t.CAPTURING_PHASE,!r(b[d],a,c)))return!1}return!0}function p(a,b){var c=t.AT_TARGET;return r(b[0],a,c)}function q(a,b){for(var c,d=a.bubbles,e=1;e=f;f++){var g=b[f].currentTarget,h=K(g);h.contains(e)&&(f!==d||g instanceof P.Node)&&(a[c++]=g)}a.length=c}return a},stopPropagation:function(){X.set(this,!0)},stopImmediatePropagation:function(){X.set(this,!0),Y.set(this,!0)}},M(_,t,document.createEvent("Event")); -var ab=v("UIEvent",t),bb=v("CustomEvent",t),cb={get relatedTarget(){return V.get(this)||O(N(this).relatedTarget)}},db=L({initMouseEvent:w("initMouseEvent",14)},cb),eb=L({initFocusEvent:w("initFocusEvent",5)},cb),fb=v("MouseEvent",ab,db),gb=v("FocusEvent",ab,eb),hb=Object.create(null),ib=function(){try{new window.FocusEvent("focus")}catch(a){return!1}return!0}();if(!ib){var jb=function(a,b,c){if(c){var d=hb[c];b=L(L({},d),b)}hb[a]=b};jb("Event",{bubbles:!1,cancelable:!1}),jb("CustomEvent",{detail:null},"Event"),jb("UIEvent",{view:null,detail:0},"Event"),jb("MouseEvent",{screenX:0,screenY:0,clientX:0,clientY:0,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,button:0,relatedTarget:null},"UIEvent"),jb("FocusEvent",{relatedTarget:null},"UIEvent")}y.prototype=Object.create(t.prototype),L(y.prototype,{get returnValue(){return this.impl.returnValue},set returnValue(a){this.impl.returnValue=a}});var kb=window.EventTarget,lb=["addEventListener","removeEventListener","dispatchEvent"];[Node,Window].forEach(function(a){var b=a.prototype;lb.forEach(function(a){Object.defineProperty(b,a+"_",{value:b[a]})})}),B.prototype={addEventListener:function(a,b,c){if(z(b)&&!A(a)){var d=new s(a,b,c),e=Q.get(this);if(e){for(var f=0;fd;d++)b[d]=f(a[d]);return b.length=e,b}function e(a,b){a.prototype[b]=function(){return d(this.impl[b].apply(this.impl,arguments))}}var f=a.wrap;c.prototype={item:function(a){return this[a]}},b(c.prototype,"item"),a.wrappers.NodeList=c,a.addWrapNodeListMethod=e,a.wrapNodeList=d}(window.ShadowDOMPolyfill),function(a){"use strict";a.wrapHTMLCollection=a.wrapNodeList,a.wrappers.HTMLCollection=a.wrappers.NodeList}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){A(a instanceof w)}function c(a){var b=new y;return b[0]=a,b.length=1,b}function d(a,b,c){C(b,"childList",{removedNodes:c,previousSibling:a.previousSibling,nextSibling:a.nextSibling})}function e(a,b){C(a,"childList",{removedNodes:b})}function f(a,b,d,e){if(a instanceof DocumentFragment){var f=h(a);N=!0;for(var g=f.length-1;g>=0;g--)a.removeChild(f[g]),f[g].parentNode_=b;N=!1;for(var g=0;ge;e++)d.appendChild(J(b[e]));return d}function q(a){if(void 0!==a.firstChild_)for(var b=a.firstChild_;b;){var c=b;b=b.nextSibling_,c.parentNode_=c.previousSibling_=c.nextSibling_=void 0}a.firstChild_=a.lastChild_=void 0}function r(a){if(a.invalidateShadowRenderer()){for(var b=a.firstChild;b;){A(b.parentNode===a);var c=b.nextSibling,d=J(b),e=d.parentNode;e&&U.call(e,d),b.previousSibling_=b.nextSibling_=b.parentNode_=null,b=c}a.firstChild_=a.lastChild_=null}else for(var c,f=J(a),g=f.firstChild;g;)c=g.nextSibling,U.call(f,g),g=c}function s(a){var b=a.parentNode;return b&&b.invalidateShadowRenderer()}function t(a){for(var b,c=0;c>>0}function c(a){d.call(this,a)}var d=a.wrappers.CharacterData,e=(a.enqueueMutation,a.mixin),f=a.registerWrapper,g=window.Text;c.prototype=Object.create(d.prototype),e(c.prototype,{splitText:function(a){a=b(a);var c=this.data;if(a>c.length)throw new Error("IndexSizeError");var d=c.slice(0,a),e=c.slice(a);this.data=d;var f=this.ownerDocument.createTextNode(e);return this.parentNode&&this.parentNode.insertBefore(f,this.nextSibling),f}}),f(g,c,document.createTextNode("")),a.wrappers.Text=c}(window.ShadowDOMPolyfill),function(a){"use strict";function b(b,c){var d=b.parentNode;if(d&&d.shadowRoot){var e=a.getRendererForHost(d);e.dependsOnAttribute(c)&&e.invalidate()}}function c(a,b,c){k(a,"attributes",{name:b,namespace:null,oldValue:c})}function d(a){h.call(this,a)}function e(a,c,d){var e=d||c;Object.defineProperty(a,c,{get:function(){return this.impl[c]},set:function(a){this.impl[c]=a,b(this,e)},configurable:!0,enumerable:!0})}var f=a.ChildNodeInterface,g=a.GetElementsByInterface,h=a.wrappers.Node,i=a.ParentNodeInterface,j=a.SelectorsInterface,k=(a.addWrapNodeListMethod,a.enqueueMutation),l=a.mixin,m=(a.oneOf,a.registerWrapper),n=a.wrappers,o=window.Element,p=["matches","mozMatchesSelector","msMatchesSelector","webkitMatchesSelector"].filter(function(a){return o.prototype[a]}),q=p[0],r=o.prototype[q];d.prototype=Object.create(h.prototype),l(d.prototype,{createShadowRoot:function(){var b=new n.ShadowRoot(this);this.impl.polymerShadowRoot_=b;var c=a.getRendererForHost(this);return c.invalidate(),b},get shadowRoot(){return this.impl.polymerShadowRoot_||null},setAttribute:function(a,d){var e=this.impl.getAttribute(a);this.impl.setAttribute(a,d),c(this,a,e),b(this,a)},removeAttribute:function(a){var d=this.impl.getAttribute(a);this.impl.removeAttribute(a),c(this,a,d),b(this,a)},matches:function(a){return r.call(this.impl,a)}}),p.forEach(function(a){"matches"!==a&&(d.prototype[a]=function(a){return this.matches(a)})}),o.prototype.webkitCreateShadowRoot&&(d.prototype.webkitCreateShadowRoot=d.prototype.createShadowRoot),e(d.prototype,"id"),e(d.prototype,"className","class"),l(d.prototype,f),l(d.prototype,g),l(d.prototype,i),l(d.prototype,j),m(o,d,document.createElementNS(null,"x")),a.matchesNames=p,a.wrappers.Element=d}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){switch(a){case"&":return"&";case"<":return"<";case">":return">";case'"':return""";case" ":return" "}}function c(a){return a.replace(z,b)}function d(a){return a.replace(A,b)}function e(a){for(var b={},c=0;c";case Node.TEXT_NODE:var k=a.data;return b&&C[b.localName]?k:d(k);case Node.COMMENT_NODE:return"";default:throw console.error(a),new Error("not implemented")}}function g(a){a instanceof y.HTMLTemplateElement&&(a=a.content);for(var b="",c=a.firstChild;c;c=c.nextSibling)b+=f(c,a);return b}function h(a,b,c){var d=c||"div";a.textContent="";var e=w(a.ownerDocument.createElement(d));e.innerHTML=b;for(var f;f=e.firstChild;)a.appendChild(x(f))}function i(a){o.call(this,a)}function j(a,b){var c=w(a.cloneNode(!1));c.innerHTML=b;for(var d,e=w(document.createDocumentFragment());d=c.firstChild;)e.appendChild(d);return x(e)}function k(b){return function(){return a.renderAllPending(),this.impl[b]}}function l(a){p(i,a,k(a))}function m(b){Object.defineProperty(i.prototype,b,{get:k(b),set:function(c){a.renderAllPending(),this.impl[b]=c},configurable:!0,enumerable:!0})}function n(b){Object.defineProperty(i.prototype,b,{value:function(){return a.renderAllPending(),this.impl[b].apply(this.impl,arguments)},configurable:!0,enumerable:!0})}var o=a.wrappers.Element,p=a.defineGetter,q=a.enqueueMutation,r=a.mixin,s=a.nodesWereAdded,t=a.nodesWereRemoved,u=a.registerWrapper,v=a.snapshotNodeList,w=a.unwrap,x=a.wrap,y=a.wrappers,z=/[&\u00A0"]/g,A=/[&\u00A0<>]/g,B=e(["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]),C=e(["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"]),D=/MSIE/.test(navigator.userAgent),E=window.HTMLElement,F=window.HTMLTemplateElement;i.prototype=Object.create(o.prototype),r(i.prototype,{get innerHTML(){return g(this)},set innerHTML(a){if(D&&C[this.localName])return void(this.textContent=a);var b=v(this.childNodes);this.invalidateShadowRenderer()?this instanceof y.HTMLTemplateElement?h(this.content,a):h(this,a,this.tagName):!F&&this instanceof y.HTMLTemplateElement?h(this.content,a):this.impl.innerHTML=a;var c=v(this.childNodes);q(this,"childList",{addedNodes:c,removedNodes:b}),t(b),s(c,this)},get outerHTML(){return f(this,this.parentNode)},set outerHTML(a){var b=this.parentNode;if(b){b.invalidateShadowRenderer();var c=j(b,a);b.replaceChild(c,this)}},insertAdjacentHTML:function(a,b){var c,d;switch(String(a).toLowerCase()){case"beforebegin":c=this.parentNode,d=this;break;case"afterend":c=this.parentNode,d=this.nextSibling;break;case"afterbegin":c=this,d=this.firstChild;break;case"beforeend":c=this,d=null;break;default:return}var e=j(c,b);c.insertBefore(e,d)}}),["clientHeight","clientLeft","clientTop","clientWidth","offsetHeight","offsetLeft","offsetTop","offsetWidth","scrollHeight","scrollWidth"].forEach(l),["scrollLeft","scrollTop"].forEach(m),["getBoundingClientRect","getClientRects","scrollIntoView"].forEach(n),u(E,i,document.createElement("b")),a.wrappers.HTMLElement=i,a.getInnerHTML=g,a.setInnerHTML=h}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){c.call(this,a)}var c=a.wrappers.HTMLElement,d=a.mixin,e=a.registerWrapper,f=a.wrap,g=window.HTMLCanvasElement;b.prototype=Object.create(c.prototype),d(b.prototype,{getContext:function(){var a=this.impl.getContext.apply(this.impl,arguments);return a&&f(a)}}),e(g,b,document.createElement("canvas")),a.wrappers.HTMLCanvasElement=b}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){c.call(this,a)}var c=a.wrappers.HTMLElement,d=a.mixin,e=a.registerWrapper,f=window.HTMLContentElement;b.prototype=Object.create(c.prototype),d(b.prototype,{get select(){return this.getAttribute("select")},set select(a){this.setAttribute("select",a)},setAttribute:function(a,b){c.prototype.setAttribute.call(this,a,b),"select"===String(a).toLowerCase()&&this.invalidateShadowRenderer(!0)}}),f&&e(f,b),a.wrappers.HTMLContentElement=b}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){d.call(this,a)}function c(a,b){if(!(this instanceof c))throw new TypeError("DOM object constructor cannot be called as a function.");var e=f(document.createElement("img"));d.call(this,e),g(e,this),void 0!==a&&(e.width=a),void 0!==b&&(e.height=b)}var d=a.wrappers.HTMLElement,e=a.registerWrapper,f=a.unwrap,g=a.rewrap,h=window.HTMLImageElement;b.prototype=Object.create(d.prototype),e(h,b,document.createElement("img")),c.prototype=b.prototype,a.wrappers.HTMLImageElement=b,a.wrappers.Image=c}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){c.call(this,a)}var c=a.wrappers.HTMLElement,d=a.mixin,e=a.registerWrapper,f=window.HTMLShadowElement;b.prototype=Object.create(c.prototype),d(b.prototype,{}),f&&e(f,b),a.wrappers.HTMLShadowElement=b}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){if(!a.defaultView)return a;var b=k.get(a);if(!b){for(b=a.implementation.createHTMLDocument("");b.lastChild;)b.removeChild(b.lastChild);k.set(a,b)}return b}function c(a){for(var c,d=b(a.ownerDocument),e=h(d.createDocumentFragment());c=a.firstChild;)e.appendChild(c);return e}function d(a){if(e.call(this,a),!l){var b=c(a);j.set(this,i(b))}}var e=a.wrappers.HTMLElement,f=a.mixin,g=a.registerWrapper,h=a.unwrap,i=a.wrap,j=new WeakMap,k=new WeakMap,l=window.HTMLTemplateElement;d.prototype=Object.create(e.prototype),f(d.prototype,{get content(){return l?i(this.impl.content):j.get(this)}}),l&&g(l,d),a.wrappers.HTMLTemplateElement=d}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){c.call(this,a)}var c=a.wrappers.HTMLElement,d=a.registerWrapper,e=window.HTMLMediaElement;b.prototype=Object.create(c.prototype),d(e,b,document.createElement("audio")),a.wrappers.HTMLMediaElement=b}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){d.call(this,a)}function c(a){if(!(this instanceof c))throw new TypeError("DOM object constructor cannot be called as a function.");var b=f(document.createElement("audio"));d.call(this,b),g(b,this),b.setAttribute("preload","auto"),void 0!==a&&b.setAttribute("src",a)}var d=a.wrappers.HTMLMediaElement,e=a.registerWrapper,f=a.unwrap,g=a.rewrap,h=window.HTMLAudioElement;b.prototype=Object.create(d.prototype),e(h,b,document.createElement("audio")),c.prototype=b.prototype,a.wrappers.HTMLAudioElement=b,a.wrappers.Audio=c}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){return a.replace(/\s+/g," ").trim()}function c(a){e.call(this,a)}function d(a,b,c,f){if(!(this instanceof d))throw new TypeError("DOM object constructor cannot be called as a function.");var g=i(document.createElement("option"));e.call(this,g),h(g,this),void 0!==a&&(g.text=a),void 0!==b&&g.setAttribute("value",b),c===!0&&g.setAttribute("selected",""),g.selected=f===!0}var e=a.wrappers.HTMLElement,f=a.mixin,g=a.registerWrapper,h=a.rewrap,i=a.unwrap,j=a.wrap,k=window.HTMLOptionElement;c.prototype=Object.create(e.prototype),f(c.prototype,{get text(){return b(this.textContent)},set text(a){this.textContent=b(String(a))},get form(){return j(i(this).form)}}),g(k,c,document.createElement("option")),d.prototype=c.prototype,a.wrappers.HTMLOptionElement=c,a.wrappers.Option=d}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){c.call(this,a)}var c=a.wrappers.HTMLElement,d=a.mixin,e=a.registerWrapper,f=a.unwrap,g=a.wrap,h=window.HTMLSelectElement;b.prototype=Object.create(c.prototype),d(b.prototype,{add:function(a,b){"object"==typeof b&&(b=f(b)),f(this).add(f(a),b)},remove:function(a){"object"==typeof a&&(a=f(a)),f(this).remove(a)},get form(){return g(f(this).form)}}),e(h,b,document.createElement("select")),a.wrappers.HTMLSelectElement=b}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){c.call(this,a)}var c=a.wrappers.HTMLElement,d=a.mixin,e=a.registerWrapper,f=a.unwrap,g=a.wrap,h=a.wrapHTMLCollection,i=window.HTMLTableElement;b.prototype=Object.create(c.prototype),d(b.prototype,{get caption(){return g(f(this).caption)},createCaption:function(){return g(f(this).createCaption())},get tHead(){return g(f(this).tHead)},createTHead:function(){return g(f(this).createTHead())},createTFoot:function(){return g(f(this).createTFoot())},get tFoot(){return g(f(this).tFoot)},get tBodies(){return h(f(this).tBodies)},createTBody:function(){return g(f(this).createTBody())},get rows(){return h(f(this).rows)},insertRow:function(a){return g(f(this).insertRow(a))}}),e(i,b,document.createElement("table")),a.wrappers.HTMLTableElement=b}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){c.call(this,a)}var c=a.wrappers.HTMLElement,d=a.mixin,e=a.registerWrapper,f=a.wrapHTMLCollection,g=a.unwrap,h=a.wrap,i=window.HTMLTableSectionElement;b.prototype=Object.create(c.prototype),d(b.prototype,{get rows(){return f(g(this).rows)},insertRow:function(a){return h(g(this).insertRow(a))}}),e(i,b,document.createElement("thead")),a.wrappers.HTMLTableSectionElement=b}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){c.call(this,a)}var c=a.wrappers.HTMLElement,d=a.mixin,e=a.registerWrapper,f=a.wrapHTMLCollection,g=a.unwrap,h=a.wrap,i=window.HTMLTableRowElement;b.prototype=Object.create(c.prototype),d(b.prototype,{get cells(){return f(g(this).cells)},insertCell:function(a){return h(g(this).insertCell(a))}}),e(i,b,document.createElement("tr")),a.wrappers.HTMLTableRowElement=b}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){switch(a.localName){case"content":return new c(a);case"shadow":return new e(a);case"template":return new f(a)}d.call(this,a)}var c=a.wrappers.HTMLContentElement,d=a.wrappers.HTMLElement,e=a.wrappers.HTMLShadowElement,f=a.wrappers.HTMLTemplateElement,g=(a.mixin,a.registerWrapper),h=window.HTMLUnknownElement;b.prototype=Object.create(d.prototype),g(h,b),a.wrappers.HTMLUnknownElement=b}(window.ShadowDOMPolyfill),function(a){"use strict";var b=a.registerObject,c="http://www.w3.org/2000/svg",d=document.createElementNS(c,"title"),e=b(d),f=Object.getPrototypeOf(e.prototype).constructor;a.wrappers.SVGElement=f}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){m.call(this,a)}var c=a.mixin,d=a.registerWrapper,e=a.unwrap,f=a.wrap,g=window.SVGUseElement,h="http://www.w3.org/2000/svg",i=f(document.createElementNS(h,"g")),j=document.createElementNS(h,"use"),k=i.constructor,l=Object.getPrototypeOf(k.prototype),m=l.constructor;b.prototype=Object.create(l),"instanceRoot"in j&&c(b.prototype,{get instanceRoot(){return f(e(this).instanceRoot)},get animatedInstanceRoot(){return f(e(this).animatedInstanceRoot)}}),d(g,b,j),a.wrappers.SVGUseElement=b}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){c.call(this,a)}var c=a.wrappers.EventTarget,d=a.mixin,e=a.registerWrapper,f=a.wrap,g=window.SVGElementInstance;g&&(b.prototype=Object.create(c.prototype),d(b.prototype,{get correspondingElement(){return f(this.impl.correspondingElement)},get correspondingUseElement(){return f(this.impl.correspondingUseElement)},get parentNode(){return f(this.impl.parentNode)},get childNodes(){throw new Error("Not implemented")},get firstChild(){return f(this.impl.firstChild)},get lastChild(){return f(this.impl.lastChild)},get previousSibling(){return f(this.impl.previousSibling)},get nextSibling(){return f(this.impl.nextSibling)}}),e(g,b),a.wrappers.SVGElementInstance=b)}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){this.impl=a}var c=a.mixin,d=a.registerWrapper,e=a.unwrap,f=a.unwrapIfNeeded,g=a.wrap,h=window.CanvasRenderingContext2D;c(b.prototype,{get canvas(){return g(this.impl.canvas)},drawImage:function(){arguments[0]=f(arguments[0]),this.impl.drawImage.apply(this.impl,arguments)},createPattern:function(){return arguments[0]=e(arguments[0]),this.impl.createPattern.apply(this.impl,arguments)}}),d(h,b,document.createElement("canvas").getContext("2d")),a.wrappers.CanvasRenderingContext2D=b}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){this.impl=a}var c=a.mixin,d=a.registerWrapper,e=a.unwrapIfNeeded,f=a.wrap,g=window.WebGLRenderingContext;if(g){c(b.prototype,{get canvas(){return f(this.impl.canvas)},texImage2D:function(){arguments[5]=e(arguments[5]),this.impl.texImage2D.apply(this.impl,arguments)},texSubImage2D:function(){arguments[6]=e(arguments[6]),this.impl.texSubImage2D.apply(this.impl,arguments)}});var h=/WebKit/.test(navigator.userAgent)?{drawingBufferHeight:null,drawingBufferWidth:null}:{};d(g,b,h),a.wrappers.WebGLRenderingContext=b}}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){this.impl=a}var c=a.registerWrapper,d=a.unwrap,e=a.unwrapIfNeeded,f=a.wrap,g=window.Range;b.prototype={get startContainer(){return f(this.impl.startContainer)},get endContainer(){return f(this.impl.endContainer)},get commonAncestorContainer(){return f(this.impl.commonAncestorContainer)},setStart:function(a,b){this.impl.setStart(e(a),b)},setEnd:function(a,b){this.impl.setEnd(e(a),b)},setStartBefore:function(a){this.impl.setStartBefore(e(a))},setStartAfter:function(a){this.impl.setStartAfter(e(a))},setEndBefore:function(a){this.impl.setEndBefore(e(a))},setEndAfter:function(a){this.impl.setEndAfter(e(a))},selectNode:function(a){this.impl.selectNode(e(a))},selectNodeContents:function(a){this.impl.selectNodeContents(e(a))},compareBoundaryPoints:function(a,b){return this.impl.compareBoundaryPoints(a,d(b))},extractContents:function(){return f(this.impl.extractContents())},cloneContents:function(){return f(this.impl.cloneContents())},insertNode:function(a){this.impl.insertNode(e(a))},surroundContents:function(a){this.impl.surroundContents(e(a))},cloneRange:function(){return f(this.impl.cloneRange())},isPointInRange:function(a,b){return this.impl.isPointInRange(e(a),b)},comparePoint:function(a,b){return this.impl.comparePoint(e(a),b)},intersectsNode:function(a){return this.impl.intersectsNode(e(a))},toString:function(){return this.impl.toString()}},g.prototype.createContextualFragment&&(b.prototype.createContextualFragment=function(a){return f(this.impl.createContextualFragment(a))}),c(window.Range,b,document.createRange()),a.wrappers.Range=b}(window.ShadowDOMPolyfill),function(a){"use strict";var b=a.GetElementsByInterface,c=a.ParentNodeInterface,d=a.SelectorsInterface,e=a.mixin,f=a.registerObject,g=f(document.createDocumentFragment());e(g.prototype,c),e(g.prototype,d),e(g.prototype,b);var h=f(document.createComment(""));a.wrappers.Comment=h,a.wrappers.DocumentFragment=g}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){var b=k(a.impl.ownerDocument.createDocumentFragment());c.call(this,b),i(b,this),this.treeScope_=new d(this,g(a));var e=a.shadowRoot;m.set(this,e),l.set(this,a)}var c=a.wrappers.DocumentFragment,d=a.TreeScope,e=a.elementFromPoint,f=a.getInnerHTML,g=a.getTreeScope,h=a.mixin,i=a.rewrap,j=a.setInnerHTML,k=a.unwrap,l=new WeakMap,m=new WeakMap,n=/[ \t\n\r\f]/;b.prototype=Object.create(c.prototype),h(b.prototype,{get innerHTML(){return f(this)},set innerHTML(a){j(this,a),this.invalidateShadowRenderer()},get olderShadowRoot(){return m.get(this)||null},get host(){return l.get(this)||null},invalidateShadowRenderer:function(){return l.get(this).invalidateShadowRenderer()},elementFromPoint:function(a,b){return e(this,this.ownerDocument,a,b)},getElementById:function(a){return n.test(a)?null:this.querySelector('[id="'+a+'"]')}}),a.wrappers.ShadowRoot=b}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){a.previousSibling_=a.previousSibling,a.nextSibling_=a.nextSibling,a.parentNode_=a.parentNode}function c(a,c,e){var f=G(a),g=G(c),h=e?G(e):null;if(d(c),b(c),e)a.firstChild===e&&(a.firstChild_=e),e.previousSibling_=e.previousSibling;else{a.lastChild_=a.lastChild,a.lastChild===a.firstChild&&(a.firstChild_=a.firstChild);var i=H(f.lastChild);i&&(i.nextSibling_=i.nextSibling)}f.insertBefore(g,h)}function d(a){var c=G(a),d=c.parentNode;if(d){var e=H(d);b(a),a.previousSibling&&(a.previousSibling.nextSibling_=a),a.nextSibling&&(a.nextSibling.previousSibling_=a),e.lastChild===a&&(e.lastChild_=a),e.firstChild===a&&(e.firstChild_=a),d.removeChild(c)}}function e(a,b){g(b).push(a),x(a,b);var c=J.get(a);c||J.set(a,c=[]),c.push(b)}function f(a){I.set(a,[])}function g(a){var b=I.get(a);return b||I.set(a,b=[]),b}function h(a){for(var b=[],c=0,d=a.firstChild;d;d=d.nextSibling)b[c++]=d;return b}function i(a,b,c){for(var d=a.firstChild;d;d=d.nextSibling)if(b(d)){if(c(d)===!1)return}else i(d,b,c)}function j(a,b){var c=b.getAttribute("select");if(!c)return!0;if(c=c.trim(),!c)return!0;if(!(a instanceof z))return!1;if("*"===c||c===a.localName)return!0;if(!M.test(c))return!1;if(":"===c[0]&&!N.test(c))return!1;try{return a.matches(c)}catch(d){return!1}}function k(){for(var a=0;ap;p++){var q=H(f[k++]);g.get(q)||d(q)}for(var r=n.addedCount,s=f[k]&&H(f[k]),p=0;r>p;p++){var t=e[j++],u=t.node;c(b,u,s),g.set(u,!0),t.sync(g)}l+=r}for(var m=l;m=0;j--)i=Object.create(i);["createdCallback","attachedCallback","detachedCallback","attributeChangedCallback"].forEach(function(a){var b=e[a];b&&(i[a]=function(){A(this)instanceof d||y(this),b.apply(A(this),arguments)})});var k={prototype:i};c.extends&&(k.extends=c.extends),d.prototype=e,d.prototype.constructor=d,a.constructorTable.set(i,d),a.nativePrototypeTable.set(e,i);F.call(z(this),b,k);return d},t([window.HTMLDocument||window.Document],["registerElement"])}t([window.HTMLBodyElement,window.HTMLDocument||window.Document,window.HTMLHeadElement,window.HTMLHtmlElement],["appendChild","compareDocumentPosition","contains","getElementsByClassName","getElementsByTagName","getElementsByTagNameNS","insertBefore","querySelector","querySelectorAll","removeChild","replaceChild"].concat(u)),t([window.HTMLDocument||window.Document],["adoptNode","importNode","contains","createComment","createDocumentFragment","createElement","createElementNS","createEvent","createEventNS","createRange","createTextNode","elementFromPoint","getElementById","getSelection"]),v(b.prototype,j),v(b.prototype,l),v(b.prototype,n),v(b.prototype,{get implementation(){var a=C.get(this);return a?a:(a=new g(z(this).implementation),C.set(this,a),a)}}),w(window.Document,b,document.implementation.createHTMLDocument("")),window.HTMLDocument&&w(window.HTMLDocument,b),B([window.HTMLBodyElement,window.HTMLDocument||window.Document,window.HTMLHeadElement]),h(g,"createDocumentType"),h(g,"createDocument"),h(g,"createHTMLDocument"),i(g,"hasFeature"),w(window.DOMImplementation,g),t([window.DOMImplementation],["createDocumentType","createDocument","createHTMLDocument","hasFeature"]),a.adoptNodeNoRemove=d,a.wrappers.DOMImplementation=g,a.wrappers.Document=b}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){c.call(this,a)}var c=a.wrappers.EventTarget,d=a.wrappers.Selection,e=a.mixin,f=a.registerWrapper,g=a.renderAllPending,h=a.unwrap,i=a.unwrapIfNeeded,j=a.wrap,k=window.Window,l=window.getComputedStyle,m=window.getSelection;b.prototype=Object.create(c.prototype),k.prototype.getComputedStyle=function(a,b){return j(this||window).getComputedStyle(i(a),b)},k.prototype.getSelection=function(){return j(this||window).getSelection()},delete window.getComputedStyle,delete window.getSelection,["addEventListener","removeEventListener","dispatchEvent"].forEach(function(a){k.prototype[a]=function(){var b=j(this||window);return b[a].apply(b,arguments)},delete window[a]}),e(b.prototype,{getComputedStyle:function(a,b){return g(),l.call(h(this),i(a),b)},getSelection:function(){return g(),new d(m.call(h(this)))}}),f(k,b),a.wrappers.Window=b}(window.ShadowDOMPolyfill),function(a){"use strict";var b=a.unwrap,c=window.DataTransfer||window.Clipboard,d=c.prototype.setDragImage;c.prototype.setDragImage=function(a,c,e){d.call(this,b(a),c,e)}}(window.ShadowDOMPolyfill),function(a){"use strict";function b(a){var b=c[a],d=window[b];if(d){var e=document.createElement(a),f=e.constructor;window[b]=f}}var c=(a.isWrapperFor,{a:"HTMLAnchorElement",area:"HTMLAreaElement",audio:"HTMLAudioElement",base:"HTMLBaseElement",body:"HTMLBodyElement",br:"HTMLBRElement",button:"HTMLButtonElement",canvas:"HTMLCanvasElement",caption:"HTMLTableCaptionElement",col:"HTMLTableColElement",content:"HTMLContentElement",data:"HTMLDataElement",datalist:"HTMLDataListElement",del:"HTMLModElement",dir:"HTMLDirectoryElement",div:"HTMLDivElement",dl:"HTMLDListElement",embed:"HTMLEmbedElement",fieldset:"HTMLFieldSetElement",font:"HTMLFontElement",form:"HTMLFormElement",frame:"HTMLFrameElement",frameset:"HTMLFrameSetElement",h1:"HTMLHeadingElement",head:"HTMLHeadElement",hr:"HTMLHRElement",html:"HTMLHtmlElement",iframe:"HTMLIFrameElement",img:"HTMLImageElement",input:"HTMLInputElement",keygen:"HTMLKeygenElement",label:"HTMLLabelElement",legend:"HTMLLegendElement",li:"HTMLLIElement",link:"HTMLLinkElement",map:"HTMLMapElement",marquee:"HTMLMarqueeElement",menu:"HTMLMenuElement",menuitem:"HTMLMenuItemElement",meta:"HTMLMetaElement",meter:"HTMLMeterElement",object:"HTMLObjectElement",ol:"HTMLOListElement",optgroup:"HTMLOptGroupElement",option:"HTMLOptionElement",output:"HTMLOutputElement",p:"HTMLParagraphElement",param:"HTMLParamElement",pre:"HTMLPreElement",progress:"HTMLProgressElement",q:"HTMLQuoteElement",script:"HTMLScriptElement",select:"HTMLSelectElement",shadow:"HTMLShadowElement",source:"HTMLSourceElement",span:"HTMLSpanElement",style:"HTMLStyleElement",table:"HTMLTableElement",tbody:"HTMLTableSectionElement",template:"HTMLTemplateElement",textarea:"HTMLTextAreaElement",thead:"HTMLTableSectionElement",time:"HTMLTimeElement",title:"HTMLTitleElement",tr:"HTMLTableRowElement",track:"HTMLTrackElement",ul:"HTMLUListElement",video:"HTMLVideoElement"});Object.keys(c).forEach(b),Object.getOwnPropertyNames(a.wrappers).forEach(function(b){window[b]=a.wrappers[b]})}(window.ShadowDOMPolyfill),function(){window.wrap=ShadowDOMPolyfill.wrapIfNeeded,window.unwrap=ShadowDOMPolyfill.unwrapIfNeeded,Object.defineProperty(Element.prototype,"webkitShadowRoot",Object.getOwnPropertyDescriptor(Element.prototype,"shadowRoot"));var a=Element.prototype.createShadowRoot;Element.prototype.createShadowRoot=function(){var b=a.call(this);return CustomElements.watchShadow(this),b},Element.prototype.webkitCreateShadowRoot=Element.prototype.createShadowRoot}(),function(a){function b(a,b){var c="";return Array.prototype.forEach.call(a,function(a){c+=a.textContent+"\n\n"}),b||(c=c.replace(l,"")),c}function c(a){var b=document.createElement("style");return b.textContent=a,b}function d(a){var b=c(a);document.head.appendChild(b);var d=[];if(b.sheet)try{d=b.sheet.cssRules}catch(e){}else console.warn("sheet not found",b);return b.parentNode.removeChild(b),d}function e(){v.initialized=!0,document.body.appendChild(v);var a=v.contentDocument,b=a.createElement("base");b.href=document.baseURI,a.head.appendChild(b)}function f(a){v.initialized||e(),document.body.appendChild(v),a(v.contentDocument),document.body.removeChild(v)}function g(a,b){if(b){var e;if(a.match("@import")&&x){var g=c(a);f(function(a){a.head.appendChild(g.impl),e=g.sheet.cssRules,b(e)})}else e=d(a),b(e)}}function h(a){a&&j().appendChild(document.createTextNode(a))}function i(a,b){var d=c(a);d.setAttribute(b,""),d.setAttribute(z,""),document.head.appendChild(d)}function j(){return w||(w=document.createElement("style"),w.setAttribute(z,""),w[z]=!0),w}var k={strictStyling:!1,registry:{},shimStyling:function(a,c,d){var e=this.prepareRoot(a,c,d),f=this.isTypeExtension(d),g=this.makeScopeSelector(c,f),h=b(e,!0);h=this.scopeCssText(h,g),a&&(a.shimmedStyle=h),this.addCssToDocument(h,c)},shimStyle:function(a,b){return this.shimCssText(a.textContent,b)},shimCssText:function(a,b){return a=this.insertDirectives(a),this.scopeCssText(a,b)},makeScopeSelector:function(a,b){return a?b?"[is="+a+"]":a:""},isTypeExtension:function(a){return a&&a.indexOf("-")<0},prepareRoot:function(a,b,c){var d=this.registerRoot(a,b,c);return this.replaceTextInStyles(d.rootStyles,this.insertDirectives),this.removeStyles(a,d.rootStyles),this.strictStyling&&this.applyScopeToContent(a,b),d.scopeStyles},removeStyles:function(a,b){for(var c,d=0,e=b.length;e>d&&(c=b[d]);d++)c.parentNode.removeChild(c)},registerRoot:function(a,b,c){var d=this.registry[b]={root:a,name:b,extendsName:c},e=this.findStyles(a);d.rootStyles=e,d.scopeStyles=d.rootStyles;var f=this.registry[d.extendsName];return!f||a&&!a.querySelector("shadow")||(d.scopeStyles=f.scopeStyles.concat(d.scopeStyles)),d},findStyles:function(a){if(!a)return[];var b=a.querySelectorAll("style");return Array.prototype.filter.call(b,function(a){return!a.hasAttribute(A)})},applyScopeToContent:function(a,b){a&&(Array.prototype.forEach.call(a.querySelectorAll("*"),function(a){a.setAttribute(b,"")}),Array.prototype.forEach.call(a.querySelectorAll("template"),function(a){this.applyScopeToContent(a.content,b)},this))},insertDirectives:function(a){return a=this.insertPolyfillDirectivesInCssText(a),this.insertPolyfillRulesInCssText(a)},insertPolyfillDirectivesInCssText:function(a){return a=a.replace(m,function(a,b){return b.slice(0,-2)+"{"}),a.replace(n,function(a,b){return b+" {"})},insertPolyfillRulesInCssText:function(a){return a=a.replace(o,function(a,b){return b.slice(0,-1)}),a.replace(p,function(a,b,c,d){var e=a.replace(b,"").replace(c,"");return d+e})},scopeCssText:function(a,b){var c=this.extractUnscopedRulesFromCssText(a);if(a=this.insertPolyfillHostInCssText(a),a=this.convertColonHost(a),a=this.convertColonAncestor(a),a=this.convertCombinators(a),b){var a,d=this;g(a,function(c){a=d.scopeRules(c,b)})}return a=a+"\n"+c,a.trim()},extractUnscopedRulesFromCssText:function(a){for(var b,c="";b=q.exec(a);)c+=b[1].slice(0,-1)+"\n\n";for(;b=r.exec(a);)c+=b[0].replace(b[2],"").replace(b[1],b[3])+"\n\n";return c},convertColonHost:function(a){return this.convertColonRule(a,cssColonHostRe,this.colonHostPartReplacer)},convertColonAncestor:function(a){return this.convertColonRule(a,cssColonAncestorRe,this.colonAncestorPartReplacer)},convertColonRule:function(a,b,c){return a.replace(b,function(a,b,d,e){if(b=polyfillHostNoCombinator,d){for(var f,g=d.split(","),h=[],i=0,j=g.length;j>i&&(f=g[i]);i++)f=f.trim(),h.push(c(b,f,e));return h.join(",")}return b+e})},colonAncestorPartReplacer:function(a,b,c){return b.match(s)?this.colonHostPartReplacer(a,b,c):a+b+c+", "+b+" "+a+c},colonHostPartReplacer:function(a,b,c){return a+b.replace(s,"")+c},convertCombinators:function(a){for(var b=0;b","+","~"],d=a,e="["+b+"]";return c.forEach(function(a){var b=d.split(a);d=b.map(function(a){var b=a.trim().replace(polyfillHostRe,"");return b&&c.indexOf(b)<0&&b.indexOf(e)<0&&(a=b.replace(/([^:]*)(:*)(.*)/,"$1"+e+"$2$3")),a}).join(a)}),d},insertPolyfillHostInCssText:function(a){return a.replace(hostRe,s).replace(colonHostRe,s).replace(colonAncestorRe,t)},propertiesFromRule:function(a){return a.style.content&&!a.style.content.match(/['"]+/)?a.style.cssText.replace(/content:[^;]*;/g,"content: '"+a.style.content+"';"):a.style.cssText},replaceTextInStyles:function(a,b){a&&b&&(a instanceof Array||(a=[a]),Array.prototype.forEach.call(a,function(a){a.textContent=b.call(this,a.textContent)},this))},addCssToDocument:function(a,b){a.match("@import")?i(a,b):h(a)}},l=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//gim,m=/\/\*\s*@polyfill ([^*]*\*+([^/*][^*]*\*+)*\/)([^{]*?){/gim,n=/polyfill-next-selector[^}]*content\:[\s]*'([^']*)'[^}]*}([^{]*?){/gim,o=/\/\*\s@polyfill-rule([^*]*\*+([^/*][^*]*\*+)*)\//gim,p=/(polyfill-rule)[^}]*(content\:[\s]*'([^']*)'[^;]*;)[^}]*}/gim,q=/\/\*\s@polyfill-unscoped-rule([^*]*\*+([^/*][^*]*\*+)*)\//gim,r=/(polyfill-unscoped-rule)[^}]*(content\:[\s]*'([^']*)'[^;]*;)[^}]*}/gim,s="-shadowcsshost",t="-shadowcssancestor",u=")(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))?([^,{]*)";cssColonHostRe=new RegExp("("+s+u,"gim"),cssColonAncestorRe=new RegExp("("+t+u,"gim"),selectorReSuffix="([>\\s~+[.,{:][\\s\\S]*)?$",hostRe=/@host/gim,colonHostRe=/\:host/gim,colonAncestorRe=/\:ancestor/gim,polyfillHostNoCombinator=s+"-no-combinator",polyfillHostRe=new RegExp(s,"gim"),polyfillAncestorRe=new RegExp(t,"gim"),combinatorsRe=[/\^\^/g,/\^/g,/\/shadow\//g,/\/shadow-deep\//g];var v=document.createElement("iframe");v.style.display="none";var w,x=navigator.userAgent.match("Chrome"),y="shim-shadowdom",z="shim-shadowdom-css",A="no-shim";if(window.ShadowDOMPolyfill){h("style { display: none !important; }\n");var B=wrap(document),C=B.querySelector("head");C.insertBefore(j(),C.childNodes[0]),document.addEventListener("DOMContentLoaded",function(){var b=a.urlResolver;if(window.HTMLImports&&!HTMLImports.useNative){var c="link[rel=stylesheet]["+y+"]",d="style["+y+"]";HTMLImports.importer.documentPreloadSelectors+=","+c,HTMLImports.importer.importsPreloadSelectors+=","+c,HTMLImports.parser.documentSelectors=[HTMLImports.parser.documentSelectors,c,d].join(",");var e=HTMLImports.parser.parseGeneric;HTMLImports.parser.parseGeneric=function(a){if(!a[z]){var c=a.__importElement||a;if(!c.hasAttribute(y))return void e.call(this,a);a.__resource?(c=a.ownerDocument.createElement("style"),c.textContent=b.resolveCssText(a.__resource,a.href)):b.resolveStyle(c),c.textContent=k.shimStyle(c),c.removeAttribute(y,""),c.setAttribute(z,""),c[z]=!0,c.parentNode!==C&&(a.parentNode===C?C.replaceChild(c,a):C.appendChild(c)),c.__importParsed=!0,this.markParsingComplete(a)}};var f=HTMLImports.parser.hasResource;HTMLImports.parser.hasResource=function(a){return"link"===a.localName&&"stylesheet"===a.rel&&a.hasAttribute(y)?a.__resource:f.call(this,a)}}})}a.ShadowCSS=k}(window.Platform)):!function(){window.templateContent=window.templateContent||function(a){return a.content},window.wrap=window.unwrap=function(a){return a};var a=Element.prototype.webkitCreateShadowRoot;Element.prototype.webkitCreateShadowRoot=function(){var b=this.webkitShadowRoot,c=a.call(this);return c.olderShadowRoot=b,c.host=this,CustomElements.watchShadow(this),c},Object.defineProperties(Element.prototype,{shadowRoot:{get:function(){return this.webkitShadowRoot}},createShadowRoot:{value:function(){return this.webkitCreateShadowRoot()}}}),window.templateContent=function(a){if(window.HTMLTemplateElement&&HTMLTemplateElement.bootstrap&&HTMLTemplateElement.bootstrap(a),!a.content&&!a._content){for(var b=document.createDocumentFragment();a.firstChild;)b.appendChild(a.firstChild);a._content=b}return a.content||a._content}}(),function(a){"use strict";function b(a){return void 0!==m[a]}function c(){h.call(this),this._isInvalid=!0}function d(a){return""==a&&c.call(this),a.toLowerCase()}function e(a){var b=a.charCodeAt(0);return b>32&&127>b&&-1==[34,35,60,62,63,96].indexOf(b)?a:encodeURIComponent(a)}function f(a){var b=a.charCodeAt(0);return b>32&&127>b&&-1==[34,35,60,62,96].indexOf(b)?a:encodeURIComponent(a)}function g(a,g,h){function i(a){t.push(a)}var j=g||"scheme start",k=0,l="",r=!1,s=!1,t=[];a:for(;(a[k-1]!=o||0==k)&&!this._isInvalid;){var u=a[k];switch(j){case"scheme start":if(!u||!p.test(u)){if(g){i("Invalid scheme.");break a}l="",j="no scheme";continue}l+=u.toLowerCase(),j="scheme";break;case"scheme":if(u&&q.test(u))l+=u.toLowerCase();else{if(":"!=u){if(g){if(o==u)break a;i("Code point not allowed in scheme: "+u);break a}l="",k=0,j="no scheme";continue}if(this._scheme=l,l="",g)break a;b(this._scheme)&&(this._isRelative=!0),j="file"==this._scheme?"relative":this._isRelative&&h&&h._scheme==this._scheme?"relative or authority":this._isRelative?"authority first slash":"scheme data"}break;case"scheme data":"?"==u?(query="?",j="query"):"#"==u?(this._fragment="#",j="fragment"):o!=u&&" "!=u&&"\n"!=u&&"\r"!=u&&(this._schemeData+=e(u));break;case"no scheme":if(h&&b(h._scheme)){j="relative";continue}i("Missing scheme."),c.call(this);break;case"relative or authority":if("/"!=u||"/"!=a[k+1]){i("Expected /, got: "+u),j="relative";continue}j="authority ignore slashes";break;case"relative":if(this._isRelative=!0,"file"!=this._scheme&&(this._scheme=h._scheme),o==u){this._host=h._host,this._port=h._port,this._path=h._path.slice(),this._query=h._query;break a}if("/"==u||"\\"==u)"\\"==u&&i("\\ is an invalid code point."),j="relative slash";else if("?"==u)this._host=h._host,this._port=h._port,this._path=h._path.slice(),this._query="?",j="query";else{if("#"!=u){var v=a[k+1],w=a[k+2];("file"!=this._scheme||!p.test(u)||":"!=v&&"|"!=v||o!=w&&"/"!=w&&"\\"!=w&&"?"!=w&&"#"!=w)&&(this._host=h._host,this._port=h._port,this._path=h._path.slice(),this._path.pop()),j="relative path";continue}this._host=h._host,this._port=h._port,this._path=h._path.slice(),this._query=h._query,this._fragment="#",j="fragment"}break;case"relative slash":if("/"!=u&&"\\"!=u){"file"!=this._scheme&&(this._host=h._host,this._port=h._port),j="relative path";continue}"\\"==u&&i("\\ is an invalid code point."),j="file"==this._scheme?"file host":"authority ignore slashes";break;case"authority first slash":if("/"!=u){i("Expected '/', got: "+u),j="authority ignore slashes";continue}j="authority second slash";break;case"authority second slash":if(j="authority ignore slashes","/"!=u){i("Expected '/', got: "+u);continue}break;case"authority ignore slashes":if("/"!=u&&"\\"!=u){j="authority";continue}i("Expected authority, got: "+u);break;case"authority":if("@"==u){r&&(i("@ already seen."),l+="%40"),r=!0;for(var x=0;x')})}),a.createDOM=b}(window.Platform),window.templateContent=window.templateContent||function(a){return a.content},function(a){a=a||(window.Inspector={});var b;window.sinspect=function(a,d){b||(b=window.open("","ShadowDOM Inspector",null,!0),b.document.write(c),b.api={shadowize:shadowize}),f(a||wrap(document.body),d)};var c=["",""," "," ShadowDOM Inspector"," "," "," ",'
    ',"
",'
'," ",""].join("\n"),d=[],e=function(){var a=b.document,c=a.querySelector("#crumbs"); -c.textContent="";for(var e,g=0;e=d[g];g++){var h=a.createElement("a");h.href="#",h.textContent=e.localName,h.idx=g,h.onclick=function(a){for(var b;d.length>this.idx;)b=d.pop();f(b.shadow||b,b),a.preventDefault()},c.appendChild(a.createElement("li")).appendChild(h)}},f=function(a,c){var f=b.document;k=[];var g=c||a;d.push(g),e(),f.body.querySelector("#tree").innerHTML="
"+j(a,a.childNodes)+"
"},g=Array.prototype.forEach.call.bind(Array.prototype.forEach),h={STYLE:1,SCRIPT:1,"#comment":1,TEMPLATE:1},i=function(a){return h[a.nodeName]},j=function(a,b,c){if(i(a))return"";var d=c||"";if(a.localName||11==a.nodeType){var e=a.localName||"shadow-root",f=d+l(a);"content"==e&&(b=a.getDistributedNodes()),f+="
";var h=d+"  ";g(b,function(a){f+=j(a,a.childNodes,h)}),f+=d,{br:1}[e]||(f+="</"+e+">",f+="
")}else{var k=a.textContent.trim();f=k?d+'"'+k+'"
':""}return f},k=[],l=function(a){var b="<",c=a.localName||"shadow-root";return a.webkitShadowRoot||a.shadowRoot?(b+=' ",k.push(a)):b+=c||"shadow-root",a.attributes&&g(a.attributes,function(a){b+=" "+a.name+(a.value?'="'+a.value+'"':"")}),b+=">"};shadowize=function(){var a=Number(this.attributes.idx.value),b=k[a];b?f(b.webkitShadowRoot||b.shadowRoot,b):(console.log("bad shadowize node"),console.dir(this))},a.output=j}(window.Inspector),function(){var a=document.createElement("style");a.textContent="body {transition: opacity ease-in 0.2s; } \nbody[unresolved] {opacity: 0; display: block; overflow: hidden; } \n";var b=document.querySelector("head");b.insertBefore(a,b.firstChild)}(Platform),function(a){function b(a,b){return b=b||[],b.map||(b=[b]),a.apply(this,b.map(d))}function c(a,c,d){var e;switch(arguments.length){case 0:return;case 1:e=null;break;case 2:e=c.apply(this);break;default:e=b(d,c)}f[a]=e}function d(a){return f[a]}function e(a,c){HTMLImports.whenImportsReady(function(){b(c,a)})}var f={};a.marshal=d,a.module=c,a.using=e}(window),function(a){function b(a){f.textContent=d++,e.push(a)}function c(){for(;e.length;)e.shift()()}var d=0,e=[],f=document.createTextNode("");new(window.MutationObserver||JsMutationObserver)(c).observe(f,{characterData:!0}),a.endOfMicrotask=b}(Platform),function(a){function b(a,b,d){return a.replace(d,function(a,d,e,f){var g=e.replace(/["']/g,"");return g=c(b,g),d+"'"+g+"'"+f})}function c(a,b){var c=new URL(b,a);return d(c.href)}function d(a){var b=document.baseURI,c=new URL(a,b);return c.host===b.host&&c.port===b.port&&c.protocol===b.protocol?e(b.pathname,c.pathname):a}function e(a,b){for(var c=a.split("/"),d=b.split("/");c.length&&c[0]===d[0];)c.shift(),d.shift();for(var e=0,f=c.length-1;f>e;e++)d.unshift("..");return d.join("/")}var f={resolveDom:function(a,b){b=b||a.ownerDocument.baseURI,this.resolveAttributes(a,b),this.resolveStyles(a,b);var c=a.querySelectorAll("template");if(c)for(var d,e=0,f=c.length;f>e&&(d=c[e]);e++)d.content&&this.resolveDom(d.content,b)},resolveTemplate:function(a){this.resolveDom(a.content,a.ownerDocument.baseURI)},resolveStyles:function(a,b){var c=a.querySelectorAll("style");if(c)for(var d,e=0,f=c.length;f>e&&(d=c[e]);e++)this.resolveStyle(d,b)},resolveStyle:function(a,b){b=b||a.ownerDocument.baseURI,a.textContent=this.resolveCssText(a.textContent,b)},resolveCssText:function(a,c){return a=b(a,c,g),b(a,c,h)},resolveAttributes:function(a,b){a.hasAttributes&&a.hasAttributes()&&this.resolveElementAttributes(a,b);var c=a&&a.querySelectorAll(j);if(c)for(var d,e=0,f=c.length;f>e&&(d=c[e]);e++)this.resolveElementAttributes(d,b)},resolveElementAttributes:function(a,b){b=b||a.ownerDocument.baseURI,i.forEach(function(d){var e=a.attributes[d];if(e&&e.value&&e.value.search(k)<0){var f=c(b,e.value);e.value=f}})}},g=/(url\()([^)]*)(\))/g,h=/(@import[\s]+(?!url\())([^;]*)(;)/g,i=["href","src","action"],j="["+i.join("],[")+"]",k="{{.*}}";a.urlResolver=f}(Platform),function(a){function b(a){u.push(a),t||(t=!0,q(d))}function c(a){return window.ShadowDOMPolyfill&&window.ShadowDOMPolyfill.wrapIfNeeded(a)||a}function d(){t=!1;var a=u;u=[],a.sort(function(a,b){return a.uid_-b.uid_});var b=!1;a.forEach(function(a){var c=a.takeRecords();e(a),c.length&&(a.callback_(c,a),b=!0)}),b&&d()}function e(a){a.nodes_.forEach(function(b){var c=p.get(b);c&&c.forEach(function(b){b.observer===a&&b.removeTransientObservers()})})}function f(a,b){for(var c=a;c;c=c.parentNode){var d=p.get(c);if(d)for(var e=0;e0){var e=c[d-1],f=n(e,a);if(f)return void(c[d-1]=f)}else b(this.observer);c[d]=a},addListeners:function(){this.addListeners_(this.target)},addListeners_:function(a){var b=this.options;b.attributes&&a.addEventListener("DOMAttrModified",this,!0),b.characterData&&a.addEventListener("DOMCharacterDataModified",this,!0),b.childList&&a.addEventListener("DOMNodeInserted",this,!0),(b.childList||b.subtree)&&a.addEventListener("DOMNodeRemoved",this,!0)},removeListeners:function(){this.removeListeners_(this.target)},removeListeners_:function(a){var b=this.options;b.attributes&&a.removeEventListener("DOMAttrModified",this,!0),b.characterData&&a.removeEventListener("DOMCharacterDataModified",this,!0),b.childList&&a.removeEventListener("DOMNodeInserted",this,!0),(b.childList||b.subtree)&&a.removeEventListener("DOMNodeRemoved",this,!0)},addTransientObserver:function(a){if(a!==this.target){this.addListeners_(a),this.transientObservedNodes.push(a);var b=p.get(a);b||p.set(a,b=[]),b.push(this)}},removeTransientObservers:function(){var a=this.transientObservedNodes;this.transientObservedNodes=[],a.forEach(function(a){this.removeListeners_(a);for(var b=p.get(a),c=0;cc&&(b=a[c]);c++)this.require(b);this.checkDone()},addNode:function(a){this.inflight++,this.require(a),this.checkDone()},require:function(a){var b=a.src||a.href;a.__nodeUrl=b,this.dedupe(b,a)||this.fetch(b,a)},dedupe:function(a,b){if(this.pending[a])return this.pending[a].push(b),!0;return this.cache[a]?(this.onload(a,b,this.cache[a]),this.tail(),!0):(this.pending[a]=[b],!1)},fetch:function(a,d){c.load&&console.log("fetch",a,d);var e=function(b,c){this.receive(a,d,b,c)}.bind(this);b.load(a,e)},receive:function(a,b,c,d){this.cache[a]=d;for(var e,f=this.pending[a],g=0,h=f.length;h>g&&(e=f[g]);g++)this.onload(a,e,d),this.tail();this.pending[a]=null},tail:function(){--this.inflight,this.checkDone()},checkDone:function(){this.inflight||this.oncomplete()}},b=b||{async:!0,ok:function(a){return a.status>=200&&a.status<300||304===a.status||0===a.status},load:function(c,d,e){var f=new XMLHttpRequest;return(a.flags.debug||a.flags.bust)&&(c+="?"+Math.random()),f.open("GET",c,b.async),f.addEventListener("readystatechange",function(){4===f.readyState&&d.call(e,!b.ok(f)&&f,f.response||f.responseText,c)}),f.send(),f},loadDocument:function(a,b,c){this.load(a,b,c).responseType="document"}},a.xhr=b,a.Loader=d}(window.HTMLImports),function(a){function b(a){return"link"===a.localName&&a.rel===g}function c(a){var b,c=d(a);try{b=btoa(c)}catch(e){b=btoa(unescape(encodeURIComponent(c))),console.warn("Script contained non-latin characters that were forced to latin. Some characters may be wrong.",a)}return"data:text/javascript;base64,"+b}function d(a){return a.textContent+e(a)}function e(a){var b=a.__nodeUrl;if(!b){b=a.ownerDocument.baseURI;var c="["+Math.floor(1e3*(Math.random()+1))+"]",d=a.textContent.match(/Polymer\(['"]([^'"]*)/);c=d&&d[1]||c,b+="/"+c+".js"}return"\n//# sourceURL="+b+"\n"}function f(a){var b=a.ownerDocument.createElement("style");return b.textContent=a.textContent,n.resolveUrlsInStyle(b),b}var g="import",h=a.flags,i=/Trident/.test(navigator.userAgent),j=window.ShadowDOMPolyfill?window.ShadowDOMPolyfill.wrapIfNeeded(document):document,k={documentSelectors:"link[rel="+g+"]",importsSelectors:["link[rel="+g+"]","link[rel=stylesheet]","style","script:not([type])",'script[type="text/javascript"]'].join(","),map:{link:"parseLink",script:"parseScript",style:"parseStyle"},parseNext:function(){var a=this.nextToParse();a&&this.parse(a)},parse:function(a){if(this.isParsed(a))return void(h.parse&&console.log("[%s] is already parsed",a.localName));var b=this[this.map[a.localName]];b&&(this.markParsing(a),b.call(this,a))},markParsing:function(a){h.parse&&console.log("parsing",a),this.parsingElement=a},markParsingComplete:function(a){a.__importParsed=!0,a.__importElement&&(a.__importElement.__importParsed=!0),this.parsingElement=null,h.parse&&console.log("completed",a),this.parseNext()},parseImport:function(a){if(a.import.__importParsed=!0,HTMLImports.__importsParsingHook&&HTMLImports.__importsParsingHook(a),a.dispatchEvent(a.__resource?new CustomEvent("load",{bubbles:!1}):new CustomEvent("error",{bubbles:!1})),a.__pending)for(var b;a.__pending.length;)b=a.__pending.shift(),b&&b({target:a});this.markParsingComplete(a)},parseLink:function(a){b(a)?this.parseImport(a):(a.href=a.href,this.parseGeneric(a))},parseStyle:function(a){var b=a;a=f(a),a.__importElement=b,this.parseGeneric(a)},parseGeneric:function(a){this.trackElement(a),document.head.appendChild(a)},trackElement:function(a,b){var c=this,d=function(d){b&&b(d),c.markParsingComplete(a)};if(a.addEventListener("load",d),a.addEventListener("error",d),i&&"style"===a.localName){var e=!1;if(-1==a.textContent.indexOf("@import"))e=!0;else if(a.sheet){e=!0;for(var f,g=a.sheet.cssRules,h=g?g.length:0,j=0;h>j&&(f=g[j]);j++)f.type===CSSRule.IMPORT_RULE&&(e=e&&Boolean(f.styleSheet))}e&&a.dispatchEvent(new CustomEvent("load",{bubbles:!1}))}},parseScript:function(b){var d=document.createElement("script");d.__importElement=b,d.src=b.src?b.src:c(b),a.currentScript=b,this.trackElement(d,function(){d.parentNode.removeChild(d),a.currentScript=null}),document.head.appendChild(d)},nextToParse:function(){return!this.parsingElement&&this.nextToParseInDoc(j)},nextToParseInDoc:function(a,c){for(var d,e=a.querySelectorAll(this.parseSelectorsForNode(a)),f=0,g=e.length;g>f&&(d=e[f]);f++)if(!this.isParsed(d))return this.hasResource(d)?b(d)?this.nextToParseInDoc(d.import,d):d:void 0;return c},parseSelectorsForNode:function(a){var b=a.ownerDocument||a;return b===j?this.documentSelectors:this.importsSelectors},isParsed:function(a){return a.__importParsed},hasResource:function(a){return b(a)&&!a.import?!1:!0}},l=/(url\()([^)]*)(\))/g,m=/(@import[\s]+(?!url\())([^;]*)(;)/g,n={resolveUrlsInStyle:function(a){var b=a.ownerDocument,c=b.createElement("a");return a.textContent=this.resolveUrlsInCssText(a.textContent,c),a},resolveUrlsInCssText:function(a,b){var c=this.replaceUrls(a,b,l);return c=this.replaceUrls(c,b,m)},replaceUrls:function(a,b,c){return a.replace(c,function(a,c,d,e){var f=d.replace(/["']/g,"");return b.href=f,f=b.href,c+"'"+f+"'"+e})}};a.parser=k,a.path=n,a.isIE=i}(HTMLImports),function(a){function b(a){return c(a,m)}function c(a,b){return"link"===a.localName&&a.getAttribute("rel")===b}function d(a,b){var c=a;c instanceof Document||(c=document.implementation.createHTMLDocument(m)),c._URL=b;var d=c.createElement("base");d.setAttribute("href",b),c.baseURI||(c.baseURI=b);var e=c.createElement("meta");return e.setAttribute("charset","utf-8"),c.head.appendChild(e),c.head.appendChild(d),a instanceof Document||(c.body.innerHTML=a),window.HTMLTemplateElement&&HTMLTemplateElement.bootstrap&&HTMLTemplateElement.bootstrap(c),c}function e(a,b){b=b||n,g(function(){h(a,b)},b)}function f(a){return"complete"===a.readyState||a.readyState===u}function g(a,b){if(f(b))a&&a();else{var c=function(){("complete"===b.readyState||b.readyState===u)&&(b.removeEventListener(v,c),g(a,b))};b.addEventListener(v,c)}}function h(a,b){function c(){f==g&&requestAnimationFrame(a)}function d(){f++,c()}var e=b.querySelectorAll("link[rel=import]"),f=0,g=e.length;if(g)for(var h,j=0;g>j&&(h=e[j]);j++)i(h)?d.call(h):(h.addEventListener("load",d),h.addEventListener("error",d));else c()}function i(a){return k?a.import&&"loading"!==a.import.readyState:a.__importParsed}var j="import"in document.createElement("link"),k=j,l=a.flags,m="import",n=window.ShadowDOMPolyfill?ShadowDOMPolyfill.wrapIfNeeded(document):document;if(k)var o={};else var p=(a.xhr,a.Loader),q=a.parser,o={documents:{},documentPreloadSelectors:"link[rel="+m+"]",importsPreloadSelectors:["link[rel="+m+"]"].join(","),loadNode:function(a){r.addNode(a)},loadSubtree:function(a){var b=this.marshalNodes(a);r.addNodes(b)},marshalNodes:function(a){return a.querySelectorAll(this.loadSelectorsForNode(a))},loadSelectorsForNode:function(a){var b=a.ownerDocument||a;return b===n?this.documentPreloadSelectors:this.importsPreloadSelectors},loaded:function(a,c,e){if(l.load&&console.log("loaded",a,c),c.__resource=e,b(c)){var f=this.documents[a];f||(f=d(e,a),f.__importLink=c,this.bootDocument(f),this.documents[a]=f),c.import=f}q.parseNext()},bootDocument:function(a){this.loadSubtree(a),this.observe(a),q.parseNext()},loadedAll:function(){q.parseNext()}},r=new p(o.loaded.bind(o),o.loadedAll.bind(o));var s={get:function(){return HTMLImports.currentScript||document.currentScript},configurable:!0};if(Object.defineProperty(document,"_currentScript",s),Object.defineProperty(n,"_currentScript",s),!document.baseURI){var t={get:function(){return window.location.href},configurable:!0};Object.defineProperty(document,"baseURI",t),Object.defineProperty(n,"baseURI",t)}var u=HTMLImports.isIE?"complete":"interactive",v="readystatechange";a.hasNative=j,a.useNative=k,a.importer=o,a.whenImportsReady=e,a.IMPORT_LINK_TYPE=m,a.isImportLoaded=i,a.importLoader=r}(window.HTMLImports),function(a){function b(a){for(var b,d=0,e=a.length;e>d&&(b=a[d]);d++)"childList"===b.type&&b.addedNodes.length&&c(b.addedNodes)}function c(a){for(var b,e=0,g=a.length;g>e&&(b=a[e]);e++)d(b)&&f.loadNode(b),b.children&&b.children.length&&c(b.children)}function d(a){return 1===a.nodeType&&g.call(a,f.loadSelectorsForNode(a))}function e(a){h.observe(a,{childList:!0,subtree:!0})}var f=(a.IMPORT_LINK_TYPE,a.importer),g=HTMLElement.prototype.matches||HTMLElement.prototype.matchesSelector||HTMLElement.prototype.webkitMatchesSelector||HTMLElement.prototype.mozMatchesSelector||HTMLElement.prototype.msMatchesSelector,h=new MutationObserver(b);a.observe=e,f.observe=e}(HTMLImports),function(){function a(){HTMLImports.importer.bootDocument(b)}"function"!=typeof window.CustomEvent&&(window.CustomEvent=function(a,b){var c=document.createEvent("HTMLEvents");return c.initEvent(a,b.bubbles===!1?!1:!0,b.cancelable===!1?!1:!0,b.detail),c});var b=window.ShadowDOMPolyfill?window.ShadowDOMPolyfill.wrapIfNeeded(document):document;HTMLImports.whenImportsReady(function(){HTMLImports.ready=!0,HTMLImports.readyTime=(new Date).getTime(),b.dispatchEvent(new CustomEvent("HTMLImportsLoaded",{bubbles:!0}))}),HTMLImports.useNative||("complete"===document.readyState||"interactive"===document.readyState&&!window.attachEvent?a():document.addEventListener("DOMContentLoaded",a))}(),window.CustomElements=window.CustomElements||{flags:{}},function(a){function b(a,c,d){var e=a.firstElementChild;if(!e)for(e=a.firstChild;e&&e.nodeType!==Node.ELEMENT_NODE;)e=e.nextSibling;for(;e;)c(e,d)!==!0&&b(e,c,d),e=e.nextElementSibling;return null}function c(a,b){for(var c=a.shadowRoot;c;)d(c,b),c=c.olderShadowRoot}function d(a,d){b(a,function(a){return d(a)?!0:void c(a,d)}),c(a,d)}function e(a){return h(a)?(i(a),!0):void l(a)}function f(a){d(a,function(a){return e(a)?!0:void 0})}function g(a){return e(a)||f(a)}function h(b){if(!b.__upgraded__&&b.nodeType===Node.ELEMENT_NODE){var c=b.getAttribute("is")||b.localName,d=a.registry[c];if(d)return A.dom&&console.group("upgrade:",b.localName),a.upgrade(b),A.dom&&console.groupEnd(),!0}}function i(a){l(a),r(a)&&d(a,function(a){l(a)})}function j(a){if(E.push(a),!D){D=!0;var b=window.Platform&&window.Platform.endOfMicrotask||setTimeout;b(k)}}function k(){D=!1;for(var a,b=E,c=0,d=b.length;d>c&&(a=b[c]);c++)a();E=[]}function l(a){C?j(function(){m(a)}):m(a)}function m(a){(a.attachedCallback||a.detachedCallback||a.__upgraded__&&A.dom)&&(A.dom&&console.group("inserted:",a.localName),r(a)&&(a.__inserted=(a.__inserted||0)+1,a.__inserted<1&&(a.__inserted=1),a.__inserted>1?A.dom&&console.warn("inserted:",a.localName,"insert/remove count:",a.__inserted):a.attachedCallback&&(A.dom&&console.log("inserted:",a.localName),a.attachedCallback())),A.dom&&console.groupEnd())}function n(a){o(a),d(a,function(a){o(a)})}function o(a){C?j(function(){p(a)}):p(a)}function p(a){(a.attachedCallback||a.detachedCallback||a.__upgraded__&&A.dom)&&(A.dom&&console.group("removed:",a.localName),r(a)||(a.__inserted=(a.__inserted||0)-1,a.__inserted>0&&(a.__inserted=0),a.__inserted<0?A.dom&&console.warn("removed:",a.localName,"insert/remove count:",a.__inserted):a.detachedCallback&&a.detachedCallback()),A.dom&&console.groupEnd())}function q(a){return window.ShadowDOMPolyfill?ShadowDOMPolyfill.wrapIfNeeded(a):a}function r(a){for(var b=a,c=q(document);b;){if(b==c)return!0;b=b.parentNode||b.host}}function s(a){if(a.shadowRoot&&!a.shadowRoot.__watched){A.dom&&console.log("watching shadow-root for: ",a.localName);for(var b=a.shadowRoot;b;)t(b),b=b.olderShadowRoot}}function t(a){a.__watched||(w(a),a.__watched=!0)}function u(a){if(A.dom){var b=a[0];if(b&&"childList"===b.type&&b.addedNodes&&b.addedNodes){for(var c=b.addedNodes[0];c&&c!==document&&!c.host;)c=c.parentNode;var d=c&&(c.URL||c._URL||c.host&&c.host.localName)||"";d=d.split("/?").shift().split("/").pop()}console.group("mutations (%d) [%s]",a.length,d||"")}a.forEach(function(a){"childList"===a.type&&(G(a.addedNodes,function(a){a.localName&&g(a)}),G(a.removedNodes,function(a){a.localName&&n(a)}))}),A.dom&&console.groupEnd()}function v(){u(F.takeRecords()),k()}function w(a){F.observe(a,{childList:!0,subtree:!0})}function x(a){w(a)}function y(a){A.dom&&console.group("upgradeDocument: ",a.baseURI.split("/").pop()),g(a),A.dom&&console.groupEnd()}function z(a){a=q(a);for(var b,c=a.querySelectorAll("link[rel="+B+"]"),d=0,e=c.length;e>d&&(b=c[d]);d++)b.import&&b.import.__parsed&&z(b.import);y(a)}var A=window.logFlags||{},B=window.HTMLImports?HTMLImports.IMPORT_LINK_TYPE:"none",C=!window.MutationObserver||window.MutationObserver===window.JsMutationObserver;a.hasPolyfillMutations=C;var D=!1,E=[],F=new MutationObserver(u),G=Array.prototype.forEach.call.bind(Array.prototype.forEach);a.IMPORT_LINK_TYPE=B,a.watchShadow=s,a.upgradeDocumentTree=z,a.upgradeAll=g,a.upgradeSubtree=f,a.insertedNode=i,a.observeDocument=x,a.upgradeDocument=y,a.takeRecords=v}(window.CustomElements),function(a){function b(b,f){var g=f||{};if(!b)throw new Error("document.registerElement: first argument `name` must not be empty");if(b.indexOf("-")<0)throw new Error("document.registerElement: first argument ('name') must contain a dash ('-'). Argument provided was '"+String(b)+"'.");if(m(b))throw new Error("DuplicateDefinitionError: a type with name '"+String(b)+"' is already registered");if(!g.prototype)throw new Error("Options missing required prototype property");return g.__name=b.toLowerCase(),g.lifecycle=g.lifecycle||{},g.ancestry=c(g.extends),d(g),e(g),k(g.prototype),n(g.__name,g),g.ctor=o(g),g.ctor.prototype=g.prototype,g.prototype.constructor=g.ctor,a.ready&&a.upgradeDocumentTree(document),g.ctor}function c(a){var b=m(a);return b?c(b.extends).concat([b]):[]}function d(a){for(var b,c=a.extends,d=0;b=a.ancestry[d];d++)c=b.is&&b.tag;a.tag=c||a.__name,c&&(a.is=a.__name)}function e(a){if(!Object.__proto__){var b=HTMLElement.prototype;if(a.is){var c=document.createElement(a.tag);b=Object.getPrototypeOf(c)}for(var d,e=a.prototype;e&&e!==b;){var d=Object.getPrototypeOf(e);e.__proto__=d,e=d}}a.native=b}function f(a){return g(z(a.tag),a)}function g(b,c){return c.is&&b.setAttribute("is",c.is),b.removeAttribute("unresolved"),h(b,c),b.__upgraded__=!0,j(b),a.insertedNode(b),a.upgradeSubtree(b),b}function h(a,b){Object.__proto__?a.__proto__=b.prototype:(i(a,b.prototype,b.native),a.__proto__=b.prototype)}function i(a,b,c){for(var d={},e=b;e!==c&&e!==HTMLElement.prototype;){for(var f,g=Object.getOwnPropertyNames(e),h=0;f=g[h];h++)d[f]||(Object.defineProperty(a,f,Object.getOwnPropertyDescriptor(e,f)),d[f]=1);e=Object.getPrototypeOf(e)}}function j(a){a.createdCallback&&a.createdCallback()}function k(a){if(!a.setAttribute._polyfilled){var b=a.setAttribute;a.setAttribute=function(a,c){l.call(this,a,c,b)};var c=a.removeAttribute;a.removeAttribute=function(a){l.call(this,a,null,c)},a.setAttribute._polyfilled=!0}}function l(a,b,c){var d=this.getAttribute(a);c.apply(this,arguments);var e=this.getAttribute(a);this.attributeChangedCallback&&e!==d&&this.attributeChangedCallback(a,d,e)}function m(a){return a?x[a.toLowerCase()]:void 0}function n(a,b){x[a]=b}function o(a){return function(){return f(a)}}function p(a,b,c){return a===y?q(b,c):A(a,b)}function q(a,b){var c=m(b||a);if(c){if(a==c.tag&&b==c.is)return new c.ctor;if(!b&&!c.is)return new c.ctor}if(b){var d=q(a);return d.setAttribute("is",b),d}var d=z(a);return a.indexOf("-")>=0&&h(d,HTMLElement),d}function r(a){if(!a.__upgraded__&&a.nodeType===Node.ELEMENT_NODE){var b=a.getAttribute("is"),c=m(b||a.localName);if(c){if(b&&c.tag==a.localName)return g(a,c);if(!b&&!c.extends)return g(a,c)}}}function s(b){var c=B.call(this,b);return a.upgradeAll(c),c}a||(a=window.CustomElements={flags:{}});var t=a.flags,u=Boolean(document.registerElement),v=!t.register&&u&&!window.ShadowDOMPolyfill;if(v){var w=function(){};a.registry={},a.upgradeElement=w,a.watchShadow=w,a.upgrade=w,a.upgradeAll=w,a.upgradeSubtree=w,a.observeDocument=w,a.upgradeDocument=w,a.upgradeDocumentTree=w,a.takeRecords=w}else{var x={},y="http://www.w3.org/1999/xhtml",z=document.createElement.bind(document),A=document.createElementNS.bind(document),B=Node.prototype.cloneNode;document.registerElement=b,document.createElement=q,document.createElementNS=p,Node.prototype.cloneNode=s,a.registry=x,a.upgrade=r}var C;C=Object.__proto__||v?function(a,b){return a instanceof b}:function(a,b){for(var c=a;c;){if(c===b.prototype)return!0;c=c.__proto__}return!1},a.instanceof=C,document.register=document.registerElement,a.hasNative=u,a.useNative=v}(window.CustomElements),function(a){function b(a){return"link"===a.localName&&a.getAttribute("rel")===c}var c=a.IMPORT_LINK_TYPE,d={selectors:["link[rel="+c+"]"],map:{link:"parseLink"},parse:function(a){if(!a.__parsed){a.__parsed=!0;var b=a.querySelectorAll(d.selectors);e(b,function(a){d[d.map[a.localName]](a)}),CustomElements.upgradeDocument(a),CustomElements.observeDocument(a)}},parseLink:function(a){b(a)&&this.parseImport(a)},parseImport:function(a){a.import&&d.parse(a.import)}},e=Array.prototype.forEach.call.bind(Array.prototype.forEach);a.parser=d,a.IMPORT_LINK_TYPE=c}(window.CustomElements),function(a){function b(){CustomElements.parser.parse(document),CustomElements.upgradeDocument(document);var a=window.Platform&&Platform.endOfMicrotask?Platform.endOfMicrotask:setTimeout;a(function(){CustomElements.ready=!0,CustomElements.readyTime=Date.now(),window.HTMLImports&&(CustomElements.elapsed=CustomElements.readyTime-HTMLImports.readyTime),document.dispatchEvent(new CustomEvent("WebComponentsReady",{bubbles:!0})),window.HTMLImports&&(HTMLImports.__importsParsingHook=function(a){CustomElements.parser.parse(a.import)})})}if("function"!=typeof window.CustomEvent&&(window.CustomEvent=function(a){var b=document.createEvent("HTMLEvents");return b.initEvent(a,!0,!0),b}),"complete"===document.readyState||a.flags.eager)b();else if("interactive"!==document.readyState||window.attachEvent||window.HTMLImports&&!window.HTMLImports.ready){var c=window.HTMLImports&&!HTMLImports.ready?"HTMLImportsLoaded":"DOMContentLoaded";window.addEventListener(c,b)}else b()}(window.CustomElements),function(){if(window.ShadowDOMPolyfill){var a=["upgradeAll","upgradeSubtree","observeDocument","upgradeDocument"],b={};a.forEach(function(a){b[a]=CustomElements[a]}),a.forEach(function(a){CustomElements[a]=function(c){return b[a](wrap(c))}})}}(),function(a){function b(a){this.regex=a}var c=a.endOfMicrotask;b.prototype={extractUrls:function(a,b){for(var c,d,e=[];c=this.regex.exec(a);)d=new URL(c[1],b),e.push({matched:c[0],url:d.href});return e},process:function(a,b,c){var d=this.extractUrls(a,b);this.fetch(d,{},c)},fetch:function(a,b,d){var e=a.length;if(!e)return d(b);for(var f,g,h,i=function(){0===--e&&d(b)},j=function(a,c){var d=c.match,e=d.url;if(a)return b[e]="",i();var f=c.response||c.responseText;b[e]=f,this.fetch(this.extractUrls(f,e),b,i)},k=0;e>k;k++)f=a[k],h=f.url,b[h]?c(i):(g=this.xhr(h,j,this),g.match=f,b[h]=g)},xhr:function(a,b,c){var d=new XMLHttpRequest;return d.open("GET",a,!0),d.send(),d.onload=function(){b.call(c,null,d)},d.onerror=function(){b.call(c,null,d)},d}},a.Loader=b}(window.Platform),function(a){function b(){this.loader=new d(this.regex)}var c=a.urlResolver,d=a.Loader;b.prototype={regex:/@import\s+(?:url)?["'\(]*([^'"\)]*)['"\)]*;/g,resolve:function(a,b,c){var d=function(d){c(this.flatten(a,b,d))}.bind(this);this.loader.process(a,b,d)},resolveNode:function(a,b){var c=a.textContent,d=a.ownerDocument.baseURI,e=function(c){a.textContent=c,b(a)};this.resolve(c,d,e)},flatten:function(a,b,d){for(var e,f,g,h=this.loader.extractUrls(a,b),i=0;ig&&(d=a[g]);g++)this.resolveNode(d,c)}};var e=new b;a.styleResolver=e}(window.Platform),function(a){a=a||{},a.external=a.external||{};var b={shadow:function(a){return a?a.shadowRoot||a.webkitShadowRoot:void 0},canTarget:function(a){return a&&Boolean(a.elementFromPoint)},targetingShadow:function(a){var b=this.shadow(a);return this.canTarget(b)?b:void 0},olderShadow:function(a){var b=a.olderShadowRoot;if(!b){var c=a.querySelector("shadow");c&&(b=c.olderShadowRoot)}return b},allShadows:function(a){for(var b=[],c=this.shadow(a);c;)b.push(c),c=this.olderShadow(c);return b},searchRoot:function(a,b,c){if(a){var d,e,f=a.elementFromPoint(b,c);for(e=this.targetingShadow(f);e;){if(d=e.elementFromPoint(b,c)){var g=this.targetingShadow(d);return this.searchRoot(g,b,c)||d}e=this.olderShadow(e)}return f}},owner:function(a){for(var b=a;b.parentNode;)b=b.parentNode;return b.nodeType!=Node.DOCUMENT_NODE&&b.nodeType!=Node.DOCUMENT_FRAGMENT_NODE&&(b=document),b},findTarget:function(a){var b=a.clientX,c=a.clientY,d=this.owner(a.target);return d.elementFromPoint(b,c)||(d=document),this.searchRoot(d,b,c)}};a.targetFinding=b,a.findTarget=b.findTarget.bind(b),window.PointerEventsPolyfill=a}(window.PointerEventsPolyfill),function(){function a(a){return"body ^^ "+b(a)}function b(a){return'[touch-action="'+a+'"]'}function c(a){return"{ -ms-touch-action: "+a+"; touch-action: "+a+"; touch-action-delay: none; }"}var d=["none","auto","pan-x","pan-y",{rule:"pan-x pan-y",selectors:["pan-x pan-y","pan-y pan-x"]}],e="";d.forEach(function(d){String(d)===d?(e+=b(d)+c(d)+"\n",e+=a(d)+c(d)+"\n"):(e+=d.selectors.map(b)+c(d.rule)+"\n",e+=d.selectors.map(a)+c(d.rule)+"\n")});var f=document.createElement("style");f.textContent=e,document.head.appendChild(f)}(),function(a){function b(a,e){e=e||{};var f=e.buttons;if(!d&&!f&&"touch"!==a)switch(e.which){case 1:f=1;break;case 2:f=4;break;case 3:f=2;break;default:f=0}var i;if(c)i=new MouseEvent(a,e);else{i=document.createEvent("MouseEvent");for(var j,k={},l=0;l-1?this.values[c]=b:(this.keys.push(a),this.values.push(b))},has:function(a){return this.keys.indexOf(a)>-1},"delete":function(a){var b=this.keys.indexOf(a);b>-1&&(this.keys.splice(b,1),this.values.splice(b,1))},get:function(a){var b=this.keys.indexOf(a);return this.values[b]},clear:function(){this.keys.length=0,this.values.length=0},forEach:function(a,b){this.values.forEach(function(c,d){a.call(b,c,this.keys[d],this)},this)},pointers:function(){return this.keys.length}},a.PointerMap=b}(window.PointerEventsPolyfill),function(a){var b=["bubbles","cancelable","view","detail","screenX","screenY","clientX","clientY","ctrlKey","altKey","shiftKey","metaKey","button","relatedTarget","buttons","pointerId","width","height","pressure","tiltX","tiltY","pointerType","hwTimestamp","isPrimary","type","target","currentTarget","which"],c=[!1,!1,null,null,0,0,0,0,!1,!1,!1,!1,0,null,0,0,0,0,0,0,0,"",0,!1,"",null,null,0],d="undefined"!=typeof SVGElementInstance,e={targets:new WeakMap,handledEvents:new WeakMap,pointermap:new a.PointerMap,eventMap:{},eventSources:{},eventSourceList:[],registerSource:function(a,b){var c=b,d=c.events;d&&(d.forEach(function(a){c[a]&&(this.eventMap[a]=c[a].bind(c))},this),this.eventSources[a]=c,this.eventSourceList.push(c))},register:function(a){for(var b,c=this.eventSourceList.length,d=0;c>d&&(b=this.eventSourceList[d]);d++)b.register.call(b,a)},unregister:function(a){for(var b,c=this.eventSourceList.length,d=0;c>d&&(b=this.eventSourceList[d]);d++)b.unregister.call(b,a)},contains:a.external.contains||function(a,b){return a.contains(b)},down:function(a){a.bubbles=!0,this.fireEvent("pointerdown",a)},move:function(a){a.bubbles=!0,this.fireEvent("pointermove",a)},up:function(a){a.bubbles=!0,this.fireEvent("pointerup",a)},enter:function(a){a.bubbles=!1,this.fireEvent("pointerenter",a)},leave:function(a){a.bubbles=!1,this.fireEvent("pointerleave",a)},over:function(a){a.bubbles=!0,this.fireEvent("pointerover",a)},out:function(a){a.bubbles=!0,this.fireEvent("pointerout",a)},cancel:function(a){a.bubbles=!0,this.fireEvent("pointercancel",a)},leaveOut:function(a){this.out(a),this.contains(a.target,a.relatedTarget)||this.leave(a)},enterOver:function(a){this.over(a),this.contains(a.target,a.relatedTarget)||this.enter(a)},eventHandler:function(a){if(!this.handledEvents.get(a)){var b=a.type,c=this.eventMap&&this.eventMap[b];c&&c(a),this.handledEvents.set(a,!0)}},listen:function(a,b){b.forEach(function(b){this.addEvent(a,b)},this)},unlisten:function(a,b){b.forEach(function(b){this.removeEvent(a,b)},this)},addEvent:a.external.addEvent||function(a,b){a.addEventListener(b,this.boundHandler)},removeEvent:a.external.removeEvent||function(a,b){a.removeEventListener(b,this.boundHandler)},makeEvent:function(a,b){this.captureInfo&&(b.relatedTarget=null);var c=new PointerEvent(a,b);return b.preventDefault&&(c.preventDefault=b.preventDefault),this.targets.set(c,this.targets.get(b)||b.target),c},fireEvent:function(a,b){var c=this.makeEvent(a,b);return this.dispatchEvent(c)},cloneEvent:function(a){for(var e,f={},g=0;gg&&(b=c[g]);g++){var i=Math.abs(e-b.x),j=Math.abs(f-b.y);if(d>=i&&d>=j)return!0}},prepareEvent:function(a){var c=b.cloneEvent(a),d=c.preventDefault;return c.preventDefault=function(){a.preventDefault(),d()},c.pointerId=this.POINTER_ID,c.isPrimary=!0,c.pointerType=this.POINTER_TYPE,c},mousedown:function(a){if(!this.isEventSimulatedFromTouch(a)){var d=c.has(this.POINTER_ID);d&&this.cancel(a);var e=this.prepareEvent(a);c.set(this.POINTER_ID,a),b.down(e)}},mousemove:function(a){if(!this.isEventSimulatedFromTouch(a)){var c=this.prepareEvent(a);b.move(c)}},mouseup:function(a){if(!this.isEventSimulatedFromTouch(a)){var d=c.get(this.POINTER_ID);if(d&&d.button===a.button){var e=this.prepareEvent(a);b.up(e),this.cleanupMouse()}}},mouseover:function(a){if(!this.isEventSimulatedFromTouch(a)){var c=this.prepareEvent(a);b.enterOver(c)}},mouseout:function(a){if(!this.isEventSimulatedFromTouch(a)){var c=this.prepareEvent(a);b.leaveOut(c)}},cancel:function(a){var c=this.prepareEvent(a);b.cancel(c),this.cleanupMouse()},cleanupMouse:function(){c["delete"](this.POINTER_ID)}};a.mouseEvents=e}(window.PointerEventsPolyfill),function(a){var b,c=a.dispatcher,d=a.findTarget,e=a.targetFinding.allShadows.bind(a.targetFinding),f=c.pointermap,g=Array.prototype.map.call.bind(Array.prototype.map),h=2500,i=200,j="touch-action",k=!1,l={scrollType:new WeakMap,events:["touchstart","touchmove","touchend","touchcancel"],register:function(a){k?c.listen(a,this.events):b.enableOnSubtree(a)},unregister:function(a){k&&c.unlisten(a,this.events)},elementAdded:function(a){var b=a.getAttribute(j),d=this.touchActionToScrollType(b);d&&(this.scrollType.set(a,d),c.listen(a,this.events),e(a).forEach(function(a){this.scrollType.set(a,d),c.listen(a,this.events)},this))},elementRemoved:function(a){this.scrollType["delete"](a),c.unlisten(a,this.events),e(a).forEach(function(a){this.scrollType["delete"](a),c.unlisten(a,this.events)},this)},elementChanged:function(a,b){var c=a.getAttribute(j),d=this.touchActionToScrollType(c),f=this.touchActionToScrollType(b);d&&f?(this.scrollType.set(a,d),e(a).forEach(function(a){this.scrollType.set(a,d)},this)):f?this.elementRemoved(a):d&&this.elementAdded(a)},scrollTypes:{EMITTER:"none",XSCROLLER:"pan-x",YSCROLLER:"pan-y",SCROLLER:/^(?:pan-x pan-y)|(?:pan-y pan-x)|auto$/},touchActionToScrollType:function(a){var b=a,c=this.scrollTypes;return"none"===b?"none":b===c.XSCROLLER?"X":b===c.YSCROLLER?"Y":c.SCROLLER.exec(b)?"XY":void 0},POINTER_TYPE:"touch",firstTouch:null,isPrimaryTouch:function(a){return this.firstTouch===a.identifier},setPrimaryTouch:function(a){(0===f.pointers()||1===f.pointers()&&f.has(1))&&(this.firstTouch=a.identifier,this.firstXY={X:a.clientX,Y:a.clientY},this.scrolling=!1,this.cancelResetClickCount())},removePrimaryPointer:function(a){a.isPrimary&&(this.firstTouch=null,this.firstXY=null,this.resetClickCount())},clickCount:0,resetId:null,resetClickCount:function(){var a=function(){this.clickCount=0,this.resetId=null}.bind(this);this.resetId=setTimeout(a,i)},cancelResetClickCount:function(){this.resetId&&clearTimeout(this.resetId)},typeToButtons:function(a){var b=0;return("touchstart"===a||"touchmove"===a)&&(b=1),b},touchToPointer:function(a){var b=c.cloneEvent(a);return b.pointerId=a.identifier+2,b.target=d(b),b.bubbles=!0,b.cancelable=!0,b.detail=this.clickCount,b.button=0,b.buttons=this.typeToButtons(this.currentTouchEvent),b.width=a.webkitRadiusX||a.radiusX||0,b.height=a.webkitRadiusY||a.radiusY||0,b.pressure=a.webkitForce||a.force||.5,b.isPrimary=this.isPrimaryTouch(a),b.pointerType=this.POINTER_TYPE,b},processTouches:function(a,b){var c=a.changedTouches;this.currentTouchEvent=a.type;var d=g(c,this.touchToPointer,this);d.forEach(function(b){b.preventDefault=function(){this.scrolling=!1,this.firstXY=null,a.preventDefault()}},this),d.forEach(b,this)},shouldScroll:function(a){if(this.firstXY){var b,c=this.scrollType.get(a.currentTarget);if("none"===c)b=!1;else if("XY"===c)b=!0;else{var d=a.changedTouches[0],e=c,f="Y"===c?"X":"Y",g=Math.abs(d["client"+e]-this.firstXY[e]),h=Math.abs(d["client"+f]-this.firstXY[f]);b=g>=h}return this.firstXY=null,b}},findTouch:function(a,b){for(var c,d=0,e=a.length;e>d&&(c=a[d]);d++)if(c.identifier===b)return!0},vacuumTouches:function(a){var b=a.touches;if(f.pointers()>=b.length){var c=[];f.forEach(function(a,d){if(1!==d&&!this.findTouch(b,d-2)){var e=a.out;c.push(this.touchToPointer(e))}},this),c.forEach(this.cancelOut,this)}},touchstart:function(a){this.vacuumTouches(a),this.setPrimaryTouch(a.changedTouches[0]),this.dedupSynthMouse(a),this.scrolling||(this.clickCount++,this.processTouches(a,this.overDown))},overDown:function(a){f.set(a.pointerId,{target:a.target,out:a,outTarget:a.target});c.over(a),c.enter(a),c.down(a)},touchmove:function(a){this.scrolling||(this.shouldScroll(a)?(this.scrolling=!0,this.touchcancel(a)):(a.preventDefault(),this.processTouches(a,this.moveOverOut)))},moveOverOut:function(a){var b=a,d=f.get(b.pointerId);if(d){var e=d.out,g=d.outTarget;c.move(b),e&&g!==b.target&&(e.relatedTarget=b.target,b.relatedTarget=g,e.target=g,b.target?(c.leaveOut(e),c.enterOver(b)):(b.target=g,b.relatedTarget=null,this.cancelOut(b))),d.out=b,d.outTarget=b.target}},touchend:function(a){this.dedupSynthMouse(a),this.processTouches(a,this.upOut)},upOut:function(a){this.scrolling||(c.up(a),c.out(a),c.leave(a)),this.cleanUpPointer(a)},touchcancel:function(a){this.processTouches(a,this.cancelOut)},cancelOut:function(a){c.cancel(a),c.out(a),c.leave(a),this.cleanUpPointer(a)},cleanUpPointer:function(a){f["delete"](a.pointerId),this.removePrimaryPointer(a)},dedupSynthMouse:function(b){var c=a.mouseEvents.lastTouches,d=b.changedTouches[0];if(this.isPrimaryTouch(d)){var e={x:d.clientX,y:d.clientY};c.push(e);var f=function(a,b){var c=a.indexOf(b);c>-1&&a.splice(c,1)}.bind(null,c,e);setTimeout(f,h)}}};k||(b=new a.Installer(l.elementAdded,l.elementRemoved,l.elementChanged,l)),a.touchEvents=l}(window.PointerEventsPolyfill),function(a){var b=a.dispatcher,c=b.pointermap,d=window.MSPointerEvent&&"number"==typeof window.MSPointerEvent.MSPOINTER_TYPE_MOUSE,e={events:["MSPointerDown","MSPointerMove","MSPointerUp","MSPointerOut","MSPointerOver","MSPointerCancel","MSGotPointerCapture","MSLostPointerCapture"],register:function(a){b.listen(a,this.events)},unregister:function(a){b.unlisten(a,this.events)},POINTER_TYPES:["","unavailable","touch","pen","mouse"],prepareEvent:function(a){var c=a;return d&&(c=b.cloneEvent(a),c.pointerType=this.POINTER_TYPES[a.pointerType]),c},cleanup:function(a){c["delete"](a)},MSPointerDown:function(a){c.set(a.pointerId,a);var d=this.prepareEvent(a);b.down(d)},MSPointerMove:function(a){var c=this.prepareEvent(a);b.move(c)},MSPointerUp:function(a){var c=this.prepareEvent(a);b.up(c),this.cleanup(a.pointerId)},MSPointerOut:function(a){var c=this.prepareEvent(a);b.leaveOut(c)},MSPointerOver:function(a){var c=this.prepareEvent(a);b.enterOver(c)},MSPointerCancel:function(a){var c=this.prepareEvent(a);b.cancel(c),this.cleanup(a.pointerId)},MSLostPointerCapture:function(a){var c=b.makeEvent("lostpointercapture",a);b.dispatchEvent(c)},MSGotPointerCapture:function(a){var c=b.makeEvent("gotpointercapture",a);b.dispatchEvent(c)}};a.msEvents=e}(window.PointerEventsPolyfill),function(a){var b=a.dispatcher;if(void 0===window.navigator.pointerEnabled){if(Object.defineProperty(window.navigator,"pointerEnabled",{value:!0,enumerable:!0}),window.navigator.msPointerEnabled){var c=window.navigator.msMaxTouchPoints;Object.defineProperty(window.navigator,"maxTouchPoints",{value:c,enumerable:!0}),b.registerSource("ms",a.msEvents)}else b.registerSource("mouse",a.mouseEvents),void 0!==window.ontouchstart&&b.registerSource("touch",a.touchEvents);b.register(document)}}(window.PointerEventsPolyfill),function(a){function b(a){if(!e.pointermap.has(a))throw new Error("InvalidPointerId")}var c,d,e=a.dispatcher,f=window.navigator;f.msPointerEnabled?(c=function(a){b(a),this.msSetPointerCapture(a)},d=function(a){b(a),this.msReleasePointerCapture(a)}):(c=function(a){b(a),e.setCapture(a,this)},d=function(a){b(a),e.releaseCapture(a,this)}),window.Element&&!Element.prototype.setPointerCapture&&Object.defineProperties(Element.prototype,{setPointerCapture:{value:c},releasePointerCapture:{value:d}})}(window.PointerEventsPolyfill),PointerGestureEvent.prototype.preventTap=function(){this.tapPrevented=!0},function(a){a=a||{},a.utils={LCA:{find:function(a,b){if(a===b)return a;if(a.contains){if(a.contains(b))return a;if(b.contains(a))return b}var c=this.depth(a),d=this.depth(b),e=c-d;for(e>0?a=this.walk(a,e):b=this.walk(b,-e);a&&b&&a!==b;)a=this.walk(a,1),b=this.walk(b,1);return a},walk:function(a,b){for(var c=0;b>c;c++)a=a.parentNode;return a},depth:function(a){for(var b=0;a;)b++,a=a.parentNode;return b}}},a.findLCA=function(b,c){return a.utils.LCA.find(b,c)},window.PointerGestures=a}(window.PointerGestures),function(a){function b(){if(c){var a=new Map;return a.pointers=d,a}this.keys=[],this.values=[]}var c=window.Map&&window.Map.prototype.forEach,d=function(){return this.size};b.prototype={set:function(a,b){var c=this.keys.indexOf(a);c>-1?this.values[c]=b:(this.keys.push(a),this.values.push(b))},has:function(a){return this.keys.indexOf(a)>-1},"delete":function(a){var b=this.keys.indexOf(a);b>-1&&(this.keys.splice(b,1),this.values.splice(b,1))},get:function(a){var b=this.keys.indexOf(a);return this.values[b]},clear:function(){this.keys.length=0,this.values.length=0},forEach:function(a,b){this.values.forEach(function(c,d){a.call(b,c,this.keys[d],this)},this)},pointers:function(){return this.keys.length}},a.PointerMap=b}(window.PointerGestures),function(a){var b=["bubbles","cancelable","view","detail","screenX","screenY","clientX","clientY","ctrlKey","altKey","shiftKey","metaKey","button","relatedTarget","buttons","pointerId","width","height","pressure","tiltX","tiltY","pointerType","hwTimestamp","isPrimary","type","target","currentTarget","screenX","screenY","pageX","pageY","tapPrevented"],c=[!1,!1,null,null,0,0,0,0,!1,!1,!1,!1,0,null,0,0,0,0,0,0,0,"",0,!1,"",null,null,0,0,0,0],d={handledEvents:new WeakMap,targets:new WeakMap,handlers:{},recognizers:{},events:{},registerRecognizer:function(a,b){var c=b;this.recognizers[a]=c,c.events.forEach(function(a){if(c[a]){this.events[a]=!0;var b=c[a].bind(c);this.addHandler(a,b)}},this)},addHandler:function(a,b){var c=a;this.handlers[c]||(this.handlers[c]=[]),this.handlers[c].push(b)},registerTarget:function(a){this.listen(Object.keys(this.events),a)},unregisterTarget:function(a){this.unlisten(Object.keys(this.events),a)},eventHandler:function(a){if(!this.handledEvents.get(a)){var b=a.type,c=this.handlers[b];c&&this.makeQueue(c,a),this.handledEvents.set(a,!0)}},makeQueue:function(a,b){var c=this.cloneEvent(b);setTimeout(this.runQueue.bind(this,a,c),0)},runQueue:function(a,b){this.currentPointerId=b.pointerId;for(var c,d=0,e=a.length;e>d&&(c=a[d]);d++)c(b);this.currentPointerId=0},listen:function(a,b){a.forEach(function(a){this.addEvent(a,this.boundHandler,!1,b)},this)},unlisten:function(a){a.forEach(function(a){this.removeEvent(a,this.boundHandler,!1,inTarget)},this)},addEvent:function(a,b,c,d){d.addEventListener(a,b,c)},removeEvent:function(a,b,c,d){d.removeEventListener(a,b,c)},makeEvent:function(a,b){return new PointerGestureEvent(a,b)},cloneEvent:function(a){for(var d,e={},f=0;fthis.WIGGLE_THRESHOLD&&this.cancel()}},fireHold:function(a,c){var d={pointerType:this.heldPointer.pointerType,clientX:this.heldPointer.clientX,clientY:this.heldPointer.clientY};c&&(d.holdTime=c);var e=b.makeEvent(a,d);b.dispatchEvent(e,this.target),e.tapPrevented&&b.preventTap(this.heldPointer.pointerId)}};b.registerRecognizer("hold",c)}(window.PointerGestures),function(a){var b=a.dispatcher,c=new a.PointerMap,d={events:["pointerdown","pointermove","pointerup","pointercancel"],WIGGLE_THRESHOLD:4,clampDir:function(a){return a>0?1:-1},calcPositionDelta:function(a,b){var c=0,d=0;return a&&b&&(c=b.pageX-a.pageX,d=b.pageY-a.pageY),{x:c,y:d}},fireTrack:function(a,c,d){var e=d,f=this.calcPositionDelta(e.downEvent,c),g=this.calcPositionDelta(e.lastMoveEvent,c);g.x&&(e.xDirection=this.clampDir(g.x)),g.y&&(e.yDirection=this.clampDir(g.y));var h={dx:f.x,dy:f.y,ddx:g.x,ddy:g.y,clientX:c.clientX,clientY:c.clientY,pageX:c.pageX,pageY:c.pageY,screenX:c.screenX,screenY:c.screenY,xDirection:e.xDirection,yDirection:e.yDirection,trackInfo:e.trackInfo,relatedTarget:c.target,pointerType:c.pointerType},i=b.makeEvent(a,h);e.lastMoveEvent=c,b.dispatchEvent(i,e.downTarget)},pointerdown:function(a){if(a.isPrimary&&("mouse"===a.pointerType?1===a.buttons:!0)){var b={downEvent:a,downTarget:a.target,trackInfo:{},lastMoveEvent:null,xDirection:0,yDirection:0,tracking:!1};c.set(a.pointerId,b)}},pointermove:function(a){var b=c.get(a.pointerId);if(b)if(b.tracking)this.fireTrack("track",a,b);else{var d=this.calcPositionDelta(b.downEvent,a),e=d.x*d.x+d.y*d.y;e>this.WIGGLE_THRESHOLD&&(b.tracking=!0,this.fireTrack("trackstart",b.downEvent,b),this.fireTrack("track",a,b))}},pointerup:function(a){var b=c.get(a.pointerId);b&&(b.tracking&&this.fireTrack("trackend",a,b),c.delete(a.pointerId))},pointercancel:function(a){this.pointerup(a)}};b.registerRecognizer("track",d)}(window.PointerGestures),function(a){var b=a.dispatcher,c={MIN_VELOCITY:.5,MAX_QUEUE:4,moveQueue:[],target:null,pointerId:null,events:["pointerdown","pointermove","pointerup","pointercancel"],pointerdown:function(a){a.isPrimary&&!this.pointerId&&(this.pointerId=a.pointerId,this.target=a.target,this.addMove(a))},pointermove:function(a){a.pointerId===this.pointerId&&this.addMove(a)},pointerup:function(a){a.pointerId===this.pointerId&&this.fireFlick(a),this.cleanup()},pointercancel:function(){this.cleanup()},cleanup:function(){this.moveQueue=[],this.target=null,this.pointerId=null},addMove:function(a){this.moveQueue.length>=this.MAX_QUEUE&&this.moveQueue.shift(),this.moveQueue.push(a)},fireFlick:function(a){for(var c,d,e,f,g,h,i,j=a,k=this.moveQueue.length,l=0,m=0,n=0,o=0;k>o&&(i=this.moveQueue[o]);o++)c=j.timeStamp-i.timeStamp,d=j.clientX-i.clientX,e=j.clientY-i.clientY,f=d/c,g=e/c,h=Math.sqrt(f*f+g*g),h>n&&(l=f,m=g,n=h);var p=Math.abs(l)>Math.abs(m)?"x":"y",q=this.calcAngle(l,m);if(Math.abs(n)>=this.MIN_VELOCITY){var r=b.makeEvent("flick",{xVelocity:l,yVelocity:m,velocity:n,angle:q,majorAxis:p,pointerType:a.pointerType});b.dispatchEvent(r,this.target)}},calcAngle:function(a,b){return 180*Math.atan2(b,a)/Math.PI}};b.registerRecognizer("flick",c)}(window.PointerGestures),function(a){var b=a.dispatcher,c=new a.PointerMap,d=180/Math.PI,e={events:["pointerdown","pointermove","pointerup","pointercancel"],reference:{},pointerdown:function(b){if(c.set(b.pointerId,b),2==c.pointers()){var d=this.calcChord(),e=this.calcAngle(d);this.reference={angle:e,diameter:d.diameter,target:a.findLCA(d.a.target,d.b.target)}}},pointerup:function(a){c.delete(a.pointerId)},pointermove:function(a){c.has(a.pointerId)&&(c.set(a.pointerId,a),c.pointers()>1&&this.calcPinchRotate())},pointercancel:function(a){this.pointerup(a)},dispatchPinch:function(a,c){var d=a/this.reference.diameter,e=b.makeEvent("pinch",{scale:d,centerX:c.center.x,centerY:c.center.y});b.dispatchEvent(e,this.reference.target)},dispatchRotate:function(a,c){var d=Math.round((a-this.reference.angle)%360),e=b.makeEvent("rotate",{angle:d,centerX:c.center.x,centerY:c.center.y});b.dispatchEvent(e,this.reference.target)},calcPinchRotate:function(){var a=this.calcChord(),b=a.diameter,c=this.calcAngle(a);b!=this.reference.diameter&&this.dispatchPinch(b,a),c!=this.reference.angle&&this.dispatchRotate(c,a)},calcChord:function(){var a=[];c.forEach(function(b){a.push(b)});for(var b,d,e,f=0,g={a:a[0],b:a[1]},h=0;hf&&(f=e,g={a:i,b:k})}return b=Math.abs(g.a.clientX+g.b.clientX)/2,d=Math.abs(g.a.clientY+g.b.clientY)/2,g.center={x:b,y:d},g.diameter=f,g},calcAngle:function(a){var b=a.a.clientX-a.b.clientX,c=a.a.clientY-a.b.clientY;return(360+Math.atan2(c,b)*d)%360}};b.registerRecognizer("pinch",e)}(window.PointerGestures),function(a){var b=a.dispatcher,c=new a.PointerMap,d={events:["pointerdown","pointermove","pointerup","pointercancel","keyup"],pointerdown:function(a){a.isPrimary&&!a.tapPrevented&&c.set(a.pointerId,{target:a.target,buttons:a.buttons,x:a.clientX,y:a.clientY})},pointermove:function(a){if(a.isPrimary){var b=c.get(a.pointerId);b&&a.tapPrevented&&c.delete(a.pointerId)}},shouldTap:function(a,b){return a.tapPrevented?void 0:"mouse"===a.pointerType?1===b.buttons:!0},pointerup:function(d){var e=c.get(d.pointerId);if(e&&this.shouldTap(d,e)){var f=a.findLCA(e.target,d.target);if(f){var g=b.makeEvent("tap",{x:d.clientX,y:d.clientY,detail:d.detail,pointerType:d.pointerType});b.dispatchEvent(g,f)}}c.delete(d.pointerId)},pointercancel:function(a){c.delete(a.pointerId)},keyup:function(a){var c=a.keyCode;if(32===c){var d=a.target;d instanceof HTMLInputElement||d instanceof HTMLTextAreaElement||b.dispatchEvent(b.makeEvent("tap",{x:0,y:0,detail:0,pointerType:"unavailable"}),d)}},preventTap:function(a){c.delete(a)}};b.registerRecognizer("tap",d)}(window.PointerGestures),function(a){function b(){c.immediateRegister=!0;var b=c.registerQueue;b.forEach(a.register),b.length=0}var c=a.dispatcher;"complete"===document.readyState?b():document.addEventListener("readystatechange",function(){"complete"===document.readyState&&b()})}(window.PointerGestures),function(){"use strict";function a(a){for(;a.parentNode;)a=a.parentNode;return"function"==typeof a.getElementById?a:null}function b(a,b){var c=a.bindings;if(!c)return void(a.bindings={});var d=c[b];d&&(d.close(),c[b]=void 0)}function c(a){return null==a?"":a}function d(a,b){a.data=c(b)}function e(a){return function(b){return d(a,b)}}function f(a,b,d,e){return d?void(e?a.setAttribute(b,""):a.removeAttribute(b)):void a.setAttribute(b,c(e))}function g(a,b,c){return function(d){f(a,b,c,d)}}function h(a){switch(a.type){case"checkbox":return s;case"radio":case"select-multiple":case"select-one":return"change";case"range":if(/Trident|MSIE/.test(navigator.userAgent))return"change";default:return"input"}}function i(a,b,d,e){a[b]=(e||c)(d)}function j(a,b,c){return function(d){return i(a,b,d,c)}}function k(){}function l(a,b,c,d){function e(){c.setValue(a[b]),c.discardChanges(),(d||k)(a),Platform.performMicrotaskCheckpoint()}var f=h(a);a.addEventListener(f,e);var g=c.close;c.close=function(){g&&(a.removeEventListener(f,e),c.close=g,c.close(),g=void 0)}}function m(a){return Boolean(a)}function n(b){if(b.form)return r(b.form.elements,function(a){return a!=b&&"INPUT"==a.tagName&&"radio"==a.type&&a.name==b.name});var c=a(b);if(!c)return[];var d=c.querySelectorAll('input[type="radio"][name="'+b.name+'"]');return r(d,function(a){return a!=b&&!a.form})}function o(a){"INPUT"===a.tagName&&"radio"===a.type&&n(a).forEach(function(a){var b=a.bindings.checked;b&&b.setValue(!1)})}function p(a,b){var d,e,f,g=a.parentNode;g instanceof HTMLSelectElement&&g.bindings&&g.bindings.value&&(d=g,e=d.bindings.value,f=d.value),a.value=c(b),d&&d.value!=f&&(e.setValue(d.value),e.discardChanges(),Platform.performMicrotaskCheckpoint())}function q(a){return function(b){p(a,b)}}var r=Array.prototype.filter.call.bind(Array.prototype.filter);Node.prototype.bind=function(a,b){console.error("Unhandled binding to Node: ",this,a,b)},Node.prototype.unbind=function(a){b(this,a)},Node.prototype.unbindAll=function(){if(this.bindings){for(var a=Object.keys(this.bindings),b=0;b0;){var e=c[d];I[e.name]&&("template"!==e.name&&b.setAttribute(e.name,e.value),a.removeAttribute(e.name))}return b}function o(a){var b=a.ownerDocument.createElement("template");a.parentNode.insertBefore(b,a);for(var c=a.attributes,d=c.length;d-->0;){var e=c[d];b.setAttribute(e.name,e.value),a.removeAttribute(e.name) -}return a.parentNode.removeChild(a),b}function p(a,b,c){var d=a.content;if(c)return void d.appendChild(b);for(var e;e=b.firstChild;)d.appendChild(e)}function q(a){N?a.__proto__=HTMLTemplateElement.prototype:k(a,HTMLTemplateElement.prototype)}function r(a){a.setModelFn_||(a.setModelFn_=function(){a.setModelFnScheduled_=!1;var b=z(a,a.delegate_&&a.delegate_.prepareBinding);w(a,b,a.model_)}),a.setModelFnScheduled_||(a.setModelFnScheduled_=!0,Observer.runEOM_(a.setModelFn_))}function s(a,b,c,d){if(a&&a.length){for(var e,f=a.length,g=0,h=0,i=0,j=!0;f>h;){var g=a.indexOf("{{",h),k=a.indexOf("[[",h),l=!1,m="}}";if(k>=0&&(0>g||g>k)&&(g=k,l=!0,m="]]"),i=0>g?-1:a.indexOf(m,g+2),0>i){if(!e)return;e.push(a.slice(h));break}e=e||[],e.push(a.slice(h,g));var n=a.slice(g+2,i).trim();e.push(l),j=j&&l,e.push(Path.get(n));var o=d&&d(n,b,c);e.push(o),h=i+2}return h===f&&e.push(""),e.hasOnePath=5===e.length,e.isSimplePath=e.hasOnePath&&""==e[0]&&""==e[4],e.onlyOneTime=j,e.combinator=function(a){for(var b=e[0],c=1;cc?(this.keys.push(a),this.values.push(b)):this.values[c]=b},get:function(a){var b=this.keys.indexOf(a);if(!(0>b))return this.values[b]},"delete":function(a){var b=this.keys.indexOf(a);return 0>b?!1:(this.keys.splice(b,1),this.values.splice(b,1),!0)},forEach:function(a,b){for(var c=0;cb;)this.reportInstanceMoved(b),b++},closeInstanceBindings:function(a){for(var b=0;b=48&&57>=a}function d(a){return 32===a||9===a||11===a||12===a||160===a||a>=5760&&" ᠎              ".indexOf(String.fromCharCode(a))>0}function e(a){return 10===a||13===a||8232===a||8233===a}function f(a){return 36===a||95===a||a>=65&&90>=a||a>=97&&122>=a}function g(a){return 36===a||95===a||a>=65&&90>=a||a>=97&&122>=a||a>=48&&57>=a}function h(a){return"this"===a}function i(){for(;Y>X&&d(W.charCodeAt(X));)++X}function j(){var a,b;for(a=X++;Y>X&&(b=W.charCodeAt(X),g(b));)++X;return W.slice(a,X)}function k(){var a,b,c;return a=X,b=j(),c=1===b.length?S.Identifier:h(b)?S.Keyword:"null"===b?S.NullLiteral:"true"===b||"false"===b?S.BooleanLiteral:S.Identifier,{type:c,value:b,range:[a,X]}}function l(){var a,b,c=X,d=W.charCodeAt(X),e=W[X];switch(d){case 46:case 40:case 41:case 59:case 44:case 123:case 125:case 91:case 93:case 58:case 63:return++X,{type:S.Punctuator,value:String.fromCharCode(d),range:[c,X]};default:if(a=W.charCodeAt(X+1),61===a)switch(d){case 37:case 38:case 42:case 43:case 45:case 47:case 60:case 62:case 124:return X+=2,{type:S.Punctuator,value:String.fromCharCode(d)+String.fromCharCode(a),range:[c,X]};case 33:case 61:return X+=2,61===W.charCodeAt(X)&&++X,{type:S.Punctuator,value:W.slice(c,X),range:[c,X]}}}return b=W[X+1],e===b&&"&|".indexOf(e)>=0?(X+=2,{type:S.Punctuator,value:e+b,range:[c,X]}):"<>=!+-*%&|^/".indexOf(e)>=0?(++X,{type:S.Punctuator,value:e,range:[c,X]}):void s({},V.UnexpectedToken,"ILLEGAL")}function m(){var a,d,e;if(e=W[X],b(c(e.charCodeAt(0))||"."===e,"Numeric literal must start with a decimal digit or a decimal point"),d=X,a="","."!==e){for(a=W[X++],e=W[X],"0"===a&&e&&c(e.charCodeAt(0))&&s({},V.UnexpectedToken,"ILLEGAL");c(W.charCodeAt(X));)a+=W[X++];e=W[X]}if("."===e){for(a+=W[X++];c(W.charCodeAt(X));)a+=W[X++];e=W[X]}if("e"===e||"E"===e)if(a+=W[X++],e=W[X],("+"===e||"-"===e)&&(a+=W[X++]),c(W.charCodeAt(X)))for(;c(W.charCodeAt(X));)a+=W[X++];else s({},V.UnexpectedToken,"ILLEGAL");return f(W.charCodeAt(X))&&s({},V.UnexpectedToken,"ILLEGAL"),{type:S.NumericLiteral,value:parseFloat(a),range:[d,X]}}function n(){var a,c,d,f="",g=!1;for(a=W[X],b("'"===a||'"'===a,"String literal must starts with a quote"),c=X,++X;Y>X;){if(d=W[X++],d===a){a="";break}if("\\"===d)if(d=W[X++],d&&e(d.charCodeAt(0)))"\r"===d&&"\n"===W[X]&&++X;else switch(d){case"n":f+="\n";break;case"r":f+="\r";break;case"t":f+=" ";break;case"b":f+="\b";break;case"f":f+="\f";break;case"v":f+=" ";break;default:f+=d}else{if(e(d.charCodeAt(0)))break;f+=d}}return""!==a&&s({},V.UnexpectedToken,"ILLEGAL"),{type:S.StringLiteral,value:f,octal:g,range:[c,X]}}function o(a){return a.type===S.Identifier||a.type===S.Keyword||a.type===S.BooleanLiteral||a.type===S.NullLiteral}function p(){var a;return i(),X>=Y?{type:S.EOF,range:[X,X]}:(a=W.charCodeAt(X),40===a||41===a||58===a?l():39===a||34===a?n():f(a)?k():46===a?c(W.charCodeAt(X+1))?m():l():c(a)?m():l())}function q(){var a;return a=$,X=a.range[1],$=p(),X=a.range[1],a}function r(){var a;a=X,$=p(),X=a}function s(a,c){var d,e=Array.prototype.slice.call(arguments,2),f=c.replace(/%(\d)/g,function(a,c){return b(cX&&(a.push(bb()),!v(")"));)u(",");return u(")"),a}function E(){var a;return a=q(),o(a)||t(a),Z.createIdentifier(a.value)}function F(){return u("."),E()}function G(){var a;return u("["),a=bb(),u("]"),a}function H(){var a,b;for(a=C();v(".")||v("[");)v("[")?(b=G(),a=Z.createMemberExpression("[",a,b)):(b=F(),a=Z.createMemberExpression(".",a,b));return a}function I(){var a,b;return $.type!==S.Punctuator&&$.type!==S.Keyword?b=ab():v("+")||v("-")||v("!")?(a=q(),b=I(),b=Z.createUnaryExpression(a.value,b)):w("delete")||w("void")||w("typeof")?s({},V.UnexpectedToken):b=ab(),b}function J(a){var b=0;if(a.type!==S.Punctuator&&a.type!==S.Keyword)return 0;switch(a.value){case"||":b=1;break;case"&&":b=2;break;case"==":case"!=":case"===":case"!==":b=6;break;case"<":case">":case"<=":case">=":case"instanceof":b=7;break;case"in":b=7;break;case"+":case"-":b=9;break;case"*":case"/":case"%":b=11}return b}function K(){var a,b,c,d,e,f,g,h;if(g=I(),b=$,c=J(b),0===c)return g;for(b.prec=c,q(),e=I(),d=[g,b,e];(c=J($))>0;){for(;d.length>2&&c<=d[d.length-2].prec;)e=d.pop(),f=d.pop().value,g=d.pop(),a=Z.createBinaryExpression(f,g,e),d.push(a);b=q(),b.prec=c,d.push(b),a=I(),d.push(a)}for(h=d.length-1,a=d[h];h>1;)a=Z.createBinaryExpression(d[h-1].value,d[h-2],a),h-=2;return a}function L(){var a,b,c;return a=K(),v("?")&&(q(),b=L(),u(":"),c=L(),a=Z.createConditionalExpression(a,b,c)),a}function M(){var a,b;return a=q(),a.type!==S.Identifier&&t(a),b=v("(")?D():[],Z.createFilter(a.value,b)}function N(){for(;v("|");)q(),M()}function O(){i(),r();var a=bb();a&&(","===$.value||"in"==$.value&&a.type===U.Identifier?Q(a):(N(),"as"===$.value?P(a):Z.createTopLevel(a))),$.type!==S.EOF&&t($)}function P(a){q();var b=q().value;Z.createAsExpression(a,b)}function Q(a){var b;","===$.value&&(q(),$.type!==S.Identifier&&t($),b=q().value),q();var c=bb();N(),Z.createInExpression(a.name,b,c)}function R(a,b){return Z=b,W=a,X=0,Y=W.length,$=null,_={labelSet:{}},O()}var S,T,U,V,W,X,Y,Z,$,_;S={BooleanLiteral:1,EOF:2,Identifier:3,Keyword:4,NullLiteral:5,NumericLiteral:6,Punctuator:7,StringLiteral:8},T={},T[S.BooleanLiteral]="Boolean",T[S.EOF]="",T[S.Identifier]="Identifier",T[S.Keyword]="Keyword",T[S.NullLiteral]="Null",T[S.NumericLiteral]="Numeric",T[S.Punctuator]="Punctuator",T[S.StringLiteral]="String",U={ArrayExpression:"ArrayExpression",BinaryExpression:"BinaryExpression",CallExpression:"CallExpression",ConditionalExpression:"ConditionalExpression",EmptyStatement:"EmptyStatement",ExpressionStatement:"ExpressionStatement",Identifier:"Identifier",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",ObjectExpression:"ObjectExpression",Program:"Program",Property:"Property",ThisExpression:"ThisExpression",UnaryExpression:"UnaryExpression"},V={UnexpectedToken:"Unexpected token %0",UnknownLabel:"Undefined label '%0'",Redeclaration:"%0 '%1' has already been declared"};var ab=H,bb=L;a.esprima={parse:R}}(this),function(a){"use strict";function b(a,b,d,e){var f;try{if(f=c(a),f.scopeIdent&&(d.nodeType!==Node.ELEMENT_NODE||"TEMPLATE"!==d.tagName||"bind"!==b&&"repeat"!==b))throw Error("as and in can only be used within