How to Change the Background Color of a Web page with CSS


In this tutorial, we show how to change the background color of a web page using CSS.

To change the Background Color of the body of a web page in CSS, go to body tag in the CSS file. It should look like this:

The example below changes the background attribute to "silver".


As you can see, this page has a background of silver because this code, shown above, is added to the CSS body tag.

Just insert the appropriate color which you desire into the CSS body tag, red, blue, brown, white, black, green, yellow, navy, purple. As with all CSS color tags, you can specify it by color name, red, blue, yellow, etc., by hexademical equivalent, #FFFFF is white, or by RGB Value, 255,165,0 is orange.

Note- When changing the background of a web page, remember you are changing the background attribute. You simply change the color assigned to the background attribute. The color attribute is not the background color. It's the color of the text.

For example, let's say we have the following CSS tag:

font: 13px "Arial";

In this example, the background of the web page will be red. The color attribute is referring to the color of the text of the body, not the background. So the background will be red, while the color of the text of the body will be black. This is shown so that you will not confuse the background color vs. the color of text in the body.

HTML Comment Box is loading comments...