?
This document uses PHP Chinese website manual Release
已廢棄
該特性已經(jīng)從 Web 標準中刪除,雖然一些瀏覽器目前仍然支持它,但也許會在未來的某個時間停止支持,請盡量不要使用該特性。
HTML Center 元素 (<center>
) 是個塊級元素,可以包含段落,以及其它塊級和內(nèi)聯(lián)元素。這個元素的整個內(nèi)容在它的上級元素中水平居中(通常是<body>
)。
這個標簽已經(jīng)在 HTML 4(以及 XHTML 1)中廢除了,以支持CSStext-align
屬性,它可以用于 <div>
元素,或者獨立的<p>
。對于居中的塊,使用其它 CSS 屬性,例如 margin-left
和margin-right
,并將其設(shè)置為 auto
(或者將 margin
設(shè)為0 auto
).
這個元素實現(xiàn)了HTMLElement
接口。
實現(xiàn)注解: 直到 Gecko 1.9.2(包含), Firefox 為這個元素實現(xiàn)了 HTMLSpanElement
接口。
<center>This text will be centered.<p>So will this paragraph.</p></center>
<div style="text-align:center">This text will be centered.<p>So will this paragraph.</p></div>
<p style="text-align:center">This line will be centered.<br>And so will this line.</p>
向<div>
或者 {HTMLElement("p")}} 元素應(yīng)用 {Cssxref("text-align")}}:center
會使這些元素的內(nèi)容居中,當它們的外形尺寸沒有改變的時候。
Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic Support | (Yes) | (Yes) | (Yes)1 | (Yes) | (Yes) | (Yes) |
Feature | Android | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
---|---|---|---|---|---|---|---|
Basic Support | (Yes) | (Yes) | (Yes) | (Yes)1 | (Yes) | (Yes) | (Yes) |