Grid-based design: Part 2, Designing blog theme templates

The previous grid article dealt with how to come up with a CSS strategy when you're working with another visual designer's comps. Now I'd like to discuss doing grid-based theme design for open source content management systems, e.g. Drupal and WordPress. The purpose of this article is to give you an idea of how to approach blog theme design using a grid system. After reading this, you should be able to create a fully-functional grid-based design and HTML prototype that can be coverted into a theme template.

Creating the design grid

I recently redesigned this site because I wanted a layout that provided larger areas for my content. I needed a system that provided me the flexibility to get creative with the layout, but I also wanted to be sure not to lose control of the order and balance of page elements. While the spare layout of my previous design worked well, the new design would be a little more information dense.

For the new layout I used a grid with a simple division of thirds at a fixed width of 801 px. To get to this width, I played around with different sizes that could be centered within a 1024px x 768px browser window with ample white space on the sides. I targetted my maximum width around 800px.

I started by dividing up 800px into thirds and had an approximate width of 267px per third to play with. I borrowed the idea from the MIG design of using a 3 pixel border to separate each division. This odd-sized gutter makes room for 1px vertical border lines with 1px of padding at each side if I need it. I kept sub-dividing the thirds and after a bit of tweaking came up with the grid below. Each little pink box is 1/12 the width of the page (64px wide). 4 of these side to side make up a third of the width, which I would use for normal column of text. 2 or 3 of these side to side would be nice for a narrow column.

grid
Screen shot of the grid (shrunken to fit)

So now I have a grid that could easily be divided into the thirds I needed to make a multi-column layout. This gives me a very simple grid to work with and I don't think I'd need to have smaller grid divisions for blog themes. Next step is to start looking at layout sketches I had in mind and think about how to turn them into XHTML & CSS. The visual design I'm basing this demo on is an old theme I once used on my blog, with a little modification of the graphics and color palette. You can see a screenshot of the old theme (it's the one in the upper left hand corner).

Turning boxes into content areas

To get started, I think about the page elements I want to use. I want the page to have these parts:

  • header
    • logo
    • graphic element
  • body
    • weblog content
      • blog entry
        • entry metadata
        • comments
    • local navigation
    • advertisements
  • footer

I have some hierarchy of elements established in this list. You probably won't need to jot down a list of elements like this to do a weblog layout, but it helps to show where we're going.

Using the list as a starting point, I start to think about where I want these elements to go on the grid. You can use the grid like a wireframe (page schematic) by selecting areas of content and blocking them out, labeling them as you go.

grid template
Wireframe of content areas

Above, I took each of the page elements and blocked them out. We're going to take the wireframe and create the visual design elements for the page and design the layout of the content blocks.

grid template
Visual design comprehensive sketch over grid

As I'm doing this design, I realize that I don't actually need 3 grid blocks for the ads, so I use 2 instead. The layout is looking good to me so far, so now I start thinking about how to turn the blocks into CSS.

Turning content areas into CSS elements

Working with grids makes it easier to visualize a strategy for the CSS layout. I start by thinking of the hierarchy of divs that will make up my page wrapper and all of the child divs nested within it. I'll label those in the wireframe to show what I'm thinking.

grid template

As you can see, I'm going to enclose the entire page in div#wrapper. The rest is a bit like a sandwich. On the top, I put the #logo and #graphic in div#header. On the bottom, I have div#footer with my copyright info. And sandwiched in the middle is div#main which encloses the 3 column layout of #localnav, #content and #ads.

Next I go about measuring each content block and recording it's dimensions. I'm mainly looking for widths here except for the header, where I actually want the height as well. Heights will, of course, stretch vertically in the div#main. I measure the #header out to be 801px wide by 131px high. In the screenshot below, I show how I get the dimensions of #logo using the Info panel in Photoshop. I do this to each content area, getting fixed widths for all the areas.

mesuring content modules

Creating the style sheet for the layout

Constructing a shell

When I'm done gathering my measurements, I can start to construct the stylesheet. I start by creating a barebones shell that will look a bit like our wireframe. First I record the main divisions in my CSS file.

