1、支持視頻和音頻文件的播放。就像支持圖片文件一樣。
音頻文件
<audio controls="controls" autoplay="autoplay">
<source src="file.ogg" />
<source src="file.mp3" />
<a href="file.mp3">Download this file.</a>
</audio>
視頻文件
<video controls preload>
<source src="cohagenPhoneCall.ogv" type="video/ogg"; codecs='vorbis, theora'" />
<source src="cohagenPhoneCall.mp4" type="video/mp4; 'codecs='avc1.42E01E, mp4a.40.2'" />
<div> your browser is old. <a href="cohagenPhoneCall.mp4">download this video instead.</a> </div>
</video>
2、必填項屬性<input
type="text" name="someInput" required="required">
加上required屬性即爲必填項,無須再通過JS寫驗證
3、直接使用正則表達式<input
id="username" type="text" name="username" placeholder="4 <> 10" required="required" autofocus="autofocus" pattern="[A-Za-z]{4,10}">
可以直接在pattern屬性中書寫正則表達式,無須再通過JS去匹配
4、郵箱驗證<input
id="email" type="email" name="email">新增email類型,無需再通過JS去驗證郵箱格式
6、可以不用雙引號<h6
id=someid class=myclass> start the reactor. </h6>設置ID和樣式時可省略""這種寫法了
7......
8......
9......
總言之,html5在xhtml的基礎上新增了部分標記,擴展了一些原來標記的屬性和類型。從而達到使開發更輕鬆省事,頁面更美觀,簡潔