Home > Article > Web Front-end > How to change font color in html
Changing font color in HTML
The font color of HTML elements can be set through the CSS property color
. The color
attribute specifies the foreground color of the text, that is, the color of the text itself.
Syntax:
<code class="html"><element style="color: color-value;">文本内容</element></code>
color-value Options:
#, followed by six hexadecimal digits representing the intensity of the red, green, and blue channels. For example: #ff0000
means red. rgb()
, followed by three comma-separated integers representing the intensity of the red, green, and blue channels. For example: rgb(255, 0, 0)
means red. rgba()
, followed by four comma-separated integers, representing the intensity and transparency of the red, green, and blue channels. For example: rgba(255, 0, 0, 0.5)
means translucent red. red
, green
, blue
. Example:
Set the text font color to red:
<code class="html"><p style="color: #ff0000;">红色文本</p></code>
Set the text font color to rgba red with an transparency of 50 %:
<code class="html"><p style="color: rgba(255, 0, 0, 0.5);">半透明红色文本</p></code>
The above is the detailed content of How to change font color in html. For more information, please follow other related articles on the PHP Chinese website!