
上QQ阅读APP看书,第一时间看更新
5.2 设置网页文本的缩进和间距
网页基本上是由文本和图片构成,文本的样式设置及风格影响着整个网页的美观程度,本节主要介绍HTML中文本的缩进和间距的设置。
5.2.1 设置首行缩进属性

text-indent(首行缩进)属性用于设置文本的首行缩进,它的取值可以是百分比数值、浮点数和单位标识符组成的长度值,允许为负值。
【例5-8】(实例文件:ch05\Chap5.8.html)设置首行缩进。

相关的代码实例请参考Chap5.8.html文件,在IE浏览器中运行的结果如图5-8所示。

图5-8 设置首行缩进属性
5.2.2 设置字符间距属性

设置letter-spacing(字符间距)属性,对于汉语而言,是字与字之间的间距;对于英文而言,是字母与字母之间的间距。取值可以是正值或者负值。
【例5-9】(实例文件:ch05\Chap5.9.html)设置字符间距。

相关的代码实例请参考Chap5.9.html文件,在IE浏览器中运行的结果如图5-9所示。

图5-9 设置字符间距属性
5.2.3 设置单词间距属性

word-spacing(单词间距)属性用于指定某个区域或者段落中单词与单词之间的间隔。它的取值可以是正值或负值。
【例5-10】(实例文件:ch05\Chap5.10.html)设置单词间距。

相关的代码实例请参考Chap5.10.html文件,在IE浏览器中运行的结果如图5-10所示。

图5-10 设置单词间距属性