本章将教您如何设置HTML元素中可用的内容字体.您可以设置元素的以下字体属性 :
font-family 属性是用于更改字体的面.
font-style 属性用于将字体设为斜体或斜体.
font-variant 属性用于创建小型大写字母效果.
font-weight 属性用于增加或减少字体显示的粗体或亮度.
font-size 属性用于增加或减少字体的大小.
font property用作速记来指定许多其他字体属性.
设置字体系列
以下是示例,演示如何设置元素的字体系列.可能的值可以是任何字体系列名称.
This text is rendered in either georgia, garamond, or the default serif font depending on which font you have at your system.
Set the Font Style
以下是示例,演示如何设置元素的字体样式。 可能的值为normal,italic和oblique。
This text will be rendered in italic style
Set the Font Variant
以下示例演示如何设置元素的字体变体。 可能的值是普通和小型上限。
This text will be rendered as small caps
Set the Font Weight
以下示例演示如何设置元素的字体粗细。 font-weight属性提供指定字体粗体的功能。 可能的值可以是正常的,粗体的,更大胆的,更轻的,100,200,300,400,500,600,700,800,900。
This font is bold.
This font is bolder.
This font is 500 weight.
Set the Font Size
以下示例演示如何设置元素的字体大小。 font-size属性用于控制字体的大小。 可能的值可以是xx-小,x-小,小,中,大,x-大,xx-大,更小,更大,像素大小或%。
This font size is 20 pixels
This font size is small
This font size is large
Set the Font Size Adjust
以下示例演示如何设置元素的字体大小调整。 使用此属性可以调整x高度以使字体更清晰。 可能的值可以是任何数字。
This text is using a font-size-adjust value.
Set the Font Stretch
以下示例演示如何设置元素的字体拉伸。 此属性依赖于用户的计算机来使用所使用字体的扩展版或精简版。
可能的值可以是正常的,更宽的,更窄的,超浓缩的,超凝聚的,凝聚的,半凝聚的,半膨胀的,膨胀的,超膨胀的,超膨胀的。
If this doesn't appear to work, it is likely that your computer doesn't have a
condensed or expanded version of the font being used.
Shorthand Property
您可以使用font属性一次设置所有字体属性。 例如:
Applying all the properties on the text at once.