--- comments: true date: 2011-01-23 14:19:23 layout: post slug: using-the-body-element-as-a-wrapper title: Using the <body> element as a wrapper wordpress_id: 2247 categories: - Web Development --- This is a tiny little blog post that a lot of you will already be aware of, however in _my_ experience I've found that for every one person that does realise this, there are about two who don't. A lot of developers will have a _wrapper_ `
` in their markup in which the page is contained. It might look something like this:
[content]
/* CSS */ body{ font-family:sans-serif; background:#fff; color:#333; } #wrapper{ width:940px; margin:0 auto; }
It _most_ situations this could be simply rewritten: [content] /* CSS */ body{ font-family:sans-serif; background:#fff; color:#333; width:940px; margin:0 auto; } You `` _is_ a container. Obviously there will be _some_ instances where this won't be suitable--and you'll spot what those are as you come across them--but for the most part, you can drop that unnecessary wrapper `
` and **use the `` element as a wrapper**. Hat-tip to [Simon Wiffen](http://twitter.com/simonwiffen) for showing me this a while ago.