Learn to Code HTML & CSS
Develop & Style Websites
Shay Howe
LEARN TO CODE HTML & CSS: DEVELOP & STYLE WEBSITES
Shay Howe
NEW RIDERS
www.newriders.com
To report errors, please send a note to
New Riders is an imprint of Peachpit, a division of Pearson Education.
Copyright 2014 by W. Shay Howe
Project Editors: Michael J. Nolan and Nancy Peterson
Development Editor: Jennifer Lynn
Production Editor: David Van Ness
Copyeditor: Jennifer Needham
Technical Editor: Chris Mills
Indexer: Karin Arrigoni
Proofreader: Darren Meiss
Cover Designer: Shay Howe
Interior Designer: Mimi Heft
Compositor: WolfsonDesign
NOTICE OF RIGHTS
All rights reserved. No part of this book may be reproduced or transmitted in any form by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of the publisher. For information on getting permission for reprints and excerpts, contact .
NOTICE OF LIABILITY
The information in this book is distributed on an As Is basis without warranty. While every precaution has been taken in the preparation of the book, neither the author nor Peachpit shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the instructions contained in this book or by the computer software and hardware products described in it.
TRADEMARKS
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 Peachpit was aware of a trademark claim, the designations appear as requested by the owner of the trademark. All other product names and services identified throughout this book are used in editorial fashion only and for the benefit of such companies with no intention of infringement of the trademark. No such use, or the use of any trade name, is intended to convey endorsement or other affiliation with this book.
ISBN 13: 978-0-321-94052-0
ISBN 10: 0-321-94052-0
9 8 7 6 5 4 3 2 1
Printed and bound in the United States of America
For you.
One way or another this book ended up in your hands. Im excited to see what you do with it, and I hope the knowledge within this book makes as large an impact on your life as it has on my own.
About the Author
Born and raised in the small town of Lima, Ohio, Shay Howe grew up disassembling remote controls and other electronics in hopes of learning how they worked. When the Internet was introduced, he was fascinated and immediately began learning all he could about it. Upon graduating from high school, he moved to Tempe, Arizona, where he attended the University of Advancing Technology and received a Bachelor of Arts degree in digital multimedia with a focus in web design.
Currently living in Chicago, Illinois, Shay is a designer and front-end developer with a passion for solving problems while building creative and intuitive websites. He specializes in web and product design and front-end development, specialties that he regularly writes and speaks about.
Shay is co-founder of Chicago Camps, which hosts low-cost, high-value technology events in the Chicago area. He is also co-organizer of Refresh Chicago and UX Happy Hour, which help to refresh the creative, technical, and professional culture of New Media endeavors.
Perhaps most importantly, though, Shay is the undisputed office table tennis champion.
Acknowledgments
To everyone who helped make this book a reality, from the bottom of my heart, I cannot thank you enough!
There are so many people who have helped me in my career and with this book that its going to be impossible to thank them all. I will undoubtedly forget someone important, and I apologize to whoever that may be. That said, I have to begin by thanking my family and friends. Theres no way this book would ever exist without their help and support.
My wife, Becky, was encouraging from day one and has always been supportive of my endeavors, no matter if they seemed like good ideas or not. Our pup, Gatsby, who makes me smile every day, kept my feet warm all winter while I was writing, using them as his bed under my desk. All of the thanks in the world would not be enough for my parents, Wes and Deb, who have provided me with more support and guidance than I could have ever dreamed. I love them all.
Before this was a book it was a website, and that website received feedback from some of the best in the business. Im incredibly thankful to Jeff Cohen, Mike Gibson, Scott Robbin, Christopher Webb, Russell Schoenbeck, Dan Kim, Chris Mills, Bruce Lawson, Christian Heilmann, and many others for their initial feedback on these lessons. Of course the website itself wouldnt have existed without the help of Darby Frey, who has had my back for years and is easily one of the best guys I know.
I tapped on quite a few friends for content for this book, and I was overwhelmed by all of their contributions. I owe two-handed high fives to Aaron Irizarry, Adam Connor, AJ Self, Arman Ghosh, Bermon Painter, Brad Smith, Candi Lemoine, Carolyn Chandler, Chris Mills, Dan Denney, Darby Frey, Erica Decker, Estelle Weyl, Jen Myers, Jenn Downs, Jennifer Jones, Leslie Jensen-Inman, Maya Bruck, Russ Unger, Tessa Harmon, Victoria Pater, Vitaly Friedman, and Zoe Mickley Gillenwater. Next time I see each of them the high fives are payable in full, and dinner is on me.
I owe a ton of thanks to the New Riders family who helped bring this all together. Michael Nolan eased my fear of writing a book and gave me a gracious introduction to New Riders. Jennifer Lynn deserves an award for keeping this book on track and helping make sense of the content within it. Chris Mills did a fantastic job of making sure all of the right topics were covered in an understandable manner. Jennifer Needham put my words to work, making me sound better than I ever imagined. Mimi Heft always went the extra mile and was incredibly patient with me. Nancy Peterson handled every request I threw at her with ease and kept the entire team on the same page. Theyre all superheroes in my eyes, and they made writing this book an amazing experience.
Much of the content within this book has been heavily influenced by those who have written books and publications before me, and who continue to be thought leaders within the industry. Without the contributions of Jeffrey Zeldman, Eric Meyer, Dan Cederholm, Dave Shea, Andy Budd, Jeremy Keith, Cameron Moll, Ethan Marcotte, Chris Coyier, and others, its hard to say what Id know.
Today the Mozilla Developer Network and Dev.Opera communities are publishing some of best content on HTML and CSS; they have become staples within a long list of great resources. They must be thanked, too, for their amazing contributions.
When not in the office I do my best to stay involved in the community, and to that end I help organize a handful of different events in the Chicago area. While writing this book I fell behind on my duties, and I must thank Russ Unger and Brad Simpson from Chicago Camps and Jon Buda and Anthony Zinni from Refresh Chicago for picking up my slack. They all helped to carry my portion of the work without hesitation, and Im thankful and honored to have them as partners in crime.