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 1042056 of <p>

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

修订内容

{{HTMLRef}}

HTML <p>元素(或者说 HTML 段落元素)表示文本的一个段落。该元素通常表现为一整块与相邻文本分离的文本,或以垂直的空白隔离或以首行缩进。另外,<p> 是块级元素

  • 内容分类 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")}}

属性

这个元素包含全局属性

<p> 元素的 align 属性已被弃用,请不要使用

示例

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

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

输出如下:

{{EmbedLiveSample('Example')}}

注意

使用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")}}

修订版来源

<div>{{HTMLRef}}</div>

<p><strong>HTML&nbsp;&lt;p&gt;</strong>元素(或者说 HTML 段落元素)表示文本的一个段落。该元素通常表现为一整块与相邻文本分离的文本,或以垂直的空白隔离或以首行缩进。另外,&lt;p&gt;&nbsp;是<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="属性">属性</h2>

<p>这个元素包含<a href="/en-US/docs/Web/HTML/Global_attributes">全局属性</a>。</p>

<p><span style="line-height:1.5">&lt;p&gt; 元素的&nbsp;</span><strong style="line-height:1.5">align&nbsp;</strong><span style="line-height:1.5">属性已被弃用,请不要使用</span><span style="line-height:1.5">。</span></p>

<h2 id="示例">示例</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>输出如下:</p>

<p>{{EmbedLiveSample('Example')}}</p>

<h2 id="注意">注意</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="另请参阅">另请参阅</h2>

<ul>
 <li>{{HTMLElement("hr")}}</li>
 <li>{{HTMLElement("br")}}</li>
</ul>
恢复到这个版本