.
3ss.cn

html怎么样设置段距

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

本教程操作环境: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>

效果图:

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>

赞(0)
未经允许不得转载:互联学术 » html怎么样设置段距

评论 抢沙发