CSS list-style-position Property

The CSS list-style-position property controls whether a list item marker appears inside or outside the list item's principal content box.

It accepts two values, inside and outside. The choice affects marker placement, text wrapping, and alignment, particularly when list items contain multiple lines of text.

list-style-position Syntax

The property accepts either inside or outside.

Basic Syntax

selector {
  list-style-position: outside;
}

Outside Markers

ul {
  list-style-position: outside;
}

Inside Markers

ul {
  list-style-position: inside;
}

CSS-Wide Keywords

ul {
  list-style-position: initial;
}
ul {
  list-style-position: inherit;
}
ul {
  list-style-position: unset;
}
ul {
  list-style-position: revert;
}
ul {
  list-style-position: revert-layer;
}

The initial value is outside, which places the marker outside the list item's principal content box.

Property Values

The list-style-position property has two primary values.

Value Description
outside Places the marker outside the principal content box. It does not participate in the normal inline formatting of the list item's content.
inside Places the marker as an inline element at the beginning of the list item's principal content box.
initial Resets the property to outside.
inherit Uses the computed value from the parent element.
unset Uses the inherited value because the property is inherited.
revert Reverts the property according to cascade origin rules.
revert-layer Reverts the property according to cascade layer rules.

Property Characteristics

Characteristic Value
Initial value outside
Inherited Yes
Applies to List items
Computed value As specified
Animation type Discrete
Percentages Not applicable
Primary purpose Control marker placement relative to list item content

The property is commonly applied to <ul> or <ol> elements so their list items inherit the same positioning value.

How It Works

Browsers generate a marker box for elements with the list-item display type. The list-style-position property determines how that marker box participates in layout.

HTML Example

<ul>
  <li>HTML Elements</li>
  <li>CSS Properties</li>
  <li>JavaScript Basics</li>
</ul>

Outside Position

ul {
  list-style-position: outside;
}

The marker appears outside the principal content box. The text begins at the content edge.

Inside Position

ul {
  list-style-position: inside;
}

The marker appears at the beginning of the inline content, taking up space in the first line.

Important Consideration

The property changes marker placement, not marker shape or numbering. Use list-style-type to control marker appearance.

outside Value

The outside value places the marker outside the list item's principal content box. It is the default value.

Basic Example

ul {
  list-style-position: outside;
}

Outside Square Markers

ul {
  list-style-type: square;
  list-style-position: outside;
}

Outside Decimal Markers

ol {
  list-style-type: decimal;
  list-style-position: outside;
}

Outside Markers with Indentation

ul {
  list-style-position: outside;
  padding-left: 2rem;
}

Advantages

  • Wrapped text normally aligns with the beginning of the first line's text.
  • Markers remain visually separate from the content.
  • It works well for paragraphs and longer list items.
  • It provides familiar list formatting.

Important Consideration

Outside markers may extend beyond the intended container if list indentation is removed. Allow sufficient space using padding or other layout adjustments.

inside Value

The inside value places the marker within the list item's principal content box, as part of its inline content.

Basic Example

ul {
  list-style-position: inside;
}

Inside Circle Markers

ul {
  list-style-type: circle;
  list-style-position: inside;
}

Inside Decimal Markers

ol {
  list-style-type: decimal;
  list-style-position: inside;
}

Inside Markers Without Indentation

ul {
  list-style-position: inside;
  padding-left: 0;
}

Advantages

  • The marker occupies space within the content box.
  • It can be useful when markers need to remain within a bordered or colored list item.
  • It can simplify layouts where the list has little or no left padding.
  • It provides a different wrapping behavior from outside markers.

Important Consideration

Wrapped lines may begin at the content box edge rather than aligning with the text following the marker. This can make long list items less visually consistent.

Text Wrapping

The difference between inside and outside becomes especially noticeable when a list item contains enough text to wrap onto multiple lines.

Outside Marker Wrapping

.outside-list {
  list-style-position: outside;
  width: 240px;
}

The marker sits outside the principal content box, while wrapped text normally aligns with the beginning of the first line's text.

Inside Marker Wrapping

.inside-list {
  list-style-position: inside;
  width: 240px;
}

The marker takes up space in the first line. Subsequent lines can begin at the content box edge, underneath the marker area.

HTML Example

<ul class="outside-list">
  <li>CSS properties control the appearance and layout of HTML elements across a web page.</li>
</ul>
<ul class="inside-list">
  <li>CSS properties control the appearance and layout of HTML elements across a web page.</li>
</ul>

Important Consideration

For multi-line list items, outside is generally easier to read because it provides more consistent text alignment.

Marker Alignment

Marker alignment depends on the positioning value, marker type, font metrics, and list layout.

Default Alignment

ul {
  list-style-position: outside;
}

Marker Within a Border

.bordered-list {
  list-style-position: inside;
  padding-left: 0;
}
.bordered-list li {
  border: 1px solid #cbd5e1;
  padding: 10px;
}

The marker appears inside the bordered content area.

Outside Marker with Border

.bordered-list {
  list-style-position: outside;
}
.bordered-list li {
  border: 1px solid #cbd5e1;
  padding: 10px;
}

