The Little Book of HTML/CSS Frameworks
by Jens Oliver Meiert
Copyright 2015 Jens Oliver Meiert. All rights reserved.
Printed in the United States of America.
Published by OReilly Media, Inc. , 1005 Gravenstein Highway North, Sebastopol, CA 95472.
OReilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://safaribooksonline.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com .
- Editor: Meg Foley
- Production Editor: Kristen Brown
- Copyeditor: Amanda Kersey
- Interior Designer: David Futato
- Cover Designer: Karen Montgomery
- Illustrator: Rebecca Demarest
- March 2015: First Edition
Revision History for the First Edition
- 2015-02-25: First Release
See http://oreilly.com/catalog/errata.csp?isbn=9781491920169 for release details.
The OReilly logo is a registered trademark of OReilly Media, Inc. The Little Book of HTML/CSS Frameworks, the cover image, and related trade dress are trademarks of OReilly Media, Inc.
While the publisher and the author have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the author disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights.
978-1-491-92016-9
[LSI]
Foreword
In the beginning, there was markup; and lo, it was good. Then came style sheets, which let the author make the markup pretty; and lo, they were also good.
Some of that goodness was rooted in simplicity. HTML was simple, charmingly so, and CSS started out as a small set of presentational suggestions that nevertheless allowed for a great deal of creativity. Even when you account for the fumbling browser implementations of early CSS, it was quite possible to hold in ones head every property, value, and common browser behavior. You could even document them all on a single page for easy reference.
That day is, of course, long since past. CSS has massively expanded in scope, depth, and complexity, and it has penetrated into unexpected places. Trying to keep track of everything CSS has to offer is incredibly difficult, and when you take into account all the varying support profiles and behaviors of desktop browsers, mobile browsers, OS adaptations, embedded firmware, and more, its practically impossible to comprehend a single snapshot, let alone keep up with ongoing changes.
So its no wonder there are so many CSS frameworks out there. Frameworks are a great way of taming complexity. Rather than have to remember all the fiddly details of vendor prefixes and syntax, and rather than have to put up with the limitations inherent in the CSS syntax (still no variables!), you can load up a framework and let er rip. You can even, depending on the framework, invoke a few simple classes to get precalculated layouts. Frameworks are popular for very good reasons.
On the other hand, in many ways weve traded one form of complexity for another. Its a veritable jungle of frameworks large and small out there, and figuring out how to navigate that jungle requires an expert guide to get you off to a good start. You need that guide not to tell you the specific characteristics of every plant and animal in the underbrush, but to give you hard-won advice on how to approach various situations, what to look for and what to avoid, and thus how to thrive in a constantly shifting environment.
A guide like Jens Meiert.
Ive known Jens professionally for many years now, and have been better for it. Jens is someone who always thinks deeply about the Web and the practice of building it, comes to a well-reasoned conclusion, and defends that position with honesty and candor. He cares as much as anyone Ive ever known about best practices in web development and will yield to nobody in his defense of that principle.
I know, because when a CSS reset I created became unexpectedly popular, Jens was tenacious in his view that nobody, but nobody, should use a CSS reset. While I didnt entirely agree with his conclusions about resets, I always valued his perspective in that debate, which was (as usual for Jens) an important contribution to the ongoing discussion about best and worst practices in web development. Many of his predictions about how resets would be abused came true. He made a strong case, one that was set on clear foundations and grounded in his passion for web development done right.
Some time later, Jens took that passion to Google and made significant progress in improving the markup Google produced. Anyone who cares about the Web will instantly understand what a huge contribution that was. Now hes applying that same passion to the subject of CSS frameworks.
If youre thinking about using a frameworkand there are, as youll soon read, very good reasons both for and against taking that courseJens high-level yet deeply practical advice will help you make the best decision you can. In a like manner, the principles he sets forth here will help you decide if perhaps you should develop your own framework, which is sometimes a much better idea than trying to use someone elses.
To framework or not to framework? Let Jens be your guide. I could not put you in any better hands.
Eric A. Meyer
Introduction
Many commercial websites these days are based on frameworks, and many personal websites use them, too. Yet what are frameworks, why and when do we need them, and how do we best use or build them?
This little book explores frameworks that govern HTML and CSS (and JavaScript) code. It focuses on HTML and CSS because these are at the heart of every web project. The principles outlined in the book, however, can also be applied to other forms of frameworks.
The goal of the book is to share solid, higher-level ideas around frameworks, trading some specificity for long-term usefulness. We could analyze all the different frameworks that are out right now, but if you wanted to make up your own mind or write a framework yourself, how useful would such review be if you picked this book up again in five years?
While the book attempts to cover all bases, it glosses over some of them, too. Web development has become a large field. Also, as well see shortly, framework development pivots around tailoring, and tailoring depends on circumstances. We dont know every projects circumstances, and so we cant generalize everything.
Although written in simple language, the book is geared toward expert web developers, the people who decide about whether and how to use, or whether or not to develop a framework.
It has likewise been written by a web developer. I, Jens, have during my career architected frameworks for OpenKnowledge, GMX, Aperto with their government and business clients, as well as Google. In that time, Ive not quite managed to outwit the fast pace of our industry, but Ive found that some principles, methods, and practices contribute to longer-lasting code. That has benefited the frameworks I wrote, and I hope it will benefit you through this book, too.