Home > Article > Web Front-end > How to adjust font color size in html
By using CSS styles, you can adjust the color and size of fonts in HTML. Color can be specified using the color attribute and color name, hex code, etc.; size can be specified using the font-size attribute and various units (such as px, rem, %). Composite styles can be used when adjusting color and size at the same time.
How to adjust the size and color of fonts in HTML
In HTML, you can adjust it by using CSS styles Font color and size.
Adjust font color:
Use color
attribute: color: red;
Example:
<code class="html"><p style="color: red;">红色文本</p></code>
Use CSS color name: color: blue;
Example:
<code class="html"><p style="color: blue;">蓝色文本</p></code>
Use hex code: color: #ff0000;
Example:
<code class="html"><p style="color: #ff0000;">纯红色文本</p></code>
Adjust font size :
font-size Attribute:
font-size: 20px;
<code class="html"><p style="font-size: 20px;">20px 大小的文本</p></code>
font-size: 1.5rem;
<code class="html"><p style="font-size: 1.5rem;">1.5rem 大小的文本</p></code>
font-size: 120%;
<code class="html"><p style="font-size: 120%;">120% 相对大小的文本</p></code>
Adjust font color and size simultaneously:
To adjust font color and size at the same time, you can use a compound style:<code class="html"><p style="color: blue; font-size: 20px;">蓝色 20px 文本</p></code>
The above is the detailed content of How to adjust font color size in html. For more information, please follow other related articles on the PHP Chinese website!