Home  >  Article  >  Web Front-end  >  若干个HTML5的新特性与技术

若干个HTML5的新特性与技术

WBOY
WBOYOriginal
2016-05-17 09:09:321263browse

1. 新的Doctype

尽管使用,即使浏览器不懂这句话也会按照标准模式去渲染

2. Figure元素

来语义化地表示带标题的图片

About image

This is an image of something interesting.


3. 重新定义的

已经被重新定义了,现在被用来表示小的排版,如网站底部的版权声明

4. 去掉link和script标签里面的type属性

5. 加/不加 括号

HTML5没有严格的要求属性必须加引号,闭合不闭合,但是建议加上引号和闭合标签

6. 让你的内容可编辑,只需要加一个contenteditable属性

7. Email Inputs

如果我们给Input的type设置为email,浏览器就会验证这个输入是否是email类型,当然不能只依赖前端的校验,后端也得有相应的校验

8. Placeholders

这个input属性的意义就是不必通过javascript来做placeholder的效果了

9. Local Storage

使用Local Storage可以永久存储大的数据片段在客户端(除非主动删除),目前大部分浏览器已经支持,在使用之前可以检测一下window.localStorage是否存在

10. 语义化的header和footer

11. 更多的HTML5表单特性

12. IE和HTML5

默认的,HTML5新元素被以inline的方式渲染,不过可以通过下面这种方式让

其以block方式渲染

header, footer, article, section, nav, menu, hgroup {

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里面用来将一组标题组合在一起,如

Recall Fan Page

Only for people who want the memory of a lifetime.

14. Required属性

required属性定义了一个input是否是必须的,你可以像下面这样声明

或者

15. Autofocus属性

正如它的词义,就是聚焦到输入框里面

16. Audio支持

HTML5提供了

  
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn