How to change font color in html

下次还敢
Release: 2024-04-05 09:30:23
Original
1065 people have browsed it

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

color-value Options:

  • Hexadecimal color code : Starts with #, followed by six hexadecimal digits representing the intensity of the red, green, and blue channels. For example: #ff0000 means red.
  • RGB color value: Starts with 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 color value: Starts with 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.
  • Color name: Use predefined color names, such as: red, green, blue.

Example:

Set the text font color to red:

<code class="html"><p style="color: #ff0000;">红色文本</p></code>
Copy after login

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

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!

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!