一、字体族设置(font-family)
语法:
font-family: 字体1, 字体2, ...;
示例:
p {
font-family: "Microsoft Yahei", Arial, sans-serif;
}
二、字体颜色(color)
语法:
color: 颜色值;
支持格式:
-
英文名:red
-
十六进制:#f00
-
RGB:rgb(255, 0, 0)
示例:
div { color: #f00; }
h1 { color: rgb(0, 0, 255); }
三、字体大小(font-size)
语法:
font-size: 数值+单位;
单位常用:px、em、rem
示例:
p { font-size: 16px; }
四、字体粗细(font-weight)
常用值:
-
normal(等于 400)
-
bold(等于 700)
-
数字 100 ~ 900(越大越粗)
示例:
h1 { font-weight: bold; }
h2 { font-weight: 300; }
五、字体样式(font-style)
可选值:normal、italic、oblique
示例:
p { font-style: italic; }
六、文本对齐(text-align)
可选值:left、center、right、justify
示例:
h1 { text-align: center; }
七、首行缩进(text-indent)
示例:
p { text-indent: 2em; }
八、文本装饰线(text-decoration)
可选值:none、underline、overline、line-through
示例:
a { text-decoration: none; }
h4 { text-decoration: underline; }
div { text-decoration: overline; }
h5 { text-decoration: line-through; }
九、行高(line-height)
示例:
p { line-height: 1.5; }
十、字母间距(letter-spacing)
示例:
p { letter-spacing: 2px; }
十一、单词间距(word-spacing)
示例:
p { word-spacing: 5px; }
十二、文字大小写(text-transform)
可选值:none、uppercase、lowercase、capitalize
示例:
p { text-transform: uppercase; }
十三、字体综合简写(font)
语法顺序:
font-style font-weight font-size/line-height font-family
示例:
p {
font: italic bold 16px/1.5 Arial, sans-serif;
}