aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/html/element/p/index.html
blob: 1db922a968ec4f5d47f48cd2c1a1ae3e1a5e55eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
---
title: <p>
slug: Web/HTML/Element/p
tags:
  - Element
  - HTML
  - HTML grouping content
  - Web
  - 参考
translation_of: Web/HTML/Element/p
---
<div>{{HTMLRef}}</div>

<p><strong>HTML &lt;p&gt;</strong>元素(或者说 HTML 段落元素)表示文本的一个段落。该元素通常表现为一整块与相邻文本分离的文本,或以垂直的空白隔离或以首行缩进。另外,&lt;p&gt; 是<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; 元素的 </span><strong style="line-height: 1.5;">align </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('示例', '', '', '', 'Web/HTML/Element/p') }}</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;"> {{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> </td>
  </tr>
  <tr>
   <td>{{SpecName('HTML5 W3C', 'grouping-content.html#the-p-element', '&lt;p&gt;')}}</td>
   <td>{{Spec2('HTML5 W3C')}}</td>
   <td> </td>
  </tr>
  <tr>
   <td>{{SpecName('HTML4.01', 'struct/text.html#h-9.3.1', '&lt;p&gt;')}}</td>
   <td>{{Spec2('HTML4.01')}}</td>
   <td> </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>