Cover image for HTML5 Cookbook

Book description

With scores of practical recipes you can use in your projects right away, this cookbook helps you gain hands-on experience with HTML5’s versatile collection of elements. You get clear solutions for handling issues with everything from markup semantics, web forms, and audio and video elements to related technologies such as geolocation and rich JavaScript APIs.

Table of Contents

  1. Special Upgrade Offer
  2. Preface
    1. What Is HTML5?
    2. What’s in This Book
    3. Audience
    4. Assumptions This Book Makes
    5. Conventions Used in This Book
    6. Using Code Examples
    7. Safari® Books Online
    8. How to Contact Us
    9. Acknowledgments
  3. 1. Fundamental Syntax and Semantics
    1. Introduction
    2. 1.1. Specifying the DOCTYPE
    3. 1.2. Specifying the Character Set
    4. 1.3. Specifying the Language
    5. 1.4. Optimizing <script>s and <link>s
    6. 1.5. Adding Document Structure with HTML5’s New Elements
    7. 1.6. Choosing Between <article> and <section>
    8. 1.7. Checking Your Document Outline
    9. 1.8. Modifying the Document Outline
    10. 1.9. Emphasizing Text
    11. 1.10. Adding Importance to Text
    12. 1.11. Highlighting Text for Reference
    13. 1.12. Marking Up Small Print
    14. 1.13. Defining Acronyms and Abbreviations
    15. 1.14. Adding Links to Block-Level Content
    16. 1.15. Marking Up Figures and Captions
    17. 1.16. Marking Up Dates and Times
    18. 1.17. Setting the Stage for Native Expanding and Collapsing
    19. 1.18. Controlling the Numbering of Your Lists
    20. 1.19. Hiding Content to Show Later
    21. 1.20. Making Portions of a Page Editable
    22. 1.21. Setting the Stage for Native Drag-and-Drop
  4. 2. Progressive Markup and Techniques
    1. Introduction
    2. 2.1. Adding More Semantic Meaning
    3. 2.2. Picking a Markup Style
    4. 2.3. Understanding Browser Support for HTML5
    5. 2.4. Making Internet Explorer Recognize HTML5 Elements
    6. 2.5. Detecting HTML5 Features with JavaScript
    7. 2.6. Using HTML5 Boilerplate
    8. 2.7. Validating HTML5
    9. 2.8. Mapping HTML5 Elements to ID and Class Names
  5. 3. Forms
    1. Introduction
    2. 3.1. Displaying a Search Input Field
    3. 3.2. Contact Information Input Fields
    4. 3.3. Utilizing Date and Time Input Fields
    5. 3.4. Number Inputs
    6. 3.5. Selecting from a Range of Numbers
    7. 3.6. Selecting Colors
    8. 3.7. Creating an Editable Drop-Down
    9. 3.8. Requiring a Form Field
    10. 3.9. Autofocusing a Form Field
    11. 3.10. Displaying Placeholder Text
    12. 3.11. Disabling Autocomplete
    13. 3.12. Restricting Values
    14. 3.13. Making HTML5 Work in Older Browsers
    15. 3.14. Validating Form Data in Older Browsers with JavaScript
    16. 3.15. Example: Sample Form
  6. 4. Native Audio
    1. Introduction
    2. 4.1. Adding HTML5 Audio
    3. 4.2. Manipulating the Audio Stream
    4. 4.3. Generating <audio> Using JavaScript
    5. 4.4. Visualizing <audio> Using <canvas>
    6. 4.5. Sample Design: Custom Audio Player
  7. 5. Native Video
    1. Introduction
    2. 5.1. Adding HTML5 Video
    3. 5.2. Ensuring Multi-Browser Video Support
    4. 5.3. Setting Video Dimensions
    5. 5.4. Displaying a Placeholder Image Before Video Plays
    6. 5.5. Making Video Loop
    7. 5.6. Sample Design: Manipulating Video with <canvas>
  8. 6. Microdata and Custom Data
    1. Introduction
    2. 6.1. Adding Microdata to Markup
    3. 6.2. Using Microdata and Schema.org
    4. 6.3. Adding Custom Data to Markup
    5. 6.4. Accessing Custom Data with JavaScript
    6. 6.5. Manipulating Custom Data
    7. 6.6. Example: Creating a Map Application Using Custom Data
  9. 7. Accessibility
    1. Introduction
    2. 7.1. Writing Appropriate alt Text Descriptions
    3. 7.2. Identifying Abbreviations and Acronyms
    4. 7.3. Identifying Sections of a Page Using ARIA Landmark Roles
    5. 7.4. Creating More Accessible Navigation Links
    6. 7.5. Associating Form Fields with Their Labels
    7. 7.6. Grouping Form Fields Logically
    8. 7.7. Enabling a fieldset Dynamically
    9. 7.8. Identifying Required Form Fields
    10. 7.9. Using ARIA Live Regions to Announce When Dynamic Content Is Updating
  10. 8. Geolocation
    1. Introduction
    2. 8.1. Getting Basic Geolocation Data
    3. 8.2. Getting Basic Geolocation Data with a Fallback
    4. 8.3. Reverse Geocoding an Address with Latitude and Longitude
    5. 8.4. Converting an Address into Latitude and Longitude
    6. 8.5. Getting Directions from the Current Location
    7. 8.6. Example: Starbucks to Starbucks
  11. 9. <canvas>
    1. Introduction
    2. 9.1. Drawing on a <canvas>
    3. 9.2. Using Transparency
    4. 9.3. Setting <canvas> Dimensions
    5. 9.4. Using Gradients, Patterns, and Line Styles
    6. 9.5. Pulling External Images into a <canvas> Drawing
    7. 9.6. Setting Color Transformations
    8. 9.7. Working with Geometric Transformations
    9. 9.8. Placing Text on a <canvas>
    10. 9.9. Clipping <canvas> Drawings
    11. 9.10. Animating <canvas> Drawings
    12. 9.11. Drawing Graphs with <canvas>
    13. 9.12. Saving a <canvas> Drawing to a File
  12. 10. Advanced HTML5 JavaScript
    1. Introduction
    2. 10.1. Local Storage
    3. 10.2. Application Caching
    4. 10.3. Drag and Drop
    5. 10.4. Web Workers
    6. 10.5. Web Sockets
    7. 10.6. History
    8. 10.7. Local Files
  13. A. HTML5 Resources
  14. Index
  15. About the Authors
  16. Colophon
  17. Special Upgrade Offer
  18. Copyright