Get the App
SLTechnology News&Howtos  ›  Development  › 

How to set the background color by html

Shulou Source: shulou.com Published: 2022-06-01 12:18:54 10月01日 Update

This article will explain in detail how to set the background color for html. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

One: set the background color

1. Prepare to edit HTML

First determine the background color to use, and the HTML color is determined by each code. By accessing http://www.php.cn/html/html-colornames.html in your computer's Web browser, you can view the codes for all colors and select the base color to use in the "HEX" section.

two。 Use Notepad + + or Notepad to open the HTML file and add all the style information for the page, including the background color. Add the background-color attribute to the body element. Background-color to enter between body parentheses, as follows:

one

Red background

Or

one

two

three

Body {

Background-color:red

}

3. You can use "background-color" to define the background of other elements, such as headings, paragraphs, etc. For example, to apply a background color to the main title () or paragraph (

).

Two: create a gradient background

1. When making a gradient, we need two pieces of information: the starting point and the angle, as well as the color of the transition between the gradients. You can select multiple colors to make the gradient move between all colors, and you can set the direction or angle of the gradient.

Attributes:

Background: linear gradient (direction / angle, color 1, color 2, color 3, etc.)

two。 When you make a vertical gradient, if you do not specify a direction, the gradient will create a gradient from top to bottom, adding the following code between the markers:

one

two

three

four

five

six

seven

eight

nine

ten

Html {

Min-height: 100%

}

Body {

Background:-webkit-linear-gradient (left, # 93B874, # C9DCB9)

Background:-o-linear-gradient (right,#93B874, # C9DCB9)

Background:-moz-linear-gradient (right,#93B874, # C9DCB9)

Background: linear gradient (to the right, # 93B874, # C9DCB9)

Background-color: # 93B874

}

Of course, you can also add orientation to the gradient to change the way the color offset is displayed. You can not only add more than two colors, but also add a percentage after each color. You can also set the desired spacing for each color segment, add transparency to your color, and use the same color to fade from color to empty. You can also use the rgba () function to define the color, and the end value determines the transparency: 0 solid and 1 transparent.

This is the end of this article on "how to set background color in html". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.

Tags: Color background between direction code article angle information elements attributes more title gradient paragraph linear transparency production good practical same Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei NVidia Microsoft Apple OPPO Reno