<p>The way to change font color in HTML is to use the color attribute, which can specify a color name, a hexadecimal color code, an RGB/RGBA value, or an HSL/HSLA value.<p> <p>How to change the font color in HTML <p>The method to change the font color in HTML is very simple, you can use
color
properties. The syntax is as follows:
<code class="html"><p style="color: red;">文字</p></code>
<p>
is a paragraph element used to contain text content. The style
attribute is used to set the style of an element. color
property specifies the color of the text. #ff0000
for red), The color
attribute also supports the following syntax:
red
, green
, blue
, etc. rgb(255, 0, 0)
means red. rgba(255, 0, 0, 0.5)
Represents red with 50% transparency. hsl(0, 100%, 50%)
Represents red with 100% saturation and 50% brightness. hsla(0, 100%, 50%, 0.5)
Represents a red color with 100% saturation, 50% brightness, and 50% transparency. color
property to change the font color:
<code class="html"><p style="color: #ff0000;">文字</p> <p style="color: red;">文字</p> <p style="color: rgb(255, 0, 0);">文字</p> <p style="color: rgba(255, 0, 0, 0.5);">文字</p> <p style="color: hsl(0, 100%, 50%);">文字</p> <p style="color: hsla(0, 100%, 50%, 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!