1.文本颜色
color属性用于定义文本颜色
<style>
div {
/* color: deeppink; */
/* color: #cc00ff; */
color: rgb(255, 0, 255);
}
</style>
表示 | 属性值 |
---|---|
预定义的颜色值 | red,green,blue等 |
十六进制 | #FF0000,#FF6600等 |
RGB代码 | rgb(255,0,0)或rgb*(100%,0%,0%) |
2.文本对齐
text-align属性用于定义文本对齐
<style>
h1 {
/* 本质是让h1盒子里面的文字水平居中对齐 */
/* text-align: center; */
text-align: right;
}
</style>
属性值 | 描述 |
---|---|
left | 左对齐 |
right | 右对齐 |
center | 居中对齐 |
3.文本装饰
text-decoration属性添加文本的修饰,比如下划线、删除线、上划线等
<style>
div {
/* 下划线 */
/* text-decoration: underline; */
/* 删除线 */
text-decoration: line-through;
/* 上划线 */
text-decoration: overline;
}
a {
/* 取消a默认的下划线 */
text-decoration: none;
color: #333;
}
</style>
属性值 | 描述 |
---|---|
none | 默认,没有装饰线 |
underline | 下划线 |
overline | 上划线 |
line-through | 删除线 |
4.文本缩进
text-indent属性用来指定文本第一行的缩进,通常是讲段落的首行缩进
<style>
p {
font-size: 24px;
/* 文本的第一行首行缩进 多少距离 */
/* text-indent: 20px; */
/* 如果此时写了2em 则是缩进当前元素 2个文字大小的距离 */
text-indent: 2em;
}
</style>
em是一个相对单位,是当前元素(font-size)1个文字的大小。
5.行间距
line-height 属性用于设置行与行之间的距离(行高)
<style>
div {
line-height: 26px;
}
p {
line-height: 25px;
}
</style>