css的text-align與align區別

來源:互聯網
上載者:User
text-align的簡介:

文法:

text-align : left | right | center | justify

參數:
left :  靠左對齊
right :  靠右對齊
center :  置中
justify :  左右對齊
說明:
設定或檢索對象中文本的對齊。
對應的指令碼特性為textAlign。請參閱我編寫的其他書目。
樣本:

p { text-align : center; }

在HTML中,text-align與align有什麼區別

1.align :規定 “p 元素”中的內容的水平對齊。
2.text-align:規定“元素中”的文本的水平對齊。

兩個屬性使用的地方不一樣,但是作用一樣!align相對來說比較“窄”;比如:

align(align是p的屬性):

<p align="center">This is some text!</p>

text-align(text-align則是Css的屬性):

<p style="text-align:center">

二者都可以讓p的內容置中。

align :規定 p 元素中的內容的水平對齊。
text-align:規定“元素中”的文本的水平對齊。
兩個屬性使用的地方不一樣的!

<p align="center">  This is some text!</p>

align直接寫在是p的屬性

<p style="text-align:center">

text-align則是Css的屬性
在 XHTML 1.0 Strict DTD 中,不支援 p 元素的 align 屬性。
請使用 CSS 代替。

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.