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 HTML font color and size
Font color
To set the HTML font color, use thecolor
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:
红色文本
绿色文本
蓝色文本
Font size
To set the HTML font size, use thefont-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:
16 像素文本
1.2 倍默认字体大小的文本
1.5 倍根字体大小的文本
Set both color and size in one element
To set both color and size in one element, usestyle
properties, and include thecolor
andfont-size
properties. For example:
蓝色 16 像素文本
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!