CSS propertyInteraction and more
list-style-position
Sets whether the list marker sits outside or inside the element’s block.
- Initial value
outside- Inherited
- Yes
- Animatable
- no
- Applies to
- list items (display: list-item)
- JavaScript
element.style.listStylePosition = "inside"
Example
#CSS
.steps {
list-style-position: inside;
}
.steps li {
padding: 8px 12px;
border-radius: 8px;
background: #18181b;
}Example HTML
<ol style="list-style-position: inside; margin: 0; padding: 0; display: grid; gap: 6px;">
<li style="padding: 8px 12px; border-radius: 8px; background: #18181b;">Create an account</li>
<li style="padding: 8px 12px; border-radius: 8px; background: #18181b;">Choose your first course</li>
</ol>Preview
Definition and usage
#The list-style-position property decides where a list item’s marker is drawn. With outside (the default) the marker hangs to the left of the text block, and subsequent lines align with the first line of text.
With inside, the marker becomes part of the first line of text, and wrapped lines start under the marker, at the block’s edge.
The difference is easiest to see with longer, wrapping items and with list items that have a background or border.
Syntax
#Syntax
list-style-position: outside | inside;Values
#Values in practice
#outside
The marker is outside the element’s background, the text is aligned in a column.
.demo { list-style-position: outside; }inside
The marker is in the first line, inside the background.
.demo { list-style-position: inside; }Browser support
#Widely available
Works in all modern browsers, phones included. You can use it without worry.
- Chrome
- Edge
- Firefox
- Safari
Good practices
#- In lists with a background on the items,
insideusually looks better, because the number doesn’t stick out of the tile. - For long text,
outsideis more readable, because the lines form an even column.
Related entries
#Spotted a mistake or missing an example? Write to us.