Skip to content

Commit 762eace

Browse files
committed
[css-values-5] Add sibling-count/index(). #4559
1 parent 5fc63f5 commit 762eace

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

css-values-5/Overview.bs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Default Highlight: css
1717
</pre>
1818
<pre class='link-defaults'>
1919
spec: css-values-4; type: dfn; text: determine the type of a calculation
20+
spec: selectors-4; type: dfn; text: selector
2021
</pre>
2122
<style>
2223
code, small { white-space: nowrap }
@@ -1403,6 +1404,37 @@ Generating/Caching Random Values: the <<random-caching-options>> value</h4>
14031404

14041405

14051406

1407+
<h2 id="tree-counting">
1408+
Tree Counting Functions: the ''sibling-count()'' and ''sibling-index()'' notations</h2>
1409+
1410+
The <dfn>sibling-count()</dfn> [=functional notation=] represents,
1411+
as an <<integer>>,
1412+
the total number of child <l spec=css-display-3>[=elements=]</l>
1413+
in the parent of the element on which the notation is used.
1414+
1415+
The <dfn>sibling-index()</dfn> [=functional notation=] represents,
1416+
as an <<integer>>,
1417+
the index of the element
1418+
on which the notation is used
1419+
among the children of its parent.
1420+
Like '':nth-child()'',
1421+
''sibling-index()'' is 1-indexed.
1422+
1423+
Note: The ''counter()'' function can provide similar abilities as ''sibling-index()'',
1424+
but returns a <<string>> rather than an <<integer>>.
1425+
1426+
When used on a [=pseudo-element=],
1427+
these both resolve as if specified
1428+
on its [=ultimate originating element=].
1429+
1430+
Note: Like the rest of CSS (other than [=selectors=]),
1431+
''sibling-count()'' and ''sibling-index()''
1432+
operate on the [=flat tree=].
1433+
1434+
Note: These functions may, in the future,
1435+
be extended to accept an ''of <<selector>>'' argument,
1436+
similar to '':nth-child()'',
1437+
to filter on a subset of the children.
14061438

14071439
<!--
14081440
████████ ████████ ██████

0 commit comments

Comments
 (0)