主题
文本修饰
CSS 提供了多种文本修饰相关的属性,用于美化文字外观和控制排版效果。常用的包括:
1. 文本装饰(text-decoration)
设置文本的下划线、删除线、上划线等效果:
css
a {
text-decoration: underline;
}
del {
text-decoration: line-through;
}
常用值:none
、underline
、overline
、line-through
2. 文本转换(text-transform)
控制文本的大小写形式:
css
h1 {
text-transform: uppercase;
}
可选值:
none
:不改变(默认)capitalize
:每个单词首字母大写uppercase
:全部转为大写lowercase
:全部转为小写
3. 文本缩进(text-indent)
设置段落首行缩进:
css
p {
text-indent: 2em;
}
4. 行高(line-height)
控制文本行与行之间的垂直间距:
css
p {
line-height: 1.6;
}
可以使用数字、百分比或长度单位。
5. 字母与单词间距
css
p {
letter-spacing: 0.1em; /* 字母间距 */
word-spacing: 0.5em; /* 单词间距 */
}
良好的文本修饰不仅提升可读性,也增强网页的美观度和专业感。