Home >Web Front-end >HTML Tutorial >How to set the color of html font
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.
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:
Color Code Must start with
Each code represents two hexadecimal digits (0-F), representing the intensity of red, green, and blue (RGB). 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:
green
, blue
, etc.
r
, g
and b
represent the intensity of red, green and blue respectively (0-255)
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!