Skip to content

Commit eeef379

Browse files
committed
[selectors] Rewrite :nth-of-type() and co a little better as well.
1 parent 42bc9b4 commit eeef379

2 files changed

Lines changed: 34 additions & 26 deletions

File tree

selectors/Overview.bs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2755,9 +2755,10 @@ Typed Child-indexed Pseudo-classes</h3>
27552755
'':nth-of-type()'' pseudo-class</h4>
27562756

27572757
The <dfn id='nth-of-type-pseudo' title=":nth-of-type()">:nth-of-type(<var>An+B</var>)</dfn> pseudo-class notation
2758-
represents an element that has <var>An+B</var>-1 siblings
2759-
with the same <a href="http://www.w3.org/TR/css3-namespace/#expanded-name">expanded element name</a>
2760-
<em>before</em> it in the document tree.
2758+
represents the <var>An+B</var>th element
2759+
with the same <a section href="#type-nmsp">namespace</a> and <a section href="#type-selectors">type</a>
2760+
among its siblings.
2761+
27612762
The CSS Syntax Module [[!CSS3SYN]] defines the <a href="http://dev.w3.org/csswg/css-syntax/#anb"><var>An+B</var> notation</a>.
27622763

27632764
<div class="example">
@@ -2780,9 +2781,11 @@ Typed Child-indexed Pseudo-classes</h3>
27802781
'':nth-last-of-type()'' pseudo-class</h4>
27812782

27822783
The <dfn id='nth-last-of-type' title=":nth-last-of-type()">:nth-last-of-type(<var>An+B</var>)</dfn> pseudo-class notation
2783-
represents an element that has <var>An+B</var>-1 siblings
2784-
with the same <a href="http://www.w3.org/TR/css3-namespace/#expanded-name">expanded element name</a>
2785-
<em>after</em> it in the document tree.
2784+
represents the <var>An+B</var>th element
2785+
with the same <a section href="#type-nmsp">namespace</a> and <a section href="#type-selectors">type</a>
2786+
among its siblings,
2787+
counting backwards from the end.
2788+
27862789
The CSS Syntax Module [[!CSS3SYN]] defines the <a href="http://dev.w3.org/csswg/css-syntax/#anb"><var>An+B</var> notation</a>.
27872790

27882791
<div class="example">
@@ -2804,8 +2807,8 @@ Typed Child-indexed Pseudo-classes</h3>
28042807

28052808
The <dfn id='first-of-type-pseudo'>:first-of-type</dfn> pseudo-class
28062809
represents an element that is the first sibling
2807-
with the same <a href="http://www.w3.org/TR/css3-namespace/#expanded-name">expanded element name</a>
2808-
in its sibling list.
2810+
with a particular <a section href="#type-nmsp">namespace</a> and <a section href="#type-selectors">type</a>
2811+
among its siblings.
28092812
Same as '':nth-of-type(1)''.
28102813

28112814
<div class="example">
@@ -2839,9 +2842,10 @@ Typed Child-indexed Pseudo-classes</h3>
28392842
'':last-of-type'' pseudo-class</h4>
28402843

28412844
The <dfn id='last-of-type-pseudo'>:last-of-type</dfn> pseudo-class
2842-
represents an element that is the last sibling
2843-
with the same <a href="http://www.w3.org/TR/css3-namespace/#expanded-name">expanded element name</a>
2844-
in its sibling list.
2845+
represents an element that is the first sibling
2846+
with a particular <a section href="#type-nmsp">namespace</a> and <a section href="#type-selectors">type</a>
2847+
among its siblings,
2848+
counting backwards from the end.
28452849
Same as '':nth-last-of-type(1)''.
28462850

28472851
<div class="example">
@@ -2857,7 +2861,7 @@ Typed Child-indexed Pseudo-classes</h3>
28572861

28582862
The <dfn id='only-of-type-pseudo'>:only-of-type</dfn> pseudo-class
28592863
represents an element that has no siblings
2860-
with the same <a href="http://www.w3.org/TR/css3-namespace/#expanded-name">expanded element name</a>.
2864+
with the same <a section href="#type-nmsp">namespace</a> and <a section href="#type-selectors">type</a>
28612865
Same as '':first-of-type:last-of-type''
28622866
or '':nth-of-type(1):nth-last-of-type(1)'',
28632867
but with a lower specificity.

selectors/Overview.html

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2969,10 +2969,11 @@ <h4 class="heading settled" data-level=12.5.1 id=the-nth-of-type-pseudo><span cl
29692969
<a class=css data-link-type=maybe href=#nth-of-type-pseudo title=:nth-of-type()>:nth-of-type()</a> pseudo-class</span><a class=self-link href=#the-nth-of-type-pseudo></a></h4>
29702970

