The Definitive Guide to HTML5 the Definitive Guide to HTML5 Covers Everything You Need to Create Standards- Compliant, Semantic, Modern Websites
Total Page:16
File Type:pdf, Size:1020Kb
BOOKS FOR PROFESSIONALS BY PROFESSIONALS® Freeman RELATED The Definitive Guide to HTML5 The Definitive Guide to HTML5 covers everything you need to create standards- compliant, semantic, modern websites. You’ll learn how to: • Use all of the core features of HTML5. • Make the most of the APIs that surround HTML5, such as Geolocation, Web Storage, and drag and drop. • Leverage the media capabilities of the modern web: Canvas, audio, and video. The Definitive Guide to HTML5 begins by tackling the basics of HTML5, ensuring that you know best practices and key uses of all of the important elements, including those new to HTML5. It covers extended usage of CSS3, JavaScript, and DOM manipula- tion, making you proficient in all core aspects of modern website creation. The final part of the book covers the associated W3C APIs that surround the HTML5 specification. You will achieve a thorough working knowledge of the Geolocation API, Web Storage, creating offline applications, and the new drag and drop functionality. The Definitive Guide to HTML5 also dives into the key media enhancements of HTML5 and its surrounding technologies: Canvas, video and audio. Turn to The Definitive Guide to HTML5 and find the knowledge you need to start creating the next generation of websites. US $44.99 Shelve in Web Design/HTML User level: Intermediate–Advanced SOURCE CODE ONLINE www.apress.com For your convenience Apress has placed some of the front matter material after the index. Please use the Bookmarks and Contents at a Glance links to access them. This book was purchased by [email protected] Contents at a Glance About the Author.............................................................................................. xxxiii About the Technical Reviewers ....................................................................... xxxiv Acknowledgments ............................................................................................ xxxv Part I: Getting Started.............................................................................................1 Chapter 1: Putting HTML5 in Context......................................................................3 Chapter 2: Getting Ready........................................................................................9 Chapter 3: Getting Started with HTML ..................................................................13 Chapter 4: Getting Started with CSS.....................................................................39 Chapter 5: Getting Started with JavaScript..........................................................71 Part II: The HTML Elements.................................................................................103 Chapter 6: HTML Elements in Context.................................................................105 Chapter 7: Creating HTML Documents ................................................................117 Chapter 8: Marking Up Text ................................................................................151 Chapter 9: Grouping Content...............................................................................191 Chapter 10: Creating Sections ............................................................................217 Chapter 11: Table Elements ................................................................................251 Chapter 12: Working with Forms........................................................................281 Chapter 13: Customizing the Input Element .......................................................311 Chapter 14: Other Form Elements and Input Validation .....................................351 Chapter 15: Embedding Content .........................................................................371 Part III: Cascading Style Sheets..........................................................................395 Chapter 16: CSS in Context .................................................................................397 Chapter 17: Using the CSS Selectors—Part I......................................................411 iv CONTENTS AT A GLANCE Chapter 18: Using the CSS Selectors—Part II ....................................................437 Chapter 19: Using Borders and Backgrounds.....................................................465 Chapter 20: Working with the Box Model ...........................................................497 Chapter 21: Creating Layouts .............................................................................531 Chapter 22: Styling Text .....................................................................................555 Chapter 23: Transitions, Animations, and Transforms .......................................581 Chapter 24: Other CSS Properties and Features.................................................611 Part IV: Working with the DOM ...........................................................................631 Chapter 25: The DOM in Context .........................................................................633 Chapter 26: Working with the Document Object.................................................653 Chapter 27: Working with the Window Object....................................................679 Chapter 28: Working with DOM Elements...........................................................705 Chapter 29: Styling DOM Elements .....................................................................735 Chapter 30: Working with Events .......................................................................765 Chapter 31: Using the Element-Specific Objects ................................................793 Part V: Advanced Features .................................................................................819 Chapter 32: Using Ajax – Part I...........................................................................821 Chapter 33: Using Ajax—Part II..........................................................................849 Chapter 34: Working with Multimedia................................................................873 Chapter 35: Using the Canvas Element – Part I ..................................................897 Chapter 36: Using the Canvas Element – Part II ................................................929 Chapter 37: Using Drag & Drop...........................................................................957 Chapter 38: Using Geolocation............................................................................975 Chapter 39: Using Web Storage ..........................................................................987 Chapter 40: Creating Offline Web Applications...................................................997 Index .................................................................................................................1015 v P A R T I Getting Started Before you can begin to explore HTML5, you have some preparation to do. In the next five chapters, I’ll describe the structure of the book, show you how to get set up for HTML5 development, and give you a refresher in basic HTML, CSS, and JavaScript. 1 C H A P T E R 1 Putting HTML5 in Context The Hypertext Markup Language (HTML) has been around since the early 1990s. My earliest encounter was somewhere around 1993 or 1994, when I was working at a university research lab not far from London. There was only one browser—NCSA Mosaic—and the number of web servers could be counted on one hand. When I think back to those days, I wonder why we were so excited about HTML and the World Wide Web. (We had to laboriously type all three words in those days. There wasn’t the critical mass or current sense of importance to refer to just “the Web.” Everything was very basic. I remember some images of gemstones that we could watch load...slowly. This was before the broadband revolution and the entire university had the kind of bandwidth that is common on a mobile phone these days. But we were excited. Grant proposals were hurriedly rewritten to embrace the new world, and there was a real sense that the world of technology had fractured into before-Web and after-Web periods, even if all we could do was see pictures of a coffee pot in another university not far from London (but too far to go for coffee). Since then, the Web has become indistinguishable from the Internet for many users and we are long past the point of being excited about pictures of gems. Along the way, HTML has been extended, enhanced, twisted, tortured, fought over, litigated over, ignored, embraced, denigrated for being too simple, hailed as being the future and, ultimately, settling into its current position as part of the indispensable plumbing in the daily lives of billions of people. This book is about HTML5—the latest version of the HTML standard and an attempt to bring order, structure, and enhancement to a critical technology that has finally matured after years of difficult adolescence. The History of HTML All HTML books have a section titled The History of HTML, and most use this section to give a careful timeline of the HTML standard from the moment it was created until the present day. If you need that information, I encourage you to find it on Wikipedia—although it isn’t very interesting or useful. To understand how HTML has been shaped and how we ended up at HTML5, we care about a small number of key turning points and one long-lived trend. The Introduction of JavaScript JavaScript (which, despite the name, has very little to do with the Java programming