Contents

Introduction

Acknowledgments

About the Authors

1 New Structural Elements in HTML5

BEGINNER RECIPE: Building an HTML5 Starter Document

doctype

Character Encoding

JavaScript and CSS Links

Syntax Writing Style

Where Do All the New Elements Come From?

BEGINNER RECIPE: Using the header Element to Create a Site Header

BEGINNER RECIPE: Using the hgroup Element to Group Headings

BEGINNER RECIPE: Creating Navigation with the nav Element

INTERMEDIATE RECIPE: Using the New article Element

INTERMEDIATE RECIPE: Grouping Content with the section Element

Which Should You Use: article or section?

BEGINNER RECIPE: Creating a Sidebar with the aside Element

BEGINNER RECIPE: Using the footer Element

INTERMEDIATE RECIPE: Using the HTML5 Outliner to Ensure the Correct Structure

ADVANCED RECIPE: Using All the New Elements to Build a News Page

ADVANCED RECIPE: Using All the New Elements to Build a Search Results Page

Summary

2 Grouping, Text-Level, and Redefined Semantics

BEGINNER RECIPE: Marking Up Figures and Captions with the figure and figcaption Elements

BEGINNER RECIPE: Marking Up the Date and Time with the time Element

BEGINNER RECIPE: Making a Native Toggle Widget with the details Element

BEGINNER RECIPE: Using the address Element for Contact Information

BEGINNER RECIPE: Highlighting Text with the mark Element

BEGINNER RECIPE: Using the s Element to Show Inaccurate or Irrelevant Content

Changes to Existing Elements

The cite Element

The ol Element

The dl Element

The small Element

The b and strong Elements

The i and em Elements

The abbr Element

The hr Element

Elements That Are No More

BEGINNER RECIPE: Wrapping Links Around Elements

INTERMEDIATE RECIPE: Adding Semantic Information with Microdata

INTERMEDIATE RECIPE: Using WAI-ARIA with HTML5

ADVANCED RECIPE: Marking Up an Article Page with Comments

Summary

3 Browser Handling in HTML5

BEGINNER RECIPE: Dealing with Internet Explorer

Using JavaScript to Make HTML5 Compatible

Making CSS Compatible

Boilerplates

BEGINNER RECIPE: Testing for HTML5 Features

INTERMEDIATE RECIPE: Leveraging jQuery to Replace a Calendar

INTERMEDIATE RECIPE: Using Modernizr to Detect Features

Polyfilling

Useful HTML5 Verification Sites

Summary

4 New Layout and Style Techniques with CSS3

INTERMEDIATE RECIPE: Creating a Responsive Design with CSS3 Media Queries

Sensible Usage

Targeting the iPhone and Android Devices

BEGINNER RECIPE: Using Custom Fonts with @font-face

File Formats and the Cross-Browser Fix

Type Services

INTERMEDIATE RECIPE: Making Buttons with CSS Gradients and Multiple Backgrounds

INTERMEDIATE RECIPE: Enhancing a Site with Transformations and Transitions

ADVANCED RECIPE: Creating Animations with CSS

Summary

5 HTML5 Web Forms

Validation

HTML 4 Input Types

BEGINNER RECIPE: Creating a Form to Collect Contact Information

input type="email"

input type="tel"

input type="url"

BEGINNER RECIPE: Creating a Search Form with input type="search"

BEGINNER RECIPE: Creating Calendar and Time Controls

input type="datetime"

input type="datetime-local"

input type="date"

input type="time"

input type="month"

input type="week"

Placing Restrictions on Dates and Times

BEGINNER RECIPE: Creating a Number Picker

BEGINNER RECIPE: Creating a Slider (Without the Need for JavaScript)

BEGINNER RECIPE: Creating a Color Picker

BEGINNER RECIPE: Displaying Results with the output Element

BEGINNER RECIPE: Using Form Placeholder Text

BEGINNER RECIPE: Creating an Autocomplete Feature with list and datalist

BEGINNER RECIPE: Tracking the Completion of a Task with the progress Element

BEGINNER RECIPE: Measuring with the meter Element

BEGINNER RECIPE: Jumping to a form Element When the Page Loads

BEGINNER RECIPE: Allowing Multiple Entries

BEGINNER RECIPE: Basic Validation with the required Attribute

INTERMEDIATE RECIPE: Writing Your Own Validation Rule

BEGINNER RECIPE: Limiting User Input

step

min, max

formnovalidate, novalidate

INTERMEDIATE RECIPE: Customizing and Styling the Form

Error Messages

ADVANCED RECIPE: Putting It All Together to Make a Sign-Up Form

Summary

6 Drawing with Canvas

Canvas Overview

Getting Started

X and Y Coordinates

BEGINNER RECIPE: Laying a Grid on the Canvas

Canvas Tools

BEGINNER RECIPE: Making Simple Shapes and Lines

Drawing and Styling a Rectangle or Square

Applying Gradients to Shapes

