Document Structure

Document Structure · Semantic Elements · Text · Lists · Links · Images · Tables

Learning Objectives

By the end of this session, students will be able to:

LO1 Write a valid HTML5 document with correct DOCTYPE, <html>, <head>, and <body> structure.
LO2 Apply HTML5 semantic elements to give meaningful structure to a webpage.
LO3 Use text formatting tags — headings (h1–h6), paragraphs, <strong>, <em>, <br>, <hr>.
LO4 Create ordered, unordered, and description lists using correct HTML syntax.
LO5 Insert hyperlinks and images using <a> and <img> with proper attributes.
LO6 Build structured HTML tables with thead, tbody, tfoot, colspan, and rowspan.

Aligned to: CO2  ·  PO1, PO2

HTML5 Document Structure

The required skeleton of every HTML5 webpage

Try it Yourself »
Result
DOCTYPE <!DOCTYPE html> — Tells the browser this is an HTML5 document. Must be the very first line — before <html>.
<html> lang="en" attribute — Root element wrapping the entire page. lang helps search engines & screen readers.
<head> Metadata container — Contains info about the page, not visible. Holds <title>, <meta>, <link>, <style>.
<meta> charset & viewport — charset="UTF-8" supports all characters; viewport ensures mobile-responsive display.
<body> Visible content area — Everything users see goes inside <body>: text, images, tables, links.

HTML5 Semantic Elements

Two pages can look identical in a browser — semantic HTML tells machines what each part means

Key insight: Semantic elements describe meaning, not just appearance. A <div> could hold anything; a <nav> always means navigation.
Try it Yourself »
Result
<header>Top of page/section. Contains <h1>, logo, tagline.
<nav>Site navigation links. Usually contains a <ul> of <a> tags.
<main>ONE per page. The dominant, unique page content.
<article>Self-contained content (blog post, news item, product card).
<section>Thematic grouping — should have its own heading.
<aside>Supplementary content: sidebar, related links, ads.
<footer>Bottom of page/section. Copyright, links, contact.

Text Formatting & Headings

Structure and emphasize content with HTML5 text elements

Heading hierarchy (h1–h6)

Heading 1 <h1> · Page Title, ONE per page, highest SEO weight
Heading 2 <h2> · Section headings
Heading 3 <h3> · Sub-section headings
Heading 4 <h4> · Sub-sub-sections
Heading 5 <h5> · Rarely used in practice
Heading 6 <h6> · Lowest level

Inline text elements

<strong>Bold + semantic importance (screen readers announce it)
<em>Italic + semantic emphasis
<b>Bold — visual only, no semantic meaning
<i>Italic — visual only (technical terms, foreign words)
<br>Line break — self-closing, forces a new line within a paragraph
<hr>Horizontal rule — thematic break between content blocks
<small>Smaller text — fine print, disclaimers
<mark>Highlighted text — like a yellow marker
<del>Strikethrough — deleted/removed content
<sup>/<sub>Superscript / Subscript — e.g. H2O, x2 — footnotes, chemical formulas
Try it Yourself »
Result
💡 Best practice: Use <strong> and <em> for meaningful emphasis. Use <b> and <i> only for visual styling with no semantic significance.

HTML5 Lists

Three list types for organizing content

<ul> — Unordered List

Bulleted list — order does not matter

Try it »
Result

✔ Use for: shopping lists, features, hobbies, options

<ol> — Ordered List

Numbered list — order matters

Try it »
Result

✔ Use for: steps, rankings, procedures, instructions

<dl> — Description List

Term + definition pairs

Try it »
Result

✔ Use for: glossaries, metadata, FAQs, dictionaries

🔁 Nested lists: Place a <ul> or <ol> inside a <li> to create sub-items. Browsers auto-indent nested lists. The type attribute on <ol> changes numbering: type="1" (default) · type="A" · type="a" · type="I" · type="i"

HTML5 Tables

Structured data: <table>, <thead>, <tbody>, <tfoot>, colspan & rowspan

Try it Yourself »
Result
<table>Container for the entire table
<caption>Table title — placed inside <table>, above rows
<thead>Groups header rows — for screen readers & CSS targeting
<tbody>Groups data rows — the main table body
<tfoot>Groups footer rows — totals, summaries
<tr>Table row — contains <th> or <td> cells
<th>Header cell — bold, centered by default
<td>Data cell — standard table cell
colspan="N"Merge N cells horizontally
rowspan="N"Merge N cells vertically

