Scroll marker target pseudo-classes
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The :target-after CSS pseudo-class selects scroll markers that come after the active scroll marker (the one that currently matches :target-current) within a scroll marker group. You can use this selector to style navigation items that come after the current navigation position within a scroll marker group.
Note: The :target-after pseudo-class is only valid on ::scroll-marker pseudo-elements and elements that have been designated as scroll markers via the scroll-target-group property.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
:target-after Experimental | 142 | 142 | | | 142 | |
| Other | ||||||
css.selectors.target-before Experimental | 142 | 142 | | | 142 | |
css.selectors.target-current Experimental `:target-current` | 135 | 135 | | | 135 | |
1+Supported (version) Not supported ※Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)
Syntax
CSS
.item::scroll-marker:target-current {
background: #3498db;
}
.item::scroll-marker:target-before {
opacity: 0.5;
} Live demo
Use cases
-
Using Scroll marker target pseudo-classes
Experimental: This is an experimental technology
Cautions
- Limited browser support. Check compatibility before use.
Accessibility
- Make sure visual changes are conveyed appropriately to assistive technology.