Lists work for collections of items, tables work for information that must be compared in rows and columns, and paragraphs work for connected thoughts.
What You Need to Know
Ask what relationship readers need to understand. Choosing the semantic element first makes the content easier to use before any styling.
A description list is useful for terms and definitions, not only for dictionary pages.
The goal is not to collect as many tags as possible. Pick the element that best describes what the content really is.
Example: See It in Action
Add this example to the appropriate part of a practice HTML page. Read each line before you open the page in your browser.
This is a short HTML fragment. To try it as a webpage, put it inside the body element of a complete HTML document.
<h2>Shopping list</h2>
<ul>
<li>Milk</li>
<li>Apples</li>
</ul>
<h2>Prices</h2>
<table>
<tr>
<th>Item</th>
<th>Price</th>
</tr>
<tr>
<td>Milk</td>
<td>$2</td>
</tr>
</table>
Let’s Understand the Example
- An h2 starts a major section beneath the page topic.
- Ul groups items where the order does not matter.
- Li is one item inside a list. Keep each item inside its parent list.
Look at a data cell and ask: “What row and column does this value belong to?” The header elements help answer that question, including for people who navigate the table with a screen reader.
What Should You See?
The page should display “Shopping list” as a heading, followed by its related content. Change the heading text and refresh the browser to see the result.
Read only the headings, from top to bottom. Do they tell a sensible story? If not, move sections or choose levels that match the content.
Try It Yourself
- Turn the price information into a table but keep the shopping items as a list.
- Save your changes, open or refresh the page, and compare the result with the original example.
- Tell a friend what your change did. If you are not sure, undo it, refresh the page, and compare.
Common Beginner Mistakes
- Using a table to line up two paragraphs even though there is no data comparison.
- Avoid picking tags just for their default bold, italic or spaced appearance. Use CSS for presentation.
Key Takeaways
- Lists work for collections of items, tables work for information that must be compared in rows and columns, and paragraphs work for connected thoughts.
- An h2 starts a major section beneath the page topic.
- A description list is useful for terms and definitions, not only for dictionary pages.