@@ -16,6 +16,7 @@ Abstract: Selectors Level 5 describes the selectors that already exist in [[!sel
16
16
<pre class="link-defaults">
17
17
spec:selectors-4; type:dfn; text:selector
18
18
spec:html; type:dfn; text:states set
19
+ spec:html; type:dfn; text:heading level
19
20
</pre>
20
21
21
22
<h2 id="intro">
@@ -154,6 +155,37 @@ Exposing custom state: the '':state()'' pseudo-class</h2>
154
155
see <a href="https://html.spec.whatwg.org/multipage/custom-elements.html#custom-state-pseudo-class">HTML's definition</a> for more detail.
155
156
Other host languages must define how this pseudo-class matches.
156
157
158
+ <h2 id="headings">
159
+ Heading Structures: the heading pseudo-classes '':heading'', and '':heading()''</h2>
160
+
161
+ The (non-functional) <dfn id='heading-pseudo'>:heading</dfn> pseudo-class
162
+ matches an element which has a <a>heading level</a> , with respect to the
163
+ semantics defined by the document language (e.g. [[HTML5]] ).
164
+
165
+ <div class="example">
166
+ For example, the following sheet contains a rule applying to all heading
167
+ elements in the current page:
168
+
169
+ <pre> :heading { text-decoration: underline; }</pre>
170
+ </div>
171
+
172
+ As a functional pseudo-class,
173
+ <dfn id='heading-functional-pseudo' lt=':heading()'>:heading(<var>An+B</var>)</dfn>
174
+ notation represents elements that have a <a>heading level</a> among <var> An+B</var> .
175
+
176
+ <div class="example">
177
+ The following example styles headings with levels between 1 and 3 with a
178
+ font-weight of 900, while headings with levels 6 onward with font-weight of
179
+ 500:
180
+
181
+ <pre> :heading(-n+3) { font-weight: 900; }</pre>
182
+ <pre> :heading(n+6) { font-weight: 500; }</pre>
183
+ </div>
184
+
185
+ Note: The <a>heading level</a> might be different from an element's
186
+ <a>type selector</a> . Thus, a selector ''h1:heading(3)'' matches any
187
+ ''h1'' tag which has an exposed heading level of 3.
188
+
157
189
<h2 id="combinators">
158
190
Combinators</h2>
159
191
@@ -202,6 +234,7 @@ Changes Since Level 4</h3>
202
234
<li> The functional form of the '':local-link'' pseudo-class
203
235
(deferred from an <a href="https://www.w3.org/TR/2013/WD-selectors4-20130502/">earlier draft</a> of Selectors 4)</li>
204
236
<li> The '':state()'' pseudo-class</li>
237
+ <li> The '':heading'' and '':heading()'' pseudo-classes</li>
205
238
</ul>
206
239
207
240
<h2 id="acknowledgements">
0 commit comments