Explanation and Usage: list-inside list-disc whitespace-normal [li&]:pl-6
This article explains the Tailwind CSS utility combination list-inside list-disc whitespace-normal [li&]:pl-6, shows when to use it, and gives practical examples and tips.
What each utility does
- list-inside — positions list markers (bullets) inside the content box so they align with text flow rather than hanging in the margin.
- list-disc — uses a filled circle as the list marker (disc).
- whitespace-normal — collapses consecutive whitespace and allows lines to wrap normally. Useful when list items contain long text or inline elements.
- [li&]:pl-6 — a variant using Tailwind’s arbitrary selector to apply
pl-6(padding-left: 1.5rem) to eachliinside the element. The selector targetslielements via theli&pattern so the padding applies to list items without affecting the container itself.
Why combine them
- Ensures bullets appear inside the content area and align with wrapped lines.
- Adds left padding to list items so wrapped lines have a clear visual indent.
- Keeps long list-item text readable by allowing normal wrapping.
- The arbitrary selector gives precise control over li spacing without extra wrapper markup or custom CSS.
When to use
- Multi-line list items where wrapped lines should align under the first line.
- Situations where default browser list indent is insufficient or inconsistent across browsers.
- Component-based systems where you want to apply li-specific styles from the parent without adding CSS files.
Examples
Basic HTML with Tailwind classes:
html
<ul class=“list-inside list-disc whitespace-normal [li&]:pl-6”><li>This is a short item.</li> <li>This is a very long list item that will wrap across multiple lines so you can see how the padding-left keeps wrapped lines aligned under the first line rather than under the bullet.</li> <li>Item with <strong>inline elements</strong> and links that also wrap correctly.</li></ul>
Using in a React component:
jsx
export default function Features() { return ( <ul className=“list-inside list-disc whitespace-normal [li&]:pl-6”> <li>Fast rendering with minimal layout shifts.</li> <li>Responsive behavior across screen sizes with consistent indents.</li> <li>Easy to maintain — no extra CSS required.</li> </ul> );}
Accessibility and cross-browser notes
- Screen readers announce list structure regardless of these utilities; this is purely presentational.
- Older browsers may render list markers differently; the combination above reduces visual inconsistency but test in your target browsers.
- If you rely on the marker alignment for precise layout, consider validating in narrow viewports and with increased font sizes.
Alternatives
- Use
pl-6on the container andlist-outsideif you prefer hanging bullets. - Add custom CSS targeting
ul > liif you need more complex selectors or media-query–specific indents.
Quick checklist
- Use when list items wrap and you want wrapped lines indented.
- Keep
list-inside+list-discfor inside bullets. - Use
[li&]:pl-6to apply padding to li without extra CSS files.
This combination is a small, reusable pattern that produces readable, well-aligned multi-line lists with minimal markup.
Leave a Reply