学习资源:

HTML5设计原理:http://www.cn-cuckoo.com/2010/10/21/the-design-of-html5-2151.html 很棒的文章..

HTMLppt简介:http://directguo.com/html5/

HTML5支持情况:http://www.findmebyip.com/litmus

w3school教:http://www.w3school.com.cn/html5/html_5_intro.asp

HTML DEMO:http://html5demos.com/

官方文档: http://dev.w3.org/html5/spec/

某技术blog:http://blog.sina.com.cn/s/articlelist_1792358825_0_1.html

1.浏览器兼容

  • IE就是为操蛋存在的,不得不为他进行必要的牺牲
  • 利用IE的奇怪特性,如果DOM字典里不存在此标签,可使用js的document.createElement来创建,它就会添加到DOM字典里即可识别;
    (function(){if(!
    /*@cc_on!@*/0){return }var e="abbr,article,aside,audio,canvas,datalist,details,dialog,eventsource,figure,footer,header,hgroup,mark,menu,meter,nav,output,progress,section,time,video".split(","),i=e.length;while(i--){document.createElement(e[i])}})();
  • 可参考google code:http://code.google.com/p/html5shiv/ 添加:
    <!--[if lt IE 9]>
    <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    淘宝使用的也是这个只是添加注释的时候
    <!--[if IE]>
    <script src="http://a.tbcdn.cn/p/fp/2011a/html5.js"></script>
    <![endif]--> 

2.建立HTML5文档:

  • DOCTYPE:<!DOCTYPE HTML>
  • 编码: <meta charset="gbk/UTF-8">
  • 经常见到源码中添加:<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> edge是确保了IE浏览器(IE9)或更高版本使用的是标准兼容模式.chrome是干什么的???: google: 自动开启Chrome Frame的功能 http://www.cnbeta.com/articles/94346.htm

3.一些意义标签

  • figure:
    标签用于对元素进行组合。 例如:
    <figure>
    <figcaption>PRC</figcaption>
    <p>The People's Republic of China was born in 1949...</p>
    </figure>
    <figure>
    <img alt="About image" src="path/to/image"> 
    <figcaption>
    <h6>This is an image of something interesting. </h6>
    </figcaption>
    </figure> 
  • header:
    定义文档的页眉;
  • nav:
    标签定义导航链接的部分。 
  • section:
    定义文档的一节、段。使用中常使用section来给文档分为不同的部分,section中可以有header、nav、article,footer等意义标签
  • footer:
    文档、段落section的脚注部分;
  • hgroup:
    标签用于对 section 或 网页 的标题进行组合,使用 figcaption 元素为元素组添加标题。 
  • time:
    标签定义日期或时间,或者两者。 
  • article,aside:
    定义片段中的内容和外部相关内容, article,aside中可以包含section等等在片段展示........http://www.whatwg.org/specs/web-apps/current-work/multipage/sections.html#the-article-element 

4.html5元素布局页面:
淘宝:
 

某blog模板:

百度经验http://jingyan.baidu.com/:
 

5.表单元素:
pp:http://www.oneflash.net/2010/04/html5-form-valid/ 

html5丰富了表单元素,来扩展input元素输入,如果浏览器不支持默认为text,所以使用中不会太大影响:
Email:<input type='email'  /> ,如果输入格式错误有提示如opera下:

number:<input type='number' min="0" max="100" />;鼠标可以选择数字,如果输入的数字范围错误有提示错误消息

url:<input type='url'  /> 

range:<input type="range" min='0' max='123' />

detalist: input元素的list属性和datalist的id属性相对,datalist里德option形成输入下拉提示 label出现在提示的右边如下图
 
Webpage: <input type="url" list="url_list" name="link" />
<datalist id="url_list">
<option label="Microsoft" value="http://www.microsoft.com" />
<option label="Google" value="http://www.google.com" />
<option label="W3School" value="http://www.w3school.com.cn" />
</datalist>
 
6.表单元素的新增属性:
1.autofocus:autofocus="autofocus";使其input元素自动获得焦点,当有多个元素使用此属性的时候默认为最后一个有效;
2. autocompute: autocomplete="on/off",此属性也适合与from标签,如果使用于from标签此此内的元素都会使用此属性,可以在特定的标签中使用off使其关闭此功能;

3.from: from="from_id",其值为某个from的id;如果此input表单适用于多个from可以使用空格分隔;
4.list:规定输入域的id,5楼有;
5. min,max,step:用于number类型的input,如<input type="number" min="0" max="10" step="3"/> 其中step属性决定了此表单数字,此表单只能输入0 3 6 9 ;
6. multiple: 规定输入域中可以输入多个值; 如用于type=“file”的时候可以一次选择多个文件进行上传;
7. novalidate: from标签的属性,规定了其下的input标签是否用于验证;
8.pattern: 其值为正则表达式 可以用于验证输入的值是否正确;如: <input type="text" pattern="[A-z]{3}"/> title="sssss" /> 其中title有个作用是当输入错误的时候进行提示;
9.placeholder: 很喜欢的一个属性,用于text等输入类型; 也可以用于textarea;
10.required: 规定是否是必填项目; 

posted on 2011-02-15 11:13  星光~  阅读(385)  评论(0编辑  收藏  举报