html font color:Introduction to color in CSS-Font Tutorial免费ppt模版下载-道格办公

Introduction to color in CSS

In this section, we will talk about color, because when we learn CSS styles later, we will often use color, and color is also an essential element in web pages. For example, we can set the color of a certain font, set the color of the border of the element, set the background color of the element, etc. If you want a webpage to look good, you definitely need to add some color to it.

Color value

Color is displayed through the combination of red, green and blue light. We generally specify colors in CSS in the following three ways:

  • Color name
  • Hex color value
  • RGB color

Color name

There are 147 color names defined in the HTML and CSS color specifications, of which 17 are standard colors, plus 130 other colors.

For example, red, green, blue, etc. Because there are too many color names, I won’t list them one by one here. We mainly talk about how to set the color.

Example:

For example, set the font color to red through the color name:

color:red;

Or set the element's background color to pink:

background-color: pink;

It is very simple to use, just add the color name directly after the CSS property, no other modifiers are needed.

Hex color value

The hexadecimal color value represents the color through hexadecimal, and the hexadecimal color specification is: #RRGGBB. Among them, RR is red, GG is green, and BB is blue, and the hexadecimal integer specifies the color composition. All values ​​must be between 0-9 and A-F.

Hexadecimal values ​​are written using three double digits, starting with a # sign. For example, #000000 black, #FF0000 red, #00FF00 green, #0000FF blue.

When the double digits are the same (one and two digits are the same, three and four digits are the same, five and six digits are the same), they can be abbreviated. For example, #000000 can be abbreviated to #000, #FF0000 can be abbreviated to F00, etc. But something like #101010 cannot be abbreviated.

Example:

For example, set the font color to red, green, and blue respectively:

color:#FF0000;color:#00FF00;color:#0000FF;

The above code can also be abbreviated as:

color:#F00;color:#0F0;color:#00F;

RGB color

RGB color values ​​are specified by rgb(red, green, blue). The three parameters define the intensity of red, green, and blue respectively. The parameter value can be an integer between 0 and 255, or 0% to 100 % of %.

For example, rgb(255,0,0) represents red, rgb(0,0,255) represents blue, etc.

Example:

For example, set the background color to red, green, and blue:

background-color:rgb(255,0,0);background-color:rgb(0,255,0);background-color:rgb(0,0,255);
< h1 class="pgc-h-arrow-right">Summary

The above are the three methods we talked about to specify colors in CSS. There are many colors that can be set and used, but it is impossible for us to remember all these color values, so in fact we only need to figure out how the color values ​​are used. La.

In our daily work, the designer usually designs the web page and then gives us the design drawing. When we make the web page, we only need to use the color absorber to absorb the color in the design drawing, and then we will know what it is. Color.

Articles are uploaded by users and are for non-commercial browsing only. Posted by: Lomu, please indicate the source: https://www.daogebangong.com/en/articles/detail/CSS-zhong-de-yan-se-jie-shao.html

Like (810)
Reward 支付宝扫一扫 支付宝扫一扫
single-end

Related Suggestion