文本属性
CSS Text(文本)属性可定义文本的外观,比如文本的颜色、对齐文本、装饰文本、文本缩进、行间距等
color属性设置文本颜色
div {
/* color: deeppink; */预定义的颜色值
/* color: #cc00ff; */16进制
color: rgb(255, 0, 255);RGB代码
}
text-align属性用于设置元素内文本内容的水平对齐方式left、right、center
让文字在对应容器中的对齐(相对于容器)
text-decoration属性规定添加到文本的修饰
可以给文本添加下划线、删除线、上划线
none 默认没有
underline 下划线,链接a自带下划线(常用)
overline 上划线
line-through 删除线
div {
/* 下划线 */
/* text-decoration: underline; */
/* 删除线 */
text-decoration: line-through;
/* 上划线 */
text-decoration: overline;
}
a {
/* 取消a默认的下划线 */
text-decoration: none;
color: #333;
}
text-indent属性用来指定文本的第一行的缩进,通常是将段落的首行缩进
p {
font-size: 24px;
/* 文本的第一行首行缩进 多少距离 */
/* text-indent: 20px; */
/* 如果此时写了2em 则是缩进当前元素 2个文字大小的距离 */
text-indent: 2em;
}
line-height属性用于设置行间的距离
行间距包含上间距、文本高度、下间距
line-height: 26px;5+16+5