Skip to content

Commit ce57f47

Browse files
committed
[selectors] Clarify that specificity can change per element.
--HG-- extra : rebase_source : 6869766a55ec33944bcaea0808ce4c5083889cbe
1 parent 895f9a8 commit ce57f47

2 files changed

Lines changed: 60 additions & 59 deletions

File tree

selectors/Overview.html

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
rel=dcterms.rights>
1212
<meta content="Selectors Level 4" name=dcterms.title>
1313
<meta content=text name=dcterms.type>
14-
<meta content=2013-10-18 name=dcterms.date>
14+
<meta content=2014-01-16 name=dcterms.date>
1515
<meta content="Elika J. Etemad" name=dcterms.creator>
1616
<meta content="Tab Atkins Jr." name=dcterms.creator>
1717
<meta content=W3C name=dcterms.publisher>
@@ -32,13 +32,13 @@
3232

3333
<h1 id=title>Selectors Level 4</h1>
3434

35-
<h2 class="no-num no-toc">Editor's Draft 18 October 2013</h2>
35+
<h2 class="no-num no-toc">Editor's Draft 16 January 2014</h2>
3636

3737
<dl>
3838
<dt>This version:
3939

4040
<dd><a href="http://dev.w3.org/csswg/selectors4/">
41-
http://www.w3.org/TR/2013/ED-selectors4-20131018/</a>
41+
http://www.w3.org/TR/2014/ED-selectors4-20140116/</a>
4242

4343
<dt>Editor's draft:
4444

