Praise for Head First HTML and CSS
“Head First HTML and CSS is a thoroughly modern introduction to forward-looking practices in
web page markup and presentation. It correctly anticipates readers’ puzzlements and handles
them just in time. The highly graphic and incremental approach precisely mimics the best way
to learn this stuff: make a small change and see it in the browser to understand what each new
item means.”
— Danny Goodman, author of Dynamic HTML: The Definitive Guide
“Eric Freeman and Elisabeth Robson clearly know their stuff. As the Internet becomes more com-
plex, inspired construction of web pages becomes increasingly critical. Elegant design is at the core
of every chapter here, each concept conveyed with equal doses of pragmatism and wit.”
Managing Director, Disney Online
— Ken Goldstein, Executive Vice President and
“The Web would be a much better place if every HTML author started off by reading this
book.”
http://dbaron.org/
— L. David Baron, Technical Lead, Layout and CSS, Mozilla Corporation
“I’ve been writing HTML and CSS for 10 years now, and what used to be a long trial-and-
error learning process has now been reduced neatly into an engaging paperback. HTML used
to be something you could just hack away at until things looked okay on screen, but with the
advent of web standards and the movement toward accessibility, sloppy coding practice is not
acceptable anymore…from a business standpoint or a social responsibility standpoint. Head
First HTML and CSS teaches you how to do things right from the beginning without making the
whole process seem overwhelming. HTML, when properly explained, is no more complicated
than plain English, and the authors do an excellent job of keeping every concept at eye level.”
— Mike Davidson, President and CEO, Newsvine, Inc.
“The information covered in this book is the same material the pros know, but taught in an
educational and humorous manner that doesn’t ever make you think the material is impossible
to learn or you are out of your element.”
and Professional CSS, schmitt@christopher.org
— Christopher Schmitt, author of The CSS Cookbook
“Oh, great. You made an HTML book simple enough a CEO can understand it. What will you
do next? Accounting simple enough my developer can understand it? Next thing you know, we’ll
be collaborating as a team or something.”
— Janice Fraser, CEO, Adaptive Path
More Praise for Head First HTML and CSS
“I *heart* Head First HTML and CSS—it teaches you everything you need to learn in a ‘fun
coated’ format!”
— Sally Applin, UI designer and fine artist, http://sally.com
“This book has humor and charm, but most importantly, it has heart. I know that sounds
ridiculous to say about a technical book, but I really sense that at its core, this book (or at least
its authors) really care that the reader learns the material. This comes across in the style, the
language, and the techniques. Learning—real understanding and comprehension—on the part
of the reader is clearly topmost in the minds of the authors. And thank you, thank you, thank
you, for the book’s strong and sensible advocacy of standards compliance. It’s great to see an
entry-level book, that I think will be widely read and studied, campaign so eloquently and
persuasively on behalf of the value of standards compliance in web page code. I even found
in here a few great arguments I had not thought of—ones I can remember and use when I am
asked (as I still am)—‘what’s the deal with compliance and why should we care?’ I’ll have more
ammo now! I also liked that the book sprinkles in some basics about the mechanics of actually
getting a web page live—FTP, web server basics, file structures, etc.”
— Robert Neer, Director of Product Development, Movies.com
— Newton Lee, Editor-in-Chief, ACM Computers in Entertainment
“Head First HTML and CSS is a most entertaining book for learning how to build a great web
page. It not only covers everything you need to know about HTML and CSS, it also excels in
explaining everything in layman’s terms with a lot of great examples. I found the book truly
enjoyable to read, and I learned something new!”
http://www.acmcie.org
“My wife stole the book. She’s never done any web design, so she needed a book like Head First
HTML and CSS to take her from beginning to end. She now has a list of websites she wants to
build—for our son’s class, our family…If I’m lucky, I’ll get the book back when she’s done.”
— David Kaminsky, Master Inventor, IBM
“Beware. If you’re someone who reads at night before falling asleep, you’ll have to restrict Head
First HTML and CSS to daytime reading. This book wakes up your brain.”
Fribourg University, Switzerland
— Pauline McNamara, Center for New Technologies and Education,
Praise for other books by Eric Freeman and Elisabeth Robson
“From the awesome Head First Java folks, this book uses every conceivable trick to help you
understand and remember. Not just loads of pictures: pictures of humans, which tend to interest
other humans. Surprises everywhere. Stories, because humans love narrative. (Stories about things
like pizza and chocolate. Need we say more?) Plus, it’s darned funny.”
— Bill Camarda, READ ONLY
“This book’s admirable clarity, humor, and substantial doses of clever make it the sort of book that
helps even nonprogrammers think well about problem solving.”
— Cory Doctorow, co-editor of Boing Boing
and author of Down and Out in the Magic Kingdom
and Someone Comes to Town, Someone Leaves Town
“I feel like a thousand pounds of books have just been lifted off of my head.”
— Ward Cunningham, inventor of the wiki
and founder of the Hillside Group
“This book is close to perfect, because of the way it combines expertise and readability. It speaks with
authority and it reads beautifully. It’s one of the very few software books I’ve ever read that strikes
me as indispensable. (I’d put maybe 10 books in this category, at the outside.)”
— David Gelernter, professor of computer science,
Yale University, and author of Mirror Worlds and Machine Beauty
“A nosedive into the realm of patterns, a land where complex things become simple, but where
simple things can also become complex. I can think of no better tour guides than these authors.”
former Chief Java Evangelist, Sun Microsystems
— Miko Matsumura, industry analyst, The Middleware Company
“I laughed, I cried, it moved me.”
— Daniel Steinberg, Editor-in-Chief, java.net
“Just the right tone for the geeked-out, casual-cool guru coder in all of us. The right reference for
practical development strategies—gets my brain going without having to slog through a bunch of
tired, stale professor-speak.”
— Travis Kalanick, founder of Scour and Red Swoosh,
member of the MIT TR100
“I literally love this book. In fact, I kissed this book in front of my wife.”
— Satish Kumar
Other O’Reilly books by Eric Freeman and Elisabeth Robson
Head First Design Patterns
Head First HTML with CSS & XHTML (first edition)
Head First HTML5 Programming
Other related books from O’Reilly
HTML5: Up and Running
HTML5 Canvas
HTML5: The Missing Manual
HTML5 Geolocation
HTML5 Graphics with SVG and CSS3
HTML5 Forms
HTML5 Media
Other books in O’Reilly’s Head First series
Head First C#
Head First Java
Head First Object-Oriented Analysis & Design (OOA&D)
Head First Servlets and JSP
Head First SQL
Head First Software Development
Head First JavaScript
Head First Ajax
Head First Rails
Head First PHP & MySQL
Head First Web Design
Head First Networking
Head First iPhone and iPad Development
Head First jQuery
Head First
HTML and CSS
Wouldn’t it be dreamy if there
were an HTML book that didn’t
assume you knew what elements,
attributes, validation, selectors, and
pseudo-classes were, all by page
three? It’s probably just a
fantasy…
Elisabeth Robson
Eric Freeman
Beijing • Cambridge • Farnham • Kln • Sebastopol • Tokyo
Head First HTML and CSS
by Elisabeth Robson and Eric Freeman
Copyright © 2012 Elisabeth Robson and Eric Freeman. All rights reserved.
Printed in Canada.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly Media books may be purchased for educational, business, or sales promotional use. Online editions
are also available for most titles (http://my.safaribooksonline.com). For more information, contact our corporate/
institutional sales department: (800) 998-9938 or corporate@oreilly.com.
Series Creators:
Editor:
Cover Designer:
HTML Wranglers:
Production Editor:
Indexer:
Proofreader:
Page Viewer:
Kathy Sierra, Bert Bates
Brett McLaughlin (first edition), Mike Hendrickson (second edition)
Karen Montgomery
Elisabeth Robson, Eric Freeman
Kristen Borg
Ron Strauss
Rachel Monaghan
Oliver
Printing History:
December 2005: First Edition.
September 2012: Second Edition.
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly
Media, Inc. The Head First series designations, Head First HTML and CSS, and related trade dress are trademarks
of O’Reilly Media, Inc.
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 O’Reilly Media, Inc., was aware of a trademark
claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and the authors assume no
responsibility for errors or omissions, or for damages resulting from the use of the information contained herein.
In other words, if you use anything in Head First HTML and CSS to, say, run a nuclear power plant, you’re on your
own. We do, however, encourage you to visit the Head First Lounge.
No elements or properties were harmed in the making of this book.
Thanks to Clemens Orth for the use of his photo, “applestore.jpg”, which appears in Chapter 5.
ISBN: 978-0-596-15990-0
[TI]