Skip to content

HTML Elements

A quick lookup for HTML elements grouped by category. Each entry covers what the element does, its most-used attributes, and when to reach for it.

These elements appear in every HTML file. Most live in <head> and are never visible on the page.

ElementWhat it doesKey attributes
<!DOCTYPE html>Tells the browser to use modern HTML5 parsing
<html>Root element — wraps the entire documentlang
<head>Container for metadata — not rendered on the page
<body>All visible page content goes here
<title>Sets the browser tab title and SEO page title
<meta>Metadata: character set, viewport, description, social tagscharset, name, content, property
<link>Links external resources — CSS files, faviconsrel, href, type
<script>Loads or embeds JavaScriptsrc, defer, type
<style>Embeds CSS directly in the document
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Page description for search engines">
<title>Page Title</title>
<link rel="stylesheet" href="styles.css">
<link rel="icon" href="favicon.ico">
</head>
<body>
<!-- visible content -->
<script src="app.js" defer></script>
</body>
</html>

Semantic sectioning elements describe the purpose of each region to browsers and screen readers. Prefer these over <div> wherever the semantics fit.

ElementWhat it doesNotes
<header>Site header or section headerCan appear multiple times — one for the page, one inside <article> or <section>
<nav>Navigation linksUse for primary and secondary navs, not every group of links
<main>Primary content of the pageOne per page
<article>Self-contained, independently shareable contentBlog posts, news items, cards
<section>Thematic grouping of related contentUsually has its own heading
<aside>Complementary content — sidebars, calloutsRelated to but not essential to the main content
<footer>Site footer or section footerCan also appear inside <article>
<div>Generic block container — no semantic meaningUse when no semantic element fits
ElementWhat it doesKey attributes
<h1><h6>Headings, ranked 1 (most important) to 6 (least)
<p>Paragraph
<span>Generic inline container — no semantic meaningclass, id
<strong>Important text — renders bold by default
<em>Emphasized text — renders italic by default
<small>Fine print, disclaimers, side comments
<blockquote>Block-level quotationcite (URL of source)
<cite>Title of a creative work — book, film, article
<q>Short inline quotationcite
<abbr>Abbreviation or acronymtitle (full expansion shown on hover)
<code>Inline code snippet
<pre>Preformatted text — preserves whitespace and line breaks
<mark>Highlighted / relevant text
<del>Deleted textdatetime
<ins>Inserted textdatetime, cite
<sub>Subscript
<sup>Superscript
<time>Machine-readable date or timedatetime
<br>Line break (void element)
<hr>Thematic break between content (void element)
<time datetime="2026-05-27">May 27, 2026</time>
<abbr title="Hypertext Markup Language">HTML</abbr>
<pre><code>const x = 42;</code></pre>
<blockquote cite="https://example.com">The mountains are calling.</blockquote>
ElementWhat it doesKey attributes
<ul>Unordered list — bullet points
<ol>Ordered list — numberedstart, reversed, type (1, a, A, i, I)
<li>List item — child of <ul> or <ol>value (in <ol> only — overrides the count)
<dl>Description list — key/value pairs
<dt>Description term
<dd>Description detail — follows <dt>
<ol start="3" type="a">
<li>Third item, labeled "c"</li>
<li>Fourth item, labeled "d"</li>
</ol>
<dl>
<dt>Difficulty</dt>
<dd>Moderate</dd>
<dt>Distance</dt>
<dd>8.4 miles</dd>
</dl>
ElementWhat it doesKey attributes
<a>Anchor — creates a hyperlinkhref, target, rel, download
AttributePurpose
href="#id"Jump to an element on the same page
href="mailto:…"Open email client
href="tel:…"Dial a phone number
target="_blank"Open in a new tab — always pair with rel="noopener"
downloadDownload the linked file instead of navigating
rel="noopener noreferrer"Security: prevents the new tab from accessing window.opener
<a href="/tours/">See all tours</a>
<a href="https://example.com" target="_blank" rel="noopener noreferrer">External link</a>
<a href="mailto:hello@example.com">Email us</a>
<a href="brochure.pdf" download>Download brochure</a>
ElementWhat it doesKey attributes
<img>Embeds an image (void element)src, alt, width, height, loading
<figure>Self-contained media with an optional caption
<figcaption>Caption for a <figure> — can be first or last child
<picture>Responsive image container — multiple sources
<source>Alternate source inside <picture>srcset, media, type
<!-- Basic image -->
<img src="hero.jpg" alt="Hiker at summit" width="800" height="600" loading="lazy">
<!-- Figure with caption -->
<figure>
<img src="trail.jpg" alt="Pine forest trail">
<figcaption>The Mount Rainier approach trail in October.</figcaption>
</figure>
<!-- Responsive image — browser picks the first matching source -->
<picture>
<source srcset="hero-mobile.webp" media="(max-width: 600px)" type="image/webp">
<source srcset="hero.webp" type="image/webp">
<img src="hero.jpg" alt="Mountain vista" width="1200" height="600">
</picture>

