HTML5 面试中最常问到的 10 个问题

 1. HTML5 新的 DocType 和 Charset 是什么?

  HTML5 现在已经不是 SGML 的子集,DocType 简化为:

  <!doctype html>

  HTML 5 指定 UTF-8 编码的方式如下:

  <meta charset="UTF-8">

  2. 如何在 HTML5 页面中嵌入音频?

  HTML 5 包含嵌入音频文件的标准方式,支持的格式包括 MP3、Wav 和 Ogg:

  <audio controls>

    <source src="jamshed.mp3" type="audio/mpeg">

    Your browser does'nt support audio embedding feature.

  </audio>

  3. 如何在 HTML5 页面中嵌入视频?

  和音频一样,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>

  4.除了音频和视频,HTML5 还支持其他什么新的媒体元素?

  HTML 5 对媒体支持很强,除了 audio 和 video 外,还提供:

  • <embed> 作为外部应用的容器
  • <track> 定义媒体的文本跟踪
  • <source> 对多种媒体源的支持很有帮助

  5.What is the usage of canvas Element in HTML 5?

  <canvas> is an element in HTML5 which we can use to draw graphics with the help of scripting (which is most probably JavaScript).

  This element behaves like a container for graphics and rest of things will be done by scripting. We can draw images, graphs and a bit of animations etc using <canvas> element.

  <canvas id="canvas1" width="300" height="100">

  </canvas>

  6. HTML5 有哪些不同类型的存储?

  HTML 5 支持本地存储,在之前版本中是通过 Cookie 实现的。HTML5 本地存储速度快而且安全。

  有两种不同的对象可用来存储数据:

  • localStorage 适用于长期存储数据,浏览器关闭后数据不丢失
  • sessionStorage 存储的数据在浏览器关闭后自动删除

  7. HTML5 引入什么新的表单属性?

  HTML5 引入大量新的表达属性:

  • datalist
  • datetime
  • output
  • keygen
  • date
  • month
  • week
  • time
  • number
  • range
  • email
  • url

  8. 与 HTML4 比较,HTML5 废弃了哪些元素?

  废弃的元素包括:

  • frame
  • frameset
  • noframe
  • applet
  • big
  • center
  • basefront

  9. HTML5 标准提供了哪些新的 API?

  HTML 5 提供很多新的 API,包括:

  • Media API
  • Text Track API
  • Application Cache API
  • User Interaction
  • Data Transfer API
  • Command API
  • Constraint Validation API
  • History API
  • and many more....

  10. HTML5 应用缓存和常规的 HTML 浏览器缓存有何差别?

  HTML5 的应用缓存最关键的就是支持离线应用,可获取少数或者全部网站内容,包括 HTML、CSS、图像和 JavaScript 脚本并存在本地。该特性加速了网站的性能,可通过如下方式实现:

  <!doctype html>

  <html manifest="example.appcache">

  .....

  </html>

  与传统的浏览器缓存比较,该特性并不强制要求用户访问网站。

  英文来源:webdevelopmenthelp

posted @ 2013-10-24 08:22  山顶的鱼  阅读(223)  评论(0编辑  收藏  举报