Chapter 4: HTML5 & Modern Web Development
69 slides · use ←/→ or Space to navigate, F for fullscreen.
Jump to a lesson deck: What is HTML5? History & Goals HTML4 vs HTML5: Doctype & Page Structure HTML5 Semantic & Markup Elements Native Media & Embedding Video Canvas & SVG Graphics HTML5 Forms & New Input Types CSS3 Effects & Improved Selectors Web Storage: localStorage & sessionStorage Geolocation & Web Workers Offline Apps & Drag-and-Drop Advantages of HTML5 & CSS3 HTML5 APIs, Responsive Design & Accessibility Chapter 4 Key Takeaways
Chapter 4: HTML5 & Modern Web Development
Semantic HTML5, native media, Canvas & SVG, forms, CSS3 effects, Web Storage, Geolocation, Web Workers, offline apps and drag & drop.
What is HTML5? History & Goals
HTML5 as a complete platform, where it came from, and the goals that shaped it.
What is HTML5?
HTML5 is not just a markup language — it is a complete platform for the modern web, made of three layers working together.
| Layer | Role |
|---|---|
| HTML5 — structure & markup | New semantic elements, forms and accessibility improvements |
| CSS3 — presentation & style | Animations, gradients, flex/grid layout, custom fonts |
| JavaScript — behaviour & APIs | DOM, Ajax, Canvas, Web Storage, Geolocation, Workers |
HTML5 = HTML5 markup + CSS3 + JavaScript APIs.
History of HTML
| Year | Version | Milestone |
|---|---|---|
| 1991 | HTML 1.0 | Tim Berners-Lee's first specification |
| 1995 | HTML 2.0 | First formal standard |
| 1997 | HTML 3.2 | Tables, scripting, CSS |
| 1997–98 | HTML 4.01 / XHTML 1.0 | Widely adopted |
| 2008 | HTML5 draft | W3C working draft published; WHATWG formed |
| 2014 | HTML5 | Official W3C Recommendation |
Goals of HTML5
| Goal | Meaning |
|---|---|
| Backward compatible | All existing web pages continue to work — no need to rewrite legacy sites. |
| Reduce plugin dependency | Built-in audio, video and canvas eliminate reliance on Flash and Java applets. |
| Semantic clarity | New elements communicate meaning and structure to browsers and developers. |
| Device independence | Web content renders consistently across desktops, tablets and phones. |
| Robust error handling | Browsers parse and display malformed markup gracefully and consistently. |
Activity — complete the code
Complete the HTML5 document head.
html><html lang="en"><head><meta ="UTF-8"><meta name="viewport" content="width=, initial-scale=1"><title>HTML5</title></head><body><h1>Hello HTML5</h1></body></html>
HTML4 vs HTML5: Doctype & Page Structure
What changed from HTML4/XHTML, the simplified doctype, and the new page skeleton.
HTML4 vs HTML5 — Key Differences
| Feature | HTML 4 | HTML 5 |
|---|---|---|
| Structure | Generic <div> containers | Semantic tags: <header>, <nav>, <article>, <section>, <aside>, <footer> |
| Media | Requires Flash / plug-ins | Native <audio> & <video> elements |
| Syntax | Cannot handle inaccurate code | Tolerant parser, graceful degradation |
| APIs | Traditional DOM APIs only | Canvas, Drag & Drop, Geolocation, Workers |
| Local storage | Cookies only (~4 KB) | localStorage / sessionStorage (5 MB+) |
| Forms | Basic input types | date, email, url, range, color, and more |
Document Type Declarations
HTML 4.01 and XHTML required long, version-specific doctypes. HTML5 simplified it dramatically:
<!DOCTYPE html>
Easy to memorise, and version-independent — the same doctype works for the living standard.
HTML5 Page Structure
The old way relied on generic containers with IDs:
<div id="header">...</div>
<div id="nav">...</div>
<div id="section">...</div>
<div id="aside">...</div>
<div id="footer">...</div>
HTML5 replaces them with meaningful elements:
<header>...</header>
<nav>...</nav>
<section>...</section>
<article>...</article>
<aside>...</aside>
<footer>...</footer> Activity — complete the code
Replace the old HTML4 containers with HTML5 equivalents.
<!-- Old HTML4 --><div id="header">...</div><!-- HTML5 --><>...</header><!-- Old HTML4 --><div id="footer">...</div><!-- HTML5 --><>...</footer><!-- Doctype -->html>
HTML5 Semantic & Markup Elements
The new elements that describe meaning, and the complete markup reference.
HTML5 Semantic Elements
Semantic elements describe meaning to both the browser and the developer.
| Element | Meaning |
|---|---|
<header> | Introductory content, logos, navigation |
<nav> | Primary navigation links |
<main> | Dominant content of the document |
<article> | Self-contained, independent content |
<section> | Thematic grouping of content |
<aside> | Tangentially related content (sidebars) |
<footer> | Footer for the nearest section or the document |
<figure> / <figcaption> | Self-contained illustration or media, with a caption |
<time> | Machine-readable date or time (ISO 8601) |
<mark> | Highlighted / search-relevant text |
<details> / <summary> | Disclosure widget with a visible label |
Markup Elements Reference
| Element | Purpose |
|---|---|
<figure> | Independent, self-contained content (image, code, diagram) with optional caption |
<progress> | Task completion indicator (loading, processing) |
<meter> | Scalar measurement within a known range (disk space, score) |
<details> / <summary> | Disclosure widget hidden until toggled; summary is the visible label |
<aside> | Content related but aside from the main content (sidebars, pull quotes) |
<figcaption> | Caption or legend for the parent <figure> |
<time> | Machine-readable date/time using ISO 8601 |
New Elements at a Glance
<figure>, <figcaption>, <svg>, <footer>, <progress>, <header>, <section>, <video>, <hgroup>, <details>.
Activity — complete the code
Complete the semantic markup elements.
<figure><img src="chart.png" alt="Sales chart"><>Sales chart</figcaption></figure><><summary>Click to expand</summary><p>Hidden content.</p></details><progress value="70" ="100"></progress>
Native Media & Embedding Video
audio, video, source and track — plus embedding YouTube with iframes.
HTML5 Media Elements
| Element | Purpose |
|---|---|
<audio> | Embeds audio with native browser controls. Supports MP3, OGG, WAV. No Flash required. |
<video> | Embeds video. Supports MP4, WebM, OGG. Attributes: controls, autoplay, loop, muted. |
<source> | Specifies multiple media resources so the browser picks its best-supported format. |
<track> | Adds timed text tracks (subtitles, captions, chapters) to video and audio. |
<embed> | Container for external applications or plug-ins (legacy) — prefer audio/video. |
Video Example
<video width="640" height="368" controls poster="thumb.jpg">
<source src="movie.mp4" type="video/mp4">
<source src="movie.webm" type="video/webm">
Your browser does not support the video tag.
</video>
Audio Example
<audio controls>
<source src="music.mp3" type="audio/mpeg">
<source src="music.ogg" type="audio/ogg">
Your browser does not support the audio element.
</audio>
Use multiple <source> elements to ensure cross-browser compatibility.
Embedding YouTube Videos
- Upload your video to YouTube and obtain its video ID from the URL.
- Use an
<iframe>element — not the older<embed>or<object>tags. - Set the
srctohttps://www.youtube.com/embed/{VIDEO_ID}. - Control dimensions with
widthandheightattributes. - Add parameters for autoplay, loop, controls, etc.
<!-- Basic YouTube embed -->
<iframe
src="https://www.youtube.com/embed/VIDEO_ID"
width="560" height="315"
title="YouTube video"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen>
</iframe> Activity — complete the code
Complete the native video element.
<video width="640" height="368" poster="thumb.jpg"><source src="movie.mp4" type=""><source src="movie.webm" type="video/webm">< src="subs.vtt" kind="captions" default>Your browser does not support the video tag.</video>
Canvas & SVG Graphics
Bitmap drawing with Canvas, scalable vector graphics with SVG, and when to use each.
The HTML5 Canvas Element
The <canvas> element provides a resolution-dependent bitmap surface for JavaScript-driven drawing.
<canvas id="myCanvas" width="400" height="300"></canvas>
const canvas = document.getElementById("myCanvas");
const ctx = canvas.getContext("2d");
// Draw a red rectangle
ctx.fillStyle = "rgb(200, 0, 0)";
ctx.fillRect(10, 10, 120, 90);
// Draw a blue rectangle (overlapping)
ctx.fillStyle = "rgba(0, 0, 200, 0.6)";
ctx.fillRect(60, 55, 120, 90);
// Draw a circle
ctx.beginPath();
ctx.arc(250, 150, 60, 0, Math.PI * 2);
ctx.fillStyle = "#0891B2";
ctx.fill();
Canvas capabilities
- Draw shapes, paths and gradients
- Render and manipulate images
- Animate using
requestAnimationFrame - Capture user events (click, drag)
- Export the result as PNG or JPEG
Canvas is raster-based — quality degrades when scaled.
Scalable Vector Graphics (SVG)
Inline SVG in HTML5:
<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200">
<circle cx="60" cy="60" r="40" fill="#0891B2" />
<rect x="100" y="20" width="80" height="80" fill="#7C3AED" />
<text x="20" y="160" font-size="18">SVG</text>
</svg>
SVG key properties
- Resolution independent — scales perfectly at any size
- Supports event handlers (
onclick,onmouseover) - Part of the DOM — style with CSS, script with JS
- Ideal for icons, charts, maps and illustrations
- Each shape is a separate DOM element
- Accessible — add
title,descand ARIA attributes
Canvas vs SVG — When to Use Which?
| Criterion | Canvas | SVG |
|---|---|---|
| Type | Raster (pixel-based) | Vector (coordinate-based) |
| Resolution | Dependent — blurs when scaled | Independent — crisp at any size |
| Event handling | Not built-in (manual hit-testing) | Native (each shape is a DOM node) |
| Performance | Fast for many pixels / frames | Slower with many DOM elements |
| Best use cases | Games, photo editing, animation | Charts, maps, icons, diagrams |
| Accessibility | Limited without extra work | Full ARIA / semantic support |
| Export | PNG / JPEG snapshot | XML file, scalable, editable |
Activity — complete the code
Complete the canvas drawing code and the SVG shape.
<canvas id="art" width="400" height="300"></canvas><script>const ctx = document.getElementById("art").("2d");ctx. = "#2563eb";ctx.fillRect(10, 10, 120, 90);</script><svg xmlns="http://www.w3.org/2000/svg">< cx="60" cy="60" r="40" fill="teal" /></svg>
HTML5 Forms & New Input Types
Enhanced inputs, validation attributes and new form elements.
New HTML5 Input Types
| Type | Purpose |
|---|---|
email | Auto-validates email format |
url | Validates URL format |
number | Spinner control with min / max / step |
range | Slider control |
date | Native date picker |
time | Native time picker |
datetime-local | Date + time combined |
month / week | Month / week selector |
search | Clear button on supported browsers |
color | Colour picker widget |
tel | Opens numeric keypad on mobile |
HTML5 Form Enhancements
<!-- Placeholder text -->
<input type="text" placeholder="Your name">
<!-- Pattern validation -->
<input type="text" pattern="[0-9]{5}" title="5 digits">
<!-- Required field -->
<input type="email" required>
<!-- Autocomplete -->
<input type="text" autocomplete="name">
Datalist (Suggestions)
<input list="courses" name="course">
<datalist id="courses">
<option value="HTML">
<option value="CSS">
<option value="JavaScript">
</datalist>
Provides a list of pre-defined options for an <input> — like an autocomplete suggestion box.
Output, Progress & Meter
<input type="range" id="r" value="0"
oninput="o.value = r.value">
<output id="o" for="r">0</output>
<progress value="70" max="100">70%</progress>
<meter value="75" min="0" max="100">75%</meter>
| Element | Purpose |
|---|---|
<output> | Represents the result of a calculation or user interaction — ideal for live form computations. |
<progress> | Displays a progress bar indicating how much of a task has been completed. |
<meter> | Represents a scalar measurement within a known range — disk usage, score, relevance. |
Activity — complete the code
Complete the HTML5 form with new input types and elements.
<form><input type="" placeholder="you@example.com"><input type="" name="age" min="1" max="120"><input ="courses" name="course"><datalist id="courses"><option value="HTML"><option value="CSS"></datalist>< value="70" max="100"></progress></form>
CSS3 Effects & Improved Selectors
Rounded corners, shadows, gradients, transforms and the new CSS3 selectors.
CSS3 Key Features
| Feature | Example |
|---|---|
| Rounded corners | border-radius: 12px; |
| Box shadow | box-shadow: 4px 4px 12px rgba(0,0,0,.25); |
| Gradients | background: linear-gradient(135deg, #0891B2, #7C3AED); |
| Text shadow | text-shadow: 2px 2px 4px rgba(0,0,0,.35); |
| Opacity / RGBA | background-color: rgba(8,145,178,.6); |
| Transforms | transform: rotate(45deg) scale(1.2); |
| Multiple columns | column-count: 3; column-gap: 1.5rem; |
| Transitions & animation | transition: all .3s ease-in-out; |
CSS3 in Practice — Code Example
.card {
padding: 2rem;
width: 300px;
/* Rounded corners */
border-radius: 16px;
/* Gradient background */
background: linear-gradient(135deg, #0891B2, #7C3AED);
/* Shadow */
box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
/* Transition for hover effect */
transition: transform .3s ease, box-shadow .3s ease;
}
.card:hover {
transform: translateY(-6px) scale(1.02);
box-shadow: 0 16px 40px rgba(0, 0, 0, .35);
}
border-radiuscreates rounded corners without images.linear-gradientreplaces gradient images.box-shadoweliminates the need for shadow images.transitionanimates property changes smoothly.transformallows 2D/3D manipulation.
Vendor prefixes are rarely needed in modern browsers.
CSS3 Improved Selectors
| Selector | Matches |
|---|---|
[attr^="value"] | Attribute starts-with — e.g. links starting with https |
[attr$="value"] | Attribute ends-with — e.g. images ending in .png |
[attr*="value"] | Attribute contains — flexible substring matching |
:nth-child(n) | Select by position — e.g. every 2nd row in a table |
:first-child / :last-child | First / last child of its parent |
:checked | Checked checkbox/radio inputs |
:not(selector) | All elements that do NOT match the given selector |
:focus-visible | Show the focus ring only for keyboard users — improves UX |
Activity — complete the code
Complete the CSS3 card effect.
.card {border-radius: ;background: -gradient(135deg, #0891B2, #7C3AED);box-shadow: 0 8px 24px rgba(0, 0, 0, .25);transition: transform .3s ease;}.card:hover {transform: translateY(-6px) (1.02);}
Web Storage: localStorage & sessionStorage
Client-side storage APIs, code examples, and how they compare with cookies and IndexedDB.
The Web Storage API
Before HTML5, cookies (~4 KB) were the only client-side storage option — limited, insecure, and sent with every request.
| localStorage | sessionStorage |
|---|---|
|
Persistent — survives browser close/reopen Scoped per origin (domain + protocol + port) ~5 MB per origin (browser-dependent) JavaScript key-value API: setItem / getItemNOT sent to server — stays in the browser Use for preferences, cached data, offline content |
Session-scoped — cleared when the tab/window closes Each tab has its own independent storage Same ~5 MB size limit Identical API to localStorage Use for per-session state: forms, wizard steps More private — not shared between tabs |
Web Storage — Code Examples
// localStorage
if (typeof Storage !== "undefined") {
// Store a string value
localStorage.setItem("username", "Alice");
// Store an object (serialize to JSON)
const prefs = { theme: "dark", lang: "en" };
localStorage.setItem("prefs", JSON.stringify(prefs));
// Retrieve and parse
const saved = JSON.parse(localStorage.getItem("prefs"));
console.log(saved.theme); // "dark"
// Remove one key / clear everything
localStorage.removeItem("username");
localStorage.clear();
}
// sessionStorage
sessionStorage.setItem("step", "2");
const step = sessionStorage.getItem("step"); // "2"
// Iterate all keys
for (let i = 0; i < sessionStorage.length; i++) {
const key = sessionStorage.key(i);
console.log(key, sessionStorage.getItem(key));
}
Storage Options Comparison
| Size limit | Sent to server | Data types | Best for | |
|---|---|---|---|---|
| Cookie | ~4 KB | Yes (every request) | Strings only | Auth tokens |
| localStorage | ~5 MB+ | No | Strings only | Preferences / cache |
| sessionStorage | ~5 MB+ | No | Strings only | Per-session state |
| IndexedDB | Hundreds of MB+ | No | Any JS object | Large / complex data |
Activity — complete the code
Complete the Web Storage code.
// Save a valuelocalStorage.("username", "Alice");// Read a valueconst name = localStorage.("username");// sessionStorage is cleared when the closes.
Geolocation & Web Workers
Location-aware apps with explicit permission, and background threads for heavy computation.
HTML5 Geolocation API
Geolocation lets a web application access the user's physical location — with explicit permission.
// Check if geolocation is supported
if ("geolocation" in navigator) {
// Get current position (one-time)
navigator.geolocation.getCurrentPosition(
(position) => {
const lat = position.coords.latitude;
const lon = position.coords.longitude;
const acc = position.coords.accuracy; // meters
console.log(`Lat: ${lat}, Lon: ${lon}, Accuracy: ${acc}m`);
},
(error) => console.error("Error: ", error.message),
{ enableHighAccuracy: true, timeout: 5000 }
);
// Watch position changes (continuous)
const watchId = navigator.geolocation.watchPosition(callback);
// Stop watching
navigator.geolocation.clearWatch(watchId);
}
Methods
getCurrentPosition()— retrieves the position oncewatchPosition()— continuously monitors positionclearWatch(id)— stops watching
Location sources
IP address, Wi-Fi triangulation, cell tower data and GPS (device hardware).
Geolocation: Privacy & Best Practices
- User consent required — the browser always prompts before sharing location; no data is transmitted without explicit permission.
- Accuracy varies — IP address is city-level (~10 m), Wi-Fi is more precise, GPS is most accurate.
- HTTPS required — modern browsers block geolocation over HTTP. Always deploy with TLS/HTTPS.
- Respect the user — cache location when appropriate and don't call
watchPosition()unnecessarily (it drains battery).
Web Workers — Background Threads
JavaScript is single-threaded by design. Web Workers add true background execution so heavy tasks don't freeze the UI.
// main.js
const worker = new Worker("worker.js");
worker.postMessage({ data: bigArray });
worker.onmessage = (e) => {
console.log("Result:", e.data);
};
// worker.js
self.onmessage = (e) => {
const result = heavyComputation(e.data);
self.postMessage(result);
};
- CPU-intensive tasks don't freeze the UI.
- Multiple workers can run in parallel.
- Communicate via
postMessage()/onmessage. - No access to the DOM (runs in a separate scope).
Activity — complete the code
Complete the Geolocation call and the Web Worker.
if ("geolocation" in navigator) {navigator.geolocation.((position) => {console.log(position.coords.latitude);});}// Background threadconst worker = new ("worker.js");worker.({ data: bigArray });
Offline Apps & Drag-and-Drop
Cache manifests for offline use and the native Drag & Drop API.
HTML5 Offline Applications
HTML5 supports local caching of web app code and content, enabling use without an internet connection. A cache manifest lists what to store.
CACHE MANIFEST
# Version 1.0.2
CACHE:
index.html
styles/app.css
scripts/app.js
images/logo.png
NETWORK:
api/login.php
FALLBACK:
/app/ /offline.html
| Section | Meaning |
|---|---|
CACHE | Files listed here are downloaded once and served from the local cache thereafter. |
NETWORK | Files in this section always require a network connection — never cached. |
FALLBACK | Specifies a fallback page to serve when a network resource is unavailable. |
Modern practice replaces App Cache with Service Workers, which give finer control over offline caching.
HTML5 Drag and Drop API
<div id="item" draggable="true">Drag me!</div>
<div id="zone">Drop here</div>
const item = document.getElementById("item");
const zone = document.getElementById("zone");
// Events on the draggable element
item.addEventListener("dragstart", (e) => {
e.dataTransfer.setData("text/plain", e.target.id);
e.target.style.opacity = "0.5";
});
item.addEventListener("dragend", (e) => {
e.target.style.opacity = "1";
});
// Events on the drop target
zone.addEventListener("dragover", (e) => {
e.preventDefault(); // allow the drop
});
zone.addEventListener("drop", (e) => {
e.preventDefault();
const id = e.dataTransfer.getData("text/plain");
zone.appendChild(document.getElementById(id));
});
| Event | Fires when |
|---|---|
dragstart | Dragging begins |
drag | Continuously while dragging |
dragend | The drag operation ends |
dragenter | A dragged item enters a target |
dragover | Dragging over a target |
dragleave | The item leaves a target |
drop | The item is released on a target |
Activity — complete the code
Complete the Drag and Drop handlers.
<div id="item" ="true">Drag me!</div>zone.addEventListener("", (e) => {e.preventDefault();});zone.addEventListener("drop", (e) => {const id = e..getData("text/plain");});
Advantages of HTML5 & CSS3
Multi-platform reach, SEO, offline capability, browser consistency and the standards timeline.
Cost-Effective Multi-Platform Development
- Write once, deploy everywhere — HTML5 code runs on desktops, tablets, phones and smart TVs.
- Lower costs — one codebase serves all platforms, reducing development, testing and maintenance effort.
- Hybrid apps — combine web standards inside a native wrapper to publish to app stores.
- iOS & Android — the recommended approach for cross-platform mobile; frameworks like Cordova/Capacitor wrap it natively.
- Code reuse — shared templates, CSS and JavaScript across desktop and mobile sites.
HTML5 & Search Engine Optimisation (SEO)
| Factor | Benefit |
|---|---|
| Semantic structure | Search engines read <article>, <nav>, <main> to understand page structure — improving index quality. |
| Logical hierarchy | A clean heading hierarchy (h1 → h2 → h3) signals document meaning to bots and screen readers. |
| Native video | HTML5 video is indexable by search engines — unlike Flash content. |
| Performance | Offline cache, local storage and reduced plugin overhead speed up page load — a key ranking signal. |
| Microdata | Structured data (Schema.org) enables Google Rich Snippets: stars, prices, events. |
Offline Browsing — A Business Advantage
- Publishers & news — readers access articles downloaded while online, continuing offline on public transport or in poor signal areas.
- Enterprise apps — field workers use web-based tools in remote locations, syncing when connectivity returns.
- Performance boost — cached assets (CSS, JS, images) are served instantly from local storage rather than the network.
- User retention — apps that work offline are perceived as more reliable and professional.
Consistency Across Browsers & Devices
HTML5 and CSS3 target a consistent rendering model, reducing the "works in Chrome, breaks in Firefox" problem. Modern browsers score 85–95% of the HTML5 specification.
| Browser | HTML5 test score (/555) |
|---|---|
| Chrome | 528 |
| Opera | 518 |
| Edge | 492 |
| Firefox | 491 |
| Safari | 471 |
Business Intelligence & Native Video
- HTML5-compatible devices share a consistent data collection and analytics layer.
- Standard browser APIs (Fetch, WebSockets) enable real-time dashboards.
- Native video plays on all devices — including iOS — without Flash or Silverlight, and positively impacts SEO.
- Accessible, standards-compliant HTML5 sites reach a wider audience, including assistive-technology users.
Web Standards Evolution
| Era | HTML | CSS | JavaScript |
|---|---|---|---|
| 1991–96 | HTML 1–2 | CSS 1–2 | — |
| 1997–98 | HTML 3.2–4.0 | CSS 2.1 | JS / ECMA |
| 2003–08 | HTML 4.01 / XHTML 1 | CSS 2.1 | DOM 2, Ajax |
| 2009–14 | XHTML 2 (abandoned), HTML5 draft | CSS 3 modules | DOM APIs |
| 2014–22 | HTML5 Recommendation | CSS 3 modules | ES6+, Fetch |
Activity — complete the code
Complete the SEO-friendly semantic markup and native video.
<!-- SEO-friendly semantic structure --><><>Article content</article></main><!-- Native video (indexable, no Flash) --><video ><source src="promo.mp4" type=""></video>
HTML5 APIs, Responsive Design & Accessibility
The full API picture, responsive techniques, and making HTML5 accessible.
HTML5 APIs — The Full Picture
| API | Purpose |
|---|---|
| Canvas 2D API | Draw shapes, text and images via JavaScript |
| Web Workers API | Background threads for heavy computation |
| History API | Manipulate browser history without a page reload |
| Fetch API | Modern replacement for XMLHttpRequest |
| Web Storage API | localStorage and sessionStorage |
| Drag & Drop API | Native drag-and-drop interactions |
| Notifications API | Display native desktop notifications |
| Fullscreen API | Request fullscreen for any element |
| Geolocation | Access user location with permission |
| File API | Read local files in the browser |
| WebSocket API | Full-duplex real-time communication |
| Server-Sent Events | Push data from server to browser |
HTML5 & Responsive Web Design
Viewport meta tag
<meta name="viewport" content="width=device-width, initial-scale=1">
Controls how the browser scales the page on mobile devices — essential for all responsive sites.
Flexible images
img { max-width: 100%; height: auto; }
CSS media queries
@media (max-width: 768px) {
.sidebar { display: none; }
.main { width: 100%; }
}
CSS Grid & Flexbox
.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
Modern CSS layout systems replace table-based and float-based layouts with responsive-friendly alternatives.
HTML5 & Web Accessibility
| Practice | Detail |
|---|---|
| Semantic HTML5 elements | Screen readers understand <nav>, <main>, <article> — no extra ARIA needed for basic structure. |
| Alt text for images | <img alt="Description"> provides text alternatives. |
| Captioned media | The <track> element adds subtitles, captions and descriptions to video and audio. |
| ARIA attributes | role, aria-label, aria-describedby, aria-live enhance complex interactive widgets. |
| Keyboard navigation | All interactive elements must be keyboard-focusable (Tab / Enter / Space) with visible focus indicators. |
| Colour contrast | WCAG 2.1 requires 4.5:1 for normal text and 3:1 for large text. |
Activity — complete the code
Complete the responsive page setup.
<meta name="" content="width=device-width, initial-scale=1">img {max-width: ;height: auto;}.grid {display: grid;grid-template-columns: repeat(, minmax(200px, 1fr));}
Chapter 4 Key Takeaways
Everything you need to remember about HTML5.
Key Takeaways
| # | Takeaway |
|---|---|
| 1 | HTML5 = HTML + CSS3 + JS APIs — it's a complete platform, not just a markup language. |
| 2 | Semantic elements — <header>, <nav>, <article>, <section> improve structure, SEO and accessibility. |
| 3 | Native media — <audio> and <video> eliminate Flash dependency; built-in, cross-browser, mobile-ready. |
| 4 | Powerful APIs — Canvas, Geolocation, Web Storage, Workers, Drag & Drop — all without plugins. |
| 5 | CSS3 effects — gradients, shadows, animations, transforms, flexbox & grid — pure CSS, no images. |
| 6 | Offline & storage — app cache and localStorage enable offline-capable web apps with persistent data. |
Further Reading
- MDN Web Docs —
developer.mozilla.org - HTML5 Specification —
html.spec.whatwg.org - W3Schools HTML5 —
w3schools.com/html - Can I use —
caniuse.com
Activity — complete the code
Complete the HTML5 recap.
HTML5 = HTML + CSS3 + APIsSemantic elements: <header>, <nav>, <>, <section>Native media: <> and <video>APIs: Canvas, Geolocation, Web Storage,