Mobile HTML5

Estelle Weyl Mobile HTML5 by Estelle Weyl Copyright © 2014 Estelle Weyl. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://my.safaribooksonline.com). For more information, contact our corporate/ institutional sales department: 800-998-9938 or [email protected]. Editors: Simon St. Laurent and Meghan Blanchette Indexer: Lucie Haskins Production Editor: Kristen Brown Cover Designer: Randy Comer Copyeditor: Kiel Van Horn Interior Designer: David Futato Proofreaders: Troy Mott and Jasmine Kwityn Illustrator: Rebecca Demarest

November 2013: First Edition

Revision History for the First Edition: 2013-11-12: First release

See http://oreilly.com/catalog/errata.csp?isbn=9781449311414 for release details.

Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. Mobile HTML5, the image of a Racket-tailed Drongo, and related trade dress are trademarks of O’Reilly Media, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a trade‐ mark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein.

ISBN: 978-1-449-31141-4 [LSI] Table of Contents

Introduction...... xi Native Applications Versus Web Applications xii What’s New(t)? New Elements and APIs xvii What’s New in CSS? xix Mobile-Specific Considerations xx Why This Book? xx What’s in This Book xxii Conventions Used in This Book xxiii Using Code Examples xxiii Safari® Books Online xxiv How to Contact Us xxiv Acknowledgments xxv

1. Setting the Stage to Learn Mobile HTML5, CSS3, and JavaScript APIs...... 1 CubeeDoo: HTML5 Mobile Game 2 Development Tools 4 Text Editor 4 Browser 5 Debugging Tools 5 Desktop Debuggers 6 Remote Debugging 8 Testing Tools 15 Emulators and Simulators 15 Online Tools 17 Phones 18 Automated Testing 20

2. Upgrading to HTML5...... 23 HTML5 Syntax 24 Elements 24

iii Attributes 25 Global and Internationalization Attributes 26 HTML 4 Attributes Made Core in HTML5 29 New to HTML5: Global Accessibility and Interactive Attributes 31 HTML Element/Attribute Syntax 35 Self-Closing Elements 37 Best Practices 38 The Required Components 39 Elements Found in the 44 : Adding Metadata 45 Mobile Meta Tags 47 Mobile Vendor-Specific Values 49 The of Your Web Page 50 s Aren’t Just for Stylesheets 51

3. Elements That Are New in HTML5...... 59 Sectioning Elements in HTML5 60

61
62
Versus
62