Home >Web Front-end >HTML Tutorial >How to set the color of html font

How to set the color of html font

下次还敢
下次还敢Original
2024-04-11 07:55:40709browse

There are three ways to set font color in HTML: using hexadecimal color codes, using color names, and using RGB values. Hexadecimal color codes use the format #rrggbb, where # begins and rrggbb is a hexadecimal number representing the intensity of red, green, and blue respectively. Color names specify colors, such as red, green, blue, etc. RGB values ​​use the format rgb(r, g, b), where r, g, and b are integers in the range 0-255, representing the intensity of red, green, and blue, respectively.

How to set the color of html font

HTML font color setting

The method to set font color in HTML is very simple, use color Attributes are enough.

Setting method:

##

Text

Among them, the

#rrggbb part is the hexadecimal color code, indicating the value of the color. For example:

    ##Red:
  • #ff0000
  • Green:
  • #00ff00
  • Blue:
  • #0000ff
NOTE:

Color Code Must start with
  • #. Each code represents two hexadecimal digits (0-F), representing the intensity of red, green, and blue (RGB).
  • Strength ranges from 0 (none) to F (maximum).
Example:

In the following example, we set the color of the text to red:

<code class="html"><p style="color: #ff0000;">这是红色的文本。</p></code>

Other ways:

In addition to hexadecimal color codes, you can also set colors using color names or RGB values:

    Color names:
  • red, green, blue, etc.
  • RGB values:
  • rgb(r, g, b), where r, g and b represent the intensity of red, green and blue respectively (0-255)
Example:

The following example sets text to green using a color name:

<code class="html"><p style="color: green;">这是绿色的文本。</p></code>

The above is the detailed content of How to set the color of html font. 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