CSS中如何设置单词的间距?

html-css020

CSS中如何设置单词的间距?,第1张

CSS用word-spacing属性来设置单词的间距。例如:

<html>

    <head>

        <style type="text/css">

            p.spread {word-spacing: 30px}

            p.tight {word-spacing: -0.5em}

        </style>

    </head>

    <body>

        <p class="spread">This is some text. This is some text.</p>

        <p class="tight">This is some text. This is some text.</p>

</body>

</html>

效果如图:

可以看到,word-spacing属性既可以使单词间距变小,也可以变大。

对于中文,CSS区分不出来词,使用letter-spacing属性调节字之间的间距。

你的例子里,你需要把要调节间距的字符放到同一个标签内部,比如<p></p>中。如果不同标签之间的距离,用margin(外边距)或padding(内边距)都可以。

line-height:行间距

ling-height:属于用于设置行间距,就是行与行之间的距离。

text-aligh:水平对齐方式

text-aligh属性用于设置文本内容的水平对齐,相当于html中的align对齐属性,其可用属性值:

left

right

center

text-indent:首行缩进

text-indent属性用于设置首行文本的缩进,其属性值可为不同单位的数值。

letter-spacing:字间距

letter-spacing属性用于定以字间距,所谓字间距就是字符与字符之间的空白,其属性值可谓不同单位的数值,允许使用负值,默认为normal

word-spacing:单词间距

word-spacing属性用于设定英文单词之间的间距,对中文字符无效。