aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/html/element/br/index.html
blob: aa3e6ea1440d7afd4d8e9ac0361e2125e03887b0 (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
---
title: <br>
slug: Web/HTML/Element/br
translation_of: Web/HTML/Element/br
---
<p><strong>HTML &lt;br&gt; 元素</strong>在文本中生成一个换行(回车)符号。此元素在写诗和地址时很有用,这些地方的换行都非常重要。</p>

<table class="properties">
 <tbody>
  <tr>
   <th scope="row"><a href="/en-US/docs/HTML/Content_categories">内容分类</a></th>
   <td><a href="/en-US/docs/HTML/Content_categories#Flow_content">Flow content</a>, <a href="/en-US/docs/HTML/Content_categories#Phrasing_content">phrasing content</a>.</td>
  </tr>
  <tr>
   <th scope="row">允许的内容</th>
   <td>无,这是一个{{Glossary("空元素")}}.</td>
  </tr>
  <tr>
   <th scope="row">标签略写</th>
   <td>必须有一个开始标签,并且一定不能有结束标签。在 XHTML中将元素写为 <code>&lt;br /&gt;</code></td>
  </tr>
  <tr>
   <th scope="row">允许的父元素</th>
   <td>任意可容纳 <a href="/en-US/docs/HTML/Content_categories#Phrasing_content">phrasing content</a> 的元素。</td>
  </tr>
  <tr>
   <th scope="row">Permitted ARIA roles</th>
   <td>任意</td>
  </tr>
  <tr>
   <th scope="row">DOM 接口</th>
   <td>{{domxref("HTMLBRElement")}}</td>
  </tr>
 </tbody>
</table>

<h2 id="属性">属性</h2>

<p>此元素的属性包括<a href="/en-US/docs/HTML/Global_attributes">全局属性</a></p>

<dl>
 <dt>{{htmlattrdef("clear")}} {{deprecatedGeneric('inline','HTML4.01')}} {{obsoleteGeneric('inline','HTML5')}}</dt>
 <dd>指定换行后下一行文本开始位置。
 <div class="note">
 <p><strong>使用注意: 此属性</strong>{{HTMLVersionInline(5)}} 中已被废弃,<strong>请勿使用</strong>。 请用 {{CSSxref('clear')}} 属性替代。</p>
 </div>
 </dd>
</dl>

<h2 id="注意">注意</h2>

<p>不要用 <code>&lt;br&gt;</code> 来增加文本之间的行间隔;应使用 <a href="/en-US/docs/CSS">CSS</a> {{cssxref('margin')}} 属性或{{HTMLElement("p")}} 元素。</p>

<h2 id="例子">例子</h2>

<pre class="brush: html">Mozilla Foundation&lt;br&gt;
1981 Landings Drive&lt;br&gt;
Building K&lt;br&gt;
Mountain View, CA 94043-0801&lt;br&gt;
USA
</pre>

<p>The HTML above outputs:</p>

<p>Mozilla Foundation<br>
 1981 Landings Drive<br>
 Building K<br>
 Mountain View, CA 94043-0801<br>
 USA</p>

<h2 id="技术规范">技术规范</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', 'semantics.html#the-br-element', '&lt;br&gt;')}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td> </td>
  </tr>
  <tr>
   <td>{{SpecName('HTML5 W3C', 'text-level-semantics.html#the-br-element', '&lt;br&gt;')}}</td>
   <td>{{Spec2('HTML5 W3C')}}</td>
   <td> </td>
  </tr>
  <tr>
   <td>{{SpecName('HTML4.01', 'struct/text.html#h-9.3.2.1', '&lt;br&gt;')}}</td>
   <td>{{Spec2('HTML4.01')}}</td>
   <td> </td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容性">浏览器兼容性</h2>



<p>{{Compat("html.elements.br")}}</p>

<h2 id="参见">参见</h2>

<ul>
 <li>{{HTMLElement("address")}} element</li>
 <li>{{HTMLElement("p")}} element</li>
</ul>

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