Making the CSS Switch with Grids, Part 2

A month ago I was talking about designing with grids and specifically with 960 pixel wide grids due to the amount of divisors it has. Over the weekend a new CSS framework called Blueprint was release which emphasizes just those two aspects. Blueprint includes a small set of css files but packs quite a punch, especially for a first release.

There are only 5 css files for the entire framework, split up in designations like “grid”, “reset” and “typography”. A more in depth description of what they do can be found on the Blueprint tutorial page. The concepts make for learning how to create your own designs relatively easy. There are a few basic ideas to all layouts:

  1. A div with a class of “container” will hold everything within a box
  2. The first item in a container (the one farthest to the left), needs a class of “first”
  3. The last item in a container (the one on the right) needs a class of “last”
  4. vertical columns need a class of “column”
  5. You can specify a class from “span-1″ to “span-9″ to determine how wide a column should be.
  6. You can create another “container” within any column and repeat these steps.

A container sets the width to the magic number, 960px wide. This means that if you were trying to make a layout like AdamFortuna.com which has 100% wide portions, each would be it’s own element with a container inside of it, so the header would look like this:
[html]

[/html]
The “header” would then be responsible for setting the background color. The heavy amount of classes do all the work, keeping your css free of all IDs, one of the main reasons I don’t like Yahoo Grids is that it uses ID tags, not to mention littering your css with “yui” everywhere. Blueprint does a good job of staying towards the semantic css side of things, although ideally you wouldn’t have numbered classes like “span-3″, it would be more like “pod” or “asides”. I’m happy with the mix though, and you can specify additional styles by tagging it up with your own IDs. In the Blueprint example you’ll also see a pair of background images that come along with the framework to use when testing your layouts.

Blueprint is still at version .3, with it just out in the public eye, but I see it being very useful down the line. If you’re pulling your hair out trying to get a normal box layout without tables, it’s a great resource to check out.

If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

Comments
I not so long ago write my own small guide to getting started using Blueprint. You can find it on my website. Blueprint does get a bit messy with the more sections you require but it is a great place to start and can easily be adjusted.
I like the idea here. There are too few CSS frameworks and even less that are fully tested. I’ve been warming up to YUI but its difficult to move over to when you’ve already started with a design and used IDs for all your Divs. Ahhh… if only something as simple as table based layouts were realistic (yea… I know I know, just let them go… its 2007, not 1997…)
Hey,

Just to be clear, YUI Grids uses only 2 IDs: #doc wraps the entire document and sets the width (750px, 950px, 974px, and 100%). The second ID used is #yui-main, which wraps the primary content (column) of the page. I chose IDs in these two cases because the DOM nodes they represent are single and unique. All other nodes use classes.

#yui-main is needed in the DOM so that you can have “source-order independence” which is good for search engine optimization (SEO) and accessibility.

Thanks for letting me clarify these facts.

Thanks,
Nate

Nate Koechley
YUI Team, Yahoo!

Leave a comment

(required)

(required)