Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9 Chapter 10 Chapter 11 Chapter 12 Chapter 13 Chapter 14
Chapter 4

HTML5 APIs, Responsive Design & Accessibility

The full API picture, responsive techniques, and making HTML5 accessible.


HTML5 APIs — The Full Picture

APIPurpose
Canvas 2D APIDraw shapes, text and images via JavaScript
Web Workers APIBackground threads for heavy computation
History APIManipulate browser history without a page reload
Fetch APIModern replacement for XMLHttpRequest
Web Storage APIlocalStorage and sessionStorage
Drag & Drop APINative drag-and-drop interactions
Notifications APIDisplay native desktop notifications
Fullscreen APIRequest fullscreen for any element
GeolocationAccess user location with permission
File APIRead local files in the browser
WebSocket APIFull-duplex real-time communication
Server-Sent EventsPush 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

PracticeDetail
Semantic HTML5 elementsScreen readers understand <nav>, <main>, <article> — no extra ARIA needed for basic structure.
Alt text for images<img alt="Description"> provides text alternatives.
Captioned mediaThe <track> element adds subtitles, captions and descriptions to video and audio.
ARIA attributesrole, aria-label, aria-describedby, aria-live enhance complex interactive widgets.
Keyboard navigationAll interactive elements must be keyboard-focusable (Tab / Enter / Space) with visible focus indicators.
Colour contrastWCAG 2.1 requires 4.5:1 for normal text and 3:1 for large text.

Activity — complete the code

Complete the code correctly to mark this lesson as complete automatically.

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));
}