The marker is positioned outside the principal content box and may appear outside the item's border.

Important Consideration

The property does not provide precise marker offsets. For custom marker placement, a pseudo-element may offer greater control.

Unordered Lists

Unordered lists use bullet-style markers by default. The positioning property works with any supported marker type.

Disc Outside

ul {
  list-style-type: disc;
  list-style-position: outside;
}

Disc Inside

ul {
  list-style-type: disc;
  list-style-position: inside;
}

Square Outside

ul {
  list-style-type: square;
  list-style-position: outside;
}

Circle Inside

ul {
  list-style-type: circle;
  list-style-position: inside;
}

Important Consideration

Changing the position of a marker does not change the semantic purpose of an unordered list.

Ordered Lists

Ordered lists use numbered or sequential markers. The list-style-position property determines whether those markers appear inside or outside the content box.

Decimal Outside

ol {
  list-style-type: decimal;
  list-style-position: outside;
}

Decimal Inside

ol {
  list-style-type: decimal;
  list-style-position: inside;
}

Roman Numerals Outside

ol {
  list-style-type: upper-roman;
  list-style-position: outside;
}

Alphabetic Markers Inside

ol {
  list-style-type: lower-alpha;
  list-style-position: inside;
}

Important Consideration

Long numbered lists may require additional indentation when using outside, especially when markers contain multiple digits or Roman numerals.

Image Markers

The list-style-position property also controls the placement of image markers specified with list-style-image.

Image Marker Outside

ul {
  list-style-image: url("images/checkmark.svg");
  list-style-position: outside;
}

Image Marker Inside

ul {
  list-style-image: url("images/checkmark.svg");
  list-style-position: inside;
}

Image with Fallback Marker

ul {
  list-style-type: disc;
  list-style-image: url("images/checkmark.svg");
  list-style-position: outside;
}

Important Consideration

The positioning property does not control the image's dimensions. Image sizing depends on the image itself and the applicable marker sizing rules.

list-style Shorthand

The list-style shorthand combines marker type, position, and image into a single declaration.

Separate Properties

ul {
  list-style-type: square;
  list-style-position: inside;
  list-style-image: none;
}

Equivalent Shorthand

ul {
  list-style: square inside;
}

Outside Decimal Markers

ol {
  list-style: decimal outside;
}

Inside Image Markers

ul {
  list-style: disc inside url("images/checkmark.svg");
}

Shorthand Reset Behavior

ul {
  list-style-position: inside;
  list-style: square;
}

The shorthand resets the position to outside because the position component was omitted.

Important Consideration

When using the shorthand, include the desired position value if you do not want it reset to the initial value.

Spacing and Indentation

The list-style-position property works with margins and padding to determine how markers and list content fit within the available space.

Outside Markers with Padding

ul {
  list-style-position: outside;
  padding-left: 2rem;
}

Inside Markers Without Padding

ul {
  list-style-position: inside;
  padding-left: 0;
}

Compact List Layout

.compact-list {
  list-style-position: inside;
  margin: 0;
  padding: 0;
}

Spacing Between List Items

.spaced-list {
  list-style-position: outside;
  padding-left: 1.75rem;
}
.spaced-list li {
  margin-bottom: 0.5rem;
}

Important Consideration

Removing indentation while using outside markers may cause markers to extend beyond the list container. Check the result at different viewport widths.

Nested Lists

Nested lists can use different marker positions at different levels.

HTML Example

<ul class="nested-list">
  <li>HTML
    <ul>
      <li>Elements</li>
      <li>Attributes</li>
    </ul>
  </li>
  <li>CSS
    <ul>
      <li>Selectors</li>
      <li>Properties</li>
    </ul>
  </li>
</ul>

CSS Example

.nested-list {
  list-style-position: outside;
}
.nested-list ul {
  list-style-position: inside;
}

Different Marker Types

.nested-list {
  list-style: disc outside;
}
.nested-list ul {
  list-style: circle inside;
}

Important Consideration

Nested lists inherit positioning values unless a more specific declaration overrides them. Explicit styles help maintain predictable layouts.

Inheritance

The list-style-position property is inherited, allowing list items to use the value declared on their parent list.

Parent List Declaration

ul {
  list-style-position: inside;
}

Override a List Item

ul li.special {
  list-style-position: outside;
}

Explicit Inheritance

li {
  list-style-position: inherit;
}

Reset to the Initial Value

li {
  list-style-position: initial;
}

The initial value is outside.

Important Consideration

Inherited positioning can affect nested lists. Use scoped selectors when different list sections require different layouts.

Accessibility

Marker positioning affects visual layout but does not change the semantic meaning of an HTML list.

Use Semantic List Elements

<ul>
  <li>HTML Elements</li>
  <li>CSS Properties</li>
  <li>JavaScript Basics</li>
</ul>

Consider Multi-Line Readability

Outside markers generally provide more consistent alignment for wrapped text. This can improve readability for longer list items.

Allow Space for Markers

Outside markers should remain visible when text is enlarged or the viewport becomes narrow.

Preserve List Structure

Do not replace semantic lists with paragraphs containing manually typed bullet characters simply to achieve a particular visual layout.

