How to change font color in html

下次还敢
Release: 2024-04-05 09:12:22
Original
1156 people have browsed it
<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>How to change font color in html

<p>How to change the font color in HTML

<p>The method to change the font color in HTML is very simple, you can usecolor properties. The syntax is as follows:

<code class="html"><p style="color: red;">文字</p></code>
Copy after login
<p>Where:

  • <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.
<p>Syntax Extensions

<p>In addition to simple hexadecimal color codes (such as #ff0000 for red), The color attribute also supports the following syntax:

  • Color names: red, green, blue, etc.
  • RGB value: rgb(255, 0, 0) means red.
  • RGBA values: rgba(255, 0, 0, 0.5) Represents red with 50% transparency.
  • HSL value: hsl(0, 100%, 50%) Represents red with 100% saturation and 50% brightness.
  • HSLA values: hsla(0, 100%, 50%, 0.5) Represents a red color with 100% saturation, 50% brightness, and 50% transparency.
<p>Example

<p>The following example shows how to use the 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>
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!

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!