The list-style property
list-style sets how markers look in ul and ol lists: the marker type, its position and an image. It is a shorthand for list-style-type, list-style-position and list-style-image.
Syntax
list-style: <type> <position> <image>;
list-style: disc | circle | square | decimal | upper-roman | none;
list-style: inside | outside;
list-style: square inside; - Initial value
disc outside none- Inherited
- yes
- Applies to
- list items (display: list-item, such as li); convenient to set on ul or ol, since the property is inherited
Values
| Value | What it does |
|---|---|
none | no marker — what menus and navigation use |
disc | a filled circle — the default for ul |
circle | a hollow circle |
square | a square |
decimal | numbers 1, 2, 3 — the default for ol |
upper-roman | Roman numerals I, II, III |
inside | the marker inside the item box, with the text wrapping around it |
outside | the marker to the left, outside the text — the default |
Example
.menu {
list-style: none;
padding: 0;
display: flex;
gap: 16px;
}
.square { list-style: square inside; }
.roman { list-style: upper-roman; }
li::marker { color: #0284c7; } <ul class="menu">
<li>Home</li>
<li>Courses</li>
<li>Contact</li>
</ul>
<ul class="square">
<li>square, inside</li>
<li>square, inside</li>
</ul>
<ol class="roman">
<li>Roman numerals</li>
<li>Roman numerals</li>
<li>Roman numerals</li>
</ol> Result
Good to know
- list-style: none removes the markers but not the indent: browsers give ul and ol a padding-left (about 40px). For a menu add padding: 0.
- The ::marker pseudo-element changes the marker's color and size, for example li::marker { color: … }.
- In Safari with VoiceOver a list with list-style: none may stop being announced as a list. If that matters to readers, add role="list" to the ul.
Sources and specification
- MDN: the list-style property — MDN Web Docs
- CSS Lists and Counters Module Level 3 (W3C) — W3C
See also
The display property
The CSS display property sets how an element takes part in layout: as a block, inline with text, as a flex or grid container, or not at all. Values, examples.
The padding property
The CSS padding property sets the inner space between the border and the content: the 1–4 value forms, percentages, its effect on width and box-sizing.
The <ul> tag
Purpose of <ul>: a list of items with no meaningful order, each item an <li>.
The <ol> tag
The HTML <ol> tag creates an ordered list where the sequence matters. The start, reversed and type attributes, <li> items and a ready example.
Build a navigation menu
Practice exercise: build a semantic navigation menu using <nav> and a list of links.
CSS Flexbox for beginners
A beginner's guide to CSS Flexbox: display: flex, axes, justify-content, align-items, flex-wrap, gap and flex: 1, with examples of a menu, cards and centering.