1、新的 HTML5 文档类型和字符集是?
HTML5 文档类型很简单:<!doctype html>
HTML5 废弃了一些过时的,不合理的 HTML 标签:
<ul><li><span style="font-family: 'Times New Roman';">frame</span></li><li><span style="font-family: 'Times New Roman';">frameset</span></li><li><span style="font-family: 'Times New Roman';">noframe</span></li><li><span style="font-family: 'Times New Roman';">applet</span></li><li><span style="font-family: 'Times New Roman';">big</span></li><li><span style="font-family: 'Times New Roman';">center</span></li><li><span style="font-family: 'Times New Roman';">basefront</span></li></ul>
HTML5 新增了很多表单元素让开发者构建更优秀的 Web 应用程序。
<ul><li><span style="font-family: 'Times New Roman';">datalist</span></li><li><span style="font-family: 'Times New Roman';">datetime</span></li><li><span style="font-family: 'Times New Roman';">output</span></li><li><span style="font-family: 'Times New Roman';">keygen</span></li><li><span style="font-family: 'Times New Roman';">date</span></li><li><span style="font-family: 'Times New Roman';">month</span></li><li><span style="font-family: 'Times New Roman';">week</span></li><li><span style="font-family: 'Times New Roman';">time</span></li><li><span style="font-family: 'Times New Roman';">color</span></li><li><span style="font-family: 'Times New Roman';">number</span></li><li><span style="font-family: 'Times New Roman';">range</span></li><li><span style="font-family: 'Times New Roman';">email</span></li><li><span style="font-family: 'Times New Roman';">url</span></li></ul>
<ul><li><span style="font-family: 'Times New Roman';">Media API</span></li><li><span style="font-family: 'Times New Roman';">Text Track API</span></li><li><span style="font-family: 'Times New Roman';">Application Cache API</span></li><li><span style="font-family: 'Times New Roman';">User Interaction</span></li><li><span style="font-family: 'Times New Roman';">Data Transfer API</span></li><li><span style="font-family: 'Times New Roman';">Command API</span></li><li><span style="font-family: 'Times New Roman';">Constraint Validation API</span></li><li><span style="font-family: 'Times New Roman';">History API</span></li></ul>
HTML5 支持 MP3、Wav 和 Ogg 格式的音频,下面是在网页中嵌入音频的简单示例:
<audio controls> <source src=”jamshed.mp3″ type=”audio/mpeg”> Your browser does’nt support audio embedding feature. </audio>
和音频类似,HTML5 支持 MP4、WebM 和 Ogg 格式的视频,下面是简单示例:
<video width=”450″ height=”340″ controls> <source src=”jamshed.mp4″ type=”video/mp4″> Your browser does’nt support video embedding feature. </video>
HTML5 对于多媒体提供了强有力的支持,除了 audio 和 video 标签外,还支持以下标签:
<embed> 标签定义嵌入的内容,比如插件。 <embed type=”video/quicktime” src=”Fishing.mov”> <source> 对于定义多个数据源很有用。 <video width=”450″ height=”340″ controls> <source src=”jamshed.mp4″ type=”video/mp4″> <source src=”jamshed.ogg” type=”video/ogg”> </video>
<video width=”450″ height=”340″ controls> <source src=”jamshed.mp4″ type=”video/mp4″> <source src=”jamshed.ogg” type=”video/ogg”> <track kind=”subtitles” label=”English” src=”jamshed_en.vtt” srclang=”en” default></track> <track kind=”subtitles” label=”Arabic” src=”jamshed_ar.vtt” srclang=”ar”></track> </video>
Canvas 元素用于在网页上绘制图形,该元素标签强大之处在于可以直接在 HTML 上进行图形操作,
9、HTML5 存储类型有什么区别?
HTML5 能够本地存储数据,在之前都是使用 cookies 使用的。HTML5 提供了下面两种本地存储方案:
- localStorage 用于持久化的本地存储,数据永远不会过期,关闭浏览器也不会丢失。
- sessionStorage 同一个会话中的页面才能访问并且当会话结束后数据也随之销毁。因此sessionStorage不是一种持久化的本地存储,仅仅是会话级别的存储
应用程序缓存是 HTML5 的重要特性之一,提供了离线使用的功能,让应用程序可以获取本地的网站内容,例如 HTML、CSS、图片以及 JavaScript。这个特性可以提高网站性能,它的实现借助于 manifest 文件,如下: