首页 > 技术文章 > htm5

liner730 2015-07-11 11:00 原文

  htm5在html4.0、 xhtm1.0的基础上增加了音频、视频、拖拽等功能,不过,htmL5,还在完善中,不过大部分浏览器都已经支持了部分功能。

兼容性:


最新版本的 Safari、Chrome、Firefox 以及 Opera 支持某些 HTML5 特性。Internet Explorer 9 将支持某些 HTML5 特性。



header标签定义文档的页眉。

nav 标签定义导航链接的部分。

footer 标签定义页脚。

它们和之前的DIV差不多,但是这样更加有利于搜索引擎搜索到。

 

article定义标签定义独立的内容 

<article>

   <a href="http://www.apple.com">Safari 5 released</a><br /   7 Jun 2010. Just after the announcement of the new iPhone 4 at WWDC,    Apple announced the release of Safari 5 for Windows and Mac......

</article>

 

section标签定义文档中的节 

  <section>     

<h1>PRC</h   

  <p>The People's Republic of China was born in 1949...</p> 

  </section>

 

 

datalist 定义下拉列表,必须加上input

<input type="text" list="cars" />
<datalist id="cars">
  <option >1</option>
  <option >2</option>
  <option >3</option>
</datalist>
progress 表示下载进度

<progress max="100" value="50"></progress>

<time> 标签定义公历的时间

<p>我们在每天早上 <time>9:00</time> 开始营业。</p>

audio定义音频
<audio src="someaudio.wav">
您的浏览器不支持 audio 标签。
</audio>

如果不支持,则显示里面的内容



video标签定义视频

<video src="movie.ogg" controls="controls">
您的浏览器不支持 video 标签。
</video>

如果不支持,则显示里面的内容

HTML5 的新的表单属性

autocomplete 属性规定 form 或 input 域应该拥有自动完成功能。

E-mail: <input type="email" name="email"/>
自动实现邮箱的验证

required 属性规定必须在提交之前填写输入域(不能为空)。

Name: <input type="text" name="usr_name" required="required" />

placeholder 属性提供一种提示,输入域所期待的值。获得焦点后,消失。
<input type="search" name="user_search"  placeholder="Search W3School" />


autofocus 属性规定在页面加载时,域自动地获得焦点。(程序最先出现的,执行最先出现的。)
User name: <input type="text" name="user_name"  autofocus="autofocus" />


novalidate 属性规定在提交表单时不应该验证 form 或 input 域。
 <form action="demo_form.asp" method="get" novalidate="true">
    E-mail: <input type="email" name="user_email" />
    <input type="submit" />
    </form>


pattern属性规定用于验证 input 域的模式

表示只能输入A-z,只能是3位数。
    Country code: <input type="text" name="country_code"
     pattern="[A-z]{3}" title="Three letter country code" />

在购物车,添加数量的时候,可以用到添加、减少数量
    name:<input type="number" min="1" max="10"/>

推荐阅读