WebDev Story

WebDev Story: HTML Elements

markup, inline & block, events, tag reference

1.0 HTML Markup

HyperText Markup Language (HTML) is a declarative language specifying what will be placed on a web page. An HTML document is a tree of elements, each wrapped in opening and closing tags.
<htmltag>               <!-- any standard tag, e.g. div -->
  <custom-child-tag>    <!-- user-defined; must be hyphenated -->
    "literal text"
  </custom-child-tag>
</htmltag>
The HTML standard requires that all custom (user-defined) tags are hyphenated to avoid clashes with future standard tags.

1.1 Inline and Block Elements

HTML elements divide into two fundamental display categories that control how they are placed on the page:
  • Inline elements flow horizontally from left to right within their container:
    span, a, br, strong, em, sub, sup, code, img, ...
  • Block elements stack vertically from top to bottom, each on its own line:
    html, body, head, header, main, footer, section, article, nav, aside,
    div, p, h1–h6, pre, blockquote, form, table, ol, ul, li, ...
A typical HTML page skeleton looks like this:
<!DOCTYPE html>
<html>
  <head>
    <style> /* linked and inline styles */ </style>
    <script> /* linked and inline scripts */ </script>
  </head>
  <body>
    <!-- content markup -->
    <script> /* inline run-at-load scripts */ </script>
  </body>
</html>

1.2 HTML Events

