In Web programming, we often need to set the color of text in HTML pages. Setting the font color in HTML is very simple, just use the "color" attribute.
Syntax:
<font color="颜色">文本</font>
For example, if we want to set the color of a text to red, we can write like this:
<font color="red">这是红色文本</font>
In addition to using color names, you can also Use hexadecimal, RGB values, etc. to specify colors:
The following is an example of setting colors using hexadecimal and RGB values:
<font color="#00FF00">这是绿色文本</font> <font color="rgb(0,0,255)">这是蓝色文本</font>
In addition to using the font tag, you can also set the color of the font in CSS:
<style> p { color: green; } </style> <p>这是绿色文本</p>
You can also use various color values in CSS, such as color names, hexadecimal codes, RGB values, HSL values, etc., which is more flexible and convenient.
Summary:
HTML mainly uses the "color" attribute to set the font color. You can use color names, hexadecimal, RGB values, etc. to specify colors. Font color can also be set in CSS, which is more flexible and convenient.
The above is the detailed content of How to set font color in html. For more information, please follow other related articles on the PHP Chinese website!