Home  >  Article  >  Web Front-end  >  How to set color in css

How to set color in css

coldplay.xixi
coldplay.xixiOriginal
2021-04-15 16:09:407625browse

The way to set color in css is to use the color attribute. The color attribute specifies the color of the text. This attribute sets the foreground color of an element. Raster images are not affected by color. The syntax is [color: value;].

How to set color in css

The operating environment of this tutorial: windows7 system, css3 version, DELL G3 computer.

How to set color in css:

color attribute

The color attribute specifies the color of the text.

This attribute sets the foreground color of an element (in HTML representation, the color of the element's text); raster images are not affected by color. This color also applies to all borders of the element, unless overridden by border-color or another border-color property.

To set the foreground color of an element, the easiest way is to use the color attribute.

Syntax:

color : value;

Attribute value

  • color_name: Specifies the color value as the color of the color name (such as red).

  • hex_number: specifies the color value as a hexadecimal value (such as #ff0000).

  • rgb_number: Specifies the color value as the color of the rgb code (such as rgb(255,0,0)).

Note: When using color to set the color of the text font, you need to use a reasonable background color and text color matching, which can improve the readability of the text.

In HTML, you can directly use the color attribute setting through css in the tag where the text is located. Or use id or class to introduce external CSS font color style to set the font color.

Related learning recommendations: css tutorial

The above is the detailed content of How to set color in css. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:How to set borders in cssNext article:How to set borders in css