HTML5 Multimedia Developme
Total Page:16
File Type:pdf, Size:1020Kb
HTML5 Multimedia Development Cookbook Recipes for practical, real-world HTML5 multimedia-driven development Dale Cruse Lee Jordan BIRMINGHAM - MUMBAI HTML5 Multimedia Development Cookbook Copyright © 2011 Packt Publishing 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 embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: May 2011 Production Reference: 1160511 Published by Packt Publishing Ltd. 32 Lincoln Road Olton Birmingham, B27 6PA, UK. ISBN 978-1-849691-04-8 www.packtpub.com Cover Image by Jacqueline Stetson ([email protected]) Credits Authors Project Coordinator Dale Cruse Leena Purkait Lee Jordan Proofreader Reviewers Clyde Jenkins Shi Chuan Christopher Scott Hernandez Indexer Monica Ajmera Mehta Laurentiu Nicolae Rekha Nair Acquisition Editor Steven Wilding Production Coordinators Shantanu Zagade Development Editor Melwyn D'sa Kartikey Pandey Cover Work Technical Editor Shantanu Zagade Arun Nadar Foreword Maybe you've heard the story—or probably urban legend—about the university that didn't lay any grass or pour any concrete when it first opened, leaving the campus grounds as solid dirt. Then, as students began to traverse the campus from one class to the next, campus planners mapped the common paths they took, and then landscaped and paved concrete trails based on these paths. HTML5 shares the same moral as that story: Utility based on convention. An extraordinary update to the web's markup language, the HTML5 specification incorporates many of the conventions we've all been using in our markup and formalizes them as an official recommendation. Dale Cruse's HTML5 Multimedia Development Cookbook comes at the perfect time when many of us are transitioning to this new specification. Browser vendors, thankfully, are following suit by adopting HTML5 components at an impressive pace. But the real secret sauce of Dale's work is the fact that this book—the one you're holding now—is a cookbook in every respect (and from a guy who doubles as a wine savant, no less). Its pages are filled with recipes for creating successful, real-world implementations of HTML5 websites. You'll find thorough, detailed chapters covering forms, video, audio, and much more. There's even a chapter that'll help you style your HTML5 using CSS3, and a chapter explaining how to ensure your HTML5 content is accessible to those using assistive technologies. Every chapter includes exceptional examples from across the web, carefully dissected. Dale is a master chef when it comes to web standards and forward-thinking, and backwards-compatible markup. I've had the pleasure of working with him in the past on a project of mine, and it was just as clear then as it is now that he knows his stuff. Whether it's the remarkable or the commonplace, the innovative or the practical, Dale Cruse's HTML5 Multimedia Development Cookbook will have you preparing, sautéing, and serving incredible HTML5 websites in no time. Bon appétit. Cameron Moll Founder of AuthenticJobs.com Author of Mobile Web Design and Co-author of CSS Mastery: Advanced Web Standards Solutions About the Authors Dale Cruse, a Boston-area web developer, has been publishing websites for high- profile clients ranging from the U.S. Army to Bloomingdale's since 1995. He has been a guest lecturer at the Art Institute of New England and is currently pursuing speaking opportunities. Contact him at http://dalejcruse.com. He is also the author of the Champagne blog Drinks Are On Me at http://drinksareonme.net. A number of people contributed to the success of this book, and it would take more space than I have to thank each one individually. Thank you to the entire Packt Publishing team for working so diligently to help me develop such a high quality product of which we can all be proud of. For my friend of roughly 20 years, Michelle Yaiser: Thank you for believing in me through thick and thin. Web developer Paul Ramos and I complete each other's sentences. Thank you for being there, brother. Roxane Velozo is the Robin to my Batman. Thanks for being the best professional sidekick a superhero could ever have. For Jeffrey Zeldman, Cameron Moll, and Dan Cederholm: I could never hope for a better trio of professional role models. Thank you, gentlemen. Lee Jordan is a designer and new media developer. She brings a strong design background and concern for the visual and emotional impact of media to web-based projects. Experienced in multiple CMS platforms including Expression Engine, Plone, WordPress, PostNuke, and Google's Blogger, she has maintained, explored, and used most of them on a day-to-day basis. She spends her spare time as the leader of a local scout troop, taking long hikes with her family in the beautiful North Georgia woods, trying to taste test every variety of chocolate that exists, and playing with code and pixels. Design topics or whatever she can think of at the time are posted on her blog at http://leejordan.net. Lee has written three previous books with Packt Publishing: Project Management for dotProject, WordPress Themes 2.8, and Blogger: Beyond the Basics. I couldn't do this without the support of my family, but it is one special person's time to shine—Jason—keep trying and don't give up. Sometimes all we need is practice and the will to keep moving forward. About the Reviewers Shi Chuan is an open web developer, member of HTML5 Boilerplate, and the lead of Mobile Boilerplate. Shi has over four years of experience in web development. Half indie and half commercial, he worked with both MNCs and small local startups. Shi Chuan has spent a large portion of his career working in digital adverting. He worked for Ogilvy Singapore, and helped the launch with many brand site, and micro-site, for clients like Yahoo, Nokia, Levi's, IBM, and many other global companies around the world. What he also enjoys is to work with smaller clients that allow him greater freedom to experiment with real cool and kick-ass stuff. As a member of HTML5 Boilerplate, he has developed a stronger sense of community and web evangelism. He is excited about the future of the technology and is doing the best he can to embrace fashion's free culture and to help shape a better web. He has a semi-regular blog at: http://www.blog.highub.com. Christopher Scott Hernandez has been working on the web since his freshman year in high school, when he designed and developed a product catalog for his father's upholstery business. Born and raised in beautiful Austin, Texas, he now lives in sunny Philadelphia and works as a web developer for an international e-commerce agency. When he's not pushing pixels or developing websites, Chris enjoys spending time with his brilliant wife Josie and their canine trio: Darwin, Truman, and Toby. He also maintains a blog and portfolio at http://christopher-scott.com. Laurentiu Nicolae is a Web developer, with over 5 years of experience. He has been working as a freelancer for different clients from Europe and the United States, and now he is working for BootsnAll. He is specialized in developing websites, being a "native writer" in web languages, like PHP, HTML, XHTML, CSS, and JavaScript. He lives in Bucharest, Romania with his wife, Georgiana, and their son Matei. Table of Contents Preface 1 Chapter 1: Structuring for Rich Media Applications 5 Introduction 5 Setting up an HTML5 test area 7 Using the header tag for logos and site titles 10 Creating a table of contents using the nav tag 14 Using section tags to structure areas of a page 16 Aligning graphics using the aside tag 19 Displaying multiple sidebars using the aside tag 22 Implementing the footer tag 24 Applying the outline algorithm 28 Creating a stylish promo page in HTML5 29 Chapter 2: Supporting the Content 35 Introduction 35 Structuring a blog article 36 Highlighting text using the mark element 40 Using the time element 44 Specifying the pubdate of an article 46 Displaying comment blocks using the article element 49 Adding fonts dynamically with @font-face 51 Adding drop-shadow effects to fonts 55 Applying gradient effects to fonts 57 Annotating visual elements using the figure and figcaption tags 58 Table of Contents Chapter 3: Styling with CSS 63 Introduction 63 Setting elements to display:block 66 Styling a nav block element 68 Using background-size to control background appearance 73 Adding rounded corners with border-radius 76 Including multiple background images 79 Adding a box shadow to images 83 Styling for Internet Explorer browsers 85 Chapter 4: Creating Accessible Experiences 89 Introduction 89 Testing browser support 90 Adding skip navigation 94 Adding meta tags 97 Using semantic descriptions in tags for screen readers 99 Providing alternate site views 102 Using hgroup to create accessible header areas 107 Displaying alternate