How to set color of html font

下次还敢
Release: 2024-04-11 08:28:31
Original
760 people have browsed it
<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>
Copy after login
<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>
Copy after login
<p>Use hex code:

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

<code class="html"><span style="color: rgb(255, 0, 0)">这个文本是红色的。</span></code>
Copy after login
<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!

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!