Changing font color in HTML can be accomplished by using CSS styles or the deprecated <font> tag. When using CSS styles, simply create a CSS style and specify the desired color value using the color property, then apply the style to the text element whose color you want to change.
Change font color in HTML
Changing font color in HTML is very easy, just use CSS styles That’s it.
Steps:
<style>
tag CSS style and give it an identifier, such as "font-color". color
property in the CSS style to set the desired font color. Colors can be set by specifying a hexadecimal color code (for example, #ff0000
for red) or by using a color name (for example, red
). class
or id
properties. Example:
The following code creates a paragraph in HTML and changes the font color to red using CSS:
<code class="html"><html> <head> <style> .red-font { color: red; } </style> </head> <body> <p class="red-font">这是一个红色的段落。</p> </body> </html></code>
Other options:
In addition to using CSS styles, you can also use the <font>
tag to change the font color. However, the <font>
tag is no longer part of the HTML standard and is therefore deprecated.
Tip:
inherit
value. rgba()
function to specify color transparency. currentColor
keyword to indicate the color of the current element. 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!