Eric Meyer is going to talk about CSS frameworks here at An Event Apart San Francisco.
He did a Google search for “CSS Frameworks” and put together a list of the big players. It’s a list of nine frameworks. Eric wants to know two things: what are they doing the same and what are they doing differently.
Let’s get one question out of the way, the question
which one is right for you? Answer… none of the above. It’s like templates. There’s nothing wrong with templates but you don’t put together your client’s site based on a template, right? They can be a good starting point for ideas but you do your own designs. If you’re going to use a framework, it should be yours; one that you’ve created. You can look at existing frameworks for ideas and hack at it. But the professionals in this room are not well served by picking up a framework and using it as-is.
Eric put together a grid of features and which frameworks support those features. Every framework does reset, colours, and fonts. The fact that every framework has a reset is evidence of the frustration we all feel with the inconsistencies between browsers. The rules for colour tend to be much more minimal. Font styling, on the other hand, is more fully-featured generally. Whereas the colour might just be set for the
body element, font sizes and faces are specified throughout. Usually that font face is Helvetica. Most frameworks steer away from trying to style form elements. Almost all of them do layout, usually combinations of columns. Four of the nine frameworks included print styles. Three of the nine included hacks.
Four of the nine frameworks are setting font sizes on the body with pixels. Tripoli uses Richard’s 62.5% rule. Eric points out how using a 76% rule on the
body can lead to inconsistent font-sizing between browsers because of the inconsistencies of rounding off font sizes. Only two of the frameworks aren’t using unitless
line-heights. Generally you want a line height of
1 to get propagated down the document tree rather than simply the computed value of
1em in pixels. You don’t want a 40 pixel element having a line height of 12 pixels.
Most of these frameworks, with the exception of YUI, are setting heading sizes in some form or another. The only place where you’ll see a heading size go below
1em is in a browser style sheet. In the frameworks, no heading size, even
h6, goes below the size of body text,
1em. Blueprint and Elements set pretty large sizes on
h2. The other frameworks cluster around the same size range, never getting very big or very small. Eric averaged out all the measurements to get the average size for
Where frameworks are using IDs or classes, what names are they using? Four of them use psuedo-namespaced class names beginning with
span- (which you would apply to a
div!?). You’re supposed put classes in your markup like
span-5 or whatever. This seems pretty complicated. Three frameworks use more intuitive names like
main. In fact
footer are universal IDs across the three frameworks.
Style inclusion patterns
Some of the frameworks have a single short style sheet that you point to from your markup, which then links off to separate style sheets for fonts, colours, layout, etc. But most of them use separate style sheets and you must link to each one in your markup. Eric reckons that this is because IE for Windows will cache the first style sheet you point to with a
link element but not any subsequent style sheets with
What the hack?
There are two kinds of hacks:
- Hacks that point to failings in CSS like self-clearing floated elements and things like pseudo-padding.
- Hacks for Internet Explorer 6.
Some cool bits
Some of the frameworks provide compressed versions for production use to keep file size down.
Three of the frameworks had debugging styles that you could “turn on” to say, display the grid in the document.
YAML provides a draft file which is like a template style sheet. The selectors are written out but the declarations are left empty. This could be a handy training tool (fill in the curly braces).
960 provides “sketch” files: PDFs of the grid for you to print out and scribble on.
Thus endeth Eric’s roundup of CSS frameworks.