Important Consideration

Choose marker positioning based on readability and layout requirements. Test lists with text resizing and narrow viewports.

list-style-position Example

This example compares outside and inside markers using list items with enough text to wrap onto multiple lines.

HTML Example

<div class="list-position-demo">
  <div class="demo-item">
    <h3>Outside Markers</h3>
    <ul class="outside-list">
      <li>HTML provides the structure and meaning of web page content.</li>
      <li>CSS controls the appearance and layout of HTML elements.</li>
    </ul>
  </div>
  <div class="demo-item">
    <h3>Inside Markers</h3>
    <ul class="inside-list">
      <li>HTML provides the structure and meaning of web page content.</li>
      <li>CSS controls the appearance and layout of HTML elements.</li>
    </ul>
  </div>
</div>

CSS Example

.list-position-demo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}
.list-position-demo .demo-item {
  padding: 15px;
  border: 1px solid #cbd5e1;
  background-color: #f8fafc;
}
.list-position-demo h3 {
  margin: 0 0 12px;
  font-size: 1rem;
}
.list-position-demo ul {
  margin: 0;
}
.list-position-demo li {
  margin-bottom: 12px;
}
.list-position-demo .outside-list {
  list-style-type: disc;
  list-style-position: outside;
  padding-left: 1.5rem;
}
.list-position-demo .inside-list {
  list-style-type: disc;
  list-style-position: inside;
  padding-left: 0;
}
Browser Result

Outside Markers

  • HTML provides the structure and meaning of web page content.
  • CSS controls the appearance and layout of HTML elements.

Inside Markers

  • HTML provides the structure and meaning of web page content.
  • CSS controls the appearance and layout of HTML elements.

With outside, wrapped text normally aligns with the beginning of the first line's text. With inside, the marker occupies space in the first line, and subsequent lines can begin at the content box edge.

Switch Both Lists to Outside

.list-position-demo ul {
  list-style-position: outside;
  padding-left: 1.5rem;
}

Switch Both Lists to Inside

.list-position-demo ul {
  list-style-position: inside;
  padding-left: 0;
}

These changes affect marker placement without changing the list content or marker type.

Common Mistakes

Confusing Position with Marker Type

list-style-position controls placement. Use list-style-type to change bullets, numbers, or other marker styles.

Expecting Precise Marker Offsets

The property only accepts inside and outside. It does not accept pixel or percentage offsets.

Removing All Padding with Outside Markers

Outside markers can extend beyond the intended container when insufficient space is available.

Ignoring Text Wrapping

Inside markers can cause continuation lines to align differently from the first line's text.

Overwriting Position with the Shorthand

ul {
  list-style-position: inside;
  list-style: square;
}

The shorthand resets the position to outside.

Applying the Property to Ordinary Blocks

Marker positioning affects list-item boxes. An ordinary block does not generate a list marker simply because the property is declared.

Forgetting Inheritance

Nested lists can inherit the marker position from their ancestors unless explicitly overridden.

Using Inside for Every Long List

Inside positioning may be less readable for long, wrapped list items.

Assuming Position Changes HTML Semantics

Marker positioning does not change whether a list is ordered or unordered.

Ignoring Responsive Layouts

List marker placement and indentation should be checked on narrow screens and at larger text sizes.

Important Considerations

Keep the following points in mind when using list-style-position:

  • The property controls the placement of list item markers.
  • It accepts inside and outside.
  • The initial value is outside.
  • The property is inherited.
  • It applies to list items.
  • The outside value places the marker outside the principal content box.
  • The inside value places the marker within the principal content box.
  • Outside markers do not participate in normal inline content formatting.
  • Inside markers occupy space at the beginning of the inline content.
  • Marker position affects how text wraps.
  • Outside markers generally provide more consistent alignment for multi-line items.
  • Inside markers can be useful for bordered or compact list layouts.
  • The property works with standard bullets and numbered markers.
  • It also works with image markers.
  • It does not change marker shape or numbering style.
  • Use list-style-type to change marker appearance.
  • Use list-style-image to specify image markers.
  • The list-style shorthand includes marker positioning.
  • Omitted shorthand components reset to their initial values.
  • Margins and padding influence available marker space.
  • Outside markers may extend beyond containers with insufficient indentation.
  • The property does not provide precise marker offsets.
  • Nested lists may inherit positioning values.
  • Different list levels can use different positions.
  • Marker positioning does not change HTML list semantics.
  • Choose positioning based on readability and layout requirements.
  • Test the result with wrapped text and narrow viewports.

Browser Support

The CSS list-style-position property is widely supported across modern browsers, including Chrome, Edge, Firefox, Safari, and Opera.

Both inside and outside have long-established browser support. Minor differences in marker alignment and spacing may occur because of browser layout and font rendering.

For current compatibility information, visit Can I Use? and search for list-style-position.

Specifications

The list-style-position property is defined in the CSS Lists and Counters Module Level 3 specification.

CSS Lists and Counters Module Level 3: list-style-position

The specification defines the positioning of marker boxes relative to list item content.

For additional documentation and examples, consult MDN Web Docs.

MDN Web Docs: list-style-position