HTML参考手册
标签 | Elements
section
HTML Section 元素 表示包含在HTML文件中的功能性的独立的部分,通常具有一个标题,它不必代表它的更具体的语义单元。
举个例子,导航菜单应该包装在一个<nav>
元素中,但是一个搜索结果列表和一个地图显示及其控件没有具体的元素,可以放在一个<section>
。
内容类别 |
Flow content, Sectioning content, palpable content. |
---|---|
允许的内容 |
Flow content. |
标记遗漏 |
没有,起始和结束标签都是强制性的。 |
允许父母 |
任何接受 Flow content 的元素。请注意,<section>元素不能是<address>元素的后代。 |
允许ARIA角色 |
alert, alertdialog, application, banner, complementary, contentinfo, dialog, document, feed, log, main, marquee, navigation, search, status, tabpanel |
DOM界面 |
HTML元素 |
属性
这个元素只包含全局属性。
使用说明
- 每一个都
<section>
应该被识别出来,通常包括一个标题(<h1>
-<h6>
元素)作为元素的一个子<section>
元素。
- 如果单独联合一个
<section>
元素的内容是有意义的,请改用一个<article>
元素。
- 不要将该
<section>
元素用作通用容器; 这是为什么<div>
,特别是当切片只是为了造型的目的。经验法则是一个部分应逻辑地出现在文档的大纲中。
例1
Before
<div>
<h1>Heading</h1>
<p>Bunch of awesome content</p>
</div>
After
<section>
<h1>Heading</h1>
<p>Bunch of awesome content</p>
</section>
例2
Before
<div>
<h2>Heading</h2>
<img src="bird.jpg" alt="bird">
</div>
After
<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 |
标签 | Elements相关
超文本标记语言,它通过标记符号来标记要显示的网页中的各个部分。网页文件本身是一种文本文件,通过在文本文件中添加标记符,可以告诉浏览器如何显示其中的内容(如:文字如何处理,画面如何安排,图片如何显示等)。浏览器按顺序阅读网页文件,然后根据标记符解释和显示其标记的内容,对书写出错的标记将不指出其错误,且不停止其解释执行过程,编制者只能通过显示效果来分析出错原因和出错部位。但需要注意的是,对于不同的浏览器,对同一标记符可能会有不完全相同的解释,因而可能会有不同的显示效果。