CSS background-color

The function of CSS background-color is used to set the background color of webpages, and it can also be used to set the background color of webpage elements, such as DIV blocks, span areas, table backgrounds and even text background colors. You can use the background-color technique to design , The color values ​​that can be used for background-color include color English names, hexadecimal color codes, and RGB color codes. It is a CSS standard webpage and element background color design method. All mainstream browsers support the background-color property.

CSS background-color basic syntax

background-color: color name or color code;


The color name or color code in the grammar can be determined freely. For more colors, please refer to the color code table .

CSS background-color syntax example 1. Web page background

<body style="background-color:gray;">
... web content...
</body>

As shown in the example, adding "style="background-color:gray;"" to the </body> tag of the webpage means that the background color of the entire webpage is gray, and gray is the English name for gray. Choose more colors from the color code table and adjust different web page background colors to match the overall style design.

CSS background-color syntax example 2: DIV block background color

<div style="background-color:#FFBB73;">Modify the background color of the DIV block</div>
<div style="background-color:pink;">Modify the background color of the DIV block</div>
< div style="background-color:rgb(232,106,192);">Modify the background color of the DIV block</div>

The above example is presented as

Modify the background color of the DIV block
Modify the background color of the DIV block
Modify the background color of the DIV block

In the example, three DIV blocks with different colors are created , using the hexadecimal color code, the English name of the color, and the RGB color code. The difference between the three representation methods is only the color value. The same technique can also be used in other If you want to use a picture as a background, please refer to: CSS background-image background picture .

Post a Comment

0 Comments