">. Where Home >Web Front-end >HTML Tutorial >How to set color of html font 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!How to set color of html font
<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 color
attributes.
<p>Syntax:
<code class="html"><element style="color: <color-name> | <hex-code> | <rgb-code>"></code>
<p>Where:
<p>Example:
<p>Use predefined color name:
<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>
<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. font-color
attribute, but it is deprecated and it is recommended to use color
.