CSS Reference ยท Lists, Tables and Generated Content
The list-style-image property
Reference for the CSS list-style-image property: use an image as the list marker, set a fallback type, and learn why ::marker or ::before often work better.
The list-style-image property replaces the marker of a list item with an image. If the image fails to load, the browser falls back to the marker given by list-style-type.
CSS
ul.checks { list-style-image: url("/images/check.svg"); list-style-type: square; /* fallback */ }
Try it
Syntax
CSS
list-style-image: none | <image>;
| Initial value | none |
| Applies to | List items |
| Inherited | Yes |
| Animatable | No |
| Computed value | none, or the image with its URL made absolute |
Values
| Value | Description |
|---|---|
none |
No image; the marker comes from list-style-type. |
url(...) |
An image file. Bitmaps and SVG both work. |
Other <image> values |
Gradients and image-set() are accepted syntactically, but a gradient has no natural size, so results vary; prefer SVG or bitmap files. |
Usage notes
- Limited control. You cannot size, position or recolor the image with this property. It is shown at its natural size (SVGs need
widthandheightattributes), and its vertical alignment is up to the browser. - Prefer
::markeror::before. Putting a background image or an inline SVG on a::beforepseudo-element, or usingcontenton::marker, gives full control of size and alignment. - Always give a fallback. Set
list-style-typetoo, so a missing or blocked image does not leave the list without markers. - Not recolored. An SVG marker does not inherit
currentColorfrom the list text. - Meaning. If the bullet carries meaning (a check or a cross), say it in text as well, since images in markers are not exposed to assistive technology.
- Relative URLs resolve against the style sheet that contains the rule, not the page.
Browser support
Supported in all browsers for url() images. Treat gradients as unreliable and check a compatibility table before using them.
Related
list-styleโ shorthandlist-style-type::marker- Lesson: Styling lists