Home >Web Front-end >HTML Tutorial >How to change font color and size in html
Change font color in HTML: Use CSS's color property, which accepts hexadecimal values, RGB values, or color names. Change font size: Use CSS's font-size property, which accepts absolute, relative, or percentage sizes. Change font color and size simultaneously: Use a CSS style block containing the color and font-size properties.
Changing font color and size in HTML
How to change font color?
To change the font color in HTML, you can use the CSS color
property. This property accepts a hexadecimal value, RGB value, or color name.
Syntax:
<code class="html"><element style="color: value;">文字</element></code>
Example:
Change text color to red:
<code class="html"><p style="color: red;">红色文字</p></code>
How to change font size?
To change the font size in HTML, you can use the CSS font-size
property. This property accepts absolute size (such as pixels), relative size (such as em), or percentage size.
Syntax:
<code class="html"><element style="font-size: value;">文字</element></code>
Example:
Change text size to 20px:
<code class="html"><p style="font-size: 20px;">20px 大小的文字</p></code>
Change font color and size at the same time
To change font color and size at the same time, you can use a style block in CSS.
Syntax:
<code class="html"><element style="color: value; font-size: value;">文字</element></code>
Example:
Change text color to blue and size to 18px:
<code class="html"><p style="color: blue; font-size: 18px;">蓝色 18px 大小的文字</p></code>
The above is the detailed content of How to change font color and size in html. For more information, please follow other related articles on the PHP Chinese website!