Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 627875 of <p>

  • 版本网址缩略名: Web/HTML/Element/p
  • 版本标题: <p>
  • 版本 id: 627875
  • 创建于:
  • 创建者: xingzhi
  • 是否是当前版本?
  • 评论

修订内容

总结

HTML的<p>元素(或者HTML段落元素)表示一个段落。段落是块级元素

  • 内容分类 Flow content, palpable content.
  • 允许的内容 Phrasing content.
  • 标签省略起始标签是必需的,结束标签在以下情形中可以省略。<p>元素后紧跟{{HTMLElement("address")}}, {{HTMLElement("article")}}, {{HTMLElement("aside")}}, {{HTMLElement("blockquote")}}, {{HTMLElement("div")}}, {{HTMLElement("dl")}}, {{HTMLElement("fieldset")}}, {{HTMLElement("footer")}}, {{HTMLElement("form")}}, {{HTMLElement("h1")}}, {{HTMLElement("h2")}}, {{HTMLElement("h3")}}, {{HTMLElement("h4")}}, {{HTMLElement("h5")}}, {{HTMLElement("h6")}}, {{HTMLElement("header")}}, {{HTMLElement("hr")}}, {{HTMLElement("menu")}}, {{HTMLElement("nav")}}, {{HTMLElement("ol")}}, {{HTMLElement("pre")}}, {{HTMLElement("section")}}, {{HTMLElement("table")}}, {{HTMLElement("ul")}}或另一个{{HTMLElement("p")}}元素;或者父元素中没有其他内容了,而且父元素不是{{HTMLElement("a")}}元素
  • 允许的父元素任何接受flow content的元素
  • DOM接口 {{domxref("HTMLParagraphElement")}}

属性

这个元素包含全局属性

在{{HTMLVersionInline(5)}}中,<p>元素的align属性{{obsolete_inline}}。

示例

<p>这是第一个段落。这是第一个段落。
   这是第一个段落。这是第一个段落。
</p>

<p>这是第二个段落。这是第二个段落。
   这是第二个段落。这是第二个段落。
</p>

以上的HTML输出如下:

这是第一个段落。这是第一个段落。这是第一个段落。这是第一个段落。

这是第二个段落。这是第二个段落。这是第二个段落。这是第二个段落。

注意

使用CSS {{cssxref("margin")}}属性去改变段落之间的间隙,不要在段落之间插入空的段落元素或者{{HTMLElement("br")}}元素。

规范

Specification Status Comment
{{SpecName('HTML WHATWG', 'grouping-content.html#the-p-element', '<p>')}} {{Spec2('HTML WHATWG')}}  
{{SpecName('HTML5 W3C', 'grouping-content.html#the-p-element', '<p>')}} {{Spec2('HTML5 W3C')}}  
{{SpecName('HTML4.01', 'struct/text.html#h-9.3.1', '<p>')}} {{Spec2('HTML4.01')}}  

浏览器兼容性

{{CompatibilityTable}}
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 1.0 {{CompatGeckoDesktop("1.0")}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}}
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support {{CompatVersionUnknown}} {{CompatGeckoMobile("1.0")}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}}

另请参阅

  • {{HTMLElement("hr")}}
  • {{HTMLElement("br")}}
{{HTMLRef}}

修订版来源

<h2 id=".E6.80.BB.E7.BB.93">总结</h2>
<p><span class="seoSummary">HTML的&lt;p&gt;元素(或者HTML段落元素)表示一个段落。段落是</span><a href="/en-US/docs/HTML/Block-level_elements">块级元素</a>。</p>
<ul class="htmlelt">
 <li><dfn><a href="/en-US/docs/Web/HTML/Content_categories">内容分类</a></dfn> <a href="/en-US/docs/Web/HTML/Content_categories#Flow_content">Flow content</a>, palpable content.</li>
 <li><dfn>允许的内容</dfn> <a href="/en-US/docs/Web/HTML/Content_categories#Phrasing_content">Phrasing content</a>.</li>
 <li><dfn>标签省略</dfn>起始标签是必需的,结束标签在以下情形中可以省略。&lt;p&gt;元素后紧跟{{HTMLElement("address")}}, {{HTMLElement("article")}}, {{HTMLElement("aside")}}, {{HTMLElement("blockquote")}}, {{HTMLElement("div")}}, {{HTMLElement("dl")}}, {{HTMLElement("fieldset")}}, {{HTMLElement("footer")}}, {{HTMLElement("form")}}, {{HTMLElement("h1")}}, {{HTMLElement("h2")}}, {{HTMLElement("h3")}}, {{HTMLElement("h4")}}, {{HTMLElement("h5")}}, {{HTMLElement("h6")}}, {{HTMLElement("header")}}, {{HTMLElement("hr")}}, {{HTMLElement("menu")}}, {{HTMLElement("nav")}}, {{HTMLElement("ol")}}, {{HTMLElement("pre")}}, {{HTMLElement("section")}}, {{HTMLElement("table")}}, {{HTMLElement("ul")}}或另一个{{HTMLElement("p")}}元素;或者父元素中没有其他内容了,而且父元素不是{{HTMLElement("a")}}元素</li>
 <li><dfn>允许的父元素</dfn>任何接受<a href="/en-US/docs/Web/HTML/Content_categories#Flow_content">flow content</a>的元素</li>
 <li><dfn>DOM接口</dfn> {{domxref("HTMLParagraphElement")}}</li>
