How to Set the Background Color on Your Website

To change the background color on your website, you will need to style the body tag with CSS. This can be done by using the CSS background property along with a color name or hex color code either by Inline CSS Style, or by External Stylesheet.

Inline CSS Style

To change the page background on one page, simply declare a style rule directly into the HTML body tag. The example HTML/CSS code below will make the background color of the page where the code is placed white.

Example Code with Color Name

<body style="background: White;">

Example Code with Hex Color

<body style="background: #ffffff;">

View White as the web page background color.

External Stylesheet CSS

To easily change the background color for many pages on your website at one time, simply select the HTML body Element and declare a CSS style rule to the External Stylesheet. The example CSS code below will make the background color of every page on your website red.

Example Code with Color Name

body {
background: Red;
}

Example Code with Hex Color

body {
background: #ff0000;
}

View Red as the web page background color.

Notes

This default color rules you declare for the body tag will be inherited by all other HTML elements on your pages. If you want different background colors on different parts of your page, the other elements will need to be styled separately.

Return to article index.