Overview

Chapter 1. HTML5: from documents to applications

HTML5 marks a major shift in the web, moving beyond a language for describing documents and becoming a foundation for building full web applications. The chapter explains that while older HTML versions focused mainly on semantic structure, HTML5 embraces the browser as an application platform and brings together richer markup, native browser behavior, and a wide range of JavaScript-powered capabilities. It emphasizes that the biggest change is not just new tags, but the broader ecosystem of standards that make modern web apps possible.

The chapter surveys the most visible markup improvements first: a simpler document structure, new semantic elements for organizing page regions, and practical additions such as aside content, highlighted text, richer forms, progress indicators, meters, and collapsible sections. It also shows how HTML5 improves accessibility through ARIA roles and how older browsers, especially legacy Internet Explorer versions, can be supported with shivs and other fallbacks. A recurring theme is that HTML5 features should be adopted in a backward-compatible way so existing users are not excluded.

From there, the chapter expands into the wider HTML5 family: microdata for better search and machine-readable meaning, CSS3 for modern styling, and JavaScript APIs that handle drawing, media playback, drag and drop, messaging, editing, storage, offline use, geolocation, files, vector graphics, and 3D graphics. These technologies are presented as the real power behind HTML5’s application model, enabling richer interfaces and more capable web apps. The overall message is that HTML5 is less about replacing HTML4 syntax than about redefining what web pages can do when markup, scripting, and related standards work together.

Listing 1.1. hello.html—The basic structure of an HTML5 document
Listing 1.3. html5-blog.html—HTML5 markup for a blog post
Listing 1.4. ARIA combobox example from www.w3.org/TR/wai-aria/roles#combobox
Examples of some of the new form input widgets introduced in HTML5. Note that not all browsers provide support for widgets yet.
You can use the new placeholder attribute to provide a piece of text that should be displayed in a field when it’s empty. This text is typically gray and will be removed when you populate the field with a value.
The left-hand progress bar is an example of a determinate progress bar. In this example, the value of the bar is set to 50 percent, and the appearance of the bar reflects this because it’s half filled. The right-hand progress bar is an indeterminate bar and doesn’t have a value. It displays an animated full bar to indicate that something’s happening, but the percentage complete isn’t known.
A screenshot of the states in which you can represent a <meter> element: empty, low, medium, high, and full.
An example of the <details> and <summary> elements in action, first in the closed state, where only the code inside the <summary> element is visible, and second in the open state, where the entire contents of the <details> element are visible.
Google reads microdata from HTML documents to provide improved search results to users. By using microdata in your pages, you enable Google to provide similar search result listings for your website or application.
Listing 1.5. html5-microdata.html—Microdata in action
The <canvas> element allows developers to present information in more creative ways. You’ll learn how to build this game in chapter 6.
YouTube HTML5 video in action. As you can see from the code in the inspector, the YouTube video in this screenshot doesn’t use the Adobe Flash plug-in but is fully implemented using the HTML5 <video> element and related APIs.
Gmail allows you to drag files into the browser window and drop them into a designated area to add them as attachments to your messages.
A simple application demonstrating channel messaging. You’ll build this in appendix J, one of the companion appendices to chapter 4.
A chat application implemented using server-sent events
The Super HTML5 Editor application that you’ll learn to build in chapter 3 uses the designMode attribute and the Editing DOM API to allow users to edit HTML markup using a set of rich-text editing controls. The toolbar in this screenshot allows you to use Bold, Italic, Underline, Strikethrough, List, Link, and Image formatting commands on the contents of the area below the toolbar.
In chapter 5, you’ll learn how to use the localStorage interface to persist user settings in a mobile task-management application.
A screenshot of the mobile application with offline capabilities that you’ll create in chapter 5
Adding maps showing your current location in the chapter 3 application
The chapter 5 application will use IndexedDB to store a list of tasks and allow fast sorting and searching.
The Super HTML5 Editor you’ll build in chapter 3 will allow you to perform file operations such as creating a new blank file and importing an existing file either by selecting it or dragging it into the application. It’ll store these files in a sandboxed local filesystem, from which you can view, edit, and delete the files or export them to your computer by dragging them out of the application.
The SVG Aliens game in action. You’ll learn to build this game in its entirety later in this book.
The 3D Geometry Destroyer game in all its glory. Building this game is covered in chapter 9.

FAQ

What is the main shift introduced by HTML5 compared with HTML4?HTML5 shifts the web from being primarily a platform for documents to being a platform for web applications. It keeps semantic markup important, but adds features and APIs aimed at building interactive, browser-based apps.
Why are the new semantic elements in HTML5 important?They give meaning to page structure in a standardized way, making it easier for search engines, screen readers, and other tools to understand the content. They also replace inconsistent class- and ID-based structuring with elements whose purpose is built into HTML itself.
Do HTML5 semantic elements change how content looks by default?No. Most HTML5 semantic elements behave like block-level elements similar to divs. Their value is semantic meaning, not visual styling, and they can still be styled with CSS as needed.
How does HTML5 improve accessibility?HTML5 works with ARIA roles and attributes to provide richer accessibility information for assistive technologies such as screen readers. It also defines default implied roles for many elements, improving how interactive content is understood.
How can older versions of Internet Explorer support new HTML5 elements?In IE 6 to 8, you can use a small JavaScript snippet such as document.createElement("header") to force the browser to recognize and style new HTML5 elements. For broader support and printing issues, developers often use an HTML5 shiv.
What new form input types does HTML5 introduce?HTML5 adds input types such as color, date, datetime, datetime-local, email, month, number, range, search, tel, time, url, and week. Older browsers fall back to text inputs when they do not support a new type.
What HTML5 form attributes help with usability and validation?HTML5 introduces attributes such as placeholder, required, pattern, min, max, step, autofocus, autocomplete, multiple, and list. Some of these improve user experience, while others support client-side validation and input constraints.
What are the differences between progress and meter elements?The progress element represents task completion, either as a known percentage or as an indeterminate loading state. The meter element represents a scalar measurement within a known range, such as low, medium, and high values.
What is microdata used for in HTML5?Microdata adds structured semantic information to a document so search engines and other applications can interpret it more precisely. It can improve search results and other context-aware features by describing things like events, products, people, or organizations.
What are some of the major JavaScript APIs and related specifications discussed in this chapter?This chapter introduces or previews APIs and specs such as Canvas, audio and video, drag and drop, cross-document messaging, server-sent events, WebSockets, document editing, Web Storage, offline applications, geolocation, IndexedDB, file-related APIs, SVG, and WebGL.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


Close
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • HTML5 in Action HTML5 in Action ebook for free
Close
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • HTML5 in Action HTML5 in Action ebook for free