Unordered List: What It Is and How to Use It
An unordered list is a simple HTML structure used to group related items when the order doesn’t matter. It presents information as bullet points, making content easier to scan and read. Unordered lists are ideal for features, tips, ingredients, or any set of items where sequence isn’t important.
HTML structure
Use the
- tag to create the list and
- for each item:
html
<ul><li>First item</li> <li>Second item</li> <li>Third item</li></ul>
When to use an unordered list
- Presenting features or benefits
- Listing ingredients or materials
- Showing examples or options
- Grouping non-sequential steps or ideas
Styling tips
- Use CSS to customize bullets, spacing, and alignment:
css
ul.custom { list-style: disc; /* or circle, square, none */ margin-left: 1.5rem; padding: 0;}ul.custom li { margin-bottom: 0.5rem;}
- Replace default bullets with icons using background-image or ::before pseudo-element.
- For accessibility, ensure sufficient contrast and proper semantic HTML so screen readers recognize the list.
Accessibility considerations
- Keep lists concise; long paragraphs inside
- can be hard to scan.
- Use headings before lists to provide context.
- Avoid using lists purely for visual layout; use CSS for layout instead.
Examples
Shopping list:
html
<ul> <li>Milk</li> <li>Bread</li> <li>Eggs</li></ul>
Feature list:
html
<ul class=“features”> <li>Easy setup</li> <li>Responsive design</li> <li>Secure authentication</li></ul>
Conclusion
Unordered lists are a fundamental tool for organizing non-sequential information on the web. Use them to improve readability, follow semantic HTML practices, and style them to fit your design while keeping accessibility in mind.
Leave a Reply