html5新特性有哪些,h5和c3新增特征( 三 )


display: block;
}
不幸的是IE会忽略这些样式 , 可以像下面这样fix:
document.createElement(”article”);
document.createElement(”footer”);
document.createElement(”header”);
document.createElement(”hgroup”);
document.createElement(”nav”);
document.createElement(”menu”);
13. hgroup
一般在header里面用来将一组标题组合在一起 , 如
<header>
<hgroup>
<h1> Recall Fan Page </h1>
<h2> Only for people who want the memory of a lifetime. </h2>
</hgroup>
</header>
14. Required属性
required属性定义了一个input是否是必须的 , 你可以像下面这样声明
<input type=”text” name=”someInput” required>
或者
<input type=”text” name=”someInput” required=”required”>
15. Autofocus属性
正如它的词义 , 就是聚焦到输入框里面
<input type=”text” name=”someInput” placeholder=”Douglas Quaid” required autofocus>
16. Audio支持
HTML5提供了<audio>标签 , 你不需要再按照第三方插件来渲染音频 , 大多数现代浏览器提供了对于HTML5 Audio的支持 , 不过目前仍旧需要提供一些兼容处理 , 如
<audio autoplay=”autoplay” controls=”controls”>
<source src=http://www.ncwxdh.com/p/”file.ogg” />
<source src=http://www.ncwxdh.com/p/”file.mp3″ />
<a href=http://www.ncwxdh.com/p/”file.mp3″>Download this file.
</audio>
17. Video支持
和Audio很像 , <video>标签提供了对于video的支持 , 由于HTML5文档并没有给video指定一个特定的编码 , 所以浏 览器去决定要支持哪些编码 , 导致了很多不一致 。 Safari和IE支持H.264编码的格式 , Firefox和Opera支持Theora和Vorbis 编码的格式 , 当使用HTML5 video的时候 , 你必须都提供:
<video controls preload>
<source src=http://www.ncwxdh.com/p/”cohagenPhoneCall.ogv” type=”video/ogg; codecs=’vorbis, theora’” />
<source src=http://www.ncwxdh.com/p/”cohagenPhoneCall.mp4″ type=”video/mp4; ’codecs=’avc1.42E01E, mp4a.40.2′” />
<p> Your browser is old. <a href=http://www.ncwxdh.com/p/”cohagenPhoneCall.mp4″>Download this video instead.


</video>
18. 预加载视频
preload属性就像它的字面意思那么简单 , 你需要决定是否需要在页面加载的时候去预加载视频
<video preload>
19. 显示视频控制
<video preload controls>
20. 正则表达式
由于pattern属性 , 我们可以在你的markup里面直接使用正则表达式了
<form action=”" method=”post”>
<label for=”username”>Create a Username: </label>
<input type=”text” name=”username” id=”username” placeholder=”4 <> 10″ pattern=”[A-Za-z]{4,10}” autofocus required>
<button type=”submit”>Go </button>
</form>
21. 检测属性支持
除了Modernizr之外我们还可以通过javascript简单地检测一些属性是否支持 , 如:
<script>
if (!’pattern’ in document.createElement(’input’) ) {
// do client/server side validation
}
</script>
22. Mark元素
把<mark>元素看做是高亮的作用 , 当我选择一段文字的时候 , javascript对于HTML的markup效果应该是这样的:
<h3> Search Results </h3>
<p> They were interrupted, just after Quato said, <mark>”Open your Mind”</mark>. </p>
23. 什么时候用<div>
HTML5已经引入了这么多元素 , 那么div我们还要用吗?div你可以在没有更好的元素的时候去用 。
24. 想立即使用HTML5?
不要等2022了 , 现在就可以使用了 , just do it.
25. 哪些不是HTML5
1)SVG
2)CSS3

推荐阅读