29712971
<p>The <dfn class=css data-dfn-type=selector data-export="" id=nth-of-type-pseudo title=:nth-of-type()>:nth-of-type(<var>An+B</var>)<a class=self-link href=#nth-of-type-pseudo></a></dfn> pseudo-class notation
2972-
represents an element that has <var>An+B</var>-1 siblings
2973-
with the same <a href=http://www.w3.org/TR/css3-namespace/#expanded-name>expanded element name</a>
2974-
<em>before</em> it in the document tree.
2975-
The CSS Syntax Module <a data-biblio-type=normative data-link-type=biblio href=#biblio-css3syn title=CSS3SYN>[CSS3SYN]</a> defines the <a href=http://dev.w3.org/csswg/css-syntax/#anb><var>An+B</var> notation</a>.</p>
2972+
represents the <var>An+B</var>th element
2973+
with the same <a data-section="" href=#type-nmsp>namespace</a> and <a data-section="" href=#type-selectors>type</a>
2974+
among its siblings.</p>
2975+
2976+
<p>The CSS Syntax Module <a data-biblio-type=normative data-link-type=biblio href=#biblio-css3syn title=CSS3SYN>[CSS3SYN]</a> defines the <a href=http://dev.w3.org/csswg/css-syntax/#anb><var>An+B</var> notation</a>.</p>
29762977

29772978
<div class=example>
29782979
CSS example:
@@ -2993,10 +2994,12 @@ <h4 class="heading settled" data-level=12.5.2 id=the-nth-last-of-type-pseudo><sp
29932994
<a class=css data-link-type=maybe href=#nth-last-of-type title=:nth-last-of-type()>:nth-last-of-type()</a> pseudo-class</span><a class=self-link href=#the-nth-last-of-type-pseudo></a></h4>
29942995

29952996
<p>The <dfn class=css data-dfn-type=selector data-export="" id=nth-last-of-type title=:nth-last-of-type()>:nth-last-of-type(<var>An+B</var>)<a class=self-link href=#nth-last-of-type></a></dfn> pseudo-class notation
2996-
represents an element that has <var>An+B</var>-1 siblings
2997-
with the same <a href=http://www.w3.org/TR/css3-namespace/#expanded-name>expanded element name</a>
2998-
<em>after</em> it in the document tree.
2999-
The CSS Syntax Module <a data-biblio-type=normative data-link-type=biblio href=#biblio-css3syn title=CSS3SYN>[CSS3SYN]</a> defines the <a href=http://dev.w3.org/csswg/css-syntax/#anb><var>An+B</var> notation</a>.</p>
2997+
represents the <var>An+B</var>th element
2998+
with the same <a data-section="" href=#type-nmsp>namespace</a> and <a data-section="" href=#type-selectors>type</a>
2999+
among its siblings,
3000+
counting backwards from the end.</p>
3001+
3002+
<p>The CSS Syntax Module <a data-biblio-type=normative data-link-type=biblio href=#biblio-css3syn title=CSS3SYN>[CSS3SYN]</a> defines the <a href=http://dev.w3.org/csswg/css-syntax/#anb><var>An+B</var> notation</a>.</p>
30003003

30013004
<div class=example>
30023005
Example:
@@ -3017,8 +3020,8 @@ <h4 class="heading settled" data-level=12.5.3 id=the-first-of-type-pseudo><span
30173020

30183021
<p>The <dfn class=css data-dfn-type=selector data-export="" id=first-of-type-pseudo>:first-of-type<a class=self-link href=#first-of-type-pseudo></a></dfn> pseudo-class
30193022
represents an element that is the first sibling
3020-
with the same <a href=http://www.w3.org/TR/css3-namespace/#expanded-name>expanded element name</a>
3021-
in its sibling list.
3023+
with a particular <a data-section="" href=#type-nmsp>namespace</a> and <a data-section="" href=#type-selectors>type</a>
3024+
among its siblings.
30223025
Same as <span class=css>:nth-of-type(1)</span>.</p>
30233026

30243027
<div class=example>
@@ -3051,9 +3054,10 @@ <h4 class="heading settled" data-level=12.5.4 id=the-last-of-type-pseudo><span c
30513054
<a class=css data-link-type=maybe href=#last-of-type-pseudo title=:last-of-type>:last-of-type</a> pseudo-class</span><a class=self-link href=#the-last-of-type-pseudo></a></h4>
30523055

30533056
<p>The <dfn class=css data-dfn-type=selector data-export="" id=last-of-type-pseudo>:last-of-type<a class=self-link href=#last-of-type-pseudo></a></dfn> pseudo-class
3054-
represents an element that is the last sibling
3055-
with the same <a href=http://www.w3.org/TR/css3-namespace/#expanded-name>expanded element name</a>
3056-
in its sibling list.
3057+
represents an element that is the first sibling
3058+
with a particular <a data-section="" href=#type-nmsp>namespace</a> and <a data-section="" href=#type-selectors>type</a>
3059+
among its siblings,
3060+
counting backwards from the end.
30573061
Same as <span class=css>:nth-last-of-type(1)</span>.</p>
30583062

30593063
<div class=example>
@@ -3069,7 +3073,7 @@ <h4 class="heading settled" data-level=12.5.5 id=the-only-of-type-pseudo><span c
30693073

30703074
<p>The <dfn class=css data-dfn-type=selector data-export="" id=only-of-type-pseudo>:only-of-type<a class=self-link href=#only-of-type-pseudo></a></dfn> pseudo-class
30713075
represents an element that has no siblings
3072-
with the same <a href=http://www.w3.org/TR/css3-namespace/#expanded-name>expanded element name</a>.
3076+
with the same <a data-section="" href=#type-nmsp>namespace</a> and <a data-section="" href=#type-selectors>type</a>
30733077
Same as <span class=css>:first-of-type:last-of-type</span>
30743078
or <span class=css>:nth-of-type(1):nth-last-of-type(1)</span>,
30753079
but with a lower specificity.</p>

0 commit comments

Comments
 (0)