html5跟html4对比新增的特性

307 阅读1分钟

html5对比html4新增了很多功能,列举一些常用的:

  1. <!doctype>标签简化。

  2. 增加了语义化标签

image.png

  1. form表单增强
 input 的type 增加了很多新特性:比如number,seacrh,month,week,email,range,color,url
  1. 增加了canvas ,svg
  <canvas id="myCanvas" width="200" height="100"></canvas>


     <?xml version="1.0" standalone="no"?>
    <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
    "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

    <svg width="100%" height="100%" version="1.1"
    xmlns="http://www.w3.org/2000/svg">

    <rect width="300" height="100"
    style="fill:rgb(0,0,255);stroke-width:1;
    stroke:rgb(0,0,0)"/>

    </svg>
  1. 增加了本地存储功能


     window.localStorage.getItem('xx')
     window.localStorage.setItem('xx',{a:1})
  1. 增加了地理位置功能
  HTML5 Geolocation API 用于获得用户的地理位置。
  1. 增加拖放功能
 <div ondrop="drop"></div>
  1. 增加了webworker功能

当在html页面执行脚本时,页面是不可响应的,直到脚本已完成。 Web worker 是运行在后台的 JavaScript,独立于其他脚本,不会影响页面的性能。您可以继续做任何愿意做的事情:点击、选取内容等等,而此时 web worker 运行在后台。

  1. 增加音视频标签 :
    <video></video>
     <audio></audio>

完。