@@ -96,7 +96,7 @@ <h2 class="no-num no-toc">Editor's Draft 18 October 2013</h2>
9696
<!--begin-copyright-->
9797
<p class=copyright><a
9898
href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright"
99-
rel=license>Copyright</a> © 2013 <a href="http://www.w3.org/"><abbr
99+
rel=license>Copyright</a> © 2014 <a href="http://www.w3.org/"><abbr
100100
title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup> (<a
101101
href="http://www.csail.mit.edu/"><abbr
102102
title="Massachusetts Institute of Technology">MIT</abbr></a>, <a
@@ -4164,25 +4164,26 @@ <h3 id=the-nth-last-column-pseudo><span class=secno>14.3. </span> <a
41644164
<h2 id=specificity><span class=secno>15. </span> Calculating a selector's
41654165
specificity</h2>
41664166

4167-
<p>A selector's specificity is calculated as follows:
4167+
<p>A selector's specificity is calculated for a given element as follows:
41684168

41694169
<ul>
4170-
<li>count the number of ID selectors in the selector (= <a
4171-
href="#a"><var>A</var></a>)
4170+
<li>count the number of ID selectors in the selector (= <var
4171+
title="">A</var>)
41724172

41734173
<li>count the number of class selectors, attributes selectors, and
4174-
pseudo-classes in the selector (= <a href="#b"><var>B</var></a>)
4174+
pseudo-classes in the selector (= <var title="">B</var>)
41754175

41764176
<li>count the number of type selectors and pseudo-elements in the selector
4177-
(= <var>c</var>)
4177+
(= <var title="">C</var>)
41784178

41794179
<li>ignore the universal selector
41804180
</ul>
41814181

4182-
<p>The specificity of a <a href="#matches">:matches()</a> pseudo-class is
4183-
the specificity of the most specific complex selector that matched. (The
4184-
full selector's specificity is equivalent to expanding out all the
4185-
combinations in full, without <a
4182+
<p> In most cases, a selector has the same specificity for every element it
4183+
applies to. The specificity of a <a href="#matches">:matches()</a>
4184+
pseudo-class, however, is the specificity of the most specific complex
4185+
selector that matched the given element. (The full selector's specificity
4186+
is equivalent to expanding out all the combinations in full, without <a
41864187
href="#matches-pseudo"><code>:matches()</code></a>.) The specificity of a
41874188
<a href="#negation">:not()</a> pseudo-class is the specificity of the most
41884189
specifc complex selector in its selector list. In either case, the
@@ -4191,17 +4192,17 @@ <h2 id=specificity><span class=secno>15. </span> Calculating a selector's
41914192
like a tag selector.
41924193

41934194
<p> Specificities are compared by comparing the three components in order:
4194-
the specificity with a larger <a href="#a"><var>A</var></a> value is more
4195-
specific; if the two <a href="#a"><var>A</var></a> values are tied, then
4196-
the specificity with a larger <a href="#b"><var>B</var></a> value is more
4197-
specific; if the two <a href="#b"><var>B</var></a> values are also tied,
4198-
then the specificity with a larger <var>c</var> value is more specific; if
4199-
all the values are tied, the two specifities are equal.
4195+
the specificity with a larger <var title="">A</var> value is more
4196+
specific; if the two <var title="">A</var> values are tied, then the
4197+
specificity with a larger <var title="">B</var> value is more specific; if
4198+
the two <var title="">B</var> values are also tied, then the specificity
4199+
with a larger <var title="">C</var> value is more specific; if all the
4200+
values are tied, the two specifities are equal.
42004201

42014202
<p> Due to storage limitations, implementations may have limitations on the
4202-
size of <a href="#a"><var>A</var></a>, <a href="#b"><var>B</var></a>, or
4203-
<var>c</var>. If so, values higher than the limit must be clamped to that
4204-
limit, and not overflow.
4203+
size of <var title="">A</var>, <var title="">B</var>, or <var
4204+
title="">C</var>. If so, values higher than the limit must be clamped to
4205+
that limit, and not overflow.
42054206

42064207
<div class=example>
42074208
<p>Examples:
@@ -4732,10 +4733,9 @@ <h3 id=informative-references><span class=secno>21.2. </span> Informative
47324733
<dt id=ref-CSSSTYLEATTR>[CSSSTYLEATTR]
47334734

47344735
<dd>Tantek Çelik; Elika J. Etemad. <a
4735-
href="http://www.w3.org/TR/2013/PR-css-style-attr-20131003/"><cite>CSS
4736-
Style Attributes.</cite></a> 3 October 2013. W3C Proposed Recommendation.
4737-
(Work in progress.) URL: <a
4738-
href="http://www.w3.org/TR/2013/PR-css-style-attr-20131003/">http://www.w3.org/TR/2013/PR-css-style-attr-20131003/</a>
4736+
href="http://www.w3.org/TR/2013/REC-css-style-attr-20131107/"><cite>CSS
4737+
Style Attributes.</cite></a> 7 November 2013. W3C Recommendation. URL: <a
4738+
href="http://www.w3.org/TR/2013/REC-css-style-attr-20131107/">http://www.w3.org/TR/2013/REC-css-style-attr-20131107/</a>
47394739
</dd>
47404740
<!---->
47414741

@@ -4798,10 +4798,9 @@ <h3 id=informative-references><span class=secno>21.2. </span> Informative
47984798
<dt id=ref-SELECTORS-API2>[SELECTORS-API2]
47994799

48004800
<dd>Lachlan Hunt. <a
4801-
href="http://www.w3.org/TR/2012/WD-selectors-api2-20120628/"><cite>Selectors
4802-
API Level 2.</cite></a> 28 June 2012. W3C Working Draft. (Work in
4803-
progress.) URL: <a
4804-
href="http://www.w3.org/TR/2012/WD-selectors-api2-20120628/">http://www.w3.org/TR/2012/WD-selectors-api2-20120628/</a>
4801+
href="http://www.w3.org/TR/2013/NOTE-selectors-api2-20131017/"><cite>Selectors
4802+
API Level 2.</cite></a> 17 October 2013. W3C Working Group Note. URL: <a
4803+
href="http://www.w3.org/TR/2013/NOTE-selectors-api2-20131017/">http://www.w3.org/TR/2013/NOTE-selectors-api2-20131017/</a>
48054804
</dd>
48064805
<!---->
48074806

selectors/Overview.src.html

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ <h3 id="profiles">
593593

594594
<p class='issue'>
595595
The categorization of things into the "fast" or "complete" profiles needs implementor review.
596-
If some things currently not in the fast profile can reasonably be done in CSS Selectors,
596+
If some things currently not in the fast profile can reasonably be done in CSS Selectors,
597597
we should move them.
598598

599599

@@ -1576,20 +1576,20 @@ <h3 id="class-html">
15761576
<h3 id="id-selectors">
15771577
ID selectors</h3>
15781578

1579-
<p>Document languages may contain attributes that are declared to be of type ID.
1580-
What makes attributes of type ID special
1581-
is that no two such attributes can have the same value in a conformant document,
1582-
regardless of the type of the elements that carry them;
1583-
whatever the document language,
1584-
an ID typed attribute can be used to uniquely identify its element.
1585-
In HTML all ID attributes are named <code>id</code>;
1586-
XML applications may name ID attributes differently,
1587-
but the same restriction applies.
1579+
<p>Document languages may contain attributes that are declared to be of type ID.
1580+
What makes attributes of type ID special
1581+
is that no two such attributes can have the same value in a conformant document,
1582+
regardless of the type of the elements that carry them;
1583+
whatever the document language,
1584+
an ID typed attribute can be used to uniquely identify its element.
1585+
In HTML all ID attributes are named <code>id</code>;
1586+
XML applications may name ID attributes differently,
1587+
but the same restriction applies.
15881588
Which attribute on an element is considered the “ID attribute“ is defined by the document language.
15891589

1590-
<p>An <dfn>ID selector</dfn> consists of a “number sign” (U+0023, <code>#</code>)
1591-
immediately followed by the ID value,
1592-
which must be a CSS <a href="http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier">identifier</a>.
1590+
<p>An <dfn>ID selector</dfn> consists of a “number sign” (U+0023, <code>#</code>)
1591+
immediately followed by the ID value,
1592+
which must be a CSS <a href="http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier">identifier</a>.
15931593
An ID selector represents an element instance that has an identifier that matches the identifier in the ID selector.
15941594
(It is possible in non-conforming documents for multiple elements to match a single ID selector.)
15951595

@@ -1822,7 +1822,7 @@ <h3 id="local-pseudo">
18221822
<pre>nav :local-link { text-decoration: none; }</pre>
18231823
</div>
18241824

1825-
<p>As a functional pseudo-class, <code>:local-link()</code> can also accept a non-negative integer as its sole argument,
1825+
<p>As a functional pseudo-class, <code>:local-link()</code> can also accept a non-negative integer as its sole argument,
18261826
which, if the document's URL belongs to a hierarchical scheme,
18271827
indicates the number of path levels to match:
18281828
<ul>
@@ -1837,7 +1837,7 @@ <h3 id="local-pseudo">
18371837
underline.
18381838
<pre>:not(:local-link(0)) { text-decoration-style: dashed; }</pre>
18391839
</div>
1840-
1840+
18411841
<p>Path segments are portions of the URL's path that are separated by forward slashes (/).
18421842
If a segment is missing from the document's URL,
18431843
a pseudo-class requiring that segment to match does not match anything.
@@ -1883,7 +1883,7 @@ <h3 id="local-pseudo">
18831883
the functional pseudo-class matches nothing.
18841884

18851885
<p class="issue">
1886-
It's clear that, if the document URL has at least N segments,
1886+
It's clear that, if the document URL has at least N segments,
18871887
then <code>:local-link(N)</code> only matches links whose URL has at least N segments.
18881888
(This lets you assign consistent semantics to :local-link so that,
18891889
for example, :local-link(2) means a "within-repo" link on GitHub.)
@@ -2754,7 +2754,7 @@ <h3 id="selected-child-index">
27542754
The '':nth-match()'' and '':nth-last-match()'' pseudo-classes
27552755
allow one to build a selector for the latter interpretation.
27562756

2757-
<p>In the <i>fast</i> Selectors profile, only lists of <i>compound selectors</i> are allowed within these selectors.
2757+
<p>In the <i>fast</i> Selectors profile, only lists of <i>compound selectors</i> are allowed within these selectors.
27582758
In the <i>complete</i> profile, full <i>complex selectors</i> are allowed.
27592759

27602760
<h4 id="the-nth-match-pseudo">
@@ -3006,17 +3006,19 @@ <h3 id="the-nth-last-column-pseudo">
30063006
<h2 id="specificity">
30073007
Calculating a selector's specificity</h2>
30083008

3009-
<p>A selector's specificity is calculated as follows:
3009+
<p>A selector's specificity is calculated for a given element as follows:
30103010

30113011
<ul>
3012-
<li>count the number of ID selectors in the selector (= <var>A</var>)
3013-
<li>count the number of class selectors, attributes selectors, and pseudo-classes in the selector (= <var>B</var>)
3014-
<li>count the number of type selectors and pseudo-elements in the selector (= <var>c</var>)
3012+
<li>count the number of ID selectors in the selector (= <var title=''>A</var>)
3013+
<li>count the number of class selectors, attributes selectors, and pseudo-classes in the selector (= <var title=''>B</var>)
3014+
<li>count the number of type selectors and pseudo-elements in the selector (= <var title=''>C</var>)
30153015
<li>ignore the universal selector
30163016
</ul>
30173017

3018-
<p>The specificity of a <a href="#matches">:matches()</a> pseudo-class is
3019-
the specificity of the most specific complex selector that matched.
3018+
<p>
3019+
In most cases, a selector has the same specificity for every element it applies to.
3020+
The specificity of a <a href="#matches">:matches()</a> pseudo-class, however,
3021+
is the specificity of the most specific complex selector that matched the given element.
30203022
(The full selector's specificity is equivalent to expanding out all the combinations in full, without <code>:matches()</code>.)
30213023
The specificity of a <a href="#negation">:not()</a> pseudo-class is
30223024
the specificity of the most specifc complex selector in its selector list.
@@ -3025,17 +3027,17 @@ <h2 id="specificity">
30253027

30263028
<p>
30273029
Specificities are compared by comparing the three components in order:
3028-
the specificity with a larger <var>A</var> value is more specific;
3029-
if the two <var>A</var> values are tied,
3030-
then the specificity with a larger <var>B</var> value is more specific;
3031-
if the two <var>B</var> values are also tied,
3032-
then the specificity with a larger <var>c</var> value is more specific;
3030+
the specificity with a larger <var title=''>A</var> value is more specific;
3031+
if the two <var title=''>A</var> values are tied,
3032+
then the specificity with a larger <var title=''>B</var> value is more specific;
3033+
if the two <var title=''>B</var> values are also tied,
3034+
then the specificity with a larger <var title=''>C</var> value is more specific;
30333035
if all the values are tied,
30343036
the two specifities are equal.
30353037

30363038
<p>
30373039
Due to storage limitations,
3038-
implementations may have limitations on the size of <var>A</var>, <var>B</var>, or <var>c</var>.
3040+
implementations may have limitations on the size of <var title=''>A</var>, <var title=''>B</var>, or <var title=''>C</var>.
30393041
If so, values higher than the limit must be clamped to that limit,
30403042
and not overflow.
30413043

0 commit comments

Comments
 (0)