In response to the piece on How To Change , I received a request from Claudia Gillentine:
Thank you for the help on changing header images. Would you please do the same kind of help for changing the background colors? The simpler Wordpress designs are wonderful for our small public library but they are so glaringly white. I really like your page with the soft grey. It is so easy on the eyes. Thank you so much for your beginner’s guide to 2.7 also–so well written and easy to follow.
So Claudia, here it is.
Changing your Wordpress Theme background is simple, however, you need to modify your theme’s CSS code. The theme style is usually in a file called style.css.
If your style.css file on your web server has a file permission set to allow others to write (666 or 766), you can edit it in your Wordpress administration by clicking the Appearance | Editor link (see Figure 1).
Figure 1:To Change a Wordpress Theme background in Wordpress Administration, Select Appearance Editor
If you see the Update File button (Figure 2) at the end of the editing box, you know you can change the file content. Continue with “Changing the Theme Background.”
If you see a sentence that says “You need to make this file writable before you can save your changes. See the Codex for more information.” or something similar, then it means your theme files are not set with write permissions. Click the link text “the Codex” for more information on changing the file permissions.
Or you can change the style.css file by downloading the file from your web server with an FTP program, editing it with an HTML-friendly text editor such as BBedit, CSSEdit or even Notepad and uploading the changed file back to your web server with your FTP program.
Note: Do Not edit your HTML and CSS files in any Microsoft editor except Notepad! They will add unexpected changes and can destroy your themes.
Changing the Theme Background
- If it is not already selected, select the stylesheet, usually style.css, from your Theme Files left in the right-hand column (Figure 3).
- Scroll down until you see the
bodyselector and its properties. (Figure 4). - What you want to change is background property value. If your Wordpress theme simply assigns a background color value, then changing it is easy. The background property will look something like this:
background: #4A79B5;ORbackground-color: #4A79B5What you want to change are the numbers and/or letters after the # sign (the value).
See the underlined property in Figure 4.If your Wordpress theme uses a background image to create the background, it include the URL of the background image and look something like this:
background: #4A79B5 url(images/body-bg.jpg) repeat-x top left;
Now you have to decide if you want to keep the background image. If you do want to keep the background image but change its color, you will need someone to change the actual image file in an image editing program like Photoshop. And that’s beyond a simple text tutorial like this one.
Hey, wait a minute, Carolyn! The example in Figure 4 only has 3 letters after the # sign. Do I need 3 characters or 6 characters? Glad you asked that question. The HTML color codes are made up of 3 hexadecimal numbers. The hexadecimal numbers are composed of 2 characters, therefore, colors made up of duplicate characters can be abbreviated with just 3 characters. For example, the color white in HTML is #ffffff which can be abbreviated #fff and black is #000000 or #000 for short. To avoid confusing yourself, just use all 6 characters. It’s better coding practice anyway.
Before you make a change in your stylesheet make note of your original color number. You’ll thank me later.
- Now simply change the HTML color code for your body background property.
- Once you have changed your HTML body background color, click Update File button (Figure 2). Once you have updated (i.e., saved) your file, you will see yellow band beneath Edit Themes that states File edited successfully (Figure 5).
Uhm, okay, Carolyn, how do I know what color code I want? Another excellent question! There are a plethora of HTML or web color charts on the Internet. You can google HTML color chart or web color chart, but one of my favorites is the Sortable Color Name Chart. Keep in mind that you can’t actually control the exact color other people will see since all monitors show colors a little differently, however, these colors are ones that you can be fairly certain will be close to consistent across monitors.
But What If Your Want to Change the Background of Some Other Part of Your Wordpress Theme?
Well, I can’t give you complete training in modifying your Wordpress Theme or CSS in this simple post, but the technique will be the same. The key is figuring out what background you need to change. For example, on my site, the background for everything except the header is not quite white. If you look at the source code for my site, you will see a <div id=”wrapper”>. If I change the background CSS for the ID wrapper, which will be listed as #wrapper, I’ll be changing the background for everything inside that division that hasn’t been assigned a different background (which in my case are the header and footer divisions).
The trick is figuring out what background you want to change. Each theme is a little different.
If you aren’t certain what you need or want to change, you can always scroll through your style sheet and change each background color one at a time and see the results.
Remember, make a note of the original background color before making any changes!
Chances are good you’ll want to switch most of them back to the original color. Make the changes one at a time and look at the results before changing another one. It’s sometimes surprising what a difference a single background change can make!
I hope this helps, Claudia and everyone else.