HTML events are generated by browser and user actions, such as page load or button click. They can be wired directly in markup as attributes:
<div onclick="doShow()">text content</div>
where doShow() is a JavaScript function defined in the current page. The table below lists the standard browser events grouped by category.
HTML Events Reference
Event Typical Targets When it fires
Window / Document lifecycle
DOMContentLoadeddocumentInitial HTML parsed (no styles/images needed).
loadwindow, img, linkAll resources finished loading.
beforeunloadwindowPage about to be unloaded (prompt user).
unloadwindowDocument is unloading.
pageshow / pagehidewindowPage shown or hidden (incl. bfcache).
visibilitychangedocumentdocument.visibilityState changes.
hashchangewindowURL fragment (#…) changes.
popstatewindowHistory entry activated (back/forward).
resizewindowViewport size changed.
scrollwindow, elementsScrolled (throttle for performance).
online / offlinewindowNetwork connection gained or lost.
storagewindowlocalStorage changed in another tab.
Focus & Forms
focus / blurinputs, focusableElement gained / lost focus (no bubble).
focusin / focusoutinputs, focusableLike focus/blur but bubbles.
inputinput, textareaUser changes value.
changeinput, selectValue committed (on blur for text inputs).
submit / resetformForm submitted or reset.
invalidform controlsConstraint validation failed.
Keyboard
keydownwindow, focusableKey pressed down.
keyupwindow, focusableKey released.
Mouse & Wheel
click / dblclickmost elementsPrimary button press & release / double.
contextmenumost elementsContext menu requested (right-click).
mousedown / mouseupmost elementsButton pressed / released.
mousemovemost elementsPointer moved.
mouseover / mouseoutmost elementsPointer enters/leaves (bubbles).
mouseenter / mouseleavemost elementsPointer enters/leaves (no bubble).
wheelscrollable, windowMouse wheel or trackpad scroll.
Touch Events
touchstart / touchendtouch targetsFinger placed on / removed from screen.
touchmovetouch targetsFinger moved on screen.
touchcanceltouch targetsTouch disrupted (e.g., app switch).
Clipboard & Drag
copy / cut / pasteeditable, documentUser copies, cuts, or pastes.
dragstart / drag / dragenddraggable elemDrag life-cycle on source.
dragenter / dragover / dragleave / dropdropzoneDrag life-cycle on target.
CSS Animations & Transitions
animationstart / animationendanimated elemCSS animation starts / ends.
transitionstart / transitionendtransitioning elemCSS transition starts / ends.
Misc
toggle<details>Details open/close state changes.
slotchange<slot>Assigned nodes changed (Shadow DOM).

1.3 Tag Reference

The table below lists all commonly used standard HTML tags, their category, a brief description, and a usage example.
HTML Tag Reference
Tag Category / Purpose Description Example
<!DOCTYPE>Document declarationSpecifies HTML version to browser.<!DOCTYPE html>
<html>RootRoot of the HTML document.<html lang="en">…</html>
<head>Metadata containerHolds metadata: title, links, scripts, meta tags.<head><title>T</title></head>
<title>MetadataDocument title shown in browser tab.<title>My Page</title>
<meta>MetadataCharset, viewport, description, etc.<meta charset="utf-8">
<link>ResourceExternal resource like stylesheet or icon.<link rel="stylesheet" href="s.css">
<script>ScriptingEmbed or load JavaScript.<script src="app.js"></script>
<body>Content rootMain visible document content.<body>…</body>
<header>SectioningIntroductory content or nav for a section/page.<header><h1>Site</h1></header>
<nav>NavigationSection with navigation links.<nav><a href="#">Home</a></nav>
<main>SectioningPrimary page content.<main>…</main>
<section>GroupingGeneric section of related content.<section><h2>F</h2></section>
<article>Independent contentSelf-contained composition (e.g., blog post).<article><p>…</p></article>
<aside>ComplementaryTangential content (e.g., sidebar).<aside>Related links</aside>
<footer>SectioningFooter for section or page.<footer>© 2026</footer>
<h1>–<h6>HeadingsSection headings with descending importance.<h2>Subheading</h2>
<p>TextParagraph.<p>Lorem ipsum.</p>
<strong>Text semanticsStrong importance (typically bold).<strong>Important</strong>
<em>Text semanticsEmphasis (typically italic).<em>Note</em>
<span>InlineGeneric inline container.<span class="hi">Text</span>
<div>BlockGeneric block container.<div>Wrapper</div>
<br>BreakLine break.Line1<br>Line2
<wbr>Preferred breakBreak here only if sequence doesn't fit.Long<wbr>Word
<hr>ThematicThematic break (horizontal rule).<hr>
<ul>ListUnordered list.<ul><li>One</li></ul>
<ol>ListOrdered list.<ol><li>First</li></ol>
<li>List itemItem in ordered/unordered list.<li>Item</li>
<dl>Definition listContainer for terms and descriptions.<dl><dt>T</dt><dd>D</dd></dl>
<img>MediaImage.<img src="p.jpg" alt="desc">
<picture>Responsive imageContainer for multiple image sources.<picture><source …><img …></picture>
<video>MediaVideo playback.<video controls><source src="m.mp4"></video>
<audio>MediaAudio playback.<audio controls><source src="s.mp3"></audio>
<iframe>EmbeddingEmbed another HTML document.<iframe src="page.html"></iframe>
<canvas>GraphicsDrawable region via scripting.<canvas width="300" height="150"></canvas>
<svg>VectorScalable vector graphics container.<svg><circle cx="50" cy="50" r="40"></svg>
<table>TabularTable container.<table>…</table>
<thead> / <tbody>StructureHeader / body group of table.<thead><tr>…</tr></thead>
<tr>RowTable row.<tr>…</tr>
<th> / <td>CellsHeader cell / data cell.<th>Name</th> <td>Val</td>
<colgroup>LayoutGroup of columns for styling/width.<col style="width:50%">
<form>InputForm container for user input.<form action="/submit">…</form>
<input>ControlSingle-line field (text, checkbox, radio, etc.).<input type="text" name="q">
<textarea>ControlMulti-line text input.<textarea>…</textarea>
<button>ControlClickable button.<button>Submit</button>
<label>FormLabel for form control.<label for="id">Name</label>
<select>ControlDropdown list.<select><option>A</option></select>
<fieldset>GroupingGroup related form controls.<fieldset>…</fieldset>
<details>DisclosureToggleable additional content.<details><summary>More</summary>…</details>
<summary>DisclosureTitle for <details>.<summary>Title</summary>
<template>InertMarkup not rendered until cloned.<template id="tpl"><div>Hi</div></template>
<slot>Shadow DOMProjection point for light DOM.<slot name="foo"></slot>
<abbr>TextAbbreviation with optional expansion.<abbr title="HyperText">HTML</abbr>
<code>Inline codeProgram code fragment.<code>let x=1;</code>
<pre>PreformattedPreserves whitespace and line breaks.<pre>line1\nline2</pre>
<blockquote>QuotationLong quotation.<blockquote>Quote</blockquote>
<mark>HighlightHighlighted text.<mark>Search hit</mark>
<time>DatetimeRepresents a date/time.<time datetime="2026-04-28">Apr 28</time>

1.4 Tutorials

The following tutorials range from beginner to intermediate. Each covers a different aspect of learning HTML effectively.
HTML Tutorials
Tutorial Type Why Use It
MDN: Structuring content with HTML Beginner Modern fundamentals: structure, links, lists, images, and forms.
MDN: HTML overview & learning path Beginner→Ref Entry to tutorials, guides, and the canonical HTML reference.
web.dev: Learn HTML Beginner→Intermediate Concise lessons and patterns from the Chrome team.
w3schools HTML Tutorial Beginner→Intermediate Executable examples, reliable source of information.
freeCodeCamp: Responsive Web Design Project-based Hands-on HTML+CSS with projects and a free certificate.
The Odin Project: Foundations Project-based Structured path with exercises and community support.
jenkov.com HTML Tutorial Comprehensive Walk-through of most important HTML parts.
WebAIM: Intro to Web Accessibility Accessibility Principles and practical tips for inclusive HTML.

1.5 References

HTML References
Resource Description
MDN HTML Reference Comprehensive documentation and tutorials for HTML elements and attributes.
HTML Living Standard The official specification maintained by WHATWG.
HTML.com Tags Reference Quick reference for all HTML tags with examples and usage tips.
htmlreference.io Purpose-specific references for individual elements.
w3schools Event Attributes Grouped by device and action type.
w3schools Global Attributes Attributes that apply to all HTML elements.
W3C HTML 5.2 Spec Detailed W3C specification for HTML 5.2.