Heapcoding

How to change background color in html using CSS

Published June 29, 2022

In this tutorial I shall show you how to change background color in html using CSS. Let’s start a tutorial without wasting your time.

Step 1 – Create a blank HTML document

First of all let’s create a blank HTML document which will contain the basic HTML tags.

How to change background color in html using CSS

In the above screenshot you can see I have added the basic html tags to create a blank html document.

Now let’s change the background color of the document using CSS.

Step 2 – Change the background color of the html page

Now let’s apply the CSS to change the document background color.

How to change background color in html using CSS

In the above screenshot you can checkout I have added a style tag and written some CSS property to body tag to change the background color of our document.

Now let’s render this into the web browser to see the changes.

How to change background color in html using CSS

In the above screenshot you can see that our document background color is changed. You can apply any color in hexadecimal or rgb value to update the background color of the webpage.

Congratulations you have learned to change background color in html using CSS.