Home > Web Front-end > Front-end Q&A > How to set font color in html

How to set font color in html

PHPz
Release: 2023-04-13 14:39:08
Original
3234 people have browsed it

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>
Copy after login

For example, if we want to set the color of a text to red, we can write like this:

<font color="red">这是红色文本</font>
Copy after login

In addition to using color names, you can also Use hexadecimal, RGB values, etc. to specify colors:

  • Hexadecimal: Use a # sign followed by six digits or letters, for example, #FFFFFF represents white.
  • RGB value: Use the "rgb()" function to write the values ​​​​of the three colors of red, green, and blue respectively. The value range is 0-255, for example, rgb(255,0,0) represents red.

The following is an example of setting colors using hexadecimal and RGB values:

<font color="#00FF00">这是绿色文本</font>
<font color="rgb(0,0,255)">这是蓝色文本</font>
Copy after login

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>
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template