Always include alt. Leave it empty (alt="") only for decorative images that convey no information.

ElementWhat it doesKey attributes
<video>Embeds a videosrc, controls, width, height, autoplay, loop, muted, poster
<audio>Embeds audiosrc, controls, loop, muted
<source>Alternate format inside <video> or <audio>src, type
<track>Captions or subtitles for mediakind, src, srclang, label, default
<iframe>Embeds another document (YouTube, maps, etc.)src, width, height, allow, title, loading
<video controls width="640" height="360" poster="thumbnail.jpg">
<source src="video.webm" type="video/webm">
<source src="video.mp4" type="video/mp4">
<track kind="subtitles" src="captions.vtt" srclang="en" label="English" default>
</video>
<iframe
src="https://www.youtube.com/embed/VIDEOID"
width="560"
height="315"
title="Video title"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
loading="lazy">
</iframe>

Never autoplay video with sound. autoplay requires muted to function in most browsers.

ElementWhat it doesKey attributes
<table>Table container
<caption>Table title — must be the first child of <table>
<thead>Header row group
<tbody>Body row group
<tfoot>Footer row group
<tr>Table row
<th>Header cellscope (col, row, colgroup, rowgroup)
<td>Data cellcolspan, rowspan
<colgroup>Groups columns for shared stylingspan
<col>Single column within <colgroup>span
<table>
<caption>Hiking tours</caption>
<thead>
<tr>
<th scope="col">Tour</th>
<th scope="col">Duration</th>
<th scope="col">Price</th>
</tr>
</thead>
<tbody>
<tr>
<td>Forest Loop</td>
<td>3 hours</td>
<td>$49</td>
</tr>
<tr>
<td>Ridge Trail</td>
<td>6 hours</td>
<td>$89</td>
</tr>
</tbody>
</table>

Always set scope="col" on column headers and scope="row" on row headers — screen readers require it.

ElementWhat it doesKey attributes
<form>Form containeraction, method (get / post), novalidate
<label>Associates text with a controlfor (matches the input’s id)
<input>Input control — type determines behaviortype, name, id, value, placeholder, required, disabled, readonly
<textarea>Multiline text inputname, rows, cols, placeholder, required
<select>Dropdown menuname, multiple, size
<option>Menu option inside <select>value, selected, disabled
<optgroup>Groups options inside <select>label
<button>Clickable buttontype (submit, reset, button)
<fieldset>Groups related controlsdisabled
<legend>Label for a <fieldset>
<datalist>Autocomplete suggestions linked to an <input>id (matched by input’s list attribute)
TypeCreatesNotes
textSingle-line text fieldDefault when type is omitted
emailEmail fieldValidates email format on submit
passwordPassword fieldHides characters
numberNumber fieldAccepts min, max, step
telPhone number fieldNo format validation — use pattern
urlURL fieldValidates URL format on submit
searchSearch fieldMay style differently per browser
dateDate pickermin, max
timeTime pickermin, max, step
colorColor pickervalue in #rrggbb format
rangeSlidermin, max, step, value
checkboxCheckboxchecked to pre-check; value sent on submit
radioRadio buttonSame name groups them; only one selectable at a time
fileFile pickeraccept, multiple
hiddenHidden fieldvalue sent with the form but not shown
submitSubmit buttonvalue sets the button label
resetReset buttonClears all form controls to their default values
buttonGeneric buttonNo built-in behavior — use with JavaScript
<form action="/contact" method="post">
<fieldset>
<legend>Contact details</legend>
<label for="name">Name</label>
<input type="text" id="name" name="name" required>
<label for="email">Email</label>
<input type="email" id="email" name="email" required>
<label for="tour">Tour interest</label>
<select id="tour" name="tour">
<optgroup label="Day hikes">
<option value="forest-loop">Forest Loop</option>
<option value="ridge-trail">Ridge Trail</option>
</optgroup>
<optgroup label="Overnight">
<option value="summit-camp">Summit Camp</option>
</optgroup>
</select>
<label for="message">Message</label>
<textarea id="message" name="message" rows="5" placeholder="Tell us about yourself"></textarea>
<button type="submit">Send message</button>
</fieldset>
</form>

Every <input> needs both id (for <label>) and name (sent with the form). Missing either breaks accessibility or form submission.

ElementWhat it doesKey attributes
<details>Collapsible disclosure widgetopen (expanded by default)
<summary>Visible label for <details> — click to expand/collapse
<details>
<summary>What should I bring?</summary>
<p>Wear sturdy shoes and bring at least two liters of water per person.</p>
</details>
<details open>
<summary>Is this tour beginner-friendly?</summary>
<p>Yes — no technical climbing required. A moderate level of fitness is recommended.</p>
</details>

<summary> must be the first child of <details>. If omitted, the browser renders a default “Details” label.