Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

How does CSS set line spacing?


May 29, 2021 Article blog



In a development web page, you need to use CSS to set the line spacing when you encounter paragraph line spacing that is too compact and affects the page's aesthetics. So in this article, the W3Cschool editor-in-chief teaches you how CSS sets line spacing.

line-height: Set line spacing.

To achieve the effect:

 How does CSS set line spacing?1

Specific code:

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>字符间距 - 编程狮(w3cschool.cn)</title>
	<style type="text/css">
		div{height: 200px;
			width: 300px;}
		#one{line-height: 30px;}
		#two{line-height: 10px;}
	</style>
</head>
<body>
	<div>
		<p id="normal">这是用来测试正常的行间距,它以正常的行间距显示。</p>
		<p id="one">这是用来测试增加的行间距,它以增加的行间距显示。</p>
		<p id="two">这是用来测试减少的行间距,它以减少的行间距显示。</p>
	</div>
</body>
</html>

That's all CSS says about how to set line spacing.