Unordered List: A Simple Guide to Bulleted Lists in HTML and Beyond
Unordered lists are a foundational element of web content and document formatting. They present groups of related items without implying a specific order, making them ideal for features, tips, ingredients, or any collection where sequence doesn’t matter. This article explains how unordered lists work in HTML, accessible best practices, styling tips with CSS, and practical use cases.
What is an unordered list?
An unordered list displays items with bullets (or other markers) to indicate each list entry. In HTML, it’s created with the
- element, and each item is wrapped in an
- element.
Basic HTML structure
html
<ul><li>First item</li> <li>Second item</li> <li>Third item</li></ul>
When to use unordered lists
- Grouping features or benefits
- Listing ingredients or materials
- Navigation menus (simple cases)
- Checklists where order doesn’t matter
Accessibility tips
- Use semantic
- and
- elements rather than manual bullets.
- Ensure list items are concise and meaningful.
- For complex list items, include headings or landmarks inside
- to improve screen-reader navigation.
Styling unordered lists with CSS
- Change bullet style:
css
ul { list-style-type: disc; } /* options: circle, square, none */
- Custom markers:
css
ul.custom { list-style: none; }ul.custom li::before { content: “•”; color: teal; display: inline-block; width: 1em; margin-left: -1em;}
- Horizontal lists (navigation):
css
nav ul { display: flex; gap: 1rem; list-style: none; padding: 0; }
Advanced patterns
- Nested unordered lists for hierarchy:
html
<ul> <li>Fruits <ul> <li>Apples</li> <li>Oranges</li> </ul> </li> <li>Vegetables</li></ul>
- Combining icons and text using background-image or ::before.
- Responsive adjustments: collapse multi-column lists on small screens.
Common pitfalls
- Using lists purely for layout — prefer CSS for visual arrangement.
- Forgetting to reset default margins/padding which can cause spacing issues.
- Over-nesting which harms readability and accessibility.
Examples
- Feature list:
html
<ul> <li>Fast performance</li> <li>Cross-browser support</li> <li>Easy integration</li></ul>
- Recipe ingredients:
html
<ul> <li>2 cups flour</li> <li>1 cup sugar</li> <li>⁄2 cup butter</li></ul>
Unordered lists are small but powerful tools for clear content structure. Use them semantically, style thoughtfully, and keep accessibility in mind to make information easy to scan for all users.
Leave a Reply