Home  >  Article  >  Web Front-end  >  How to adjust font color size in html

How to adjust font color size in html

下次还敢
下次还敢Original
2024-04-11 13:40:14928browse

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 font color size in html

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:

  1. Use color attribute: color: red;

    Example:

    <code class="html"><p style="color: red;">红色文本</p></code>
  2. Use CSS color name: color: blue;

    Example:

    <code class="html"><p style="color: blue;">蓝色文本</p></code>
  3. Use hex code: color: #ff0000;

    Example:

    <code class="html"><p style="color: #ff0000;">纯红色文本</p></code>

Adjust font size :

  1. ##Use

    font-size Attribute: font-size: 20px;

    Example:

    <code class="html"><p style="font-size: 20px;">20px 大小的文本</p></code>
  2. Use CSS font size unit:

    font-size: 1.5rem;

    Example:

    <code class="html"><p style="font-size: 1.5rem;">1.5rem 大小的文本</p></code>
  3. Use relative size units:

    font-size: 120%;

    Example:

    <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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn