您的位置:首页 > 运维架构 > 网站架构

HTML5页面架构元素 - <section>标签

2012-03-07 15:25 232 查看
在HTML5中的<section>标签在所有页面结构中应该是一个比较受到关注的标签。

通过定义探索<section>标签的用法

w3schools上的定义:


<section> 标签定义文档中的节(section、区段)。比如章节、页眉、页脚或文档中的其他部分。


延伸:

section元素代表一个页面或则一个内容块的部分,一般作为主题块列表。通常情况下它会带有一个标题和一个内容块。


Bruce Lawson的规则总结:

如果你仅仅是需要一个标签来设置他的样式和javascript控制点,那么你需要的是div标签而不是section

如果article,aside或则nav用起来更适合你的需要请不要使用section

除非section元素很自然的含有一个heading,不然你都不要使用它



如果元素的内容集中到一起显示可以表达相应的意思的话,在W3C鼓励使用article元素,而不是section元素。

通过代码探索<section>标签的用法

代码一:section元素在article中的应用,标题+内容块简单应用。来自W3C例子(http://www.whatwg.org/specs/web-apps/current-work/multipage/sections.html#the-section-element

<article>
<hgroup>
<h1>Apples</h1>
<h2>Tasty, delicious fruit!</h2>
</hgroup>
<p>The apple is the pomaceous fruit of the apple tree.</p>
<section>
<h1>Red Delicious</h1>
<p>These bright red apples are the most common found in many
supermarkets.</p>
</section>
<section>
<h1>Granny Smith</h1>
<p>These juicy, green apples make a great filling for
apple pies.</p>
</section>
</article>


代码二:section元素单独使用和嵌套使用,标题加内容块复杂体现。来自W3C的HTML5网站(http://www.w3.org/html/logo/

View Code
总结:

<section>标签可以理解为一个带语义的div标签,精简版的article标签,它通常带有一个标题和一个内容块。它不会单独为方便设置样式和编写js而生,而为自己的语义和自身内容结构而生。

参考网址:

http://www.w3school.com.cn/html5/tag_section.asp

http://www.whatwg.org/specs/web-apps/current-work/multipage/sections.html#the-section-element

http://www.w3.org/html/logo/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: