Font-style can be used to set the text italic
-Optional values:
- Normal, default value, text is displayed correctly
- Italic text is displayed in italics
- Oblique text is displayed with a slanted effect
-Most browsers do not differentiate between italic and italic, meaning that we set italic and oblique their effects are often the same
-Generally we will only use italic
Font-weight can be used to set the text's bold effect
Optional values:
- Normal, default value, text is displayed correctly
- Bold, Text bold display
The style can also specify a value of 9 between 100-900,
But because the user's computer often does not have so many levels of font, so to achieve the effect we want
That is, 200 is probably thicker than 100, 300 is probably thicker than 200, but it could be the same.
Font-variant can be used to set small caps
Optional values:
- Normal, default value, text is displayed correctly
- Small-caps text is displayed in small caps
Small caps:
All letters are shown in uppercase, but lowercase letters are capitalized,
Smaller than the size of the uppercase letters.
In the CSS also provides us with a style called font, using this style can set all the font-related styles, you can use the font style of the value, unified in the font style, different values are separated by a space
When font style is set with font, the italic size is bold, there is no order, it can even be written without writing, if you do not write the default value is used, but the font must be written in the font, and the text must be the last style, the size must be the second
In fact, using the shorthand attribute also has a better performance
First example: Use font to set all styles related to the font.
<!DOCTYPE HTML><HTML> <Head> <MetaCharSet= "UTF-8"> <title></title> <styletype= "Text/css">P{Color:Red;Font:small-caps Bold Italic 20px "Microsoft Ya Hei"; } </style> </Head> <Body> <P>the sunrise, and the day into the interest. To dig well and drink, to plough and eat. Dili to me! ABC abc</P> </Body></HTML>
Look at the effect:
A second example:
<!DOCTYPE HTML><HTML> <Head> <MetaCharSet= "UTF-8"> <title></title> <styletype= "Text/css">. P1{Color:Red; /*set a text size*/font-size:55px; /*Set a font*/font-family:"Agency FB"; /*Set Text italic*/Font-style:Italic; /*Set the text bold*/Font-weight:Bold; /*set a small capital letter*/font-variant:Small-caps; } </style> </Head> <Body> <Pclass= "P1">The sunrise, and the day into the interest. To dig well and drink, to plough and eat. Dili to me! ABC abc</P> </Body></HTML>
Look at the effect:
Front-end learning--CSS--Several attributes of font learning