本文概述
HTML段落或HTML p标签用于定义网页中的段落。让我们举一个简单的例子来看看它是如何工作的。值得注意的一点是, 浏览器本身在段落之前和之后添加一个空行。 HTML <p>标记指示新段落的开始。
注意:如果我们在一个HTML文件中使用各种<p>标记, 则浏览器会自动在两个段落之间添加一个空白行。
请参阅以下示例:
<p>This is first paragraph.</p>
<p>This is second paragraph.</p>
<p>This is third paragraph.</p>
立即测试
输出:
This is first paragraph.
This is second paragraph.
This is third paragraph.
HTML段落内的空间
如果在HTML p标签内放置了很多空格, 浏览器将在显示页面时删除多余的空格和多余的行。浏览器将空格和行数计为一个。
<p>
I am
going to provide
you a tutorial on HTML
and hope that it will
be very beneficial for you.
</p>
<p>
Look, I put here a lot
of spaces but I know, Browser will ignore it.
</p>
<p>
You cannot determine the display of HTML</p>
<p>because resized windows may create different result.
</p>
立即测试
输出:
I am
going to provide
you a tutorial on HTML
and hope that it will
be very beneficial for you.
Look, I put here a lot
of spaces but I know, Browser will ignore it.
You cannot determine the display of HTML
because resized windows may create different result.
如你所见, 浏览器将删除所有多余的行和不必要的空格。
如何在段落中使用<br>和<hr>标签?
HTML <br>标记用于换行符, 可以与段落元素一起使用。以下是显示如何将<br>与<p>元素一起使用的示例。
例:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h2> Use of line break with pragraph tag</h2>
<p><br>Papa and mama, and baby and Dot, <br>Willie and me?the whole of the lot
<br>Of us all went over in Bimberlie's sleigh, <br>To grandmama's house on Christmas day.
</p>
</body>
</html>
立即测试
输出:
HTML <hr>标记用于在两个语句或两个段落之间应用一条水平线。以下是显示<hr>标记与段落一起使用的示例。
例:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h2> Example to show a horizontal line with paragraphs</h2>
<p> An HTML hr tag draw a horizontal line and separate two paragraphs with that line.<hr> it will start a new paragraph.
</p>
</body>
</html>
立即测试
输出:
支持的浏览器
Element | Chrome | IE | Firefox | Opera | Safari |
<p> | Yes | Yes | Yes | Yes | Yes |
评论前必须登录!
注册