?
This document uses PHP Chinese website manual Release
HTML Section 元素 表示包含在HTML文件中的功能性的獨(dú)立的部分,通常具有一個(gè)標(biāo)題,它不必代表它的更具體的語(yǔ)義單元。
舉個(gè)例子,導(dǎo)航菜單應(yīng)該包裝在一個(gè)<nav>
元素中,但是一個(gè)搜索結(jié)果列表和一個(gè)地圖顯示及其控件沒有具體的元素,可以放在一個(gè)<section>
。
內(nèi)容類別 | Flow content, Sectioning content, palpable content. |
---|---|
允許的內(nèi)容 | Flow content. |
標(biāo)記遺漏 | 沒有,起始和結(jié)束標(biāo)簽都是強(qiáng)制性的。 |
允許父母 | 任何接受 Flow content 的元素。請(qǐng)注意,<section>元素不能是<address>元素的后代。 |
允許ARIA角色 | alert, alertdialog, application, banner, complementary, contentinfo, dialog, document, feed, log, main, marquee, navigation, search, status, tabpanel |
DOM界面 | HTML元素 |
這個(gè)元素只包含全局屬性。
每一個(gè)都<section>
應(yīng)該被識(shí)別出來,通常包括一個(gè)標(biāo)題(<h1>
- <h6>
元素)作為元素的一個(gè)子<section>
元素。
如果單獨(dú)聯(lián)合一個(gè)<section>
元素的內(nèi)容是有意義的,請(qǐng)改用一個(gè)<article>
元素。
不要將該<section>
元素用作通用容器; 這是為什么<div>
,特別是當(dāng)切片只是為了造型的目的。經(jīng)驗(yàn)法則是一個(gè)部分應(yīng)邏輯地出現(xiàn)在文檔的大綱中。
<div> <h1>Heading</h1> <p>Bunch of awesome content</p></div>
<section> <h1>Heading</h1> <p>Bunch of awesome content</p></section>
<div> <h2>Heading</h2> <img src="bird.jpg" alt="bird"></div>
<section> <h2>Heading</h2> <img src="bird.jpg" alt="bird"></section>
Specification | Status | Comments |
---|---|---|
HTML Living StandardThe definition of '<section>' in that specification. | Living Standard | |
HTML 5.1The definition of '<section>' in that specification. | Recommendation | |
HTML5The definition of '<section>' in that specification. | Recommendation |
Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic Support | 5 | (Yes) | 4 | 9 | 11.1 | 4.1 |
Feature | Android | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
---|---|---|---|---|---|---|---|
Basic Support | (Yes) | (Yes) | (Yes) | 4 | 9 | 11 | 4.2 |