Article Directory
CSS Fonts (font) attribute is used to define the font family , size , thickness , and text style (such as italics).
font-family
CSS uses the font-family property to define the font family of the text.
p { font-family:"微软雅黑";}
div {font-family: Arial,"Microsoft Yahei", "微软雅黑";}
font_size
CSS uses the font-size property to define the font size.
p {
font-size: 20px;
- px (pixel) size is the most commonly used unit of our web pages
- The default text size of Google Chrome is 16px
- Different browsers may display different font sizes by default, we try to give a clear value size, not the default size
- You can specify the size of the entire page text for the body
font-weight
CSS uses the font-weight property to set the weight of the text font.
p {
font-weight: bold;
}
font-style
CSS uses the font-style property to set the style of the text.
p {
font-style: normal;
}
Note: We seldom italicize the text in normal times. Instead, we need to change the italic label (em, i) to a non-italic font.
Font compound attributes
The font attribute can be written by combining the above text styles, which can save the code:
body {
font: font-style font-weight font-size/line-height font-family;
}
- When using the font attribute, it must be written in the order in the above grammatical format, the order cannot be changed , and each attribute is separated by a space
- Attributes that do not need to be set can be omitted (take the default value), but the font-size and font-family attributes must be retained, otherwise the font attribute will not work