Creating ‘Web 2.0′ Layouts using strips

November 13, 2008 | Published in: Web design & development | Tags: , , , , 10

Creating Layouts using strips

I’ve seen the ‘web 2.0′ layout (full width background, centred content) done in some pretty wacky and different ways, the worst being a background image and then fixed height sections laid on top (if the content wraps or the text is resized…bam..broken layout).

Because of this I am going to demonstrate the method I use – content strips. Hopefully this will be useful to CSS beginners who want to code this type of layout.

Essentially, what you do is treat each section, or ‘strip’, separately and layer them like a cake.

Lets take a commonly used design and demonstrate what I mean.

In the above design as you can see we have a header, a content (with two sub sections), and a footer. The footer and header require a full width background. So, horizontally we can see 3 strips – header, content, footer.

1
2
3
4
5
6
<div id="header"><p>Header</p></div>
<div id="content">
    <div class="mainContent"><p>Main Content</p></div>
    <div class="subContent"><p>Sub Content</p></div>
</div>
<div id="footer"><p>Footer</p></div>

Using CSS we can style each strip, leaving them all as full width elements. Header and footer should get a tiled background image each, and the text should be aligned center (text-align:center;).


The content itself should be centred and is common in all strips – lets say 700px wide in each section. To keep the content this wide we create a .inner class in the css stylesheet:

1
2
3
4
5
6
.inner {
    width:700px;     /* Limits its width */
    margin:0 auto;   /* Makes this inner div centered */
    text-align:left;    /* Parent strips have center aligned text */
    overflow:hidden; /* To clear floats */
}

Our HTML now looks like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<div id="header">
    <div class="inner">
        <p>Header</p>
    </div>
</div>
<div id="content">
    <div class="inner">
        <div class="mainContent"><p>Main Content</p></div>
        <div class="subContent"><p>Sub Content</p></div>
    </div>
</div>
<div id="footer">
    <div class="inner">
        <p>Footer</p>
    </div>
</div>

See how it works? Each strip can have its own background this way, and can shrink and grow to fit it’s content without breaking the layout.

As I said before, this is my preferred method of coding these kind of layouts and it has not failed me yet. I hope you found this useful.

Found this post useful? Why not buy me a coffee!

Related Entries

10 Responses to “Creating ‘Web 2.0′ Layouts using strips”

RSS feed for comments on this post.

  1. Ryan Kelly says:

    Well, you could always take the ‘inner’ DIVs out and instead set the width of the header and footer paragraphs, then set the content DIV to the width you need (assuming that in your diagram the content section does not need a background or can use the body background).

    I can’t think, off the top of my head, of any rendering issues this could cause.

    ReplyReply

    Comment made on November 16, 2008 at 2:41 am

  2. Mike Jolley says:

    With that shown on the diagram, yes your correct; you could set the width of the paragraphs. But as soon as you get more advanced content the inner divs really help matters.

    This site for instance has many strips because of all of the background images; I think I have 4 (header, nav, content, footer).

    ReplyReply

    Comment made on November 16, 2008 at 12:37 pm

  3. 2.0 myspace layouts mediation says:

    This+is+what+i+was+searhcing+for+so+many+months.

    ReplyReply

    Comment made on February 26, 2009 at 9:48 pm

  4. Asif Shabbir says:

    Their is good habit to use Div instead of using tables. Also it is easy to understand code. Thanks for posting it.

    ReplyReply

    Comment made on May 7, 2009 at 12:00 pm

  5. Ashfame says:

    Thanks for the article! I have tried such a layout earlier but didn’t end well. Now I know how to proceed. :)

    ReplyReply

    Comment made on June 7, 2009 at 5:46 pm

  6. Richard Sheppard says:

    I think I’ve used some of the wacky ways you mentioned. Was never happy with them – this is so simple, clear and effective. Thanks!

    ReplyReply

    Comment made on July 29, 2009 at 8:14 pm

  7. abhijeet says:

    does it work with wordpress????????

    ReplyReply

    Comment made on October 29, 2009 at 7:47 am

  8. Dorset Web Design Company says:

    Nice, simple and well put. A lot of people really over complicate their css and html. You just need to think simply – although it takes the benefit of experience before this “clicks”. It took me a few years of coding before I realised I was putting way too many divs and slices in.

    Can you make a few more simple cutups like for 3 column, 2 column etc for your readers that might be useful

    ReplyReply

    Comment made on November 5, 2009 at 11:58 am

  9. Mostyn Web Solutions says:

    Thanks for the article, nice approach.

    Slightly random question but is it an issue that this approach will cause multiple http requests for the different background images? Is there any way css slicing could be used for this approach? ie downloading 1 image and specifying what parts of that image are going to be used for each background?

    ReplyReply

    Comment made on January 11, 2010 at 10:50 pm

  10. Suraj Nayak says:

    didn’t get you?

    ReplyReply

    Comment made on May 20, 2010 at 2:50 pm

Leave a Reply

About this site

Blue Anvil is the online web design journal & portfolio of , a web designer from Norfolk, England. Read More »
MiniCard Theme for WordPress
  • Featured work - More

    • Beefjack
    • Integrity
    • theotaku.com
  • Latest Tweet - More

    • RT @jameskoster: Free MacBook Pro vector; http://www.potatoestomatoes.co.uk/technical/free-macbook-pro-vector/ #vector #resource
  • Out of the blue - More

    • Closing the Forums

      Just posting to let current users know that I’m closing the forum on Blue-Anvil. This is mainly due to spam-registrations getting out of hand and being a general nuisance. I will be posting good topics as FAQ items within posts if applicable.

      Please note that you can still post and get help for my plugins/themes by posting on the wordpress.org website.

    • Show off your MiniCard!

      Are you a user of the WordPress MiniCard theme? Its been downloaded over 14,000 times so far!

      If you have used it as-is, made your own child-theme or done something creative with it, please show off your MiniCard’s in the comments, I’d love to see how the theme is being used!

    • Spam Stopper updated for WordPress 3.0

      My Spam Stopper plugin has been updated for WordPress 3.0 (version 3.1.3) – you can grab it here. Sorry this update took longer than my other plugins but this one gets less lovin’ – if you want to change that feel free to donate, spread the word, or rate it on the WordPress.org plugin page.

    • SexyBookmarks & Tr.im

      Just a notice to users of the brilliant http://www.sexybookmarks.net/ plugin by shareaholic – If you use tr.im (as I have on a few client sites) be aware tr.im has ceased operation so you may see errors on your blog or in your source code; it screwed up the background and headings on one of my blogs.

      To fix, go to sexybookmarks options, switch services in the “Which URL Shortener?” box, and tick the box to reset all short urls. Once done, your blog should return to normal.