Sub topic 8
Semantic HTML: Lists, Tables and Clean Sections
Assume you know basic HTML and have edited web content before. This chapter focuses on how semantic HTML helps retrieval systems identify the boundaries and meaning of an answer. Semantic HTML uses elements that describe their purpose, such as <section>, <ol>, and <table>, instead of using generic <div> elements for everything.
Why semantic structure matters to AI retrieval
AI answer systems often retrieve a passage instead of reading an entire page. Clear HTML gives browsers, search engines, assistive technologies, and retrieval systems useful signals about how content is organized.
A clean section should answer one related question. Its heading should describe that question, and its paragraphs, lists, or tables should support the heading. A retrieved section is more useful when its meaning does not depend on a distant introduction.
Use sections to create retrieval boundaries
Use <section> when a group of content has its own topic or heading. Use a heading inside the section to name that topic. The first paragraph should state the answer directly.
For example, this structure makes the answer and its supporting details easy to identify:
<section>
<h2>What information should an API cache key include?</h2>
<p>An API cache key should include every request value that changes the response, such as the URL, query parameters, and selected request headers.</p>
<h3>Include these values</h3>
<ul>
<li>HTTP method and normalized URL</li>
<li>Query parameters that affect the result</li>
<li>Language or content negotiation headers when relevant</li>
</ul>
</section>The <ul> element represents an unordered list. Use it when the order does not matter. Use <ol> for a sequence, such as a procedure or ranked set of steps.
Do not use a list only to create visual spacing. Each list item should be a complete, useful unit. If a reader copied the list without its surrounding paragraph, the items should still be understandable.
Build tables with explicit relationships
Use a table for relationships between categories and values, not for page layout. Add a header row with <th> elements. The scope attribute tells browsers which cells each header describes.
<table>
<caption>Suggested cache durations by data type</caption>
<thead>
<tr>
<th scope="col">Data type</th>
<th scope="col">Starting TTL</th>
<th scope="col">Reason</th>
</tr>
</thead>
<tbody>
<tr>
<td>Product catalog</td>
<td>15 minutes</td>
<td>Changes periodically but can tolerate brief staleness.</td>
</tr>
<tr>
<td>Account balance</td>
<td>0 seconds</td>
<td>Users need the current value.</td>
</tr>
</tbody>
</table>A <caption> gives the table a self-contained description. Repeat important context in the cells. A cell containing only “High” is weak when retrieved alone. “High invalidation frequency” is clearer.
| Element | Use it for | Common error |
|---|---|---|
| `<section>` | A themed group with a heading | One giant section for the whole page |
| `<ul>` | Items with no required order | Putting a multi-step procedure in an unordered list |
| `<ol>` | Ordered steps or rankings | Using numbers only for visual styling |
| `<table>` | Relationships between rows and columns | Using tables for layout |
Keep markup and visible claims aligned
Semantic HTML cannot make vague writing precise. Put the answer in visible text, then use markup to describe its structure. If you add structured data later, it must describe the same visible answer.
Review each target passage on its own. Check that the heading identifies the question, the opening sentence answers it, list items include enough context, and table cells remain meaningful when separated from the page.
Exercise
Which element should you use for a three-step migration procedure, and what should the first paragraph contain?
Show answer
Use an <ol> because the order matters. The first paragraph should state the migration's direct answer or outcome before listing the steps.