【HTML5最容易犯的错】HTML5的section可不要作为div的替代品
来源:互联网 发布:高速公路的数据 编辑:程序博客网 时间:2024/04/30 07:39
人们在标签使用中最常见到的错误之一就是随意将HTML5的<section>等价于<div>——具体地说,就是直接用作替代品(用于样式)。在XHTML或者HTML4中,我们常看到这样的代码:
<!-- HTML 4-style code --><div id="wrapper"><div id="header"><h1>My super duper page</h1>Header content</div><div id="main">Page content</div><div id="secondary">Secondary content</div><div id="footer">Footer content</div></div>
而现在在HTML5中,会是这样:
<!-- 请不要复制这些代码!这是错误的! --><section id="wrapper"><header><h1>My super duper page</h1><!-- Header content --></header><section id="main"><!-- Page content --></section><section id="secondary"><!-- Secondary content --></section><footer><!-- Footer content --></footer></section>
这样使用并不正确:<section>并不是样式容器。section元素表示的是内容中用来帮助构建文档概要的语义部分。它应该包含一个头部。如果你想找一个用作页面容器的元素(就像HTML或者XHTML的风格),那么考虑如Kroc Camen所说,直接把样式写到body元素上吧。如果你仍然需要额外的样式容器,还是继续使用div吧。
基于上述思想,下面才是正确的使用HTML5和一些ARIA roles特性的例子(注意,根据你自己的设计,你也可能需要加入div)
<body><header><h1>My super duper page</h1><!-- Header content --></header><div role="main"><!-- Page content --></div><aside role="complementary"><!-- Secondary content --></aside><footer><!-- Footer content --></footer></body>
0 0
- 【HTML5最容易犯的错】HTML5的section可不要作为div的替代品
- HTML5 中 div section article 的区别
- HTML5 中 div section article 的区别
- HTML5中div section article的区别
- HTML5中div section article的区别
- HTML5中div section article的区别
- HTML5 中 div section article 的区别
- HTML5 section和div的区别
- HTML5 中 div section article 的区别
- HTML5中div section article的区别
- html5的section标签
- HTML5中div,section,article的区别总结
- HTML5中div、article、section的区别及使用介绍
- HTML5中div、article、section的区别及使用介绍
- HTML5中div、article、section的区别及使用介绍
- Html5之Div,Article,Section的区别与应用
- DIV+CSS容易犯的十个错误
- Java开发最容易犯的错误
- DesignSpark PCB
- linux下svn启动与终止
- R语言部署到linux上crontab无法运行的问题
- HDU 2054 A==B? 大数
- [2014-07-18]JAVA笔记_Object类、String类
- 【HTML5最容易犯的错】HTML5的section可不要作为div的替代品
- C数据类型
- oracle mssql mysql db2 取前几条数据
- filezilla安装的问题GLIBCXX_3.4.15
- Makefile的一个具体的实例
- 无监督特征学习——Unsupervised feature learning and deep learning
- 新的开始
- apache phoenix简单部署测试
- Extjs4 Combobox 联动始终出现loading错误的解决办法