130k views
5 votes
What is the correct html for adding a background color?

1 Answer

1 vote

The correct HTML for adding a background color to a web page is as follows:

<body>

Where "#colorcode" should be replaced with the desired color code, which can be in the form of a Hex code, RGB, RGBA or HSL.

For example, if you want to set the background color to red, the HTML would look like this:

<body>

You could also use the hex code for red:

<body>

You can also use RGB,RGBA or HSL.

<body>

<body>

<body>

Note that you can also use CSS file to set the background color of the body, instead of using the "style" attribute in the HTML.

User Ingemar
by
7.5k points