<div>

HTML <div> 元素(或是 HTML 文件區塊元素)是本質上不特別代表任何東西的通用内容流容器。它可以成為樣式化用途(使用 classid 屬性)、或是共享如 lang 同一個屬性的元素集合。它應該在沒有其他適合的語義元素(例如<article><nav> )可用時才用。

內容類型 流內容、捫及內容。
允許內容 流內容
Tag 省略 None, both the starting and ending tag are mandatory.
允許父元素 任何允許內容流的元素。
DOM 介面 HTMLDivElement

屬性

這個元素包含全域屬性

align 元素已過時,不要使用它。

範例

<div>
  <p>這裡可以是任何內容,例如 &lt;p&gt;、&lt;table&gt;。你說了算!</p>
</div> 

結果

這裡可以是任何內容,例如 <p>、<table>。你說了算!

規範

規範 狀態 註解
HTML Living Standard
The definition of '<div>' in that specification.
Living Standard 最新的快照以後並無改變
HTML5
The definition of '<div>' in that specification.
Recommendation 廢棄 align
HTML 4.01 Specification
The definition of '<div>' in that specification.
Recommendation  

瀏覽器相容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
divChrome Full support YesEdge Full support YesFirefox Full support 1IE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
align
DeprecatedNon-standard
Chrome Full support YesEdge Full support YesFirefox Full support 1IE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes

Legend

Full support  
Full support
Non-standard. Expect poor cross-browser support.
Non-standard. Expect poor cross-browser support.
Deprecated. Not for use in new websites.
Deprecated. Not for use in new websites.

詳閱