#wrapper {}
#header {}
#header #logo {}
#header #graphic {}
#main {}
#main #navigation {}
#main #content {}
#main #ads {}
#footer {}

Then I put in all the dimensions and positioning. To test my sanity and the precision of my measurements, I put the grid into the div#wrapper as a background image. The core CSS for the layout is below.

* {
  padding:0;
  margin:0;
  font-family: Helvetica, Arial, Sans-serif;
}

body {
  background: #fff;
  text-align: center;
}
#wrapper {
  text-align: left;
  margin: 20px auto;
  width: 801px;
  height: 801px;
  background: transparent
    url(grid-unit-boxes-801px.png) 0 0 repeat-y;
}
#header {
  margin-bottom: 3px;
}

#header #logo {
  float: left;
  margin-right: 3px;
  width: 198px;
  height: 198px;
  background: #ccc;
}

#header #graphic {
  float: left;
  width: 600px;
  height: 198px;
  background: #ccc;
}

#main {
  margin-bottom: 3px;
}

#main #navigation {
  float: left;
  margin-right: 3px;
  width: 198px;
  background: #ccc;
}

#main #content {
  float: left;
  margin-right: 3px;
  width: 466px;
  background: #ccc;
}

#main #ads {
  float: left;
  width: 131px;
  background: #ccc;
}

#footer {
  background: #ccc;
}

/* PIE easyclearing */
.clearfix:after {
    content: ".";
    display: block;
    height: 0;
    clear: both;
    visibility: hidden;
}

.clearfix {display: inline-table;}

/* Hides from IE-mac \*/
* html .clearfix {height: 1%;}
.clearfix {display: block;}
/* End hide from IE-mac */