{ 13 comments… read them below or add one }
Fantastic! Thank you so much for your prompt help. It was exactly what I needed to know in order to soften the all-white background.
How can I change the background of the ‘leave a reply’ box? I see that yours is pink with white boxes. Ours is white with grey boxes. Any suggestions?
Thanks, Gretchen
Gretchen,
My apologies for not getting back to you sooner. I was traveling when this came through and I got distracted and forgot to respond.
To change the background of your ‘leave a reply’ box, you will need to change the style in your Theme style sheet. This is usually style.css in Wordpress Themes. And usually you want to change the #commentform style background. It will look something like this:
#commentform{
background: #F0F0F0;
margin: 12px 12px 20px 12px;
padding:20px;
border-top: #8CA4BE 1px dotted;
border-bottom: #8CA4BE 1px dotted;
}
You can change the hex numbers (that is the #F0F0F0) after the background: attribute.
If your Theme does not have an id or class called 'commentform', you need to find out what style is associated with the comment form in your Theme. This means looking at the template. Usually, in Wordpress Themes, you will see a template labeled "comments.php." Search in that template for text "Leave a Reply" (often this is wrapped in an h3 tag). Just above that you may see some php code that begins
<?php if ('open' == $post->comment_status) : ? >And right before THAT code you should see a< div id=— this would be the name of the style for your comment form and what you need to change.I hope that helps and again my apology for not getting back to you sooner!
this is really a great tutorial, i was looking something similar and hope it will serve my purpose. I am moving from blogger to wordpress and finding difficulty in terms of updating coding.
But hope soon i will be able to fix everyrhing
really great explanation for a simple thing .. i admire your patience ^^
http://techtadka.net/tutorials/web-tutorials/201-how-to-change-a-wordpress-theme.html
tx, really usefull post!
hi, thanks so much for the tutorial above. I have a further question on the same lines. I figured out how to change the color, but i want to change the background color to an imge that is on my desktop, a jpg file saved on my desktop. I havent been able to figure out where to upload the file to..i use wordpress, and tried putting it in to my media files, but that didnt help. and i have no clue of where the code has to be changed.
Please help.
Regards,
R
RS,
Changing background images is a little more complex than changing the background color. You have to upload your image, usually to your themes directory, and then modify the body tag in your stylesheet with not only the path to the image file, but information about positioning. To help you out, I wrote a separate post with the steps that you can find here: http://carolynecooper.com/web-dev/how-to-change-your-wordpress-background-image.
I hope this answers your question and helps you out.
p.s. You can use the file your uploaded to your media directory but it requires a little more precision in the background URL attribute, particularly if you left your upload directory settings on default when you installed Wordpress. By default, Wordpress organizes your media uploads by year and month. Getting the path correct can be a real pain.
Hi Carolyn;
Your tutorial is the simplest and easiest I’ve seen yet.
What I would like to do is change the entire background of all the images that appear on the page.
The theme base isn’t something I need changing so much but all the image backgrounds and logo are what I would like to change. Is that possible?
Joni, thanks for the kind words. Regarding changing the “the entire background of all the images that appear on the page”, I’m not exactly certain what you mean. I’ve created a special post to answer your question. You can find it by clicking here: How the Background Color of Images Can Be Changed
I hope this helped answer your question. Please feel free to contact me if you need more help and thanks again for the kind words about my tutorial.
Hi Carolyne,
I explored in google for instructions on how to change the background color of my free wordpress theme. It is grey and I want to change it to white. It is only in your article that I could find a very exhaustive explanation. Kudos to you.
But Carolyne,I followed everything you have said , yet the color would not change. I substituted Background#d9d9d9 with #ffffff and clicked “update file”. The yellow band appeared saying that “File edited successfully”. But the background color has not changed. What could I have possibly missed?
Thanks for the kind words. I try to help.
I think I see the problem by viewing your website link and if you are in a hurry, just skip to the bottom of this reply. But if you want to learn how to track down the problem, read on.
Okay. There are some possibilities for why changing a background style doesn’t have any affect.
1. You didn’t change the right style.
2. The background is actually a graphic image.
3. You didn’t change the style in the correct stylesheet.
Let’s start backwards because the last one is the easiest to test.
Some stylesheets either have a custom CSS file that overrides the default or call on a CSS file that is stored somewhere else (I know, weird and dumb, but you know how geeks are — they’ve got to show off how clever they are). Anyway, to make certain you are changing the correct stylesheet. If possible, make a backup of your stylesheet. (Actually, you should keep a backup of your theme on your own hard drive just to be safe.)
1. Look again at your theme stylesheet in the Appearance Editor (the file name is style.css in most cases).
2. Now look for your base body tag which will look something like this:
body {If it has a background color, change it to something audacious like bright red. But before you do, make a note of the current color. If it doesn’t have a background color, let’s make one.
body {background-color: #ff0000;}If you have a background graphic, your body tag will look something like this:
body{background:#c35d8a url('img/header.png') repeat-x;
You will want to hide that temporarily, by doing this:
body{(This completely comments out the background.)/*background:#c35d8a url('img/header.png') repeat-x;*/
Did that change the background? If yes, then you know you are changing the correct stylesheet. If not, then you know you need to hunt for a custom stylesheet. But before you do that, quickly restore your stylesheet to the way it was.
To find out what stylesheets are being used by your theme, open a new browser tab or window and then select view source from your browser options (Safari: It’s under Develop >> Web Inspector; Chrome: It’s View >> Developer >> View Source; Firefox: It’s View >>Page Source; Internet Explorer: Sorry, dude, I can’t help you. I won’t have that browser on my machines.) You want to look at the top in the
headsection for things that say “stylesheet” like this:<link rel="stylesheet" href="http://carolynecooper.com/wp-content/themes/thesis_17/style.css?060410-205319" type="text/css" media="screen, projection" />
<link rel="stylesheet" href="http://carolynecooper.com/wp-content/themes/thesis_17/custom/layout.css?062810-35811" type="text/css" media="screen, projection" />
<!--[if lte IE 8]><link rel="stylesheet" href="http://carolynecooper.com/wp-content/themes/thesis_17/lib/css/ie.css?060410-205239" type="text/css" media="screen, projection" /><![endif]-->
<link rel="stylesheet" href="http://carolynecooper.com/wp-content/themes/thesis_17/custom/custom.css?063010-15755" type="text/css" media="screen, projection" />
In this example, I have 4 stylesheets loaded: style.css; layout.css which is in the /custom subdirectory; ie.css in the /lib/css subdirectory; and custom.css in the /custom subdirectory. Since custom.css is the last one loaded by the browser, it trumps all other styles. So if there is something in that custom.css that says my background-color is white, then I can make all the changes I want to style.css (the first stylesheet loaded) and it won’t have any affect.
So now you have made certain you are working with the correct stylesheet, look at the actual source and make certain there isn’t a wrapper around your content. For example, if you View Source for this website you will see that immediately after the
bodytag, there aredivtags before any content appears.<body class="custom cat_wp">
<div id="container">
<div id="page">
So in my case, if I wanted to change the background, I might need to change the style for
#containeror#page.Check your source and see if your theme wraps all the content inside a container or wrapper tag.
Here’s you’re problem, Sanjiv,
you’re content is wrapped in a couple of styles.
<body class=”hideHeaderMenu1″><a name=”top” rel=”nofollow”></a><a id=”skipToPosts” href=”#content” rel=”nofollow”>Skip to posts</a>
<div class=”pageContainer”>
Look first at the style
.hidHeaderMenu1. According to Safari’s Web Inspector, it has the background style:background: white url(http://mediconweb.com/wp-content/themes/arjuna-x/images/pageBG.png) repeat-x 0px 0px;In other words, your theme uses a graphic background named pageBG.png. Just delete theurl(http://mediconweb.com/wp-content/themes/arjuna-x/images/pageBG.png) repeat-x 0px 0px;bit and I bet that solves your problem.Let me know if you have any more questions. And thanks for stopping by.
Hey Carolyn,
I got it . Your 2nd suggestion worked and I got the white background, which i wanted.
Thanks a million, ’cause I have been trying do this since quite some time.
sanjiv.