22 How to use a background image for your blog
Monday, October 15, 2007 /

Instead of a simple background color, you could use a background image for your blog. This could be styled to look like wallpaper, it could repeat only vertically or horizontally, and can even be in a fixed position where it stays in place while the rest of the page scrolls down!

In this post, I will explain the how you can use background images for your blog using these different methods, with examples to demonstrate how the various effects can be achieved.






You can use virtually any image as a background for your blog. Usually background images are in JPEG format, though you could also use GIF's or BMP's. However, you must be able to host the image on an external server, as Blogger only hosts images which are contained in widgets or posts. If you're looking for free image hosting, take a look at this post.

Before you begin to add the image to your background, find the image you would like to use, and make a note of the url where it is hosted.

As I mentioned in the introduction, there are different ways you can use background images. Here I will explain:

  • How to make an image repeat across the whole page (like wallpaper)

  • How to make a background repeat vertically down the page

  • How to make the background repeat horizontally across the page

  • How to create a fixed image background (which does not scroll with the rest of the page
All of these methods are possible in Blogger Blogs, and are quite simple to achieve.

How to make make an image repeat across the whole page (like wallpaper)

This is the simplest of all background effects to achieve. Most people prefer to use a small image which tiles seamlessly. This ensures that the page loads faster, since the image has a small file size.

You can easily find such images for your background by doing a Google search for tileable backgrounds, or could even create your own.

I created this simple image to use as an example, though you could just as easily use any other image:


To make this image a tiled background for your blog, go to Template>edit html and look for the styling properties for the body of your blog, which should look something like the example below:

body {

background: $bgcolor;

margin:0;

color:$textcolor;

font:x-small Arial sans-serif;

font-size/* */:/**/small;

font-size: /**/small;

text-align: center;

}

We need to edit the line highlighted in bold, which is where we declare the background properties of the blog. To add a repeating image to the background, we simply add the following (highlighted in red) to the body properties:
body {

background:url(http://www.imagehost.com/yourimage.jpg);

margin:0;

color:$textcolor;

font:x-small Arial sans-serif;

font-size/* */:/**/small;

font-size: /**/small;

text-align: center;

}

Where the URL of the image matches the URL of your background image location.

This will make the background image repeat across the whole page, like the example below:

If you prefer, you can also view the whole demonstration page here which offers a better view of the overall effect then the iframe above.

How to make a background image repeat vertically down the page

This involves a slightly different addition of code to your template, but is essentially the same principle. Again you should find the "body" style declaration in your template and add the url for your background image. Also, you need to declare that the background will repeat on the "y" (vertical) axis, as in the example below:

body {

background:url(http://www.imagehost.com/yourimage.jpg) repeat-y;

margin:0;

color:$textcolor;

font:x-small Arial sans-serif;

font-size/* */:/**/small;

font-size: /**/small;

text-align: center;

}

Using the same example image as before, this will create the following effect (or look here for a full page preview):

How to make a background image repeat horizontally across the page

This is very similar to the method we used to tile the image vertically. However, this time we tell the browser to repeat the image on the "X" (horizontal) axis, like this:

body {

background:url(http://www.imagehost.com/yourimage.jpg) repeat-x;

margin:0;

color:$textcolor;

font:x-small Arial sans-serif;

font-size/* */:/**/small;

font-size: /**/small;

text-align: center;

}

This will produce an effect like the example below (use this link for a full page preview):

How to create a fixed image background

Usually a larger image is used for this method, so for this example we will use the following image from Pyzam.com):

To ensure this background image does not repeat, we need to add the "no-repeat" declaration to the background properties. Also, we need to add the statement that the background attachment is fixed, so that the background does not move with the page. Here again is an example of what your code should look like, with the changes highlighted in red:

body {

background:url(http://www.imagehost.com/yourimage.jpg) no-repeat;

margin:0;

color:$textcolor;

font:x-small Arial sans-serif;

font-size/* */:/**/small;

font-size: /**/small;

text-align: center;

background-attachment: fixed
}

And here is the example of what this property achieves (use this link for a full page preview):

You can add color too!

Unless you tile your background image across the whole page, you will be left with blank white areas. To fill these areas with the color of your choice, you should also add color to the background property.

If you already have a "$bgcolor" variable in your blog template, you can simply add this variable to the background properties, like this:

background: $bgcolor url(http://imagehost.com/yourimage.jpg) repeat-x;

However, if you do not have this variable in your template, or instead would prefer to declare the color yourself, you can do so using Hex values for the color you wish to display. There is a useful color calculator in the tools section which can generate the hex values require. Here is an example of how you can declare the hex values for the color in your background:
background: #ff0000 url(http://imagehost.com/yourimage.jpg) repeat-x;

Using the first image as an example, this would generate a background like this:

Positioning the background image

By default, the background image will begin in the top-left corner of the page, regardless of how you want the background image to repeat (or not) across the page. However, you can specify where you would like the image to be placed by adding some extra variables to the background specifications.

Here is an example of the bldy's background property to show where you can place the positioning variables:

background: #ffff00 url(http://imagehost.com/yourimage.jpg) positioning-variables-here no-repeat;

And here is a list of the positioning variables you can use:
  • top left

  • top center

  • top right

  • center left

  • center center

  • center right

  • bottom left

  • bottom center

  • bottom right

If you wanted to position a fixed image at the top center of a page for example, you could use the following code:

background; url(http://imagehost.com/yourimage.jpg) no-repeat top center;

It is also possible to set the starting position of the background image using percentages on the X or Y axes, or by specifying the distance in pixels from the top or left of the page. However, this can be rather complicated, and since people use many different browsers and screen resolutions when browsing the internet, this can cause serious problems for blog design! If you would still like to know more about this, I would recommend reading the information on the CSS background page at W3 schools.

I hope this tutorial has helped you understand how to use background images in your blog, and covered all aspects of how these different effects may be achieved. As always, your comments and opinions are much appreciated!

If you would like to receive updates of new tutorials and posts from Blogger Buster, please consider subscribing to our feed.

Technorati Tags: | | |

22 comments:

February 2, 2009 at 12:49 PM Rachel @ Future Pastor's Wife said...

can you email me this as well? Thanks, future.pastors.wife(at)gmail.com
For Sassygirl: I think we're on the same wavelength here... If I'm right, you would need to add a plain background color to the "content-wrapper" in your < b:skin> section as well as the background image for the main body section (I hope this makes sense!).

If you'd like me to explain the changes in full for you, send me an email and I'll email you the code changes to help you achieve this

February 6, 2009 at 11:04 PM DirtDigger (Tessa) said...

Hi,

Has anyone come up with the answer to the background ending up all white when the tag 'no-repeat' is put in? Amanda?

February 6, 2009 at 11:29 PM DirtDigger (Tessa) said...

Okay, I figured it out. For those of you getting the white background when adding the 'no-repeat' tag you need to add this

background-repeat:no-repeat;

in a new line right after the line with the image url info.

I had to start with a large picture that was optimized to reduce file size- then it took up the whole screen. Next I'm gonna try using a smaller image and center it using Amanda's directions and then maybe add color to the sides or a pattern that won't make the page to busy. I'll post my findings!

February 6, 2009 at 11:47 PM DirtDigger (Tessa) said...

Here is the rest of my experiment and it was a success! I'm starting to get a little scared- does this mean I'm starting to speak computer? :)

To get rid of the white background add this right after the image url on new line

background-repeat:no-repeat;

When using a smaller image and centering it

background-position:center center;

and to change the background color so you can make it look good with the smaller image

background-color: #000000;

put whatever color that works for your pic.

I'm posting this because everything worked for me in Amanda's directions except the above.

Hope this helps someone-

February 10, 2009 at 5:39 AM MoscowMow said...

Hi, Amanda! Thanks so much for your instructions! Could you send me the directions you sent to Patti about how to have one color on the either side of the blog (unmoveable), with the center of the blog another color? I need to know how to add a tileable picture to each of those areas.

Thank you so much! I'll link back to you!!!

March 1, 2009 at 1:24 AM becka said...

I can't get this to work :( I have no idea what I could be doing wrong, as I'm following the instructions exactly! Could it possibly be an IE thing?

Here's the code I'm using, in case I've missed something...

body {
background:url(http://s4.photobucket.com/albums/y103/beckajayne/?action=view&current=corkboard.jpg)no-repeat;
margin:0;
color:$textcolor;
font:x-small Georgia Serif;
font-size/* */:/**/small;
font-size: /**/small;
text-align: center;
background-attachment: fixed}

Aside from this, thank you so much for your blog! It's helped me out so many times, you do an awesome job!

March 25, 2009 at 7:16 AM
Vicki said...

Hello, could I also have this emailed to me? (vix62(at)hotmail.com). Thanks for the well written instructions! I've managed to add tiles thanks to you but I can't figure out how to get the white middle section.


For Sassygirl: I think we're on the same wavelength here... If I'm right, you would need to add a plain background color to the "content-wrapper" in your < b:skin> section as well as the background image for the main body section (I hope this makes sense!).

If you'd like me to explain the changes in full for you, send me an email and I'll email you the code changes to help you achieve this

March 30, 2009 at 9:10 AM DanielL said...

http://www.bloggingpro.com/archives/2007/09/21/wordpress-plugin-wanted-digg-effect-alternate-image/

April 17, 2009 at 12:39 PM Maddie said...

I had a lot of trouble trying to get the image to stay at the sides instead of covering the main blog aswell, to achieve this you need to find the section;

/* Outer-Wrapper
----------------------------------------------- */
#outer-wrapper {

width: 660px;
margin:0 auto;
padding:10px;
text-align:$startSide;
font: $bodyfont;
}
When you have found this you simply need to include an extra line with the background colour. for examle;

/* Outer-Wrapper
----------------------------------------------- */
#outer-wrapper {
background:#000000; <<---- Extra line.
width: 660px;
margin:0 auto;
padding:10px;
text-align:$startSide;
font: $bodyfont;
}

You can change the colour by changing the 000000 bit and replacing it with another colour code.

Hope this helps!

April 29, 2009 at 4:22 PM ghost said...

amanda..
thanks 4 ur tips..
i somehow got to manage my blog..
not a pro yet...
xD
will improve later..
=)

see my new background image...

May 19, 2009 at 8:32 AM Kristie Berglund said...

This has been so unbelievably helpful to me. Thanks so much!

June 15, 2009 at 5:18 PM -008' said...

I can see the background image,

but no one else can :(

I have tried hosting the pic at 3 different sites....

what am i missing?

(i am using your 3 column rounders 2)

thanks
-008'

July 26, 2009 at 1:49 PM whoatemycrayons said...

Really comprehensive guide. Thanks for sharing. I have forwarded onto an acquaintance who wanted to know how to adapt her blogger template.

July 29, 2009 at 3:46 AM estherliewian said...

I'm using this and this is effective. My friend told me
body {
background:url("http://sacrehalcyon.googlepages.com/bg_image2.png") repeat-y $startSide;
padding:0;
width:100%;
margin:0;
text-align:center;
line-height: 1.5em;
font:x-small Trebuchet MS, Verdana, Arial, Sans-serif;
color mainTextColor;
font-size/* */:/**/small;
font-size: /**/small;
}

August 6, 2009 at 7:41 PM Mr. Charleston said...

I can't for the life of me get a fixed image wallpaper to show on my blog. I created it in PhotoShop and saved it as a .jpg but no go. What should the dimensions of a full screen wallpaper be?

August 17, 2009 at 1:45 AM Septianto said...

thanks for the instructions, i wish i can customize my blog by your instructions
nur_septianto@yahoo.com

August 21, 2009 at 5:31 AM zauber-a said...

Your instructions are wonderful - thank you. I however, have the same problem as Sassygirl, in that I cannot get my main wrapper and sidebar to stay white and can't figure out why not. If I change the wrapper sections, then my sidebar pops down to the bottom of the page and the main section expands to cover the whole screen.

please help?

August 21, 2009 at 5:39 AM zauber-a said...

Oh, I just figured it out (I hope!). To get the main body white (or any other color) and keep the background picture, i added the following line to Outer Wrapper:

/* Outer-Wrapper
----------------------------------------------- */
#outer-wrapper {
background-color:#ffffff; <----new line!

August 22, 2009 at 7:07 AM Fábio de Sá said...

Hi there I followed the instructions to place my own idea, photo as a wallpaper of my blog.

I tried all the instructions you gave,but there's something wrong cause the image doesn't cover all the page it doesn't matter if I increase the size of the pic. It's strange.

If somebody could please have a look on the blog: http://lepetitbresilien-portugues.blogspot.com/

my email:lepetitbresilien@gmail.com

thanx a lot
Fabio

September 4, 2009 at 9:50 PM Dave said...

ive followed the instructions for the no-repeat one. i can not see the image on my test blog. what am i doing wrong
body {
background:$bgcolor;
background-:url (http://i457.photobucket.com/albums/qq299/Tora_Fe/Code%20Geass/CodeGeass-SchachZero.jpg)no-repeat;
background-repeat:no-repeat;
margin:0;
color:$textcolor;
font: x-small "Trebuchet MS", Trebuchet, Verdana, Sans-serif;
font-size/* */:/**/small;
font-size: /**/small;
text-align: center;
background-attachment:fixed
}

September 9, 2009 at 3:45 PM alipalli said...

Hi, thanks for all the great info! I am also having probs getting the white middle. Can you please email me and tell me how to do it? Thanks!
topaz_girl23@yahoo.com

September 21, 2009 at 1:45 PM Ryan said...

Hey,
I made my own image using Microsoft Paint, and uploaded it to HotlinkFiles.com, and tried copy/pasting the url to the HTML settings on my blog, as you described. I then got an error message saying, "Invalid variable declaration in page skin: Variable is used but not defined. Input: textcolor". Could you e-mail me with better directions? Also, I am trying to do the repeating image way.

ryguy740@yahoo.com

Post a Comment