">. Where represents the target element and can be a predefined color name, hexadecimal code or RGB code."/> ">. Where represents the target element and can be a predefined color name, hexadecimal code or RGB code.">

Home >Web Front-end >HTML Tutorial >How to set color of html font

How to set color of html font

下次还敢
下次还敢Original
2024-04-11 08:28:31837browse
<p>To set the font color in HTML, you can use the color attribute of CSS, and the syntax is . Where <element> represents the target element and can be a predefined color name, hexadecimal code, or RGB code.

<p>How to set color of html font

<p>How to set HTML font color

<p>Setting font color in HTML is very simple, you just use CSS color attributes.

<p>Syntax:

<code class="html"><element style="color: <color-name> | <hex-code> | <rgb-code>"></code>
<p>Where:

  • <element> is the HTML element you want to set the color , such as <p>, <h1>, or <span>.
  • <color-name> is a predefined color name defined by CSS, such as "red", "blue", or "black".
  • <hex-code> is a six-digit hexadecimal code that represents the color, such as "#FF0000" (red).
  • <rgb-code> is an RGB code that represents the color, such as "rgb(255, 0, 0)" (red).
<p>Example:

<p>Use predefined color name:

<code class="html"><p style="color: red">这个文字是红色的。</p></code>
<p>Use hex code:

<code class="html"><h1><span style="color: #FF0000">这个标题是红色的。</span></h1></code>
<p> Use RGB code:

<code class="html"><span style="color: rgb(255, 0, 0)">这个文本是红色的。</span></code>
<p>Note: The

  • color attribute can be applied to any HTML element.
  • You can also use the font-color attribute, but it is deprecated and it is recommended to use color.

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

Statement:
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