How to set font color and size in html

下次还敢
Release: 2024-04-11 08:41:06
Original
690 people have browsed it

To set HTML font color and size, use the following methods: Use the color attribute to set the color, which can be a hex code, RGB value, or color name. Use the font-size property to set the size, which can be absolute (pixels or inches) or relative (em or rem). To set both color and size, use the style attribute and include the color and font-size attributes.

How to set font color and size in html

How to set HTML font color and size

Font color

To set the HTML font color, use the color attribute. This property is followed by a color value, which can be a hexadecimal code, an RGB value, or a predefined color name. For example:

<code class="html"><p style="color: #ff0000;">红色文本</p>
<p style="color: rgb(0, 128, 0);">绿色文本</p>
<p style="color: blue;">蓝色文本</p></code>
Copy after login

Font size

To set the HTML font size, use the font-size attribute. This attribute is followed by a size value, which can be absolute (such as pixels or inches) or relative (such as em or rem). For example:

<code class="html"><p style="font-size: 16px;">16 像素文本</p>
<p style="font-size: 1.2em;">1.2 倍默认字体大小的文本</p>
<p style="font-size: 1.5rem;">1.5 倍根字体大小的文本</p></code>
Copy after login

Set both color and size in one element

To set both color and size in one element, use style properties, and include the color and font-size properties. For example:

<code class="html"><p style="color: blue; font-size: 16px;">蓝色 16 像素文本</p></code>
Copy after login

The above is the detailed content of How to set font color and size in html. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!