HTML5 Guidelines for Web Developers
Klaus Frster
Bernd ggl
Upper Saddle River, NJ Boston Indianapolis San Francisco
New York Toronto Montreal London Munich Paris Madrid
Capetown Sydney Tokyo Singapore Mexico City
Cover design: Marco Lindenbeck, webwo GmbH,
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 the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals.
The authors and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein.
The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales, which may include electronic versions and/or custom covers and content particular to your business, training goals, marketing focus, and branding interests. For more information, please contact:
U.S. Corporate and Government Sales
(800) 382-3419
For sales outside the United States, please contact:
International Sales
Visit us on the Web: informit.com/aw
Editor-in-Chief
Mark L. Taub
Senior Acquisitions Editor
Trina MacDonald
Development Editor
Susan Brown Zahn
Translator
Almut Dworak
Managing Editor
John Fuller
Full-Service Production Manager
Julie B. Nahil
Project Editor and Compositor
Mary Sudul, Fastpages
Copy Editor
Anne Marie Walker
Indexer
Jack Lewis
Proofreader
Linda Seifert
Library of Congress Cataloging-in-Publication Data
Frster, Klaus, 1964
[HTML 5. English]
HTML5 guidelines for Web developers / Klaus Frster, Bernd ggl.
p. cm.
Includes bibliographical references and index.
ISBN 978-0-321-77274-9 (pbk. : alk. paper)
1. HTML (Document markup language) 2. Internet programming. 3.
Web site development. I. ggl, Bernd. II. Title. III. Title: HTML 5
guidelines for Web developers.
QA76.625.F6713 2012
006.74dc23
2011014135
Copyright 2011 Pearson Education, Inc.
All rights reserved. Printed in the United States of America. This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permissions, write to:
Pearson Education, Inc.
Rights and Contracts Department
501 Boylston Street, Suite 900
Boston, MA 02116
Fax: (617) 671-3447
ISBN-13: 978-0-321-77274-9
ISBN-10: 0-321-77274-1
Text printed in the United States on recycled paper at RR Donnelley in Crawfordsville, Indiana. First printing, June 2011
Thanks to Andrea and Sabineyou are wonderful!
Preface
In 2010, HTML5 became the buzzword on the web developer scene. Large companies, such as Google, Apple, and Microsoft, began to use the new technology. The popularity of the catchword HTML5 grew, not least of all because of the heated debate between Apple and Adobe over whether this would mean the end of Flash.
In this book, we give you extensive insight into the new possibilities of HTML5. In addition to the classic specification components, such as video, audio, canvas, intelligent forms, offline applications, and microdata (to name but a few), this overview also includes topics in the immediate context of HTML5for example, geolocation, web storage, WebSockets, and web workers.
Numerous compact, clear, and practical examples illustrate the new elements and techniques in HTML5. There is something here for everyone, whether you decide you want to construct a web log, program your own video and audio player, use the browser as a graphics program, work with geographical data, test to the limit the capacity of your browser, or prefer to live out your playful nature by trying a quiz with drag and drop or playing Battleships! with WebSockets. We also give you plenty of tips and tricks regarding JavaScript and the DOM.
It is to be expected that sooner or later all browsers, in order to remain competitive in the future, will accommodate HTML5. We therefore decided not to include workarounds and compatibility libraries in most cases. In this book you will find pure HTML5, supported in our examples by at least one browser, but in most cases supported already by several manufacturers. For an up-to-date and complete reference of the new HTML elements, we refer you to the Internet. You will find the relevant links in the appropriate text passages of this book.
How to Read This Book
How you decide to explore this book is entirely up to you. The individual chapters do not necessarily have to be read consecutively and are designed to be easily understandable, even if you have not yet read the other chapters. So, you can read the book in the traditional way, from front to back; alternatively, you can read it from back to front or in any order, letting your curiosity guide you.
Who This Book Is for
You should definitely have a basic knowledge of HTML, JavaScript, and CSS; a willingness to work with a different browser for a change, not just the one you are used to; and above all, a desire to discover something new. Try new ideas, such as those in this book, or have a look at the companion website where you can see all the examples in color. Decide what you want to do and, most important, have fun!
The companion website can be found at http://html5.komplett.cc/welcome.
About the Authors
The authors of this book are as versatile and multifaceted as the new web standard they were brave enough to write about while it was still in development.
Klaus Frster, an open source enthusiast, works at the Department of Geography of the University of Innsbruck, Austria. He has attended numerous SVG Open conferences as speaker, reviewer, and workshop leader, and contributed SVG modules to the free software projects PostGIS, GRASS GIS, and SpatiaLite.
Bernd ggl, lecturer and system administrator at the University of Innsbruck, is the coauthor of a book on PHP and MySQL and has many years of experience programming web applications.
1. Overview of the New Web Standard
As is appropriate for a web standard, the story of HTML5 starts with the World Wide Web Consortium (W3C), or more precisely, with the W3C Workshop on Web Applications and Compound Documents in June 2004. But rather unusually, the development of HTML5 initially took place outside of the W3C, because the W3C was not at all thrilled with the idea of HTML5 to start with. What had happened?
1.1 How It All Started
In a joint position paper, Mozilla and Opera demanded that the W3C should ensure the continued development of HTML, DOM, and CSS as the basis of web applications of the future. Given the fact that the W3C had already sidelined HTML4 six years before and had instead elected to back XHTML, XForms, SVG, and SMIL, it was hardly surprising that this suggestion was rejected. The result was very close, with 8 votes in favor and 11 votes against, but the decision still had far-reaching consequences. In the following years, the development of HTML5 was to take place in direct competition with the W3C.