<p>To set the font color in HTML, you can use the color attribute of CSS, and the syntax is<p> <p>How to set HTML font color <p>Setting font color in HTML is very simple, you just use CSS. Where <element> represents the target element and can be a predefined color name, hexadecimal code, or RGB code.
color
attributes.
<p>Syntax:
<code class="html"><element style="color: <color-name> | <hex-code> | <rgb-code>"></code>
<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). <code class="html"><p style="color: red">这个文字是红色的。</p></code>
<code class="html"><h1><span style="color: #FF0000">这个标题是红色的。</span></h1></code>
<code class="html"><span style="color: rgb(255, 0, 0)">这个文本是红色的。</span></code>
color
attribute can be applied to any HTML element. 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!