How to adjust font color in html

下次还敢
Release: 2024-04-11 07:58:43
Original
970 people have browsed it

HTML font color can be adjusted through CSS properties. Method: use the color attribute. Color values ​​can be hexadecimal values, RGB values, RGBA values, or color names. For example: color: #FF0000; sets the red font; color: rgb(255, 0, 0); also sets the red font.

How to adjust font color in html

How to adjust the font color in HTML

In HTML, you can adjust the font color through CSS properties. You can use the color attribute.

Syntax:

<code class="css">color: [颜色值];</code>
Copy after login

Color value:

Color value can be in one of the following formats:

  • Hexadecimal value: starts with "#", followed by 6 hexadecimal digits, for example: #FF0000 (red)
  • RGB value : Starts with "rgb(", followed by 3 numbers separated by commas, representing the values ​​of the red, green, and blue channels, ranging from 0-255, for example: rgb(255, 0, 0) (red)
  • RGBA value: Similar to RGB value, but adds a 4th number, indicating transparency, ranging from 0-1, for example: rgba(255, 0, 0, 0.5) ( Translucent red)
  • Color name:HTML defines some color names, such as: red, blue, green

Usage example:

To set the font color of all text in a paragraph to red, you can use the following code:

<code class="html"><p style="color: red;">这是红色的文本。</p></code>
Copy after login

To set the font color of a specific word to blue, you can use the following code:

<code class="html"><p>这是 <span style="color: blue;">蓝色的</span> 单词。</p></code>
Copy after login

Note:

  • Make sure to use quotation marks around the color value.
  • If using hexadecimal values, end them with "# ".
  • If using RGB or RGBA values, start with "rgb(" or "rgba(".
  • If using color names, use lowercase letters.

The above is the detailed content of How to adjust font color in html. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!