CSS Portal

::scroll-marker-group CSS Pseudo Element

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The ::scroll-marker-group pseudo-element in CSS is used to represent a collection of scroll markers within a scroll container. Scroll markers are indicators placed along a scrollable area, often used in contexts like paged media, printing previews, or accessibility interfaces to denote significant positions in the content. This pseudo-element groups multiple markers together, allowing authors to style them collectively rather than individually.

This pseudo-element is particularly relevant when combined with scroll snapping behaviors. By targeting the group of markers instead of each marker individually, developers can apply styles such as color, background-color, or transform to create visual cues along the scroll axis. For example, a developer might highlight all markers that represent section boundaries in a long document.

The ::scroll-marker-group pseudo-element is often used in combination with the ::scrollbar or ::scrollbar-thumb pseudo-elements to create enhanced custom scrolling experiences. It allows for fine-grained visual control without interfering with the default scrolling behavior of the container.

Here’s a practical example demonstrating basic styling of a scroll marker group:

<div class="scroll-container">
  <div class="content">
    <section>Section 1</section>
    <section>Section 2</section>
    <section>Section 3</section>
  </div>
</div>
.scroll-container {
  scroll-snap-type: y mandatory;
  overflow-y: scroll;
  height: 300px;
}

.scroll-container::scroll-marker-group {
  background-color: rgba(0, 128, 255, 0.2);
  height: 6px;
  border-radius: 3px;
}

In this example, the ::scroll-marker-group pseudo-element provides a subtle visual track showing where scrollable content sections align, enhancing both usability and accessibility. Unlike targeting individual section elements, the pseudo-element allows styling to be applied consistently to the entire set of scroll markers at once, without additional markup or scripting.

The ::scroll-marker-group pseudo-element is still considered experimental in many browsers, so it is important to test its behavior across different platforms and provide fallback styling when necessary.

Syntax

::scroll-marker-group {
  /* ... */
}

Example

<ul class="carousel">
<li class="item" id="slide-1">1</li>
<li class="item" id="slide-2">2</li>
<li class="item" id="slide-3">3</li>
<li class="item" id="slide-4">4</li>
</ul>
/* 1. Setup the Scroll Container */
.carousel {
display: flex;
overflow-x: auto;
scroll-snap-type: x mandatory;
list-style: none;
padding: 0;
margin: 0;
width: 300px;
height: 170px;
border: 2px solid #333;

/* This property is REQUIRED to generate the ::scroll-marker-group */
/* 'after' places the group after the content in the tab order */
scroll-marker-group: after;
}

/* 2. Style the Items */
.item {
flex: 0 0 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
font-size: 3rem;
background: #eee;
scroll-snap-align: start;
}

/* 3. Generate individual markers for each item */
.item::scroll-marker {
content: ""; /* Can be text, a counter, or empty */
width: 12px;
height: 12px;
border-radius: 50%;
background-color: #ccc;
cursor: pointer;
border: none;
}

/* 4. Style the Container of the markers */
.carousel::scroll-marker-group {
display: flex;
justify-content: flex-start;
gap: 10px;
padding: 10px;
background: #f9f9f9;
}

/* 5. Style the 'Active' marker */
/* :target-current selects the marker associated with the visible item */
.item::scroll-marker:target-current {
background-color: #007bff;
transform: scale(1.2);
}

Browser Support

The following information will show you the current browser support for the CSS ::scroll-marker-group pseudo element. Hover over a browser icon to see the version that first introduced support for this CSS psuedo element.

This psuedo element is supported in some modern browsers, but not all.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 31st December 2025

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!