HTML段落

前端 潘老师 7个月前 (10-15) 136 ℃ (0) 扫码查看

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>标签用于换行,它可以与段落元素一起使用。以下是示例,展示了如何在<p>元素中使用<br>。

示例:

<!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>标签。

支持的浏览器

元素  Chrome  IE Firefox  Opera  Safari
<p> 支持 支持 支持 支持 支持

版权声明:本站文章,如无说明,均为本站原创,转载请注明文章来源。如有侵权,请联系博主删除。
本文链接:https://www.panziye.com/front/9590.html
喜欢 (0)
请潘老师喝杯Coffee吧!】
分享 (0)
用户头像
发表我的评论
取消评论
表情 贴图 签到 代码

Hi,您需要填写昵称和邮箱!

  • 昵称【必填】
  • 邮箱【必填】
  • 网址【可选】