Skip to content

Commit ad57cae

Browse files
Editorial review: Add docs for scroll-target-group (#40843)
* Add docs for scroll-target-group * Fixes for danielsakhapov review comments * Update files/en-us/web/css/css_overflow/css_carousels/index.md Co-authored-by: Dipika Bhattacharya <[email protected]> * Update files/en-us/web/css/scroll-marker-group/index.md Co-authored-by: Dipika Bhattacharya <[email protected]> * Update files/en-us/web/css/_doublecolon_scroll-marker-group/index.md Co-authored-by: Dipika Bhattacharya <[email protected]> * Update files/en-us/web/css/_doublecolon_scroll-marker-group/index.md Co-authored-by: Dipika Bhattacharya <[email protected]> * Update files/en-us/web/css/scroll-target-group/index.md Co-authored-by: Dipika Bhattacharya <[email protected]> * Update files/en-us/web/css/scroll-target-group/index.md Co-authored-by: Dipika Bhattacharya <[email protected]> * Update files/en-us/web/css/scroll-target-group/index.md Co-authored-by: Dipika Bhattacharya <[email protected]> * Update files/en-us/web/css/scroll-target-group/index.md Co-authored-by: Dipika Bhattacharya <[email protected]> * Update files/en-us/web/css/scroll-target-group/index.md Co-authored-by: Dipika Bhattacharya <[email protected]> * Update files/en-us/web/css/scroll-target-group/index.md Co-authored-by: Dipika Bhattacharya <[email protected]> * Update files/en-us/web/css/scroll-target-group/index.md Co-authored-by: Dipika Bhattacharya <[email protected]> * Update files/en-us/web/css/scroll-target-group/index.md Co-authored-by: Dipika Bhattacharya <[email protected]> * Update files/en-us/web/css/scroll-target-group/index.md Co-authored-by: Dipika Bhattacharya <[email protected]> * Update files/en-us/web/css/scroll-target-group/index.md Co-authored-by: Dipika Bhattacharya <[email protected]> * Fixes for dipika review comments * Clarify a11y semantics of scroll containers * Clarify a11y semantics of scroll containers --------- Co-authored-by: Dipika Bhattacharya <[email protected]>
1 parent 98183ef commit ad57cae

File tree

6 files changed

+490
-16
lines changed

6 files changed

+490
-16
lines changed

files/en-us/web/css/_doublecolon_scroll-marker-group/index.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@ The **`::scroll-marker-group`** [CSS](/en-US/docs/Web/CSS) [pseudo-element](/en-
2222

2323
## Description
2424

25-
A scroll container's **`::scroll-marker-group`** pseudo-element represents a **scroll marker group**. This is a container that automatically contains any {{cssxref("::scroll-marker")}} pseudo-elements generated on itself or its descendants. This allows them to be positioned and laid out as a group, and is typically used when creating a CSS carousel to provide a scroll position indicator. The individual scroll markers can be used to navigate to their associated content items.
25+
A scroll container's **`::scroll-marker-group`** pseudo-element represents a **scroll marker group container**. This is a container that automatically contains any {{cssxref("::scroll-marker")}} pseudo-elements generated on itself or its descendants. This allows them to be positioned and styled as a group. This pseudo-element is typically used when creating a CSS carousel to provide a scroll position indicator. The individual scroll markers can be used to navigate to their associated content items.
2626

27-
The scroll container must have its {{cssxref("scroll-marker-group")}} property set to a non-`none` value for the `::scroll-marker-group` pseudo-element to be generated. The {{cssxref("scroll-marker-group")}} value determines where the scroll marker group appears in the carousel's tab order and layout box order (but not DOM structure) — `before` puts it at the start, while `after` puts it at the end.
27+
The scroll container must have its {{cssxref("scroll-marker-group")}} property set to a non-`none` value for the `::scroll-marker-group` pseudo-element to be generated. The {{cssxref("scroll-marker-group")}} value determines where the scroll marker group container appears in the carousel's tab order and layout box order (but not DOM structure) — `before` puts it at the start, while `after` puts it at the end.
2828

29-
It is a best practice to match the visual rendering position of the scroll marker group with the tab order. When positioning the group at the start of the content, put it at the beginning of the tab order using `before`. When positioning the group at the end of the content, put it at the end of the tab order using `after`.
29+
> [!NOTE]
30+
> Alternatively, a scroll marker group container can be created from an existing element containing a set of {{htmlelement("a")}} elements using {{cssxref("scroll-target-group")}}.
31+
32+
As an accessibility best practice, match the visual rendering position of the scroll marker group container with the tab order. When positioning the group at the start of the content, put it at the beginning of the tab order using `before`. When positioning the group at the end of the content, put it at the end of the tab order using `after`.
3033

31-
Accessibility-wise, the scroll marker group and contained scroll markers are rendered with [`tablist`](/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/tablist_role)/[`tab`](/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/tab_role) semantics. When you <kbd>Tab</kbd> to the group, it behaves like a single item (that is, another press of the <kbd>Tab</kbd> key will move past the group to the next item), and you can move between the different scroll markers using the left and right (or up and down) cursor keys.
34+
When a scroll marker group container is created on a scroll container using the `scroll-marker-group` property, the scroll container is rendered with [`tablist`](/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/tablist_role)/[`tab`](/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/tab_role) semantics. You can <kbd>Tab</kbd> to it with the keyboard, then move between the different "pages" using the left and right (or up and down) cursor keys, which also changes the state of the associated scroll markers and scroll buttons as expected. The scroll markers can also be tabbed between normally, as expected.
3235

3336
## Examples
3437

@@ -145,9 +148,9 @@ li::scroll-marker:target-current {
145148

146149
{{EmbedLiveSample("carousel-example", "100%", "280px")}}
147150

148-
### Positioning the scroll marker group with anchor-positioning
151+
### Positioning the scroll marker group container with anchor positioning
149152

150-
This example extends the previous one, demonstrating the use of [CSS anchor positioning](/en-US/docs/Web/CSS/CSS_anchor_positioning) to position the scroll marker group relative to the carousel.
153+
This example extends the previous one, demonstrating the use of [CSS anchor positioning](/en-US/docs/Web/CSS/CSS_anchor_positioning) to position the scroll marker group container relative to the carousel.
151154

152155
#### CSS
153156

@@ -185,6 +188,7 @@ ul::scroll-marker-group {
185188
## See also
186189

187190
- {{cssxref("scroll-marker-group")}}
191+
- {{cssxref("scroll-target-group")}}
188192
- {{cssxref("::scroll-button()")}}
189193
- {{cssxref("::scroll-marker")}}
190194
- {{cssxref("::column")}}

files/en-us/web/css/_doublecolon_scroll-marker/index.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ A `::scroll-marker` is generated on an element when the `::scroll-marker`'s {{cs
2626

2727
The scroll container's `::scroll-marker-group` pseudo-element automatically contains any `::scroll-marker` pseudo-elements generated on the scroll container or its descendants. This allows them to be positioned and laid out as a group and is typically used when creating a CSS carousel to create a scroll position indicator. The individual scroll markers can be used to navigate to their associated content items.
2828

29-
Accessibility-wise, the scroll marker group and contained scroll markers are rendered with [`tablist`](/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/tablist_role)/[`tab`](/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/tab_role) semantics. When you <kbd>Tab</kbd> to the group, it behaves like a single item (that is, another press of the <kbd>Tab</kbd> key will move past the group to the next item), and you can move between the different scroll markers using the left and right (or up and down) cursor keys.
29+
> [!NOTE]
30+
> Alternatively, a scroll marker group container can be created from an existing element container using {{cssxref("scroll-target-group")}}; any contained {{htmlelement("a")}} elements with fragment identifiers linking to sections of the page automatically behave like scroll markers.
31+
32+
When a scroll marker group container is created on a scroll container using the `scroll-marker-group` property, the scroll container is rendered with [`tablist`](/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/tablist_role)/[`tab`](/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/tab_role) semantics. You can <kbd>Tab</kbd> to it with the keyboard, then move between the different "pages" using the left and right (or up and down) cursor keys, which also changes the state of the associated scroll markers and scroll buttons as expected. The scroll markers can also be tabbed between normally, as expected.
3033

3134
## Examples
3235

@@ -57,7 +60,7 @@ We have a basic HTML {{htmlelement("ul")}} list with several {{htmlelement("li")
5760

5861
We convert our `<ul>` into a scroll snapping overflow container by setting the {{cssxref("display")}} to `flex`, creating a single, non-wrapping row of `<li>` elements. The {{cssxref("overflow-x")}} property is set to `auto`, meaning if the items overflow their container on the x-axis, the content will scroll horizontally. We then convert the `<ul>` into a [scroll-snap container](/en-US/docs/Glossary/Scroll_snap#scroll_snap_container), ensuring that items always snap into place when the container is scrolled with a {{cssxref("scroll-snap-type")}} value of `mandatory`.
5962

60-
We create a scroll marker group with the `scroll-marker-group` property, placing the group after all the content.
63+
We create a scroll marker group container with the `scroll-marker-group` property, placing it after all the content.
6164

6265
```css live-sample___creating-scroll-markers live-sample___custom-numbering
6366
ul {
@@ -189,6 +192,7 @@ To improve user experience, we set a different color on the markers on {{cssxref
189192
## See also
190193

191194
- {{cssxref("scroll-marker-group")}}
195+
- {{cssxref("scroll-target-group")}}
192196
- {{cssxref("::scroll-button()")}}
193197
- {{cssxref("::scroll-marker-group")}}
194198
- {{cssxref(":target-current")}}

files/en-us/web/css/css_overflow/css_carousels/index.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Users can move through the items by clicking or activating navigational buttons
2323

2424
A key feature of carousels is **pagination** — the items feel like separate pieces of content that are moved between rather than forming one continuous section of content. You might show one item at a time or several items on each carousel "page". When several items are visible, you might show an entirely new group of items each time the "next" or "previous" button is pressed. Alternatively, you could add a single new item to one end of the list while moving the item at the other end out of view.
2525

26-
Creating carousels with JavaScript can be quite brittle and challenging to implement. They require scripts to associate scroll markers with the items they represent while continuously updating the scroll buttons to keep them operating correctly. When carousels are created using JavaScript, the accessibility of the carousel and the associated controls has to be added in.
26+
Carousels can be quite brittle and challenging to implement with JavaScript. They require scripts to associate scroll markers with the items they represent while continuously updating the scroll buttons to keep them operating correctly. When carousels are created using JavaScript, the accessibility of the carousel and the associated controls has to be added in.
2727

2828
Fortunately, we can create accessible carousels with associated controls without the use of JavaScript, using CSS carousel features.
2929

@@ -246,7 +246,7 @@ Scroll markers are a group of buttons, each one of which scrolls the carousel to
246246
In this section, we will add scroll markers to the carousel, which involves three main features:
247247

248248
- The {{cssxref("scroll-marker-group")}} property is set on the scroll container element. It needs to be set to a non-`none` value for the {{cssxref("::scroll-marker-group")}} pseudo-element to be generated; its value specifies where the scroll marker group appears in the carousel's tab order and layout box order (but not DOM structure) — `before` puts it at the start, before the scroll buttons, while `after` puts it at the end.
249-
- The {{cssxref("::scroll-marker-group")}} pseudo-element exists inside a scroll container, and is used to collect together and lay out scroll markers.
249+
- The {{cssxref("::scroll-marker-group")}} pseudo-element exists inside a scroll container, and is used to collect together, contain, and lay out scroll markers as a whole group.
250250
- {{cssxref("::scroll-marker")}} pseudo-elements exist inside the children and {{cssxref("::column")}} fragments of a scroll container ancestor, and represent their scroll markers. These are collected inside the ancestor's {{cssxref("::scroll-marker-group")}} for layout purposes.
251251

252252
To begin with, the list's `scroll-marker-group` property is set to `after`, so the `::scroll-marker-group` pseudo-element is placed after the list's DOM content in the focus and layout box order; this means it comes after the scroll buttons:
@@ -257,6 +257,9 @@ ul {
257257
}
258258
```
259259

260+
> [!NOTE]
261+
> Alternatively, a scroll marker group container can be created from an existing element containing a set of {{htmlelement("a")}} elements using {{cssxref("scroll-target-group")}}.
262+
260263
Next, the list's `::scroll-marker-group` pseudo-element is positioned relative to the carousel using CSS anchor positioning, similar to the scroll button's, except that it is horizontally centered on the carousel using a {{cssxref("justify-self")}} value of `anchor-center`. The group is laid out using flexbox, with a {{cssxref("justify-content")}} value of `center` and a {{cssxref("gap")}} of `20px` so that its children (the `::scroll-marker` pseudo-elements) are centered inside the `::scroll-marker-group` with a gap between each one.
261264

262265
```css live-sample___first-example
@@ -297,7 +300,7 @@ li::scroll-marker:target-current {
297300
```
298301

299302
> [!NOTE]
300-
> Accessibility-wise, the scroll marker group and contained scroll markers are rendered with [`tablist`](/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/tablist_role)/[`tab`](/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/tab_role) semantics. When you <kbd>Tab</kbd> to the group with the keyboard, it behaves like a single item (that is, another press of the <kbd>Tab</kbd> key will move past the group to the next item), and you can move between the different scroll markers using the left and right (or up and down) cursor keys.
303+
> When a scroll marker group container is created on a scroll container using the `scroll-marker-group` property, the scroll container is rendered with [`tablist`](/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/tablist_role)/[`tab`](/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/tab_role) semantics. You can <kbd>Tab</kbd> to it with the keyboard, then move between the different "pages" using the left and right (or up and down) cursor keys, which also changes the state of the associated scroll markers and scroll buttons as expected. The scroll markers can also be tabbed between normally, as expected.
301304
302305
## Single page carousel final result
303306

@@ -519,7 +522,7 @@ ul::scroll-marker-group {
519522

520523
### Column scroll markers
521524

522-
The CSS for creating the scroll markers in this demo is nearly identical to the [previous demo](#creating_scroll_markers), except that the selectors are different — the scroll markers are created on the generated `::column` scroll markers rather than the list items (note how we are including two pseudo-elements here, to generate scroll markers on the generated columns).
525+
The CSS for creating the scroll markers in this demo is nearly identical to the [previous demo](#creating_scroll_markers), except that the selectors are different — the scroll markers are created on the generated `::column` pseudo-elements rather than the list items. Note how we are including two pseudo-elements here to generate scroll markers on the generated columns.
523526

524527
```css live-sample___second-example
525528
ul::column::scroll-marker {

files/en-us/web/css/css_overflow/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ A link is included in the content box above to demonstrate the effects of keyboa
227227
- {{CSSxRef("overflow-y")}}
228228
- {{CSSxRef("scroll-behavior")}}
229229
- {{cssxref("scroll-marker-group")}}
230+
- {{cssxref("scroll-target-group")}}
230231
- {{CSSxRef("scrollbar-gutter")}}
231232
- {{CSSxRef("text-overflow")}}
232233

files/en-us/web/css/scroll-marker-group/index.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ sidebar: cssref
1010

1111
{{seecompattable}}
1212

13-
The **`scroll-marker-group`** [CSS](/en-US/docs/Web/CSS) property controls whether a {{glossary("scroll container")}} has a {{cssxref("::scroll-marker-group")}} pseudo-element generated and, if so, whether it should be placed immediately `before` _or_ `after` the container's contents in the default visual and tabbing order.
13+
The **`scroll-marker-group`** [CSS](/en-US/docs/Web/CSS) property controls whether a {{glossary("scroll container")}} element has a {{cssxref("::scroll-marker-group")}} pseudo-element generated. If present, the property also specifies whether the scroll marker group should be placed `before` _or_ `after` the contents of the scroll group container in the default visual and tab order.
14+
15+
> [!NOTE]
16+
> To create a scroll marker group container from an existing element that contains a set of {{htmlelement("a")}} elements, use the {{cssxref("scroll-target-group")}} property. Read about the [differences in behavior](/en-US/docs/Web/CSS/scroll-target-group#differences_between_scroll-target-group_and_scroll-marker-group) between the two.
1417
1518
## Syntax
1619

@@ -40,7 +43,7 @@ scroll-marker-group: unset;
4043
- : No `::scroll-marker-group` pseudo-element will be generated on the element. This is the default value.
4144

4245
> [!NOTE]
43-
> It is a best practice to match the visual rendering position of the scroll marker group with the tab order. When positioning the marker group at the start of the content with styles applied to {{cssxref("::scroll-marker-group")}}, put it at the beginning of the tab order using `before`. When positioning the group at the end of the content, put it at the end of the tab order using `after`.
46+
> As an accessibility best practice, match the visual rendering position of the scroll marker group container with the tab order. When positioning the marker group at the start of the content with styles applied to {{cssxref("::scroll-marker-group")}}, put it at the beginning of the tab order using `before`. When positioning the group at the end of the content, put it at the end of the tab order using `after`.
4447

4548
## Formal definition
4649

@@ -88,7 +91,7 @@ We have a basic HTML {{htmlelement("ul")}} list with several {{htmlelement("li")
8891

8992
We convert our `<ul>` into a carousel by setting the {{cssxref("display")}} to `flex`, creating a single, non-wrapping row of `<li>` elements. The {{cssxref("overflow-x")}} property is set to `auto`, meaning if the items overflow their container on the x-axis, the content will scroll horizontally. We then convert the `<ul>` into a [scroll-snap container](/en-US/docs/Glossary/Scroll_snap#scroll_snap_container), ensuring that items always snap into place when the container is scrolled with a {{cssxref("scroll-snap-type")}} value of `mandatory`.
9093

91-
We create a scroll marker group with the `scroll-marker-group` property, placing the group after all the content.
94+
We create a scroll marker group container with the `scroll-marker-group` property, placing the group after all the content.
9295

9396
```css
9497
ul {
@@ -167,7 +170,7 @@ label {
167170

168171
{{EmbedLiveSample("Examples", '', '300')}}
169172

170-
Note the placement of the scroll marker group. Check out how the keyboard tabbing order is different for `before` versus `after`, and note how the group disappears when the value is set to `none`.
173+
Note the placement of the scroll marker group container. Check out how the keyboard tabbing order is different for `before` versus `after`, and note how the group disappears when the value is set to `none`.
171174

172175
## Specifications
173176

@@ -179,6 +182,7 @@ Note the placement of the scroll marker group. Check out how the keyboard tabbin
179182

180183
## See also
181184

185+
- {{cssxref("scroll-target-group")}}
182186
- {{cssxref("::scroll-button()")}}
183187
- {{cssxref("::scroll-marker-group")}}
184188
- {{cssxref("::scroll-marker")}}

0 commit comments

Comments
 (0)