INSIGHTS
Software Development

Essential HTML Tags with Examples and Usage Rules

In this article
  1. Document and text structure
  2. Lists and description terms
  3. Links and images
  4. Tables represent data, not page layout
  5. Forms need labels and correct buttons
  6. Text emphasis and code
  7. Void and obsolete elements

Basic HTML tags are easier to learn when grouped by what a page must communicate: document structure, text, lists, links, media and controls. The goal of this reference is to show a small valid sample of each group and explain when to use it. It is not a catalogue of old presentation tags that should be copied into a new site.

Document and text structure

<main>
  <h1>Exam preparation</h1>
  <p>Start with the official learning objectives.</p>
  <h2>Practice plan</h2>
  <p>Review, test, and revisit weak areas.</p>
</main>

main names the primary content region. Headings communicate hierarchy; CSS controls visual size. Multiple unrelated headings at the same depth are not an improvement just because they add keywords.

Lists and description terms

<ul><li>Review objectives</li><li>Practice labs</li></ul>
<ol><li>Read</li><li>Apply</li><li>Test</li></ol>
<dl><dt>API</dt><dd>An interface contract.</dd></dl>

Choose unordered, ordered or description-list markup based on the relationship among items. Do not use list elements solely to add indentation or spacing.

<a href="/blog/">Browse learning articles</a>
<img src="lab-diagram.png" alt="Browser sends a request to the API server">

Descriptive link text helps navigation. Alt text should convey the purpose of an informative image, not repeat a keyword list. Do not put arbitrary user-controlled strings into attribute values without appropriate escaping.

Tables represent data, not page layout

<table>
  <caption>Practice attempts</caption>
  <thead><tr><th scope="col">Attempt</th><th scope="col">Score</th></tr></thead>
  <tbody><tr><td>1</td><td>72%</td></tr></tbody>
</table>

Captions and header cells make tabular relationships easier to understand. For layout, use CSS grid or flexbox instead of nesting tables.

Forms need labels and correct buttons

<form>
  <label for="email">Email</label>
  <input id="email" name="email" type="email" required>
  <button type="submit">Subscribe</button>
</form>

Native controls support keyboard operation and basic validation; the server still must validate submitted values. A placeholder is not a persistent accessible name.

Text emphasis and code

strong conveys importance and em conveys stress emphasis. b and i have different, non-emphasis uses. For code examples, use pre with code to preserve whitespace and protect literal angle brackets.

Void and obsolete elements

img, input, br and meta are void elements; do not add closing tags to them. Avoid legacy font and center tags in new work; use semantic HTML with CSS for appearance. Consult the HTML living standard for exact content models and parsing rules.

Filed under Software Development