![](https://csdnimg.cn/release/download_crawler_static/82004049/bg1.jpg)
开发者必须知道的 HTML5 十五大新特性
2012-10-12 20:22:37 [ 小 大] 来源 :
HTML5 想必大家都很熟悉了, 因为太多的媒体在讨论这一技术。 然而,你能准确地说出 HTML5 带来了哪
些新特性吗?本文总结了 HTML5 带来的 15 项你必须知道的新特性。
一起来看下:
1.新的文档类型 (New Doctype)
目前许多网页还在使用 XHTML 1.0 并且要在第一行像这样声明文档类型:
1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
在 HTML5 中,上面那种声明方式将失效。下面是 HTML5 中的声明方式:
1. <!DOCTYPE html >
2.脚本和链接无需 type (No More Types for Scripts and Links)
在 HTML4 或 XHTML 中,你需要用下面的几行代码来给你的网页添加 CSS和 JavaScript 文
件。
1. <link rel ="stylesheet" href ="path/to/stylesheet.css"
type ="text/css" />
2. <script type ="text/javascript"
src ="path/to/script. js " ></ script >
而在 HTML5 中,你不再需要指定类型属性。因此,代码可以简化如下:
1. <link rel ="stylesheet" href ="path/to/stylesheet.css" />
2. <script src ="path/to/script.js" ></ script >
3.语义 Header 和 Footer (The Semantic Header and Footer)
在 HTML4 或 XHTML 中,你需要用下面的代码来声明 “Header”和“Footer ”。
1. <div id ="header" >
2. ...
3. </ div >
4. ..........
5. <div id ="footer" >
6. ...