开发者

How to define spaces between two lines using CSS?

Margin, padding, o开发者_JS百科r whatever?


line-height attribute, more details: http://www.css3.com/css-line-height/


Margin is used to specify the distance between elements.

Padding is used to specify the padding between an element and it's content.

Line-height is used to specify the height of text lines in a continuous text.

So, if you have separate elements that you want a distance between, margin is appropriate:

<p style="margin: 5px 0">Line 1</p>
<p style="margin: 5px 0">Line 2</p>

If you have a continuous text where you want a distance between the text lines, line-height is appropriate:

<p style="line-height: 1.8em">Long text that spans several lines...</p>


If your lines stored in single <div> or <p> element, your can use(as was mentioned above) line-height(line-height) attribute. In case, when lines are placed in different block elements, yuo can modify space between two lines with margin(margin description) or padding(padding description) attributes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