Html5 Programmer’s Reference by Jonathan Reid

3156862467501bd.jpg Author Jonathan Reid
Isbn 1430263679
File size 5.2 MB
Year 2015
Pages 394
Language English
File format PDF
Category programming


HTML5 Programmer’s Reference Jonathan Reid HTML5 Programmer’s Reference Copyright © 2015 by Jonathan Reid This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. Exempted from this legal reservation are brief excerpts in connection with reviews or scholarly analysis or material supplied specifically for the purpose of being entered and executed on a computer system, for exclusive use by the purchaser of the work. Duplication of this publication or parts thereof is permitted only under the provisions of the Copyright Law of the Publisher’s location, in its current version, and permission for use must always be obtained from Springer. Permissions for use may be obtained through RightsLink at the Copyright Clearance Center. Violations are liable to prosecution under the respective Copyright Law. ISBN-13 (pbk): 978-1-4302-6367-8 ISBN-13 (electronic): 978-1-4302-6368-5 Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein. Managing Director: Welmoed Spahr Lead Editor: Ben Renow-Clarke Technical Reviewer: Victor Sumner Editorial Board: Steve Anglin, Mark Beckner, Gary Cornell, Louise Corrigan, Jim DeWolf, Jonathan Gennick, Robert Hutchinson, Michelle Lowman, James Markham, Susan McDermott, Matthew Moodie, Jeffrey Pepper, Douglas Pundick, Ben Renow-Clarke, Gwenan Spearing, Matt Wade, Steve Weiss Coordinating Editor: Christine Ricketts and Melissa Maldonado Copy Editor: James Fraleigh Compositor: SPi Global Indexer: SPi Global Artist: SPi Global Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail [email protected], or visit Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation. For information on translations, please e-mail [email protected], or visit Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales– eBook Licensing web page at Any source code or other supplementary material referenced by the author in this text is available to readers at For detailed information about how to locate your book’s source code, go to For my husband Steve, who is always there for me. Contents at a Glance About the Author About the Technical Reviewer Acknowledgments Introduction Part I: HTML5 in Depth Chapter 1: Welcome to HTML5 Chapter 2: HTML5 Elements Chapter 3: HTML5 APIs Chapter 4: Canvas Chapter 5: Related Standards Chapter 6: Practical HTML5 Part II: HTML5 Reference Chapter 7: HTML5 Element Reference Chapter 8: HTML5 API Reference Chapter 9: Canvas Reference Appendix A: JavaScript Tips and Techniques Index Contents About the Author About the Technical Reviewer Acknowledgments Introduction Part I: HTML5 in Depth Chapter 1: Welcome to HTML5 What Is HTML5? A Brief History of HTML Enter Hypertext Enter Markup Languages Hypertext Markup Language Is Born The Browser Wars Standards to the Rescue The Continuing Evolution of HTML The Formation of the WHATWG and the Creation of HTML5 HTML5 Features New Tags JavaScript APIs Related Standards Summary Chapter 2: HTML5 Elements Functionality, Semantics, and the Evolution of HTML Sections Grouping Semantics Audio and Video Content Embedded Audio Content Embedded Video Content Specifying Multiple Sources Interactive Elements Dialogs Progressive Disclosure Forms New Form Elements New Form Element Attributes New Input Types Deprecated Elements and Obsolete Parameters Summary Chapter 3: HTML5 APIs Server-sent Events Client Setup Sending Events from the Server Origin Limitations Security An Example Application WebSockets Connecting to the Server: Inside the WebSocket Handshake Receiving Information from the Server Sending Information to the Server Closing the Connection An Example WebSocket Application Cross Document Messaging/Web Messaging Web Storage Methods and Syntax Privacy and Web Storage Drag and Drop The draggable Property Drag-and-Drop Events The dataTransfer Object Drag-and-Drop API Examples Web Workers Creating Web Workers Inside a Web Worker A Simple Example of a Web Worker Common Use Cases Summary Chapter 4: Canvas The Canvas Drawing Mode The Canvas Drawing Context Basic Drawing Commands Gradients and Patterns Gradients Patterns Images Saving Canvas Contents Text Shadows Saving Drawing State Compositing Clipping Transformations Animation Interaction Summary Chapter 5: Related Standards Geolocation Privacy Considerations Geolocation API Animation Timing Selectors Device Orientation The compassneedscalibration Event The deviceorientation Event The devicemotion Event WebGL SVG Summary Chapter 6: Practical HTML5 Browser Support A Crash Course in Feature Detection Building a Feature Detection Script Working with Broken or Missing HTML5 Implementations Example Project: MobiDex, a Mobile Dexterity Puzzle The Playing Field UI Generating Obstacles and Targets Summary Part II: HTML5 Reference Chapter 7: HTML5 Element Reference Sections The article Element The aside Element The footer Element The header Element The nav Element The section Element Grouping The figure and figcaption Elements The main Element Semantics The bdi Element The data Element The mark Element The ruby, rp, and rt Elements The time Element The wbr Element Audio and Video Content The audio Element The source Element The track Element The video Element Interactive Elements The details and s ummary Elements Form Elements The datalist Element The meter Element The output Element The progress Element Chapter 8: HTML5 API Reference Server-sent Events WebSockets Cross-Document Messaging/Web Messaging Web Storage Drag and Drop Specifying Draggable Elements: The draggable Property Handling the Interactions: Drag-and-Drop Events Specifying Drop Targets The dataTransfer Object Web Workers Chapter 9: Canvas Reference The canvas Element The Drawing Context Defining Paths Basic Drawing Commands Stroking and Filling Paths Drawing Rectangles Gradients and Patterns Images Text Shadows Compositing Clipping Transformations Saving and Restoring Canvas State Appendix A: JavaScript Tips and Techniques Code Formatting JavaScript Rewards Verbosity Comment Annotations Using Objects as Event Handlers Promises Chaining Promises Returning Values from Promises Browser Support for Promises Further Reading Index About the Author Jonathan Reid has been building web applications professionally for almost two decades. He has built everything from simple informational websites all the way up to complex scientific and business applications, all using HTML, CSS, and JavaScript. In addition, Jon has worked at some of the top interactive agencies in the United States (EffectiveUI, Crispin Porter + Bogusky), so he knows what it is like to implement difficult and complex requirements with web technologies on a tight deadline. He currently works for Google, where he is a Senior User Experience Engineer on Google Web Designer, an HTML5 authoring tool. Jon lives in Sunnyvale with his husband of 15 years. About the Technical reviewer Victor Sumner is a senior software engineer at D2L Corporation, where he helps to build and maintain an integrated learning platform. As a self-taught developer, he is always interested in emerging technologies and enjoys working on and solving problems that are outside his comfort zone. When not at the office, Victor has a number of hobbies, including photography, horseback riding, and gaming. He lives in Ontario, Canada, with his wife, Alicia, and their two children. Acknowledgments Writing a book is never a solitary activity. I had a lot of help along the way. Pushkar Joshi, my colleague at Google, provided input on the Canvas chapter as well as some great suggestions for topics to include in the chapter. He was also kind enough to look through the chapters and provide feedback. Victor Sumner did a great job as the technical reviewer, going through every line of code in this book and testing them thoroughly. Code reviews are practically a way of life for me, so I value my reviewers greatly, and Victor did a great job. The rest of the Google Web Designer team, led by Sean Kranzberg, Tony Mowatt, and San Khong, put up with me obsessing about this book off and on for over a year. Thanks, everyone. My husband, Steve, was patient while I barricaded myself in our home office on Saturdays to write. And as always, my editors at Apress were supportive, patient, and diligent. Introduction The World Wide Web has existed for almost 25 years now. It started as a simple proposal by Tim Berners-Lee and Robert Cailliau as a way for the scientists at CERN to publish papers easily, but it rapidly grew into a platform that captured the imagination of the world. The Web may have started out as a simple document-publishing platform, but it quickly became clear that it was destined to become much more than that. As people demanded more interactivity and richer experiences, the limits of the original HTML standards quickly became obvious. The advent of other technologies like Cascading Style Sheets and JavaScript helped, but developers were still spending extensive resources on building the experiences that people wanted. HTML5 is meant to help solve some of these problems. The fifth incarnation of the HTML standard, HTML5, is designed to be both feature rich and easier to work with. Prior versions of HTML focused on how best to standardize document markup, which was a great way to bring standards to the chaos of the early Web. HTML5, however, is focused on providing a platform for building rich interactions. Much of HTML5 was also specifically designed with mobile technologies in mind, while older versions of HTML were not. What This Book Covers This book is designed to be your go-to reference for HTML5 features. It is divided into two sections. Part I, “HTML5 in Depth,” has chapters that provide detailed examinations of the HTML5 features, including multiple examples and the current level of support at press time. Chapter 1, “Welcome to HTML5,” is a history lesson, explaining how the World Wide Web and its technologies evolved, and how HTML5 came to be. This will hopefully help you understand why HTML5 is so much different from previous HTML standards, and will give you better insight in how HTML5 is structured. Chapter 2, “HTML5 Elements,” covers the new semantic tags in HTML5. As with predecessor standards, HTML5 includes a new set of tags for marking up the content in your documents. This is where you’ll find out how to use the new audio and video tags, as well as a host of other HTML5 features. Chapter 3, “HTML5 APIs,” dives into the JavaScript APIs that are specified in the HTML5 standard. You’ll learn about new ways for your HTML5 applications to communicate and save data. Chapter 4, “Canvas,” covers one of the most innovative features of HTML5: the canvas element. Here you’ll learn how to use this element to draw, modify images, and create animations. Chapter 5, “Related Standards,” covers several JavaScript APIs that are related to HTML5 (and frequently used with HTML5) but are not actually a part of the HTML5 standard. These APIs also tend to have a strong mobile focus. Chapter 6, “Practical HTML5,” covers actually working with HTML5 in production projects. It covers detecting features and applying shims, and includes a complete HTML5 mobile game designed and built from the ground up. Part II, “HTML5 Reference,” contains reference chapters for all of the HTML5 features covered in Part 1. Each chapter is designed to provide an at-a-glance reference for each feature and includes a brief description of the feature, how it is used (including both syntax and examples), and where to find its standards. Chapter 7 is the reference chapter for HTML5 elements. Chapter 8 is the reference chapter for the HTML5 JavaScript APIs. Chapter 9 is the reference chapter for the canvas element. What You Need to Know Though there are lots of detailed examples throughout the book, it is written as a reference and not as a tutorial. I’m assuming you have an intermediate understanding of how browsers work as well as how to work with JavaScript, and at least a basic understanding of CSS and the network protocols involved in HTTP. You should be comfortable creating and editing web pages and writing your own CSS and JavaScript. Running the Code Samples There are extensive code samples throughout the book. You can download the samples from, or you can type them in by hand. Many of the examples can be run by simply loading the file into a web browser using the browser’s File menu. Some examples, though, must be run from an actual server, either due to security limitations or because you will want to view them on a mobile device. To build and test all the examples in the book, I’ve used Aptana Studio, available for free at Aptana Studio comes with an internal debugging server that you can use to run any of these examples. If you prefer a stand-alone solution, I’ve had very good luck with XAMPP, a stand-alone installation of the Apache web server, along with optional components like MySQL, PHP, and Perl. And of course both MacOS and Windows come with their own web server solutions that you can activate and use, as do most standard Linux distributions. Finally, be sure to check out the “Comment Annotations” section in Appendix A, “JavaScript Tips and Techniques,” for an explanation of the format of the examples and how to read the annotations. PART I HTML5 in Depth CHAPTER 1 Welcome to HTML5 In this chapter, I’m going to dive into the history of HTML and how HTML5 came to be. I’ll talk about the evolution of HTML from a simple proposal all the way to its current version, including reviews of related technologies. I’ll also cover what HTML5 is, its scope, how it differs from previous versions, and how it fits in with other technologies. What Is HTML5? Hypertext Markup Language, or HTML, has been with us since 1989. Versions of HTML prior to 5 only defined markup tags for content: lists, paragraphs, headers, tables, and so on. HTML5, though, defines much more. It has new content tags (such as

Author Jonathan Reid Isbn 1430263679 File size 5.2 MB Year 2015 Pages 394 Language English File format PDF Category Programming Book Description: FacebookTwitterGoogle+TumblrDiggMySpaceShare The HTML5 Programmer’s Reference is for people who are working with modern web technologies who need to come up to speed fast and have answers handy for their common use cases. WithHTML5 Programmer’s Reference at their elbows, programmers can quickly learn and master these new technologies, and maybe even surprise themselves with what they can do with them. The book dives directly into the new technologies without wasting time on formalities, so it is an ideal choice for developers who already have a basic understanding of web technologies and how to work with them. The HTML5 Programmer’s Reference aims to provide everything a programmer needs for understanding and using the new HTML5 family of standards. Previous HTML standards were focused on defining tags for marking up documents. The HTML5 family of standards not only includes new semantic tags but also defines exciting new JavaScript APIs that can be used to build rich, interactive web applications for both mobile and desktop platforms. The HTML5 Programmer’s Reference focuses on providing real-world non-trivial examples to demonstrate concepts. Chapters include both in-depth discussions and full references for all HTML5 features, as well as extras like how to find the standards, the history of their evolution, and other examples and helpful resources. With this book the reader will learn everything they need to know to build the next generation of web applications. What you’ll learn Improve the semantics of your documents using new structural tags: sections, groups, forms, etc. Learn the new web form features: autofocus, placeholders, field types, etc. Explore the new AUDIO and VIDEO tags, and learn how to embed those rich media types directly into your applications. Use the new HTML5 JavaScript APIs: canvas, messaging, drag and drop, workers and sockets, etc. Learn about related JavaScript APIs including touch events, device orientation, and WebGL.     Download (5.2 MB) Css: The Missing Manual Jquery, Css3, And Html5 For Mobile/desktop Devices Html5 Games Most Wanted: Build The Best Html5 Games Pro HTML5 Accessibility Beginning Html5 Media 2nd Edition Load more posts

Leave a Reply

Your email address will not be published. Required fields are marked *