Since I posted the huge collection of Large Background Websites, I received several email requests on how to make a large background site with CSS. So, I thought it would be a good idea to share my techniques on designing large background websites. In this tutorial, I will provide various CSS examples on how you can create a large background site using either a single or double images.
Common Mistake: Background Gets Cropped (see demo)
Take a look at the demo file, it looks fine under 1280px. But if you have a high resolution display, you will see the background gets cut off on the sides.

Example #1: Single Image (see demo)
A quick solution to fix the problem mentioned earlier: make the edge of the image the same color as the BODY background color. Here, I'm going to use Web Designer Wall as an example. Take a look at the image below and notice the edge is a solid color?

CSS Part
The CSS part is very simple. Specify the background image (position it center, top) for the BODY element.

Here is the CSS code:
body {
padding: 0;
margin: 0;
background: #f8f7e5 url(wdw-bg.jpg) no-repeat center top;
width: 100%;
display: table;
}
Notice there are two extra lines in the BODY selector. That is to prevent the background image from shifting when you resize the browser smaller than the content width (it happens in Firefox).

Example #2: Double Images (see demo)
For this example, I'm going to use the job board design, Design Jobs on the Wall. I have a cork board pattern repeating in the BODY tag and a wrapper background in the center.

The trick here is to export the GIF matte with a brown color that is similar to the cork board pattern.

Example #3: Sky Background (see demo)
In this example, I have a 1px gradient that is repeated horizontally for the BODY tag. Then I attached a cloud background in the center of the #wrapper tag.

Update: Sky Background Using HTML Selector (see demo)
Thanks to the comments from the readers. Below is an example of the sky background using HTML selector to display the gradient background, so the #wrapper DIV tag is not required. It is a much more cleaner approach.

Download the demo zip now and don't forget to check out the Large Background Websites.
Credits: thanks to Alex from markup4u.com for the {width: 100%; display: table} CSS trick.
Ok so… I’m kind of a nub.. Hehe! How do I make it so that my small background image gets enlarged and stays centered in my css html website?
Why would you want to enlarge a small image? What are you trying to do?
You should try Googling “centering with css” for centering tutorials.
I love this .Thanks a lot
I cannot get this to work in firefox, demo here http://www.gloopy.co.uk
it will not resize :-
background: url(../images/bg.jpg);
background-position: center top;
background-repeat: no-repeat;
background-attachment: fixed;
width: 100%
height: 100%
Thank you!! =)
What am I doing wrong? I am using the html selector as you suggest, but it doesn’t display in firefox, chrome, or IE. Can someone please direct me or explain as to why this isn’t working. Has it been deprecated?
html {
background: #170c06 url(images/background-gradient.jpg) repeat-x;
}
Thaaaaaaank You! Great post and just what I’ve been looking for – I particularly like the html selector trick demonstrated for the cloud background image example- will run off and give it a go now….
Love the explanation and it works in IE which is what I’m looking for until IE get up to speed with with CSS3 (allows for multiple backgrounds super easy)
I’m a 100% visual person with limited HTML understanding so I use a WYSIWYG web design software… I set up a sample of your sky sample. http://threefooter.com/2backgrounds/
I see yours is written in HTML; the program I use only writes in which I hear is a very forgiven Doctype… but
Is there anyway to get my sample to work utilizing what I have? I’ve been playing with two image backgrounds for three weeks now with nothing to show.
Any help would be greatly appreciated.
Lasa
great examples and great designs. Thank you for sharing.
Great Article. Thanks :)
Brilliant! I have for so long been puzzled about working with background images in CSS. This has now cleared up any confusion I had! Thanks so much! :)
Okay, nice points an nice input!
The trick with the sky background ist just fine!
But what to do, when your background is destined to be bubbles, like in a glas of mineral water? And the wallpaper has different blue shapes all over the picture and tons of bubbles with different sizes and shapes?
You can’t just take a smaller portion out of it an x- or y-repeat ist.
Any idea???
Greets
Gerry from Germany
Tutorial for using large backgrounds in CSS
Thank you for having one of the coolest and informational sites around.
I have one question that I am a little confused with. when you have the 1 px by 514 px gradient. How do you match that up with the larger gif/jpg/png so that it matches so perfectly? My thought is that you have the picture you want and cut out of it a 1 px by 514 px and then cut out the boxes of how you want the rest of it to look? am I on the right path? thanks so much.
thanks!!!!
Je bloquais sur une règle bête, merci !
wallah… tha was really interesting! where do we get gif image for background u used in example 2 ???
hello. my website is http://iappleworld.webs.com/. its very useful but can you please email me a css code for a suitable bacground for my website.
Really a grat page. Good good good job.
I found so many interesting things I was looking for.
U rock!!
Gave me some ideas for my own layouts. I always have a difficult time coming up with a background.
thank u for this great tutorial,very helpful at all in progress my project
thanks for the interesting article, i like “Example #1: Single Image” :D