CSS pseudo-elementPseudo-elements

::marker

Styles a list item’s marker: the bullet in a ul list or the number in an ol list.

On this page

Example

#
CSS
.steps li::marker {
  color: #a78bfa;
  font-weight: 700;
}
Preview

Definition and usage

#

Every element with display: list-item, which by default means every <li>, has a marker: a dot, circle, square, or number. The ::marker pseudo-element lets you style it separately, without ::before tricks and without turning off bullets. The item’s text stays unchanged.

The set of supported properties is limited: colour, font properties, content, white-space, plus animations and transitions. Background, margins, or border won’t work. The marker’s position (inside or outside the text block) is set with list-style-position on the list item itself.

The symbol itself is easiest to change with the list-style-type property on the list, for example list-style-type: "✓ " or upper-roman. ::marker is then useful for colour and weight, so that numbers are purple and bold while the text stays regular.

Syntax

#
Syntax
selector::marker { property: value; }

Common styles

#
  • color

    Purple numbers next to regular item text.
  • font-weight

    Bold, larger numbers. The item text doesn’t change.
  • list-style-type + ::marker

    You set the symbol on the list with list-style-type and its colour with ::marker.
  • li:hover::marker

    Hover over a list item: only the colour of its number changes.

Common styles in practice

#

color

Purple numbers next to regular item text.
.demo li::marker { color: #a78bfa; }

font-weight

Bold, larger numbers. The item text doesn’t change.
.demo li::marker {
  color: #fbbf24;
  font-weight: 800;
  font-size: 1.15em;
}

list-style-type + ::marker

You set the symbol on the list with list-style-type and its colour with ::marker.
.demo { list-style-type: "✓ "; }
.demo li::marker { color: #10b981; }

li:hover::marker

Hover over a list item: only the colour of its number changes.
.demo li:hover::marker { color: #f43f5e; }

Browser support

#

Widely available

Works in all modern browsers, phones included. You can use it without worry.

  • Chrome
  • Edge
  • Firefox
  • Safari

Good practices

#
  • Use list-style-type to change the symbol itself and ::marker for colour and font. This split is the simplest and most predictable.
  • If you remove bullets with list-style: none, VoiceOver in Safari may stop announcing the element as a list. Adding role="list" to the <ul> or <ol> helps.

Related entries

#

Spotted a mistake or missing an example? Write to us.