CSS Reference ยท Pseudo-elements
The ::marker pseudo-element
Reference for the CSS ::marker pseudo-element: change the color, size and content of list bullets and numbers without extra markup, with supported properties.
The ::marker pseudo-element selects the marker box of a list item: the bullet of a <ul>, the number of an <ol>, or the arrow of a <summary>. It exists on any element whose display is list-item.
Before ::marker, changing only the bullet color meant hiding the native marker and faking one with ::before. Now you can style the real marker, which keeps numbering, accessibility and list-style behavior intact.
li::marker { color: #e8590c; font-weight: bold; }
Try it
Syntax
selector::marker { /* a limited set of properties */ }
| Property | Value |
|---|---|
| Applies to | List items and other display: list-item elements |
| Inherited | Inherits from the list item |
| Animatable | Its properties follow their own animation rules |
Values
The pseudo-element takes no arguments. Supported properties:
| Property | Description |
|---|---|
color |
Color of the bullet or number. |
font-* |
Size, weight, family and variant of the marker text. |
content |
Replaces the marker with your own text or image. |
white-space, direction, unicode-bidi, text-combine-upright |
Text handling. |
animation-*, transition-* |
Animations of allowed properties. |
Box properties such as background, padding and margin do not apply. Use list-style-position and the spacing of the <li> itself to move markers.
Usage notes
- Pair with
list-style-type. Uselist-style-typeto choose the symbol and::markerto color it. - Counters.
::markercan show a counter withcontent: counter(list-item) ". ". - Summary arrow.
summary::markerstyles the disclosure triangle of<details>;summary { list-style: none; }removes it. - Alignment is limited. You cannot offset a marker with margins. If you need full control, use
::beforeon a list without markers. - Not on every element. A
<div>has no marker unless you setdisplay: list-item. - Accessibility. A marker added via
contentmay be read aloud. Keep it short or use an alternative text form.
Browser support
Supported in all current browsers. Older versions of Safari accepted only color and font-size, so test other properties if you need to support them.
Related
list-stylelist-style-positioncontent- Lesson: Lists