Next I start putting the widths (and heights for the #header) I recorded into the style sheet, creating a shell for the site. To make the boxes lay out precisely, I use left floats for columns and the Position Is Everything easy clearing method. If you view a demo of the CSS shell pop you'll see that the boxes line up precisely against the background grid. Things are looking pretty good. Now we have to add the graphic elements from the comp.

Completing the wrapper

We're almost done now with the wrapper. To finish off the wrapper we have to cut up the background graphics and tweak the the widths just a little so that our border backgrounds fit around the grid. Take a look at the wrapper with header graphics and borders in place pop.

Final touches

It's looking nearly finished now. All that's left is to do the style elements for the HTML inside the major divs. I put in all of the HTML for the template areas. I create the site logo and drop that into div#logo. I add some padding to the columns inside div#main. Finally, I add color and sizes to the fonts. Now you can view the final HTML template pop.

Conclusion

Grids are very useful for doing even simple blog themes. They give you a solid system you can rely on to lay out your template and evolve it as needs require.

I showed you how I approach layout and site development for a weblog template and gave you an HTML prototype you can convert into a theme. You are free to use the template in this example, I'm releasing it under GPL. I hope this article helps Drupal developers in some way by giving them a process for approaching their theme designs. Have fun theming!

See also: Cutting and sewing grid-based design: Part 1, working with other people's comps

Comments

1. bertboerland (not verified) commented:

Michael, thanks for this excellent posting. Please keep sharing your knowledge!

2. Bèr (not verified) commented:

Great article!

You might also want to have a look at this great post about the "naming of the CSS":http://www.contentwithstyle.co.uk/preview/index.php?id=17
"and about naming your DOM":http://www.stuffandnonsense.co.uk/archives/whats_in_a_name_pt2.html

3. jibbajabba commented:

Yeah, I've read Mike Steinhouse's article. Believe me, what I do as a site developer is based on best practices culled from lots of articles like that.

As for this template, the CSS framework I'm using works for me. It's all pretty arbitrary from an outside persepective. What makes a framework work with regards to labeling is your consistency of use. Making it easy to use consistently over multiple applications might require some more abstract labeling of divs. Might not. I'm not so sure.

For example, does div#box1 work better than div#ads. It depends on the contingencies, i.e. will the content or layout needs change so drastically that div#ads is too specific? Perhaps. Maybe div#ads will need to become div#ads1, div#ads2, div#ads3 in the future. Nothing is lost in this case. But even more flexible is the completely arbitrary labeling of div#box1. Problem is that kind of labeling is difficult to parse out in a long style sheet, necessitating verbose commenting. Descriptive labeling takes care of that.

So it will be interesting to see what I come up with as I try to make a framework for providing multiple stylesheets for a single Drupal theme. I've done it in the past with this site and have learned by experience that as I try new CSS approaches, the labeling and order of elements has bitten me when it wasn't well thought out. Over time I've gotten it right through trial and error. I'm hopefull smarter now.

4. clint (not verified) commented:

I really appreciate your article, and thanks for going that extra length with the markup/css to put the grid into action.

I was wondering what the standard practice is to determine how many grid units your layout should have, like say if you were going for a wider layout, something like 970'ish, would you go for more grid units or stick with 12 wider units?

5. jibbajabba commented:

Good question. I think I'd go for wider units to keep the math simple. More units or a further breakdown of the 12 unit grid would give you better options for dividing your layout.

6. Derek Punsalan (not verified) commented:

Fantastic write-up (one that I have just emailed to a few people who expressed interest in a grid based design).

7. Garry (not verified) commented:

Thanks for the article Michael.
It's exactly what I've been looking for.

8. vaskos (not verified) commented:

Very useful.
It would be great if you post similar tutorial but for "liquid" (non-fixed width) templates.
Thanx!
---
Live Drupal Themes Preview - themegarden.org

9. Area Code Finder (not verified) commented:

Fantastic tutorial! I can't tell you how much it helps me out. I was looking for info like this.

10. Mac Steve (not verified) commented:

Very usefull and informative,Thanks for sharing you great knowledge in a simple and easiest way .You guys might also want to have a look http://website-design.com.au

11. chad74_WV (not verified) commented:

Michael,
Thank you so much for posting this clear, concise, easy to understand tutorial. This has by far been the most easy to understand, tutorial on CMS template making that I have ever read.

I think the grids make perfect sense. They help us view the page logically and give us a better visual representation of what we are working with, rather than a bunch of text talking about it.

Your descriptions were nice too.

Hope to read more from you.

-Chad

12. motosport (not verified) commented:

Great tutorial, thx for work!

13. Tercüme bürosu (not verified) commented:

Michael, thanks for this excellent posting...

14. Víctor Bayarri (not verified) commented:

I've been looking for a complete example from design to code and your post is really well explained.

Thanks for your great tutorial.

15. chriso (not verified) commented:

Excellent info, ive been searching for somthing like this for a while now, it will be very useful to me in my latest project. Many thanks

16. Alex (Personal Development bloger) (not verified) commented:

This is one of the best css tutorials I have ever seen - very helpful. Thanks a lot for clarifying a few things for me.
Alex

17. Anonymous (not verified) commented:

thank you for this great article.

18. Anonymous (not verified) commented:

So it will be interesting to see what I come up with as I try to make a framework for providing multiple stylesheets for a single Drupal theme. I've done it in the past with this site and have learned by experience that as I try new CSS approaches, the labeling and order of elements has bitten me when it wasn't well thought out. Over time I've gotten it right through trial and error. I'm hopefull smarter now.

19. Anonymous (not verified) commented:

great tutorial, thanks

20. internet (not verified) commented:

thank you :)

21. Atomic Popcorn (not verified) commented:

This is a great page of information. I just bookmarked it. This will be very helpful once I am done with my current job.

22. ruya (not verified) commented:

Does div #box1 work better than div #ads. It depends on the contingencies, i.e. will the content or layout needs change so drastically that div #ads is too specific ?

23. firefox (not verified) commented:

great, thanks

24. Andrzej (not verified) commented:

Excellent info, ive been searching for somthing like this for a while now, it will be very useful to me in my latest project. nice descriptions too.
Many thanks

http://www.andrzejfilipowicz.com/

25. Arzt (not verified) commented:

Great tutorial,

thanks a lot. I have been looking for sources to learn more about css and cms.
I want to make skin for my blogs, and your tutor helped me.

Thanks again.

26. Leren (not verified) commented:

nice, I a beginning template builder, but a grid is defenately the best way to start!

27. Pupil (not verified) commented:

