?
This document uses PHP Chinese website manual Release
已廢棄
該特性已經(jīng)從 Web 標(biāo)準(zhǔn)中刪除,雖然一些瀏覽器目前仍然支持它,但也許會(huì)在未來(lái)的某個(gè)時(shí)間停止支持,請(qǐng)盡量不要使用該特性。
HTML Center 元素 (<center>
) 是個(gè)塊級(jí)元素,可以包含段落,以及其它塊級(jí)和內(nèi)聯(lián)元素。這個(gè)元素的整個(gè)內(nèi)容在它的上級(jí)元素中水平居中(通常是<body>
)。
這個(gè)標(biāo)簽已經(jīng)在 HTML 4(以及 XHTML 1)中廢除了,以支持CSStext-align
屬性,它可以用于 <div>
元素,或者獨(dú)立的<p>
。對(duì)于居中的塊,使用其它 CSS 屬性,例如 margin-left
和margin-right
,并將其設(shè)置為 auto
(或者將 margin
設(shè)為0 auto
).
這個(gè)元素實(shí)現(xiàn)了HTMLElement
接口。
實(shí)現(xiàn)注解: 直到 Gecko 1.9.2(包含), Firefox 為這個(gè)元素實(shí)現(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
會(huì)使這些元素的內(nèi)容居中,當(dāng)它們的外形尺寸沒(méi)有改變的時(shí)候。
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) |