Drawing Lines and Paths

INTERMEDIATE RECIPE: Drawing Polygons with a Path

INTERMEDIATE RECIPE: Drawing Arcs and Circles

Drawing Curves

BEGINNER RECIPE: Adding Text

BEGINNER RECIPE: Drawing an Image

INTERMEDIATE RECIPE: Cropping an Image

INTERMEDIATE RECIPE: Animating a Sprite Map

Canvas Transformations

ADVANCED RECIPE: Animating an Image

ADVANCED RECIPE: Animating a Vertical Bar Chart

Summary

7 Embedding Video with HTML5

BEGINNER RECIPE: Including Video with the video Element

Browser and Device Support

HTML5 and Video Codecs

Why Should You Care About Codecs?

INTERMEDIATE RECIPE: Enabling Video for All Browsers

Adding Fallback Content for Older Browsers

New Video Attributes

INTERMEDIATE RECIPE: Creating a Video with Subtitles and Captions

Other Subtitle Styling Options

The Media API

ADVANCED RECIPE: Making Your Own Custom Controls

Summary

8 Embedding Audio with HTML5

BEGINNER RECIPE: Including Audio with the audio Element

INTERMEDIATE RECIPE: Enabling Audio for All Browsers

Adding Fallback Content for Older Browsers

New Audio Attributes

The src Attribute

The preload Attribute

The loop Attribute

The autoplay Attribute

The controls Attribute

The Media API

INTERMEDIATE RECIPE: Creating a Beat Mixer

ADVANCED RECIPE: Adding Streaming Radio

Summary

9 Changing Browser History

History Basics

Browser Compatibility

BEGINNER RECIPE: Adding to History with pushState

BEGINNER RECIPE: Creating an Image Viewer

INTERMEDIATE RECIPE: Popping State in the Image Viewer

BEGINNER RECIPE: Changing History with replaceState

INTERMEDIATE RECIPE: Changing the Page History

ADVANCED RECIPE: Using Advanced State Data Objects to Pass Information Across Pages

INTERMEDIATE RECIPE: Testing History Security

Helpful Libraries

Summary

10 Location Awareness with the Geolocation API

Geolocation Overview

Browser Compatibility

Where in the World: getCurrentPosition

BEGINNER RECIPE: Determining Your Location with a Simple getCurrentPosition

Location Privacy

INTERMEDIATE RECIPE: Mapping a Location with getCurrentPosition

INTERMEDIATE RECIPE: Determining Distance with PositionOptions

ADVANCED RECIPE: Following a Moving Location with watchPosition

Summary

11 Client-Side Storage

Client-Side Storage Overview

Data Security

Keys and Values: sessionStorage and localStorage

BEGINNER RECIPE: Getting and Setting Session Storage

Chrome Developer Tools for Viewing Storage

BEGINNER RECIPE: Styling from Session Storage

INTERMEDIATE RECIPE: Storing Forms with Local Storage

ADVANCED RECIPE: Catching Events in Local Storage

Web SQL Database API

ADVANCED RECIPE: Using a Web Database for a Grocery List

Summary

12 Communication and Threading

WebSocket API Overview

BEGINNER RECIPE: Talking Through Web Sockets

Threading Through Web Workers

BEGINNER RECIPE: Creating a Web Worker

INTERMEDIATE RECIPE: Adding Two-Way Communication

ADVANCED RECIPE: Leveraging a Shared Web Worker

Summary

13 Browser Experience in HTML5

Drag and Drop API

BEGINNER RECIPE: Dragging and Dropping Across divs

ADVANCED RECIPE: Leveraging Events and dataTransfer

Application Cache and API

Browser Cache Security

Referencing a Manifest File

BEGINNER RECIPE: Creating a Manifest File

CACHE

FALLBACK

NETWORK

Updating the Cache via the Manifest

BEGINNER RECIPE: Using Web Pages Offline

Application Cache API

Notification API

Notification Permissions

Browser Compatibility

BEGINNER RECIPE: Displaying a Simple Notification

ADVANCED RECIPE: Creating a Tweet Notification Page

Summary

14 Working with Local Files

File API Overview

File API Security

BEGINNER RECIPE: Getting File Attributes

BEGINNER RECIPE: Processing Multiple Files with Drag and Drop

The FileReader Interface

INTERMEDIATE RECIPE: Previewing Images Through readAsDataURL

ADVANCED RECIPE: Parsing a CSV File with readAsText

File API Extended Specifications

ADVANCED RECIPE: Creating a Local File

Summary

15 Integrating Device Data

Brief Device APIs History

Contacts API

BEGINNER RECIPE: Retrieving All Contacts and Mobile Numbers

Messaging API

Network Information API

Battery Status Events

HTML Media Capture

INTERMEDIATE RECIPE: Capturing Pictures with File Input

Device Orientation and Motion Events

INTERMEDIATE RECIPE: Creating a Bubble Level

Summary

Recipes

Index

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset