Summary of Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix
1. Basics: What is HTML5? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
2. Basics: The Anatomy of HTML5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3. Basics: Structuring Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4. Basics: HTML5 Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
5. Basics: Multimedia, Audio and Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
6. Multimedia: Preparing Your Media . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
7. Multimedia: Using Native HTML5 Audio . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
8. Multimedia: Using Native HTML5 Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
9. Multimedia: The source Element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
10. Mutimedia: The track Element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
11. Multimedia: Scripting Media Players . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
12. Canvas & SVG: An Introduction to Canvas . . . . . . . . . . . . . . . . . . . . . . . . 123
13. Canvas & SVG: Canvas Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
14. Canvas & SVG: Handling Non-supporting Browsers . . . . . . . . . . . . . . . . . 137
15. Canvas & SVG: Canvas Gradients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
16. Canvas & SVG: Canvas Images and Videos . . . . . . . . . . . . . . . . . . . . . . . . . 145
17. Canvas & SVG: An Introduction to SVG . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
18. Canvas & SVG: Using SVG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
19. Canvas & SVG: SVG Bézier Curves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
20. Canvas & SVG: SVG Filter Effects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
21. Canvas & SVG: Canvas or SVG? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
22. Offline Apps: Detecting When the User Is Connected . . . . . . . . . . . . . . . 179
23. Offline Apps: Application Cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
24. Offline Apps: Web Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
25. Offline Apps: Storing Data With Client-side Databases . . . . . . . . . . . . . . 215
26. APIs: Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
27. APIs: Web Workers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
28. APIs: The Geolocation API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
29. APIs: Server Sent Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
30. APIs: The WebSocket API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
31. APIs: The Cross-document Messaging API . . . . . . . . . . . . . . . . . . . . . . . . . 269
JUMP START
HTML5
BY TIFFANY B. BROWN
KERRY BUTTERS
SANDEEP PANDA
Jump Start HTML5
by Tiffany B. Brown, Kerry Butters, and Sandeep Panda
Copyright © 2014 SitePoint Pty. Ltd.
English Editor: Paul FitzpatrickProduct Manager: Simon Mackie
Cover Designer: Alex WalkerTechnical Editor: Craig Buckler
Notice of Rights
All rights reserved. No part of this book may be reproduced, stored in a retrieval system or transmitted
in any form or by any means, without the prior written permission of the publisher, except in the case
of brief quotations embodied in critical articles or reviews.
Notice of Liability
The author and publisher have made every effort to ensure the accuracy of the information herein.
However, the information contained in this book is sold without warranty, either express or implied.
Neither the authors and SitePoint Pty. Ltd., nor its dealers or distributors will be held liable for any
damages to be caused either directly or indirectly by the instructions contained in this book, or by the
software or hardware products described herein.
Trademark Notice
Rather than indicating every occurrence of a trademarked name as such, this book uses the names only
in an editorial fashion and to the benefit of the trademark owner with no intention of infringement of
the trademark.
Published by SitePoint Pty. Ltd.
48 Cambridge Street Collingwood
VIC Australia 3066
Web: www.sitepoint.com
Email: business@sitepoint.com
ISBN 978-0-9802858-2-6 (print)
ISBN 978-0-9870908-0-5 (ebook)
Printed and bound in the United States of America
iv