Great tutorial. We really can use these tips and trick, now that we are in training for webdesign and blogdesign at our University.

28. Charity cds (not verified) commented:

really helpful - thanks a million

29. AnneMarie (not verified) commented:

I was looking for resources to learn more about css, cms, skins for my blogs, etc. Your tutor helped me a lot, and I would like to invite everybody to come to my site (about parents and their children) and see the progress in the coming days/weeks.
regards, Annemarie, http://www.gastouderverzekering.nl

30. ferforje commented:

I bookmarked it too, thank you.

ferforje"

31. laptops (not verified) commented:

really good ideas for my new blog template, thanks.

32. ev (not verified) commented:

This is a great page of information. I just bookmarked it. This will be very helpful once I am done with my current job.

33. STILL LIFE PAINTING (not verified) commented:

this excellent posting
I stumbled it too, thank you.
Filipowicz
STILL LIFE PAINTING

34. technology (not verified) commented:

Great tutorial

perfect layout, i am startting to try to make new one

35. Anonymous (not verified) commented:

Good question. I think I'd go for wider units to keep the math simple. More units or a further breakdown of the 12 unit grid would give you better options for dividing your layout.

36. kadın (not verified) commented:

I bookmarked it too, thank you.

37. dizi müzikleri (not verified) commented:

thanks for article, i will follow this blog ;)

38. Dunya Zirvesi (not verified) commented:

Thanks for the article Michael.

39. Saçma Espiriler (not verified) commented:

great tutorial, thanks..

40. ses kayıt (not verified) commented:

Thank you for the wonderful Blog..

41. hotcp commented:

read it throughly, really excellent article, please keep up posting such great articles.

42. hcp (not verified) commented:

Ok i read the tutorial yesterday and today i am giving this a try, hope i can come out with a good theme using this tut, thanks anyways

43. Anonymous (not verified) commented:

i think this site is very very usefull

44. danielle (not verified) commented:

That was a very professional article and i appreciate your hard work on our behalf.I'll be looking forward to other articles you post in the future.

45. Dave (not verified) commented:

Great thanks for sharing your knowledge with us, it have been very appreciated.

46. Ramses (not verified) commented:

Perfect lesson thanks for job Michael.

47. Freelancer (not verified) commented:

Fantastic tutorial. I am a wordpress user. I will see if I can effectively apply your technique.

Once again thanks so much. I really appreciate your selfless sharing.

48. SEO (not verified) commented:

Thank you for blog michael.

SEO

49. Knight Online (not verified) commented:

Thanks for the article Michael.

50. sınıf dizisi (not verified) commented:

I will see if I can effectively apply your technique.

51. articlegood (not verified) commented:

Perfect lesson thanks for job Michael.

52. bodrum hotels (not verified) commented:

Thank you for blog michael.

53. su deposu (not verified) commented:

Thanks for the article Michael.

54. rüya tabirleri (not verified) commented:

Fantastic tutorial! I can't tell you how much it helps me out. I was looking for info like this...

55. minimal techno (not verified) commented:

Very nice tutorial! I was struggling with this and your article definitely cleared a few things up for me. Thanks!

56. el-salvador (not verified) commented:

Perfect lesson thanks for job Michael.

57. vinç (not verified) commented:

Thanks for the article Michael.

58. You Tube (not verified) commented:

Very good article, thanks Michael.
I will see if I can effectively apply your technique.

59. Mika (not verified) commented:

Hi! nice article, thank you.

60. Nelson (not verified) commented:

think the grids make perfect sense. They help us view the page logically and give us a better visual representation of what we are working with, rather than a bunch of text talking about it.

61. vinç (not verified) commented:

Very nice tutorial! I was struggling with this and your article definitely cleared a few things up for me. Thanks!

62. vana (not verified) commented:

Thanks for the article Michael.

63. Anonymous (not verified) commented:

Very nice tutorial!Thanks man..

64. Plus (not verified) commented:

Perfect job...Thanks Michael..

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <b> <strong> <dd> <dl> <dt> <i> <li> <ol> <u> <ul> <code> <blockquote>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

↑ top
ss_blog_claim=8db7b25e1299acb568b95f15134df34d