In HTML, you can set the background color by writing the "background-color" attribute inside the tag, the syntax is "
"; where the color value can be represented by a hexadecimal number, RGB value or color name.
The operating environment of this tutorial: Windows7 system, CSS3&&HTML5 version, Dell G3 computer.
Set the background color of an h2 tag to red
<h2 style="background-color:red;">这是一个标题</h2>
Set the background color of a paragraph to green Set the background color of a div to gray Recommended learning:
The above is the detailed content of How to set background color in html. For more information, please follow other related articles on the PHP Chinese website!