</ul>
<h2 id=".E5.B1.9E.E6.80.A7">属性</h2>
<p>这个元素包含<a href="/en-US/docs/Web/HTML/Global_attributes">全局属性</a>。</p>
<p><span style="line-height: 1.5;">在{{HTMLVersionInline(5)}}中,&lt;p&gt;元素的</span><strong style="line-height: 1.5;">align</strong><span style="line-height: 1.5;">属性</span><span style="line-height: 1.5;">{{obsolete_inline}}。</span></p>
<h2 id=".E7.A4.BA.E4.BE.8B">示例</h2>
<pre class="brush: html">
&lt;p&gt;这是第一个段落。这是第一个段落。
   这是第一个段落。这是第一个段落。
&lt;/p&gt;

&lt;p&gt;这是第二个段落。<span style="font-size: 1rem;">这是第二个段落。
</span><span style="font-size: 1rem;">   这是第二个段落。</span><span style="font-size: 1rem;">这是第二个段落。
</span><span style="font-size: 1rem;">&lt;/p&gt;</span></pre>
<p>以上的HTML输出如下:</p>
<p>这是第一个段落。这是第一个段落。这是第一个段落。这是第一个段落。</p>
<p>这是第二个段落。这是第二个段落。这是第二个段落。这是第二个段落。</p>
<h2 id=".E6.B3.A8.E6.84.8F">注意</h2>
<p>使用<a href="/en-US/docs/Web/CSS" style="line-height: 1.5;">CSS</a><span style="line-height: 1.5;">&nbsp;{{cssxref("margin")}}属性</span><span style="line-height: 1.5;">去改变段落之间的间隙,<strong>不要</strong>在段落之间插入空的段落元素或者</span><span style="line-height: 1.5;">{{HTMLElement("br")}}元素。</span></p>
<h2 id="Specifications" name="Specifications">规范</h2>
<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('HTML WHATWG', 'grouping-content.html#the-p-element', '&lt;p&gt;')}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td>&nbsp;</td>
  </tr>
  <tr>
   <td>{{SpecName('HTML5 W3C', 'grouping-content.html#the-p-element', '&lt;p&gt;')}}</td>
   <td>{{Spec2('HTML5 W3C')}}</td>
   <td>&nbsp;</td>
  </tr>
  <tr>
   <td>{{SpecName('HTML4.01', 'struct/text.html#h-9.3.1', '&lt;p&gt;')}}</td>
   <td>{{Spec2('HTML4.01')}}</td>
   <td>&nbsp;</td>
  </tr>
 </tbody>
</table>
<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2>
<div>
 {{CompatibilityTable}}</div>
<div id="compat-desktop">
 <table class="compat-table">
  <tbody>
   <tr>
    <th>Feature</th>
    <th>Chrome</th>
    <th>Firefox (Gecko)</th>
    <th>Internet Explorer</th>
    <th>Opera</th>
    <th>Safari (WebKit)</th>
   </tr>
   <tr>
    <td>Basic support</td>
    <td>1.0</td>
    <td>{{CompatGeckoDesktop("1.0")}}</td>
    <td>{{CompatVersionUnknown}}</td>
    <td>{{CompatVersionUnknown}}</td>
    <td>{{CompatVersionUnknown}}</td>
   </tr>
  </tbody>
 </table>
</div>
<div id="compat-mobile">
 <table class="compat-table">
  <tbody>
   <tr>
    <th>Feature</th>
    <th>Android</th>
    <th>Firefox Mobile (Gecko)</th>
    <th>IE Phone</th>
    <th>Opera Mobile</th>
    <th>Safari Mobile</th>
   </tr>
   <tr>
    <td>Basic support</td>
    <td>{{CompatVersionUnknown}}</td>
    <td>{{CompatGeckoMobile("1.0")}}</td>
    <td>{{CompatVersionUnknown}}</td>
    <td>{{CompatVersionUnknown}}</td>
    <td>{{CompatVersionUnknown}}</td>
   </tr>
  </tbody>
 </table>
</div>
<h2 id=".E5.8F.A6.E8.AF.B7.E5.8F.82.E9.98.85">另请参阅</h2>
<ul>
 <li>{{HTMLElement("hr")}}</li>
 <li>{{HTMLElement("br")}}</li>
</ul>
<div>
 {{HTMLRef}}</div>
恢复到这个版本