Home  >  Article  >  Web Front-end  >  How to set paragraph spacing in html

How to set paragraph spacing in html

青灯夜游
青灯夜游Original
2021-05-14 16:06:4412014browse

htmlHow to set the paragraph spacing: 1. Use the line-height attribute to set the paragraph spacing of a single line of text, with the syntax "line-height: value;". 2. Use the margin attribute to set the paragraph spacing of multi-line text. The syntax is "margin: spacing value;".

How to set paragraph spacing in html

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

1. Use the line-height attribute: line-height

The line-height attribute can set the distance between paragraphs. Generally, the larger the value, the greater the distance between paragraphs. The larger the spacing, of course the distance between words also becomes larger. In many cases, we generally do not use the line-height attribute to set it.

<!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>

Rendering:

How to set paragraph spacing in html

2. Use the margin attribute: margin

As long as we By setting the margin's top, bottom, left, and right margins and the distance between objects, you can achieve the distance between the top and bottom paragraphs.

<!DOCTYPE html>
<html>

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

		</style>
	</head>

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

</html>

How to set paragraph spacing in html

Recommended tutorial: "html video tutorial"

The above is the detailed content of How to set paragraph spacing in html. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn