To modify the font color in HTML, use a CSS style sheet: Inline styles: Specify the color in the element's style attribute. External stylesheet: Use class or id selectors to apply colors. Other methods: Rarely used, include the HTML5 color attribute and the XHTML presentation attribute.
How to modify the font color in HTML?
Changing the font color in HTML requires the use of a CSS style sheet. There are two main ways to do this:
1. Inline styles
Specify the font color directly in the element's style attribute. For example:
<code class="html"><p style="color: red;">这是红色文本。</p></code>
But this only applies to a single element and is not suitable for large-scale modifications.
2. External style sheet
Use an external style sheet file and use the class or id selector to apply font color. For example:
style.css
<code class="css">.red-text { color: red; }</code>
index.html
<code class="html"><p class="red-text">这是红色文本。</p></code>
3. Other methods
In addition to CSS, there are other ways to modify the font color in HTML, but these methods are rarely used:
Tip:
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!