Laboratory Activity

My Digital Profile Page  ·  45 minutes  ·  50 points

🖥️ Task: Build a personal HTML5 profile page (profile.html) using ALL elements learned today.
R1 · 5 ptsHTML5 Document Shell — Correct DOCTYPE, <html lang>, <head> with charset & viewport meta, <body>
R2 · 10 ptsSemantic Structure — <header>, <nav>, <main>, at least one <section>, <footer> — 5+ semantic elements
R3 · 8 ptsHeading & Biography — <h1> your name, <h2> sections, <p> bio with <strong> and <em>
R4 · 7 ptsTwo Lists — <ul> of 5 hobbies/interests + <ol> of your top 3 goals
R5 · 5 ptsHyperlinks — External link (target="_blank" + rel="noopener") + mailto: link
R6 · 5 ptsImage — <img> with src and descriptive alt attribute (use picsum.photos if no photo)
R7 · 8 ptsClass Schedule Table — <table> with caption, <thead>, <tbody>, <tfoot>, colspan used at least once
R8 · 2 ptsFooter — <footer> with &copy; HTML entity, your name, and year
💡 Validate your code at validator.w3.org  ·  📁 Save as profile.html  ·  Total: 50 points

Key Takeaways

HTML5 Fundamentals: Document Structure · Semantic Elements · Text · Lists · Links · Images · Tables

  1. Every HTML5 page starts with <!DOCTYPE html> followed by <html>, <head>, and <body>.
  2. Semantic elements (<header>, <nav>, <main>, <article>, <section>, <aside>, <footer>) give meaning to structure — not just visual layout.
  3. Use <strong> and <em> for meaningful emphasis; use <b> and <i> only for visual styling.
  4. HTML has three list types: <ul> (unordered/bullets), <ol> (ordered/numbered), <dl> (description/glossary).
  5. Always add alt text to images. Always add rel="noopener" when using target="_blank" on links.
  6. HTML tables use <thead>, <tbody>, <tfoot> for structure; colspan and rowspan merge cells.
  7. Validate your HTML at validator.w3.org to catch errors before they reach the browser.

Form

Forms & Validation · Multimedia Elements · Accessibility & ARIA

Learning Objectives

By the end of this lesson, you can:

PI1 Build complete HTML5 forms using appropriate input types for each field.
PI2 Apply validation attributes (required, pattern, min/max) without JavaScript.
PI3 Embed <audio> and <video> multimedia elements with fallback content.
PI4 Explain the purpose of <canvas> and when JavaScript is required to use it.
PI5 Add ARIA attributes to improve form accessibility for screen reader users.
PI6 Identify the 4 WCAG 2.1 principles and apply them to HTML structure.

HTML5 Form Structure

<form>, <fieldset>, <legend>, <label>, <button>

actionWHERE form data is sent (a URL).
methodGET → data visible in URL (searches). POST → data hidden (logins, payments).
<label for="id">Links label text to its input field. Clicking the label focuses the input. Screen readers announce it aloud.
<fieldset> + <legend>Groups related inputs visually. <legend> is the caption for the group. Improves keyboard + screen reader UX.
Try it Yourself »
Result

HTML5 Input Types

Use the correct type — it activates free mobile keyboards, date pickers, color pickers, and more

type="text"General single-line text
type="email"Email format validation
type="password"Masked characters
type="number"Numeric spinner + up/down
type="tel"Phone — phone keyboard on mobile
type="url"URL format validation
type="date"Native calendar date picker
type="time"Time picker
type="color"Native color picker — returns hex
type="range"Slider (min, max, step)
type="search"Search field with clear ×
type="checkbox"Individual on/off toggle
type="radio"One choice from a group
type="file"File upload button
type="hidden"Data sent with form, not shown
Try it Yourself »
Result

HTML5 Validation Attributes

Server-quality form validation with zero JavaScript required

