HTML Basics
HTML Lists
Lists group related items so they are easy to scan. HTML offers three types: unordered (bullets), ordered (numbers), and description lists for term-and-definition pairs.
What is an HTML List?
A list groups a set of related items. Unordered lists (<ul>) show a bullet before each item and are for items where order does not matter. Ordered lists (<ol>) number the items, which is ideal for steps or rankings.
In both cases each item is wrapped in an <li> tag. A third type, the description list (<dl>), pairs terms with their descriptions — useful for glossaries and metadata.
Basic Usage
<ul>
<li>Bulleted item</li>
<li>Another item</li>
</ul>
<ol>
<li>First step</li>
<li>Second step</li>
</ol>Example: The Three List Types
<!DOCTYPE html>
<html>
<body>
<h3>Skills (unordered)</h3>
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
<h3>Steps (ordered)</h3>
<ol>
<li>Write the code</li>
<li>Save the file</li>
<li>Open in a browser</li>
</ol>
<h3>Glossary (description)</h3>
<dl>
<dt>HTML</dt>
<dd>The structure of a page.</dd>
<dt>CSS</dt>
<dd>The style of a page.</dd>
</dl>
</body>
</html>More Examples
<ul>
<li>Front-end
<ul>
<li>HTML</li>
<li>CSS</li>
</ul>
</li>
<li>Back-end
<ul>
<li>Node.js</li>
<li>Databases</li>
</ul>
</li>
</ul><ul style="list-style-type:square;">
<li>Square bullet</li>
<li>Square bullet</li>
</ul>
<ol type="A">
<li>Item A</li>
<li>Item B</li>
</ol>List Tags Reference
| Tag | Purpose |
|---|---|
| <ul> | Unordered (bulleted) list. |
| <ol> | Ordered (numbered) list. |
| <li> | A single list item. |
| <dl> | Description list container. |
| <dt> | A term in a description list. |
| <dd> | The description of that term. |
Use an ordered list only when sequence actually matters, like steps in a recipe. If items are just a group, use an unordered list.
Website navigation menus are usually built as an unordered list of links styled with CSS — semantically it is a list of destinations.
Key Takeaways
- Use <ul> for bullets, <ol> for numbered steps.
- Every list item goes in an <li> tag.
- Use <dl>, <dt>, and <dd> for term-and-definition pairs.
- Lists can be nested to show sub-items.
