Tag list-style-position

📍 CSS list-style-position: Aligning List Markers with Precision

When working with lists in HTML, you may notice that the default bullet or number appears outside the text block. But what if you want to move it inside for better alignment or tighter design? That’s where list-style-position comes in.

This property lets you control where the list marker (bullet or number) appears in relation to the content — inside the content box or outside of it.


🧾 What is list-style-position?

The CSS list-style-position property defines the position of the list marker (e.g., bullet, number, or custom image) relative to the list item’s content.


🧬 Syntax

selector {
list-style-position: inside | outside;
}

Values:

ValueDescription
outside(Default) The marker appears outside the content box. Text wraps below.
insideThe marker appears inside the content box, aligning with the text.

🎯 Visual Example

1. Default (outside):

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

📌 Output:

• This is a long list item
that wraps to the next line.

2. Inside:

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

📌 Output:

• This is a long list item
that wraps to the next line.

Notice that with inside, the bullet moves inward, and the text wraps beneath it.


🧠 How It Works

  • The inside value pulls the bullet into the padding/content area of the list item.
  • The outside value keeps it in the margin area (standard browser behavior).
  • You may need to adjust padding or text-indent for consistent alignment depending on the layout.

🛠️ Use Cases

✅ Use inside when:

  • You want tight vertical spacing.
  • You’re designing mobile-friendly or compact interfaces.
  • You want the bullet to align with wrapped lines.

✅ Use outside when:

  • You prefer the default look and spacing.
  • You want a clear distinction between bullet and content.
  • You’re following traditional document-style formatting.

👩‍💻 Example Code

<ul class="example-list">
<li>Apples</li>
<li>Bananas</li>
<li>Cherries</li>
</ul>
.example-list {
list-style-type: disc;
list-style-position: inside;
}

✅ Browser Support

Fully supported across all major browsers:

  • ✅ Chrome
  • ✅ Firefox
  • ✅ Safari
  • ✅ Edge
  • ✅ Internet Explorer 6+

🔚 Conclusion

The CSS list-style-position property gives you layout-level control over where bullets or numbers appear. Whether you’re designing for elegance, compactness, or traditional style, this simple property helps your lists look just right.