Key insight: HTML5 validation runs in the browser BEFORE data is sent to the server — no JavaScript needed.
requiredField must not be empty on submit. <input type="email" required>
placeholderGreyed hint text inside field — disappears on typing. <input placeholder="Enter email">
patternValue must match the regular expression. <input pattern="[0-9]{11}">
minlengthMinimum character count (text inputs). <input minlength="8">
maxlengthMaximum character count (text inputs). <input maxlength="20">
minMinimum value for number or date inputs. <input type="number" min="1">
maxMaximum value for number or date inputs. <input type="number" max="100">
stepIncrement for number/range inputs. <input type="range" step="5">
Try it Yourself »
Result

More Form Elements

<select>, <textarea>, radio buttons, checkboxes — the essential form toolkit

Try it Yourself »
Result
Key rule — Radio buttons: All radio buttons in the SAME GROUP must share the same name attribute. The value attribute tells the server WHICH option was chosen. Checkboxes are independent — each has its own name.

Multimedia Elements

<audio>, <video>, <source>, fallback content, <canvas>

Try it Yourself »
Result
controlsShows play/pause/volume controls
autoplayPlays on load (+ muted required)
loopRestarts after ending
mutedStarts with sound off
posterThumbnail image before play
width/heightPixel dimensions of the player
autoplay + mutedRequired pair for autoplay
loopRepeat playback continuously
<canvas id="myCanvas" width="400" height="200"> creates a blank drawing surface. JavaScript is required to draw on it — without JS, it's a completely invisible box (only visible above because we added a CSS border to it).

Accessibility & ARIA

WCAG 2.1 Principles · ARIA Roles & Attributes · Keyboard Navigation

WCAG 2.1 — Four Principles (POUR)

👁 Perceivable

All information must be presentable to users in ways they can perceive — alt text for images, captions for video.

⌨ Operable

All UI must be navigable by keyboard alone — no mouse required. tabindex, focus order, skip links.

💡 Understandable

Content must be clear. Language declared (lang attribute). Error messages explain what went wrong.

🔧 Robust

Content must work with current and future assistive technologies — valid HTML, ARIA, semantic structure.

Key ARIA Attributes for Forms

aria-required="true"Tells screen readers a field is mandatory — use WITH the HTML required attribute.
aria-label="..."Provides an accessible name when no visible label exists.
aria-describedby="id"Points to an element that gives extra info about the field.
aria-hidden="true"Hides decorative elements from screen readers.
aria-invalid="true"Announces a validation error to assistive tech.
role="..."Gives semantic meaning: role="main", role="navigation", role="alert".
Try it Yourself »
Result

Laboratory Activity

Accessible Contact Form  ·  contact-form.html  ·  50 minutes  ·  50 points

🖥️ Task: Build an accessible contact form (contact-form.html) using ALL elements learned today.
R1 · 5 ptsHTML5 Boilerplate — DOCTYPE, html lang, meta charset, meta viewport, title
R2 · 10 ptsForm + 9 Input Types — text, email, tel, select, textarea, radio×3, checkbox, submit, reset
R3 · 8 ptsValidation Attributes — required, minlength, pattern=[0-9]{11}, placeholder, min/max on age
R4 · 7 ptsLabels + Fieldsets — Every input has <label for="id">, 2 fieldsets with legends
R5 · 5 ptsAudio Element — <audio controls> + <source> + fallback text
R6 · 5 ptsVideo Element — <video controls poster width> + 2 <source> + fallback
R7 · 5 ptsARIA Attributes — aria-required, aria-label, aria-describedby, aria-hidden
R8 · 5 ptsSemantic Structure — <header>, <nav>, <main>, <footer>, <h1>, <h2>
💡 Submit: contact-form.html + Chrome screenshot  ·  Test all validation rules before submitting  ·  Total: 50 points

Key Takeaways

What you learned today

  1. 📋 Forms & Inputs — <form>, <input> (15+ types), <select>, <textarea>, <fieldset>/<legend> — the complete form toolkit.
  2. ✅ Validation — required, placeholder, pattern, minlength/maxlength, min/max — the browser enforces rules, no JS needed.
  3. 🎬 Multimedia — <audio> and <video> with controls, source, fallback. <canvas> is a blank JS drawing surface.
  4. ♿ Accessibility — WCAG POUR principles. ARIA: aria-required, aria-label, aria-describedby, aria-hidden.

▶ Next Week

CSS3 Fundamentals

Selectors & Specificity, Cascade, Box Model, Colors, Typography, Web Fonts, Backgrounds, Borders, Shadows