list-inside list-decimal whitespace-normal [li&]:pl-6
This article explains the CSS utility-like class combination shown in the title: what each part does, when to use it, and how to implement equivalent styles in plain CSS. It’s written assuming a utility-first framework (like Tailwind) or a custom utility naming scheme, then shows vanilla-CSS alternatives and practical examples.
What the pieces mean
- &]:pl-6” data-streamdown=“unordered-list”>
- list-inside — Place list markers (bullets or numbers) inside the content box so markers align with the first line of the list item instead of outside the content box.
- CSS:
list-style-position: inside;
- CSS:
- list-decimal — Use decimal numbers for ordered lists (1, 2, 3…).
- CSS:
list-style-type: decimal;
- CSS:
- whitespace-normal — Collapse whitespace and allow wrapping normally (opposite of
nowraporprebehaviors).- CSS:
white-space: normal;
- CSS:
- [li&]:pl-6 — A bracketed arbitrary selector targeting
lielements in a specific nested or contextual pattern, applying left padding (pl-6typically means padding-left: 1.5rem in Tailwind). The notation[li&]:pl-6implies a variant that targets an element when it is the parent of anlimatching some selector; interpreted concretely, it can mean “when this component contains an li (styled as &), apply padding-left: 1.5rem to that li.” In plain CSS you’d targetlidirectly or use a contextual selector.- Example Tailwind-like utility:
.pl-6 { padding-left: 1.5rem; } - Targeting
liin CSS:ol li { padding-left: 1.5rem; }or.my-list li { padding-left: 1.5rem; }
- Example Tailwind-like utility:
Combined effect
Applied together to an ordered list, these rules produce a numbered list whose numbers sit inside the content flow, whose items wrap normally, and whose list items have left padding so text aligns visually with additional indentation.
Example (utility-first HTML)
html
<ol class=“list-inside list-decimal whitespace-normal”><li class=“pl-6”>First item that may wrap to multiple lines and aligns with the number.</li> <li class=“pl-6”>Second item with normal wrapping behavior and added left padding.</li></ol>
Equivalent plain CSS
css
.custom-list { list-style-position: inside; list-style-type: decimal; white-space: normal; padding-left: 0; /* reset if framework added default /}
.custom-list li { padding-left: 1.5rem; / matches pl-6 */}
html
<ol class=“custom-list”> <li>First item that may wrap to multiple lines and aligns with the number.</li> <li>Second item with normal wrapping behavior and added left padding.</li></ol>
Accessibility and layout notes
- Using
list-style-position: insidecan cause markers to wrap with content on narrow screens; if marker alignment is critical, preferoutsideand use padding/margins to align. - Padding on
liaffects the whole item; consider using margins on nested content instead if you only want indentation for wrapped lines. - Test with screen readers—semantic
/remains important; these visual utilities should not alter list semantics.
When to use this pattern
- When you need numbered lists where multi-line items visually align under the number.
- In prose-heavy designs where natural wrapping is required.
- When using utility frameworks and you want a compact class set to control list appearance.
Quick checklist
- Use
list-insidefor numbers inside flow. - Use
list-decimalfor numeric markers. - Use
whitespace-normalto allow wrapping. - Apply
pl-6(or equivalent padding) tolifor consistent indentation.
That’s the practical breakdown and implementation options for the title’s utility combination._
Leave a Reply