html中怎么设置段间距(html 段间距)

lxf2023-03-19 10:52:01

html设置段距的方法:1、使用line-height属性,可以设置单行文本的段距,语法“line-height:值;”。2、使用margin属性,可以设置多行文本的段距,语法“margin:间距值;”。

html中怎么设置段间距(html 段间距)

本教程操作环境:windows7系统、CSS3&&HTML5版、Dell G3电脑。

1、使用行高属性:line-height

line-height属性可以对设置段落之间的距离,一般数值越大,段落之间的间距就越大,当然字和字的距离也是变大,很多时候,我们一般不会使用line-height属性来设置。

<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<style type="text/css">
			p {
				line-height: 50px;
			}

		</style>
	</head>

	<body>
		<p>测试文本,测试文本,测试文本,测试文本,测试文本</p>
		<p>测试文本,测试文本,测试文本,测试文本,测试文本</p>
	</body>

</html>

效果图:

html中怎么设置段间距(html 段间距)

2、使用外边距属性:margin

只要我们设置margin的上下左右边距和对象之间的距离,就可以实现上下段落之间的距离。

<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<style type="text/css">
			p {
				margin: 50px;
			}

		</style>
	</head>

	<body>
		<p>测试文本,测试文本,测试文本,测试文本,测试文本</p>
		<p>测试文本,测试文本,测试文本,测试文本,测试文本</p>
	</body>

</html>

html中怎么设置段间距(html 段间距)

推荐教程:《html视频教程》

以上就是html怎么设置段距的详细内容,更多请关注AdminJS其它相关文章!