Newer Things To Know About Good Ol' HTML Lists

Master modern CSS techniques, accessibility considerations, and semantic best practices for building accessible, maintainable list components.

Understanding HTML List Types

HTML lists are among the most fundamental elements in web development, yet they're often overlooked when discussing modern techniques. Whether you're building navigation menus, product features, or step-by-step tutorials, lists form the backbone of structured web content.

Despite their ubiquity, many developers aren't aware of the evolving best practices, accessibility considerations, and modern CSS capabilities that have transformed list implementation in recent years. Our web development services team regularly implements these patterns to create accessible, maintainable interfaces. This guide explores the latest approaches to working with HTML lists, from semantic structure to advanced styling techniques.

The Three Core List Elements

Ordered Lists (<ol>)

Ordered lists represent sequences where the order carries meaning. Use them for step-by-step instructions, rankings, or any content where the numerical or sequential position matters. By default, browsers render ordered lists with numeric markers (1, 2, 3), but this can be customized through attributes or CSS.

Unordered Lists (<ul>)

Unordered lists group related items without implying any sequence. These are ideal for navigation menus, feature lists, collections of similar items, or any content where the order of presentation doesn't affect understanding.

Description Lists (<dl>)

Description lists provide a unique structure for associating terms with their definitions or descriptions. Unlike ordered and unordered lists that use <li> for items, description lists employ <dt> (definition term) and <dd> (definition description) elements.

Basic List Structure Examples
1<!-- Ordered List -->2<ol>3 <li>Step one - the beginning</li>4 <li>Step two - the middle</li>5 <li>Step three - the conclusion</li>6</ol>7 8<!-- Unordered List -->9<ul>10 <li>First item</li>11 <li>Second item</li>12 <li>Third item</li>13</ul>14 15<!-- Description List -->16<dl>17 <dt>HTML</dt>18 <dd>HyperText Markup Language for web pages</dd>19 <dt>CSS</dt>20 <dd>Cascading Style Sheets for presentation</dd>21</dl>

The Interactive Menu Element

Beyond the three core list types, HTML includes <menu> as a lesser-known option specifically designed for interactive elements. Despite its name suggesting navigation, <menu> is semantically an unordered list intended for toolbar actions, context menus, or groups of interactive controls.

The <menu> element is exposed to the accessibility tree as an unordered list, making it screen reader friendly when properly labeled. This provides a more semantic alternative to using <ul> for button groups or action toolbars. For building accessible navigation systems, our accessibility-focused web development approach ensures proper semantic markup throughout.

Using the Menu Element for Actions
1<!-- Menu element for interactive toolbar actions -->2<menu aria-label="Share article options">3 <li><button onclick="shareViaEmail()">Email</button></li>4 <li><button onclick="shareViaTwitter()">Twitter</button></li>5 <li><button onclick="shareViaFacebook()">Facebook</button></li>6 <li><button onclick="copyLink()">Copy Link</button></li>7</menu>
Adding ARIA Roles for Accessibility
1<!-- Accessible list with markers removed -->2<ul role="list">3 <li role="listitem">Item one</li>4 <li role="listitem">Item two</li>5 <li role="listitem">Item three</li>6</ul>

Advanced Targeting with Modern CSS

Modern CSS provides powerful selectors for precise list targeting. The :where() pseudo-class function allows creating selectors with zero specificity, making overrides straightforward:

/* Remove markers from all lists except those in articles */
:where(ol, ul, menu):not(article :where(ol, ul, menu)) {
 list-style: none;
 padding-left: 0;
}

The key advantage of :where() over :is() is that :where() always has zero specificity, while :is() takes the specificity of its most specific selector.

Ordered List Attributes and CSS

HTML Attributes for Ordered Lists

The <ol> element supports several attributes that control numbering behavior:

The reversed attribute causes the list to count downward:

<ol reversed>
 <li>Third place</li>
 <li>Second place</li>
 <li>First place</li>
</ol>

The start attribute specifies the starting value:

<ol start="5">
 <li>Fifth item</li>
 <li>Sixth item</li>
</ol>

The type attribute controls the numbering style: "1", "A", "a", "I", or "i".

The ::marker Pseudo-Element

Styling List Markers Directly

The ::marker pseudo-element provides direct control over list marker appearance:

li::marker {
 color: #2563eb;
 font-weight: bold;
}

You can customize:

  • Color: Any valid color value
  • Font size and weight: Typography properties
  • Content: Using the content property
/* Custom marker with emoji */
li::marker {
 content: "✓ ";
 color: #16a34a;
}

Description Lists Deep Dive

Structure and Use Cases

Description lists deserve more attention than they typically receive. The <dl> element provides semantic structure for term-description relationships. For structured content that enhances both user experience and search engine visibility, description lists offer significant advantages.

Common use cases include:

  • Glossaries and terminology definitions
  • FAQs (question-answer pairs)
  • Product specifications and attributes
  • Metadata and key-value data
  • Ingredient lists with measurements
  • Contact information formats
Description List Structure
1<dl>2 <dt>HTML</dt>3 <dd>HyperText Markup Language, the standard markup language for web pages.</dd>4 5 <dt>CSS</dt>6 <dd>Cascading Style Sheets, used for styling web page presentation.</dd>7 8 <dt>JavaScript</dt>9 <dd>A programming language that enables interactive web pages.</dd>10</dl>

Styling Description Lists

Description lists have unique styling considerations because <dt> and <dd> are sibling elements. Grid layout provides precise control:

dl {
 display: grid;
 grid-template-columns: auto 1fr;
 gap: 0.5rem 1rem;
}

dt {
 font-weight: bold;
}

dd {
 margin: 0;
}

Nested Lists for Hierarchical Content

Creating Multi-Level Structures

Lists can be nested to any depth, with <ol>, <ul>, and <dl> freely mixed. However, deeply nested lists have performance implications:

  • Each nested level adds DOM nodes, increasing memory usage
  • Screen readers announce each level, which can become verbose
  • Styling and layout calculations multiply with depth

Best practices:

  • Limit nesting to 3-4 levels maximum
  • Consider alternative structures (accordions, tree views) for complex hierarchies
  • Use CSS logical properties (padding-inline-start) for internationalization
  • Test with screen readers to ensure navigation remains manageable
Nested List Structure
1<ul>2 <li>Top-level category3 <ul>4 <li>Second-level item5 <ul>6 <li>Third-level detail</li>7 </ul>8 </li>9 <li>Another second-level item</li>10 </ul>11 </li>12 <li>Another top-level item</li>13</ul>
Key List Best Practices

Reset Carefully

When removing list markers, add role="list" for Safari accessibility

Modern Selectors

Use :where() and :not() for precise, maintainable targeting

Style Markers Directly

The ::marker pseudo-element enables native marker customization

Embrace Description Lists

<dl> is underused for its intended purpose

Summary and Key Takeaways

HTML lists remain fundamental to web development, but modern practices have evolved significantly:

  1. Reset carefully: Removing list styles requires role="list" for Safari accessibility
  2. Use modern selectors: :where() and :not() enable precise targeting
  3. Style markers directly: ::marker provides native marker customization
  4. Embrace description lists: <dl> is underused for its intended purpose
  5. Consider nesting depth: Limit to maintain accessibility and performance
  6. Build component systems: Consistent list APIs improve maintainability
  7. Test across contexts: Verify with screen readers and various browsers

Implementing these best practices ensures your list implementations are accessible, maintainable, and performant across all browsers and devices.

Frequently Asked Questions

Build Better Web Experiences

Our team specializes in modern web development practices, creating accessible, performant websites that work for everyone.