red text
. External style sheet: Use an external style sheet, such as p { color: red; }. Color code: Use a hexadecimal color code such as "#FF0000" (red) or "#0000FF" (blue). Color name: You can also use a color name, such as "red" or "blue". Tip: If you don't specify color"/> red text. External style sheet: Use an external style sheet, such as p { color: red; }. Color code: Use a hexadecimal color code such as "#FF0000" (red) or "#0000FF" (blue). Color name: You can also use a color name, such as "red" or "blue". Tip: If you don't specify color">Home > Article > Web Front-end > How to change font color in html
To change the font color in HTML, you can use the CSS color attribute. The method is as follows: Inline style: Set the color attribute directly in the HTML element, such as
red Text
. External style sheet: Use an external style sheet, such as p { color: red; }. Color code: Use a hexadecimal color code such as "#FF0000" (red) or "#0000FF" (blue). Color name: You can also use a color name, such as "red" or "blue". Tip: If you do not specify color
How to change the font color in HTML
To change the font in HTML For colors, you can use the CSS color
property. This attribute accepts a hexadecimal color code or color name, for example:
<code class="html"><p style="color: #FF0000;">红色文本</p> <p style="color: blue;">蓝色文本</p></code>
Method 1: Inline Styles
You can use inline styles directly on the HTML element Set the color
attribute in:
<code class="html"><p style="color: red;">红色文本</p></code>
Method 2: External style sheet
You can also use an external style sheet to set the font color:
<code class="css">p { color: red; }</code>
Note: If the color
attribute is not specified, the text will be displayed in the browser's default color, which is usually black.
16 hexadecimal color code
You can specify the color using hexadecimal color code, for example:
Color Name
You can also use color names, for example:
##Tip:
property can also be used to change the text color of links, form elements, and table headers.
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!