p]:inline” data-streamdown=”list-item”>7 Tips for Faster Bitmap Font Writing and Optimization

Tailoring CSS for Nested Ordered Lists: list-inside list-decimal whitespace-normal [li&]:pl-6

When building nested ordered lists in modern web layouts, controlling numbering, spacing, and indentation is essential for readability and visual hierarchy. The utility combination list-inside list-decimal whitespace-normal [li&]:pl-6 (commonly used in utility-first CSS frameworks like Tailwind CSS) provides a concise way to achieve a clean, readable nested ordered list. This article explains what each utility does, why you might combine them, and how to apply them practically with examples and tips.

What each utility does

  • list-inside Places list markers (numbers) inside the content box, so the numbers are part of the flow and wrap with the list item text.
  • list-decimal Uses decimal numbering (1., 2., 3.) for ordered lists.
  • whitespace-normal Ensures text wraps normally within list items, preventing forced unbroken lines.
  • [li&]:pl-6 A selector-targeted utility that applies left padding (pl-6) to each direct li child; the bracketed form targets the li elements inside the list via a selector variant (e.g., Tailwind’s arbitrary variants). This increases indentation for each item without moving the marker created by list-inside too far from the text.

Why combine them

    &]:pl-6” data-streamdown=“unordered-list”>

  • Readability: list-inside keeps numbers aligned with wrapped text, improving legibility on narrow viewports.
  • Consistent wrapping: whitespace-normal ensures long items wrap naturally rather than overflowing.
  • Controlled indentation: [li&]:pl-6 gives predictable left padding to list items, creating a consistent left edge and visual rhythm, especially useful when list items contain multiple lines or nested elements.
  • Semantic numbering: list-decimal provides clear, accessible numbering for ordered sequences.

Practical examples

Basic ordered list with utilities (Tailwind CSS):

    &]:pl-6”>
  1. This is a short item.
  2. This is a longer list item that will wrap to multiple lines and demonstrates how the marker stays inside the flow.
  3. Item with nested content:
    1. Nested item one.
    2. Nested item two with a long line that wraps to show indentation.

Notes:

  • The bracketed variant [li&]:pl-6 targets li children; syntax can vary by framework/version. In Tailwind, you might need a plugin or the exact arbitrary selector syntax supported by your setup.
  • If markers overlap with text at small widths, increase padding or use list-outside instead, then adjust margins.

Accessibility and cross-browser tips

    &]:pl-6” data-streamdown=“unordered-list”>

  • Test wrapping and marker positioning in multiple browsers; some older browsers render list markers differently.
  • Ensure sufficient contrast and font sizing for readability.
  • Keep semantic HTML (use
      /

        and

      • ) rather than faking lists with CSS for screen reader compatibility.

When not to use this combo

  • If you need markers outside the content block for a more traditional look—use list-outside.
  • For compact UIs where extra padding is undesirable—omit the [li&]:pl-6 or use a smaller padding value.

Quick troubleshooting

    &]:pl-6” data-streamdown=“unordered-list”>

  • Markers not aligned: verify the arbitrary selector syntax is supported and that no conflicting padding/margin exists.
  • Unexpected wrapping: check white-space inheritance and remove whitespace-nowrap if present.
  • Nested lists losing style: ensure utility classes are applied to nested

This utility combination gives a practical, readable approach to ordered lists that wrap and nest gracefully. Adjust padding and list placement to match your visual design while keeping markup semantic for accessibility.

Your email address will not be published. Required fields are marked *