<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet href='http://feed.feedsky.com/styles/temp01.xsl' type='text/xsl' ?><!--这是一个由Feedsy提供技术支持的Feed，为了提高读者阅读的体验，以及满足用户美化自己Feed的需要，我们设计了多种精美的Feed模板，提供给大家选择，所有最终呈现出来的样式，皆由用户自愿选择使用，未经许可，任何团体和个人，请不要擅自修改样式或者盗用，这是对于用户选择权的尊重。--><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:fs="http://www.feedsky.com/namespace/feed" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link href="http://feed.feedsky.com/cssrainbow" type="application/rss+xml" rel="self"></atom:link><fs:self_link href="http://feed.feedsky.com/cssrainbow" type="application/rss+xml"></fs:self_link><lastBuildDate>Sat, 31 Dec 2011 10:28:47 GMT</lastBuildDate><title>blog.moocss.com</title><description>关注Web前端技术，重视Web标准和Web性能优化。</description><image><url>http://www.feedsky.com/feed/cssrainbow/sc/gif</url><title>blog.moocss.com</title><link>http://blog.moocss.com</link></image><link>http://blog.moocss.com</link><sy:updatePeriod>hourly</sy:updatePeriod><sy:updateFrequency>1</sy:updateFrequency><language>en</language><pubDate>Sat, 31 Dec 2011 10:28:47 GMT</pubDate><item><title>坚持，改变，像树一样成长！2012…</title><link>http://item.feedsky.com/~feedsky/cssrainbow/~8577171/592315284/5452281/1/item.html</link><content:encoded>&lt;p&gt;2011是成长的一年！失落，迷茫，一直伴随着我!  收尾一点也不华丽！&lt;/p&gt;
&lt;p&gt;来个总结：&lt;/p&gt;
&lt;p&gt;Web前端规范年前就开始整理总结了，整个体系算是建立起来了，已经完成90%了，是一个不小的成果，为我后来的工作带来了不小的改变！不过随着时间的流逝，也有了更多的想法，没有整理成文档！希望元旦来了，都加上，再出一个新的版本，下一步，就是在团队里分享，更重要的是想让程序员也了解前端规范和WEB标准的重要性！这样一来就可以减轻联调时前端人员的负担！同时也能够提高公司产品的质量和维护的成本!&lt;/p&gt;
&lt;p&gt;HTML5 ,CSS3 ,nodejs, 前端MVC，等很火，移动开发也很火。但我最想提高的还是JavaScript的水平，一拖再拖没有完成学习目标！有点失落！&lt;/p&gt;
&lt;p&gt;一直想触摸，但没有触摸的dojo在ArcGIS的开发项目中小试了一把，感觉非常好，的确强大，感觉国内使用的人还是很少，当时解问题的时候，找到的中文资料很少，不过英文资料非常多，所有的问题都在英文资料中得到了解决，同时也开发出了不错产品，得到了大家的奖励！&lt;/p&gt;
&lt;p&gt;最后，来年的想法是加强Java和Scala的学习，因为我想再次改行回去，本来就是搞JavaWeb开发的，不想丢掉它，主要原因是前端这块儿在西安的重视程度不高，完全是靠自己自学，能交流的人也很少，搞到最后就遇到瓶颈了，无法突破自己，整日惶恐不安！&lt;/p&gt;
&lt;p&gt;最后我想说的是“我爱Web前端，但我更爱Java！”&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h3  class=&quot;related-posts-title&quot;&gt;相关日志 »&lt;/h3&gt;&lt;ul class=&quot;related-list&quot;&gt;&lt;li&gt;暂无相关日志&lt;/li&gt;&lt;/ul&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/592291808/moocss/feedsky/s.gif?r=http://blog.moocss.com/articles/experience-ideas/1709.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</content:encoded><wfw:commentRss>http://blog.moocss.com/articles/experience-ideas/1709.html/feed</wfw:commentRss><slash:comments>0</slash:comments><fs:srclink>http://blog.moocss.com/articles/experience-ideas/1709.html</fs:srclink><fs:srcfeed>http://feed.moocss.com/</fs:srcfeed><fs:itemid>feedsky/cssrainbow/~8577171/592315284/5452281</fs:itemid><description>2011是成长的一年！失落，迷茫，一直伴随着我!  收尾一点也不华丽！ 来个总结： Web前端规范年前就开始整理总结了，整个体系算是建立起来了，已经完成90%了，是一个不小的成果，为我后来的工作带来了不小的改变！不过随着时间的流逝，也有了更多的想法，没有整理成文档！希望元旦来了，都加上，再出一个新的版本，下一步，就是在团队里分享，更重要的是想让程序员也了解前端规范和WEB标准的重要性！这样一来就可以减轻联调时前端人员的负担！同时也能够提高公司产品的质量和维护的成本! HTML5 ,CSS3 ,nodejs, 前端MVC，等很火，移动开发也很火。但我最想提高的还是JavaScript的水平，一拖再拖没有完成学习目标！有点失落！ 一直想触摸，但没有触摸的dojo在ArcGIS的开发项目中小试了一把，感觉非常好，的确强大，感觉国内使用的人还是很少，当时解问题的时候，找到的中文资料很少，不过英文资料非常多，所有的问题都在英文资料中得到了解决，同时也开发出了不错产品，得到了大家的奖励！ 最后，来年的想法是加强Java和Scala的学习，因为我想再次改行回去，本来就是搞JavaWeb开发的，不想丢掉它，主要原因是前端这块儿在西安的重视程度不高，完全是靠自己自学，能交流的人也很少，搞到最后就遇到瓶颈了，无法突破自己，整日惶恐不安！ 最后我想说的是“我爱Web前端，但我更爱Java！” &amp;#160; &amp;#160; 相关日志 »暂无相关日志&lt;img src=&quot;http://www1.feedsky.com/t1/592291808/moocss/feedsky/s.gif?r=http://blog.moocss.com/articles/experience-ideas/1709.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>心得与思想</category><pubDate>Sat, 31 Dec 2011 18:28:47 +0800</pubDate><author>Rainbow</author><comments>http://blog.moocss.com/articles/experience-ideas/1709.html#comments</comments><guid isPermaLink="false">http://blog.moocss.com/?p=1709</guid><dc:creator>Rainbow</dc:creator></item><item><title>如何定义IE的文档兼容模式</title><link>http://item.feedsky.com/~feedsky/cssrainbow/~8577171/592315285/5452281/1/item.html</link><content:encoded>&lt;p&gt;由于现在IE浏览器的多个版本共存，同时浏览器的升级也给我们的老项目带来了不可预测的风险。浏览器的兼容性问题开始困扰我们的在线项目了。&lt;/p&gt;
&lt;p&gt;还好，微软的给我们的解决方案是设置X-UA-Compatible。&lt;/p&gt;
&lt;p&gt;X-UA-Compatible是自从IE8新加的一个设置，对于IE8以下的浏览器是不识别的。&lt;/p&gt;
&lt;p&gt;很多网站为了方便让页面在IE8/9下降级成显示为IE7就使用了X-UA-Compatible 。&lt;/p&gt;
&lt;p&gt;IE8刚开始推出的时候跟IE7有不少不同，所以为了避免制作出的页面在IE8下面出现错误，建议直接将IE8使用IE7进行渲染。这一做法过于方便，以至于现在太多网站声明了使用IE7引擎来解析页面。&lt;/p&gt;
&lt;h2&gt;语法：&lt;/h2&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;meta&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;http-equiv&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;X-UA-Compatible&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;content&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;IE=7&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;以上代码告诉IE浏览器，无论是否用DTD声明文档标准，IE8/9都会以IE7引擎来渲染页面。&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;meta&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;http-equiv&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;X-UA-Compatible&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;content&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;IE=8&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;以上代码告诉IE浏览器，IE8/9都会以IE8引擎来渲染页面。&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;meta&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;http-equiv&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;X-UA-Compatible&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;content&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;edge&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;以上代码告诉IE浏览器，Windows以最高版本的IE显示内容。&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;meta&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;http-equiv&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;X-UA-Compatible&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;content&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;IE=EmulateIE7&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;
以上代码告诉IE浏览器，根据 &amp;lt;!DOCTYPE&amp;gt; 指令确定如何呈现内容。标准模式指令以Windows Internet Explorer 7 标准模式显示，而 Quirks 模式指令以 IE5 模式显示。与 IE7 模式不同，EmulateIE7 模式遵循 &amp;lt;!DOCTYPE&amp;gt; 指令。对于多数网站来说，它是首选的兼容性模式。
&lt;/p&gt;
&lt;blockquote&gt;
&lt;h5&gt;注意X-UA-Compatible放置的位置，MSDN《&lt;a href=&quot;http://msdn.microsoft.com/zh-cn/library/cc288325%28VS.85%29.aspx&quot;&gt;定义文档兼容性&lt;/a&gt;》中是这样说的：&lt;/h5&gt;
&lt;p&gt;The X-UA-compatible header is not case sensitive; however, it must appear in the Web page&amp;rsquo;s header (the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms535252%28v=VS.85%29.aspx&quot;&gt;HEAD section&lt;/a&gt;) before all other elements, except for the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms535910%28v=VS.85%29.aspx&quot;&gt;title&lt;/a&gt; element and other &lt;strong&gt;meta&lt;/strong&gt;elements.&lt;/p&gt;
&lt;p&gt;X-UA-compatible 标头不区分大小写；不过，它必须显示在网页中除 &lt;a href=&quot;http://msdn.microsoft.com/library/ms535910.aspx&quot;&gt;title&lt;/a&gt; 元素和其他 meta 元素以外的所有其他元素之前的标头（&lt;a href=&quot;http://msdn.microsoft.com/library/ms535252.aspx&quot;&gt;HEAD 节（可能为英文网页）&lt;/a&gt;）中。&lt;/p&gt;&lt;/blockquote&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;例如下面正确的例子：&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #00bbdd;&quot;&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;html&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;head&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;meta&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;charset&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;meta&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;http-equiv&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;X-UA-Compatible&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;content&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;IE=IE7,IE9&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;title&lt;/span&gt;&amp;gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;title&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;link&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;rel&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;shortcut icon&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;/favicon.ico&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;image/x-icon&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;link&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;rel&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;icon&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;/favicon.ico&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;image/x-icon&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;link&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;rel&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;stylesheet&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;...&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;script&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;...&amp;quot;&lt;/span&gt;&amp;gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;script&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;head&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;body&lt;/span&gt;&amp;gt;&lt;/span&gt;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--网页主体--&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;body&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;html&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;被杯具的用法：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
5
6
7
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;meta&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;charset&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;title&lt;/span&gt;&amp;gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;title&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;link&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;rel&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;shortcut icon&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;/favicon.ico&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;image/x-icon&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;link&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;rel&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;icon&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;/favicon.ico&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;image/x-icon&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;link&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;rel&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;stylesheet&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;...&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;meta&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;http-equiv&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;X-UA-Compatible&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;content&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;IE=IE7,IE9&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;script&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;...&amp;quot;&lt;/span&gt;&amp;gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;script&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;对于用上IE9/IE10的人，想跳过IE8，指定在IE7和IE9中渲染，得使用了&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/cc288325(v=vs.85).aspx&quot;&gt;MSDN文档&lt;/a&gt;推荐的语法：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;meta&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;http-equiv&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;X-UA-Compatible&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;content&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;IE=7;IE=9&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;但是，以上兼容IE7/IE9的语法方式，会在IE8里会导致BUG，发现在IE8下并没有以IE7的文档模式来渲染页面。&lt;/p&gt;
&lt;h2&gt;正确的语法规则：&lt;/h2&gt;
&lt;h3&gt;1.定义多种文档模式时，使用逗号（,），而非文档中提到的分号（;） 。&lt;/h3&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;meta&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;http-equiv&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;X-UA-Compatible&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;content&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;IE=7,IE=9&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;
/*或者是*/
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;meta&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;http-equiv&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;X-UA-Compatible&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;content&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;IE=EmulateIE7,IE=EmulateIE9&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;2.或者以逗号升序连写的方式&lt;/h3&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;meta&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;http-equiv&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;X-UA-Compatible&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;content&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;IE=7,9&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;最后我们看一下&lt;a class=&quot;button&quot; href=&quot;http://emological.com/ie/&quot;&gt;书写方式测试&lt;/a&gt;&lt;/p&gt;
&lt;h3  class=&quot;related-posts-title&quot;&gt;相关日志 »&lt;/h3&gt;&lt;ul class=&quot;related-list&quot;&gt;&lt;li&gt;2011/01/05 -- &lt;a href=&quot;http://blog.moocss.com/code-snippets/html-css-code-snippets/1408.html&quot; title=&quot;注意你的button标签type的默认属性值&quot;&gt;注意你的button标签type的默认属性值&lt;/a&gt; (0)&lt;/li&gt;&lt;li&gt;2011/10/07 -- &lt;a href=&quot;http://blog.moocss.com/tutorials/html5-css3-tutorials/1661.html&quot; title=&quot;HTML5的Web标准实战&quot;&gt;HTML5的Web标准实战&lt;/a&gt; (10)&lt;/li&gt;&lt;li&gt;2011/03/21 -- &lt;a href=&quot;http://blog.moocss.com/code-snippets/html-css-code-snippets/1551.html&quot; title=&quot;一些有用的Web前端开发技巧&quot;&gt;一些有用的Web前端开发技巧&lt;/a&gt; (1)&lt;/li&gt;&lt;li&gt;2010/09/16 -- &lt;a href=&quot;http://blog.moocss.com/tutorials/html-css-tutorials/1381.html&quot; title=&quot; 无JavaScript实现内容切换效果 &quot;&gt; 无JavaScript实现内容切换效果 &lt;/a&gt; (3)&lt;/li&gt;&lt;li&gt;2010/08/17 -- &lt;a href=&quot;http://blog.moocss.com/code-snippets/html-css-code-snippets/1360.html&quot; title=&quot;IE CSS Bug Table&quot;&gt;IE CSS Bug Table&lt;/a&gt; (1)&lt;/li&gt;&lt;li&gt;2010/04/15 -- &lt;a href=&quot;http://blog.moocss.com/code-snippets/html-css-code-snippets/1234.html&quot; title=&quot;CSS中区别IE6, IE7和 IE8  的4个非常有用的字符&quot;&gt;CSS中区别IE6, IE7和 IE8  的4个非常有用的字符&lt;/a&gt; (1)&lt;/li&gt;&lt;li&gt;2010/03/09 -- &lt;a href=&quot;http://blog.moocss.com/code-snippets/html-css-code-snippets/1147.html&quot; title=&quot;IE CSS Bugs 列表和解决方法&quot;&gt;IE CSS Bugs 列表和解决方法&lt;/a&gt; (2)&lt;/li&gt;&lt;li&gt;2010/03/04 -- &lt;a href=&quot;http://blog.moocss.com/tutorials/html-css-tutorials/1137.html&quot; title=&quot;Web 设计中的 5 个最具争议性的话题&quot;&gt;Web 设计中的 5 个最具争议性的话题&lt;/a&gt; (0)&lt;/li&gt;&lt;li&gt;2010/03/02 -- &lt;a href=&quot;http://blog.moocss.com/code-snippets/html-css-code-snippets/1130.html&quot; title=&quot;IE条件注释与CSS Hacks&quot;&gt;IE条件注释与CSS Hacks&lt;/a&gt; (5)&lt;/li&gt;&lt;li&gt;2009/09/15 -- &lt;a href=&quot;http://blog.moocss.com/tutorials/html5-css3-tutorials/718.html&quot; title=&quot;漫画：混乱的标记语言XHTML2/HTML5&quot;&gt;漫画：混乱的标记语言XHTML2/HTML5&lt;/a&gt; (0)&lt;/li&gt;&lt;/ul&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/592291809/moocss/feedsky/s.gif?r=http://blog.moocss.com/tutorials/html-css-tutorials/1703.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</content:encoded><wfw:commentRss>http://blog.moocss.com/tutorials/html-css-tutorials/1703.html/feed</wfw:commentRss><slash:comments>0</slash:comments><fs:srclink>http://blog.moocss.com/tutorials/html-css-tutorials/1703.html</fs:srclink><fs:srcfeed>http://feed.moocss.com/</fs:srcfeed><fs:itemid>feedsky/cssrainbow/~8577171/592315285/5452281</fs:itemid><description>由于现在IE浏览器的多个版本共存，同时浏览器的升级也给我们的老项目带来了不可预测的风险。浏览器的兼容性问题开始困扰我们的在线项目了。 还好，微软的给我们的解决方案是设置X-UA-Compatible。 X-UA-Compatible是自从IE8新加的一个设置，对于IE8以下的浏览器是不识别的。 很多网站为了方便让页面在IE8/9下降级成显示为IE7就使用了X-UA-Compatible 。 IE8刚开始推出的时候跟IE7有不少不同，所以为了避免制作出的页面在IE8下面出现错误，建议直接将IE8使用IE7进行渲染。这一做法过于方便，以至于现在太多网站声明了使用IE7引擎来解析页面。 语法： &amp;#60;meta http-equiv=&amp;#34;X-UA-Compatible&amp;#34; content=&amp;#34;IE=7&amp;#34; /&amp;#62; 以上代码告诉IE浏览器，无论是否用DTD声明文档标准，IE8/9都会以IE7引擎来渲染页面。 &amp;#60;meta http-equiv=&amp;#34;X-UA-Compatible&amp;#34; content=&amp;#34;IE=8&amp;#34; /&amp;#62; 以上代码告诉IE浏览器，IE8/9都会以IE8引擎来渲染页面。 &amp;#60;meta http-equiv=&amp;#34;X-UA-Compatible&amp;#34; content=&amp;#34;edge&amp;#34; /&amp;#62; 以上代码告诉IE浏览器，Windows以最高版本的IE显示内容。 &amp;#60;meta http-equiv=&amp;#34;X-UA-Compatible&amp;#34; content=&amp;#34;IE=EmulateIE7&amp;#34; /&amp;#62; 以上代码告诉IE浏览器，根据 &amp;#60;!DOCTYPE&amp;#62; 指令确定如何呈现内容。标准模式指令以Windows Internet Explorer 7 标准模式显示，而 Quirks 模式指令以 IE5 模式显示。与 IE7 模式不同，EmulateIE7 模式遵循 &amp;#60;!DOCTYPE&amp;#62; 指令。对于多数网站来说，它是首选的兼容性模式。 注意X-UA-Compatible放置的位置，MSDN《定义文档兼容性》中是这样说的： The X-UA-compatible header is not case sensitive; however, it must appear in [...]&lt;img src=&quot;http://www1.feedsky.com/t1/592291809/moocss/feedsky/s.gif?r=http://blog.moocss.com/tutorials/html-css-tutorials/1703.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>HTML / CSS</category><category>X-UA-Compatible</category><category>CSS Hack</category><category>HTML</category><pubDate>Sun, 11 Dec 2011 18:31:18 +0800</pubDate><author>Rainbow</author><comments>http://blog.moocss.com/tutorials/html-css-tutorials/1703.html#comments</comments><guid isPermaLink="false">http://blog.moocss.com/?p=1703</guid><dc:creator>Rainbow</dc:creator></item><item><title>LESS的多种运行方式</title><link>http://item.feedsky.com/~feedsky/cssrainbow/~8577171/592315286/5452281/1/item.html</link><content:encoded>&lt;blockquote&gt;
&lt;h5&gt;LESS是一种动态样式语言。&lt;/h5&gt;
&lt;p&gt;LESS 将 CSS 赋予了动态语言的特性，如 变量， 继承， 运算， 函数. LESS 既可以在 客户端 上运行 (支持IE 6+, Webkit, Firefox)，也可一在服务端运行 (借助 Node.js).&lt;/p&gt;
&lt;p&gt;中文官网:&lt;a href=&quot;http://www.lesscss.net/&quot;&gt;http://www.lesscss.net/&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;虽然我们已经有了自己的公共样式类库，每一个样式类都具有单一性的作用，但是远远不够的，我们的代码看上去还是那么臃肿的，大量的样式属性，还是在多个地方重复出现，样式文件由于重复而过于庞大。&lt;/p&gt;
&lt;p&gt;这个时候，我们就可以使用LESS管理你的CSS，高效、可维护的代码就指日可待了。&lt;/p&gt;
&lt;p&gt;今天要说的是LESS的多种运行方式。&lt;/p&gt;
&lt;h2&gt;一. 客户端上编译。&lt;/h2&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;		&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;link&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;rel&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;stylesheet/less&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text/css&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;styles.less&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;script&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;less.js&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&amp;gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;script&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;注意你写好的.less文件必须在less.js之前，不然无法解析。&lt;/p&gt;
&lt;h2&gt;二. linux node下编译。&lt;/h2&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;/* linux下开发，当你保存的时候，lesstocss将你的less文件自动编译成css文件
* 用法： node lesstocss [filename1,filename2,...]
* version: v0.1
* by 飞长(veryued.org)
**/&lt;/span&gt;
&lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;//设置lessc路径&lt;/span&gt;
&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; lessc &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'~/git/less.js/bin/lessc'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; util &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; require&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'util'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;
    fs &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; require&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'fs'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;
    exec  &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; require&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'child_process'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;exec&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;//获取屏幕输入参数数组&lt;/span&gt;
&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; filenames &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; process.&lt;span style=&quot;color: #660066;&quot;&gt;argv&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;slice&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #CC0000;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
filenames.&lt;span style=&quot;color: #660066;&quot;&gt;forEach&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;val&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; index&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; array&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;filename&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; tempTime&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
        fs.&lt;span style=&quot;color: #660066;&quot;&gt;watchFile&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;''&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt;filename&lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'.less'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;curr&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;prev&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
            &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; child &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; exec&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'stat '&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt;filename&lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'.less | grep Modify'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;
                &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;error&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; stdout&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; stderr&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
                    &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;tempTime &lt;span style=&quot;color: #339933;&quot;&gt;!=&lt;/span&gt; stdout&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
                        console.&lt;span style=&quot;color: #660066;&quot;&gt;log&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;''&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt;filename&lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'.less changed'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
                        &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; lesschild &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; exec&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;''&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt;lessc&lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;' '&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt;filename&lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'.less &amp;gt; '&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt;filename&lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'.css'&lt;/span&gt;
                            &lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;erro&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;stdout&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;stderr&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
                            console.&lt;span style=&quot;color: #660066;&quot;&gt;log&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;stdout&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
                            &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;erro &lt;span style=&quot;color: #339933;&quot;&gt;!==&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
                                console.&lt;span style=&quot;color: #660066;&quot;&gt;log&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'exec erro: '&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt; erro&lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt;stderr&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
                            &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;
                        &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
                        tempTime &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; stdout&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
                    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;
                &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;error &lt;span style=&quot;color: #339933;&quot;&gt;!==&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
                    console.&lt;span style=&quot;color: #660066;&quot;&gt;log&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'exec error: '&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt; error&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
                &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;
            &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
        &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;val&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;此解决方案来自“飞长&amp;#8217;s Blog”的《&lt;a href=&quot;http://www.veryued.org/2011/11/linux%e4%b8%8bless%e5%bc%80%e5%8f%91%e5%ae%9e%e6%97%b6%e7%bc%96%e8%af%91%e5%b7%a5%e5%85%b7-by-node/&quot;&gt;linux下less开发实时编译工具 by node》文章&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;三. 使用lessphp 编译LESS 。&lt;/h2&gt;
&lt;p&gt;lessphp 是使用php写的类来编译LESS 。&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;官网地址：&lt;a href=&quot;http://leafo.net/lessphp/&quot;&gt;http://leafo.net/lessphp/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;项目托管：&lt;a href=&quot;https://github.com/leafo/lessphp&quot;&gt;https://github.com/leafo/lessphp&lt;/a&gt; &lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;四. 使用LESS for Java&lt;/h2&gt;
&lt;blockquote&gt;&lt;p&gt;官网地址: &lt;a href=&quot;http://www.asual.com/lesscss/&quot;&gt;http://www.asual.com/lesscss/&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3  class=&quot;related-posts-title&quot;&gt;相关日志 »&lt;/h3&gt;&lt;ul class=&quot;related-list&quot;&gt;&lt;li&gt;2011/09/27 -- &lt;a href=&quot;http://blog.moocss.com/code-snippets/html-css-code-snippets/1664.html&quot; title=&quot;你须知道的30个CSS选择器&quot;&gt;你须知道的30个CSS选择器&lt;/a&gt; (5)&lt;/li&gt;&lt;li&gt;2011/08/09 -- &lt;a href=&quot;http://blog.moocss.com/code-snippets/html-css-code-snippets/1617.html&quot; title=&quot;DIV 高度100%&quot;&gt;DIV 高度100%&lt;/a&gt; (1)&lt;/li&gt;&lt;li&gt;2010/11/09 -- &lt;a href=&quot;http://blog.moocss.com/code-snippets/html-css-code-snippets/1406.html&quot; title=&quot;文字垂直排版&quot;&gt;文字垂直排版&lt;/a&gt; (1)&lt;/li&gt;&lt;li&gt;2010/11/04 -- &lt;a href=&quot;http://blog.moocss.com/tutorials/html-css-tutorials/1403.html&quot; title=&quot;CSS三角形的一些应用&quot;&gt;CSS三角形的一些应用&lt;/a&gt; (0)&lt;/li&gt;&lt;li&gt;2010/10/10 -- &lt;a href=&quot;http://blog.moocss.com/code-snippets/html-css-code-snippets/1390.html&quot; title=&quot;图片(水平垂直)居中&quot;&gt;图片(水平垂直)居中&lt;/a&gt; (0)&lt;/li&gt;&lt;li&gt;2010/09/16 -- &lt;a href=&quot;http://blog.moocss.com/tutorials/html-css-tutorials/1381.html&quot; title=&quot; 无JavaScript实现内容切换效果 &quot;&gt; 无JavaScript实现内容切换效果 &lt;/a&gt; (3)&lt;/li&gt;&lt;li&gt;2010/09/02 -- &lt;a href=&quot;http://blog.moocss.com/code-snippets/html-css-code-snippets/1375.html&quot; title=&quot;图像替换技术的最佳实战&quot;&gt;图像替换技术的最佳实战&lt;/a&gt; (3)&lt;/li&gt;&lt;li&gt;2010/04/15 -- &lt;a href=&quot;http://blog.moocss.com/code-snippets/html-css-code-snippets/1234.html&quot; title=&quot;CSS中区别IE6, IE7和 IE8  的4个非常有用的字符&quot;&gt;CSS中区别IE6, IE7和 IE8  的4个非常有用的字符&lt;/a&gt; (1)&lt;/li&gt;&lt;li&gt;2010/03/04 -- &lt;a href=&quot;http://blog.moocss.com/tutorials/html-css-tutorials/1137.html&quot; title=&quot;Web 设计中的 5 个最具争议性的话题&quot;&gt;Web 设计中的 5 个最具争议性的话题&lt;/a&gt; (0)&lt;/li&gt;&lt;li&gt;2010/01/26 -- &lt;a href=&quot;http://blog.moocss.com/tutorials/html-css-tutorials/1033.html&quot; title=&quot;网页设计中的面包屑导航：实例和最佳做法&quot;&gt;网页设计中的面包屑导航：实例和最佳做法&lt;/a&gt; (0)&lt;/li&gt;&lt;/ul&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/592291810/moocss/feedsky/s.gif?r=http://blog.moocss.com/tutorials/html-css-tutorials/1701.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</content:encoded><wfw:commentRss>http://blog.moocss.com/tutorials/html-css-tutorials/1701.html/feed</wfw:commentRss><slash:comments>0</slash:comments><fs:srclink>http://blog.moocss.com/tutorials/html-css-tutorials/1701.html</fs:srclink><fs:srcfeed>http://feed.moocss.com/</fs:srcfeed><fs:itemid>feedsky/cssrainbow/~8577171/592315286/5452281</fs:itemid><description>LESS是一种动态样式语言。 LESS 将 CSS 赋予了动态语言的特性，如 变量， 继承， 运算， 函数. LESS 既可以在 客户端 上运行 (支持IE 6+, Webkit, Firefox)，也可一在服务端运行 (借助 Node.js). 中文官网:http://www.lesscss.net/ 虽然我们已经有了自己的公共样式类库，每一个样式类都具有单一性的作用，但是远远不够的，我们的代码看上去还是那么臃肿的，大量的样式属性，还是在多个地方重复出现，样式文件由于重复而过于庞大。 这个时候，我们就可以使用LESS管理你的CSS，高效、可维护的代码就指日可待了。 今天要说的是LESS的多种运行方式。 一. 客户端上编译。 1 2 &amp;#60;link rel=&amp;#34;stylesheet/less&amp;#34; type=&amp;#34;text/css&amp;#34; href=&amp;#34;styles.less&amp;#34;&amp;#62; &amp;#60;script src=&amp;#34;less.js&amp;#34; type=&amp;#34;text/javascript&amp;#34;&amp;#62;&amp;#60;/script&amp;#62; 注意你写好的.less文件必须在less.js之前，不然无法解析。 二. linux node下编译。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 [...]&lt;img src=&quot;http://www1.feedsky.com/t1/592291810/moocss/feedsky/s.gif?r=http://blog.moocss.com/tutorials/html-css-tutorials/1701.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>HTML / CSS</category><category>前端资源</category><category>CSS</category><category>LESS</category><pubDate>Sun, 04 Dec 2011 17:08:25 +0800</pubDate><author>Rainbow</author><comments>http://blog.moocss.com/tutorials/html-css-tutorials/1701.html#comments</comments><guid isPermaLink="false">http://blog.moocss.com/?p=1701</guid><dc:creator>Rainbow</dc:creator></item><item><title>无障碍实战 之 视觉隐藏内容</title><link>http://item.feedsky.com/~feedsky/cssrainbow/~8577171/592315287/5452281/1/item.html</link><content:encoded>&lt;blockquote&gt;
&lt;p&gt;原文来自：&lt;a href=&quot;http://www.topcss.org/?p=418&quot;&gt;http://www.topcss.org/?p=418&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;作者：&lt;a href=&quot;http://www.topcss.org&quot;&gt;进步博客&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
腾讯ISUX组内做的一个分享，主题是&amp;#8221;视觉隐藏内容&amp;#8221;，主要关注隐藏的方式、方法及每种方法对可访问性的影响，并着重分析了a &amp;#038; label元素的可访问性，介绍了使用clip来做视觉隐藏。内容有点散，但主题明确，其他组的几个同事来要PPT，现在传至slideshare，错误之处，请指正。
&lt;/p&gt;
&lt;div style=&quot;width:425px&quot; id=&quot;__ss_9627439&quot;&gt; &lt;strong style=&quot;display:block;margin:12px 0 4px&quot;&gt;&lt;a href=&quot;http://www.slideshare.net/wenjul/ss-9627439&quot; title=&quot;视觉隐藏内容&quot; target=&quot;_blank&quot;&gt;视觉隐藏内容&lt;/a&gt;&lt;/strong&gt; &lt;iframe src=&quot;http://www.slideshare.net/slideshow/embed_code/9627439&quot; width=&quot;425&quot; height=&quot;355&quot; frameborder=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot; scrolling=&quot;no&quot;&gt;&lt;/iframe&gt;
&lt;div style=&quot;padding:5px 0 12px&quot;&gt; View more &lt;a href=&quot;http://www.slideshare.net/&quot; target=&quot;_blank&quot;&gt;presentations&lt;/a&gt; from &lt;a href=&quot;http://www.slideshare.net/wenjul&quot; target=&quot;_blank&quot;&gt;Lee Jace&lt;/a&gt; &lt;/div&gt;
&lt;/p&gt;&lt;/div&gt;
&lt;h2&gt;一. 概述&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;http://blog.moocss.com/dw-content/demo38/assets/WCAG.jpg&quot; width=&quot;883&quot; height=&quot;634&quot; alt=&quot;Web内容无障碍指南（WCAG）2.0&quot;&gt;&lt;/p&gt;
&lt;p&gt;Web内容无障碍指南（WCAG）2.0定义了如何使web内容更便于残障人士访问。它定义了web内容无障碍的四项基本原则，即可感知、可操作、可理解和健壮性，为了达到这些基本目标，每条原则之下设置了应遵循的准则，对每一个准则，提供了可测试的成功标准。&lt;/p&gt;
&lt;table width=&quot;100%&quot; height=&quot;201&quot; border=&quot;1&quot; cellpadding=&quot;1&quot; cellspacing=&quot;1&quot; dir=&quot;ltr&quot;&gt;
&lt;tr&gt;
&lt;th rowspan=&quot;4&quot; width=&quot;81&quot;&gt;内容隐藏&lt;/th&gt;
&lt;th width=&quot;252&quot;&gt;分类&lt;/th&gt;
&lt;th width=&quot;176&quot;&gt;作用&lt;/th&gt;
&lt;th width=&quot;304&quot;&gt;示例&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td width=&quot;252&quot; height=&quot;51&quot;&gt;完全隐藏&lt;/td&gt;
&lt;td width=&quot;176&quot;&gt;用户交互&lt;/td&gt;
&lt;td width=&quot;304&quot;&gt;display:none;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td width=&quot;252&quot;&gt;对屏幕阅读器隐藏&lt;/td&gt;
&lt;td width=&quot;176&quot;&gt;减少干扰&lt;/td&gt;
&lt;td width=&quot;304&quot;&gt;tabindex=&amp;ldquo;-1&amp;rdquo;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td width=&quot;252&quot;&gt;视觉隐藏&amp;#13;&lt;br /&gt;
      （对屏幕阅读器可见）&lt;/td&gt;
&lt;td width=&quot;176&quot;&gt;提供语境信息&lt;/td&gt;
&lt;td width=&quot;304&quot;&gt;text-indent:999em;&amp;#13;&lt;br /&gt;
      line-height:99;&amp;#13;&lt;br /&gt;
      &amp;#8230;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;&lt;img src=&quot;http://blog.moocss.com/dw-content/demo38/assets/example_1.JPG&quot; width=&quot;1005&quot; height=&quot;450&quot; alt=&quot;降低信息噪音，减少干扰&quot;&gt;&lt;/p&gt;
&lt;p&gt;将重复信息和为明眼用户提供的信息从屏幕阅读器访问序列中移除。&lt;/p&gt;
&lt;h3&gt;头像链接的作用：&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;明眼用户快速辨识好友，这对视障用户没有意义；&lt;/li&gt;
&lt;li&gt;链接至好友主页，与人名链接的作用一致，作用重复；&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;为了减少干扰，我们可以使用tabindex=“-1”,将头像链接从屏幕阅读器访问序列中移除。&lt;/p&gt;
&lt;h3&gt;视觉隐藏文本思路&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;1.为屏幕阅读器提供补充文本&lt;/li&gt;
&lt;li&gt;2.通过CSS隐藏这些文本&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;http://blog.moocss.com/dw-content/demo38/assets/seo-accessibility.jpg&quot; width=&quot;699&quot; height=&quot;266&quot; alt=&quot;SEO and Accessibility&quot;&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;SEO and Accessibility&lt;/li&gt;
&lt;li&gt;High Accessibility Is Effective Search Engine Optimization&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;二. 隐藏方式对可访问性的影响&lt;/h2&gt;
&lt;table width=&quot;447&quot; border=&quot;1&quot; cellpadding=&quot;1&quot; cellspacing=&quot;1&quot;&gt;
&lt;tr&gt;
&lt;th width=&quot;143&quot; rowspan=&quot;5&quot;&gt; 视觉隐藏 &lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;–纯文本&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;–label文本&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;–链接&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;–链接文本&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;h3&gt;视觉隐藏的关注点:&lt;/h3&gt;
&lt;dl&gt;
&lt;dt&gt;1. 它应使元素消失（仿佛文档中不存在该元素）&lt;/dt&gt;
&lt;dd&gt;–应该没有多余的空白、没有滚动条、不能出现与层叠相关的问题（不可点击）等。&lt;/dd&gt;
&lt;dt&gt;2. 当隐藏容器中的元素获得焦点时，应防止出现意外的滚动。&lt;/dt&gt;
&lt;dd&gt;–即当用户使用tab导航到隐藏容器内的可聚焦的元素时，网页不应该跳跃。&lt;/dd&gt;
&lt;dt&gt;3. 双向（bidi-directional ）字符集语言友好。&lt;/dt&gt;
&lt;dd&gt;–即应该同时支持从右到左，从左到右的界面，如阿拉伯文和希伯来文。&lt;/dd&gt;
&lt;/dl&gt;
&lt;h3&gt;如何检测屏幕阅读器能否访问你隐藏的内容?&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;使用键盘来访问隐藏容器内的可聚焦元素（可以在容器中添加一条链接）。&lt;/li&gt;
&lt;li&gt;如果键盘导航能够跳至隐藏容器内的元素，那么内容是可以访问的。&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;text-indent: -999em;&lt;/h3&gt;
&lt;p&gt;作用元素：文本 | inline元素&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
5
6
7
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;a&lt;span style=&quot;color: #6666ff;&quot;&gt;.hide-indent&lt;/span&gt; &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;display&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; inline-&lt;span style=&quot;color: #993333;&quot;&gt;block&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;width&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;120px&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;height&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;30px&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;text-indent&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;-10px&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;overflow&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;hidden&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;http://blog.moocss.com/dw-content/demo38/assets/ie6-7-text-indent-bug.jpg&quot; width=&quot;439&quot; height=&quot;428&quot; alt=&quot;ie6-7 and text-indent bug&quot;&gt;&lt;/p&gt;
&lt;p&gt;
IE6/IE7下，使用负缩进的方法隐藏inline-block元素内的文本，该元素也会缩进相同的值。
&lt;/p&gt;
&lt;h3&gt;存疑:&lt;/h3&gt;
&lt;p&gt;text-indent方法不适用于right-to-left 方向的语言（阿拉伯语、希伯来语 属于双向（bidi）字符集语言）。&lt;/p&gt;
&lt;h3&gt;height: 0;&lt;/h3&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
5
6
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;.hide-h0&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;width&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;height&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;overflow&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;hidden&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;display&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; inline-&lt;span style=&quot;color: #993333;&quot;&gt;block&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;apple的voice Over无法读出高度为0元素内的内容 。&lt;/p&gt;
&lt;h3&gt;Positioning content off-screen&lt;/h3&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
5
6
7
8
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;.hide-offscreen-&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;top&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;position&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;absolute&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt; 	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/*文档流中抽出*/&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;top&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #933;&quot;&gt;-9999px&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt; 			&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/*内容垂直往上移动9999px*/&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;left&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;auto&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;				&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/*水平位置与内容原位置相同*/&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;width&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #933;&quot;&gt;1px&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;height&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #933;&quot;&gt;1px&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;overflow&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;hidden&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;http://blog.moocss.com/dw-content/demo38/assets/hide-offscreen-top.jpg&quot; width=&quot;973&quot; height=&quot;592&quot; alt=&quot;positioning content off-screen&quot;&gt;&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
5
6
7
8
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;.hide-offscreen-&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;left&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;position&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;absolute&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/*文档流中抽出*/&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;top&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;auto&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;			   &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/*垂直位置与内容原位置相同*/&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;left&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;-9999px&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;         &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/*内容水平向左移动10000px*/&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;width&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #933;&quot;&gt;1px&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;height&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #933;&quot;&gt;1px&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;overflow&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;hidden&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;http://blog.moocss.com/dw-content/demo38/assets/hide-offscreen-left.jpg&quot; width=&quot;899&quot; height=&quot;627&quot; alt=&quot;positioning content off-screen&quot;&gt;&lt;/p&gt;
&lt;p&gt;
对于明眼键盘用户的，以上两种方式，正是&amp;#8221;视觉隐藏的关注点中第二条&amp;#8221;所说的。如果隐藏的内容是垂直偏移（ 即position:absolute; top:-999em;），那么Tab键跳到隐藏容器内的可聚焦元素时，页面会出现滚动。在任何情况下，即使没有偏移（即position:absolute; left:-999em;，其行为也是混乱的，因为没有视觉线索告诉这些用户他们在页面的哪个位置。
&lt;/p&gt;
&lt;h3&gt;a元素&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;
&lt;a href=&quot;http://www.w3.org/TR/WCAG-TECHS/H30.html&quot;&gt;&lt;strong&gt;Techniques for WCAG 2.0&lt;/strong&gt;&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;
H30: Providing link text that describes the purpose of a link for anchor elements.
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;一个链接在脱离语境时仍然有意义；&lt;/li&gt;
&lt;li&gt;链接文本在它出现的页面上应该是唯一的；（即不同资源不要使用相同的链接文本）&lt;/li&gt;
&lt;li&gt;链接文本千万不要使用“点击此处”或“更多”；&lt;/li&gt;
&lt;li&gt;不要使用一个长URL作为链接文本；（屏幕阅读器会全部读出来，用户会很烦躁的）。&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Using the &lt;em&gt;alt&lt;/em&gt; attribute for the &lt;em&gt;img&lt;/em&gt; element to describe the purpose of a graphical link. &lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;a&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;routes.html&amp;quot;&lt;/span&gt;&amp;gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;img&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;topo.gif&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;alt&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;查看丽江美景&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;a&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--错误的--&amp;gt;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;a&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;routes.html&amp;quot;&lt;/span&gt;&amp;gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;img&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;topo.gif&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;alt&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;查看丽江美景&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;a&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--错误的--&amp;gt;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;a&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;routes.html&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;查看丽江美景&amp;quot;&lt;/span&gt;&amp;gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;img&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;topo.gif&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;alt&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;a&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- IE 、chrome读title值，Firefox读&amp;quot;空白&amp;quot;--&amp;gt;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;a&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;routes.html&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;img&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;topo.gif&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;alt&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;查看成都美景&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;查看丽江美景&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;a&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--正确的--&amp;gt;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;a&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;routes.html&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;查看丽江美景&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;img&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;topo.gif&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;alt&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;查看成都美景&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;a&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--正确的--&amp;gt;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;a&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.topcss.org&amp;quot;&lt;/span&gt;&amp;gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;a&lt;/span&gt;&amp;gt;&lt;/span&gt; 
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--AT在IE下读&amp;quot;www.topcss.org&amp;quot;  Firefox 、chrome下忽略--&amp;gt;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;a&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.topcss.org&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;进步博客&amp;quot;&lt;/span&gt;&amp;gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;a&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--AT在IE下读&amp;quot;进步博客&amp;quot;  Firefox、chrome下忽略--&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;&lt;p&gt;Using an empty alt attribute when the anchor (a)  \&lt;br /&gt;
     element contains text that describes the purpose of&lt;br /&gt;
     the link in addition to the img element. Note that the&lt;br /&gt;
     link text will appear on the page next to the image.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;a&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;routes.html&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;img&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;topo.gif&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;alt&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;小马哥
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;a&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;H67: Using null alt text and no title attribute on img elements for images that AT should ignore.&lt;/p&gt;
&lt;p&gt;“null” alt  ≠  have no alt&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
5
6
7
8
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;img&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;p.jpg&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;alt&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--AT 忽略图片--&amp;gt;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;img&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;p.jpg&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--AT忽略图片，但不符合规范--&amp;gt;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;img&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;p.jpg&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;alt&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;钟楼&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--IE、chrome 忽略图片 Firefox 读title值--&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;&lt;p&gt;H33: Supplementing link text with the title attribute&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4&gt;谨慎使用：&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;tool tip形式出现，大约5秒后消失&lt;/li&gt;
&lt;li&gt;无法控制title属性的内容，如对比度、字体大小、位置，放大器用户可能不能理解&lt;/li&gt;
&lt;li&gt;Title旨在提供辅助信息，mouse over元素时出现； alt是在元素无法正常渲染时出现。IE6/IE7会在无title时以tooltip的形式显式alt的值。&lt;/li&gt;
&lt;li&gt;屏幕阅读器需要用户手动设置才能读出title值，有的根本就不能。&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;label元素&lt;/h3&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;label&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;firstname&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;First name:&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;label&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;input&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;firstname&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;firstname&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--正确的--&amp;gt;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;label&lt;/span&gt;&amp;gt;&lt;/span&gt;First name: &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;input&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;firstname&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;label&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--IE6不支持--&amp;gt;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;label&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;firstname&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;First name:
	&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;input&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;firstname&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;firstname&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;label&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--nvda会重复读label文本内容--&amp;gt;&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h3&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;search-header&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;Search your contact list&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h3&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;input&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;input&amp;quot;&lt;/span&gt; aria-labelledby&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;search-header&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--IE7 | IE8 | IE9 | Firefox 支持--&amp;gt;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;input&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;input&amp;quot;&lt;/span&gt; aria-&lt;span style=&quot;color: #000066;&quot;&gt;label&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;search-header&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--IE9不支持 | Firefox 支持--&amp;gt;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--优先级：aria-labelledby &amp;gt; aria-label --&amp;gt;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;input&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;input&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;找图片&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- IE7 | IE8 | IE9 | Firefox 支持--&amp;gt;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;input&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;input&amp;quot;&lt;/span&gt; placeholder&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;输入名字&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--IE9不支持 | Firefox 支持--&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;三. 使用CLIP属性隐藏元素&lt;/h2&gt;
&lt;h3&gt;Clip属性&lt;/h3&gt;
&lt;p&gt;定义一个绝对定位 元素的可见区域。clip: rect(top, right, bottom, left);&lt;/p&gt;
&lt;p&gt;top/bottom：定义与盒子顶部边框边缘的距离；&lt;/p&gt;
&lt;p&gt;left/right：定义与盒子左边框边缘的距离；&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;http://blog.moocss.com/dw-content/demo38/assets/clip.jpg&quot; width=&quot;525&quot; height=&quot;473&quot; alt=&quot;clip&quot;/&gt;&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
5
6
7
8
9
10
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #6666ff;&quot;&gt;.element-invisible&lt;/span&gt; &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;position&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;absolute&lt;/span&gt; !important&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;clip&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; rect&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #933;&quot;&gt;1px&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;1px&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;1px&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;1px&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/* IE6, IE7 */&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;clip&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; rect&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #933;&quot;&gt;1px&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;1px&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;1px&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;1px&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;padding&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt; !important&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;border&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt; !important&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;height&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;1px&lt;/span&gt; !important&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;width&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;1px&lt;/span&gt; !important&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;overflow&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;hidden&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;http://blog.moocss.com/dw-content/demo38/assets/element-invisible.jpg&quot; width=&quot;840&quot; height=&quot;593&quot; alt=&quot;element-invisible&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;a class=&quot;button&quot; href=&quot;http://blog.moocss.com/dw-content/demo38/test.html&quot;&gt;常用的视觉隐藏方法测试&lt;/a&gt;&lt;/p&gt;
&lt;h3  class=&quot;related-posts-title&quot;&gt;相关日志 »&lt;/h3&gt;&lt;ul class=&quot;related-list&quot;&gt;&lt;li&gt;暂无相关日志&lt;/li&gt;&lt;/ul&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/592291811/moocss/feedsky/s.gif?r=http://blog.moocss.com/tutorials/accessibility/1685.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</content:encoded><wfw:commentRss>http://blog.moocss.com/tutorials/accessibility/1685.html/feed</wfw:commentRss><slash:comments>1</slash:comments><fs:srclink>http://blog.moocss.com/tutorials/accessibility/1685.html</fs:srclink><fs:srcfeed>http://feed.moocss.com/</fs:srcfeed><fs:itemid>feedsky/cssrainbow/~8577171/592315287/5452281</fs:itemid><description>原文来自：http://www.topcss.org/?p=418 作者：进步博客 腾讯ISUX组内做的一个分享，主题是&amp;#8221;视觉隐藏内容&amp;#8221;，主要关注隐藏的方式、方法及每种方法对可访问性的影响，并着重分析了a &amp;#038; label元素的可访问性，介绍了使用clip来做视觉隐藏。内容有点散，但主题明确，其他组的几个同事来要PPT，现在传至slideshare，错误之处，请指正。 视觉隐藏内容 View more presentations from Lee Jace 一. 概述 Web内容无障碍指南（WCAG）2.0定义了如何使web内容更便于残障人士访问。它定义了web内容无障碍的四项基本原则，即可感知、可操作、可理解和健壮性，为了达到这些基本目标，每条原则之下设置了应遵循的准则，对每一个准则，提供了可测试的成功标准。 内容隐藏 分类 作用 示例 完全隐藏 用户交互 display:none; 对屏幕阅读器隐藏 减少干扰 tabindex=&amp;#8220;-1&amp;#8221; 视觉隐藏&amp;#13; （对屏幕阅读器可见） 提供语境信息 text-indent:999em;&amp;#13; line-height:99;&amp;#13; &amp;#8230; 将重复信息和为明眼用户提供的信息从屏幕阅读器访问序列中移除。 头像链接的作用： 明眼用户快速辨识好友，这对视障用户没有意义； 链接至好友主页，与人名链接的作用一致，作用重复； 为了减少干扰，我们可以使用tabindex=“-1”,将头像链接从屏幕阅读器访问序列中移除。 视觉隐藏文本思路 1.为屏幕阅读器提供补充文本 2.通过CSS隐藏这些文本 SEO and Accessibility High Accessibility Is Effective Search Engine Optimization 二. 隐藏方式对可访问性的影响 视觉隐藏 –纯文本 –label文本 –链接 –链接文本 视觉隐藏的关注点: [...]&lt;img src=&quot;http://www1.feedsky.com/t1/592291811/moocss/feedsky/s.gif?r=http://blog.moocss.com/tutorials/accessibility/1685.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>Web内容无障碍</category><category>Accessibility</category><pubDate>Thu, 03 Nov 2011 22:03:09 +0800</pubDate><author>Rainbow</author><comments>http://blog.moocss.com/tutorials/accessibility/1685.html#comments</comments><guid isPermaLink="false">http://blog.moocss.com/?p=1685</guid><dc:creator>Rainbow</dc:creator></item><item><title>HTML5的Web标准实战</title><link>http://item.feedsky.com/~feedsky/cssrainbow/~8577171/592315288/5452281/1/item.html</link><content:encoded>&lt;p&gt;我记得2009年下半年的时候，我就开始尝试使用HTML5的新元素，具体的说应该是HTML5的结构性元素的使用。&lt;/p&gt;
&lt;p&gt;我使用HTML5的结构性元素重构我的博客，刚开始，查看了大量老外博客，也归纳总结了一下使用场景，在什么情况下使用HTML5的新元素代替原有的没有语义性div，还有如何组织文档内容结构也是比较头疼的事情。&lt;/p&gt;
&lt;p&gt;虽然看了一下HTML5新元素的名词解释，还是比较迷茫，毕竟是概念性的东西，没有应用于生产的案例来的真实。&lt;/p&gt;
&lt;h3&gt;当时遇到的问题:&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;如何让IE也支持HTML5的新元素？&lt;/li&gt;
&lt;li&gt;如何正确的使用HTML5的新元素代替HTML4中没有明确语义的标签？&lt;/li&gt;
&lt;li&gt;&lt;code&gt;section&gt;&lt;/code&gt;等于&lt;code&gt;div&lt;/code&gt;吗？&lt;/li&gt;
&lt;li&gt;section、article、div 的区别？&lt;/li&gt;
&lt;li&gt;如何构建正确的HTML5 Web页面？&lt;/li&gt;
&lt;li&gt;等等&amp;#8230;&amp;#8230;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;但随着Firefox、Chrome、Opera、Safari和IE9+对HTML5的支持越来越好，也有一些比较知名站点已经开始大量的尝试HTML5新技术了，例如：淘宝，支付宝，去哪儿等站点，但是它们在HTML5结构性元素上的使用，我持有疑问，不敢苟同，我认为对于初学者最好不要模仿它们，会把大家引向误区，最好多看一些老外的网站和(&lt;a href=&quot;http://dev.w3.org/html5/markup/&quot;&gt;W3C:HTML&lt;/a&gt;, &lt;a href=&quot;http://www.whatwg.org/specs/web-apps/current-work/multipage/&quot;&gt;WhatWG&lt;/a&gt;)，多分析人家是如何重构的，然后再慎重的应用于生产。&lt;/p&gt;
&lt;p&gt;对于这些HTML5结构性元素，不单单是使用了语义化类名的div的替代品,更应该是它们使我们的网页更富于语义性、组织性、结构性、模块化&amp;#8230;，如果你还是喜欢那些如此缠绕的标签汤和冗余嵌套，我无话可说。如果我们不加思考盲目的使用HTML5结构性元素的话，会陷入结构不明了，主次不分，语义不确定的状态，那和狭义的使用div+css有啥区别。&lt;/p&gt;
&lt;p&gt;我们的目标是使用HTML5的语义性标记，尽可能接近地定义内容的含义，并且不会描述表现。&lt;/p&gt;
&lt;p&gt;HTML5的Web标准实战,就是我今天要说的“如何使用HTML5的新元素构建一个结构良好，语义丰富的Web页面”。&lt;/p&gt;
&lt;p&gt;
 &lt;img src=&quot;http://blog.moocss.com/dw-content/id-and-class-attribute-list.jpg&quot; width=&quot;632&quot; height=&quot;495&quot; border=&quot;0&quot; usemap=&quot;#Map&quot; alt=&quot;常用类名和ID名的使用统计数据&quot;/&gt;&lt;/p&gt;
&lt;map name=&quot;Map&quot;&gt;
&lt;area shape=&quot;rect&quot; coords=&quot;9,5,306,481&quot; href=&quot;http://devfiles.myopera.com/articles/572/classlist-url.htm&quot;&gt;
&lt;area shape=&quot;rect&quot; coords=&quot;328,6,619,482&quot; href=&quot;http://devfiles.myopera.com/articles/572/idlist-url.htm&quot;&gt;
  &lt;/map&gt;
&lt;/p&gt;
&lt;p&gt;接下来，我就说一说我们在HTML5实战时的常见误区。&lt;/p&gt;
&lt;h2&gt;慎用section&lt;/h2&gt;
&lt;p&gt;不要把section当作div的替代品,人们在使用section的过程中，很容易把section等价于div，会直接用section代替div 。我想说的是“不要把&amp;lt;section&amp;gt;当&amp;lt;div&amp;gt;那样用。”&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;W3C官方文档中是这样说的：&lt;/p&gt;
&lt;p&gt;The section element represents a generic section of a document or application. A section, in this context, is a thematic grouping of content, typically with a heading.&lt;/p&gt;
&lt;p&gt;&amp;lt;section&amp;gt;看起来像是有语义版的&amp;lt;div&amp;gt;，但实际的使用是用在一个专题性的版块，且通常带有一个标题。适合用于章节、标签切换效果的每一个tab容器或论文中有编号的地方，也可以用于网站主页中划分简介、新闻、联系信息等板块(多为一些公司主页的版块化区域，“新闻”版块可能只有简单文章列表而没有正文，此类版块多在主要区域展示.)。&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;&lt;p&gt;官方还给了一个提示：&lt;/p&gt;
&lt;p&gt;The section element is not a generic container element. When an element is needed for styling purposes or as a convenience for scripting, authors are encouraged to use the div element instead. A general rule is that the section element is appropriate only if the element&amp;#8217;s contents would be listed explicitly in the document&amp;#8217;s outline.&lt;/p&gt;
&lt;p&gt;说的十分明确，&amp;lt;section&amp;gt;不是一个普通的容器元素，当为了样式布局时，建议使用&amp;lt;div&amp;gt;。当元素内容明确的列举在大纲时建议使用&amp;lt;section&amp;gt;。&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;我想W3C的介绍说的已经足够明确，只要谨记一点就不容易用错：&amp;lt;section&amp;gt;不是一个通用的纯容器标签。对这个问题我困惑了很久，因为有些HTML5教程让我迷惑，而很多大网站也是在疯狂的使用&amp;lt;section&amp;gt;作为容器标签。&lt;/p&gt;
&lt;h3&gt;使用&amp;lt;section&amp;gt;&lt;/h3&gt;
&lt;p&gt;&amp;lt;section&amp;gt;可以相互嵌套，在页面中定义了一个特殊的顶级区块，于是可以从&amp;lt;h1&amp;gt;开始列提纲而不用担心会破坏网页的纲要。尽管没找到明确说明，但我个人认为在每一层&amp;lt;section&amp;gt;里还是仅使用一个&amp;lt;h1&amp;gt;为佳。&lt;/p&gt;
&lt;p&gt;以Wordpress主题为例，我认为与#sidebar相对的#content部分，使用&amp;lt;section&amp;gt;包裹一堆&amp;lt;article&amp;gt;作为页面的主要内容并不太合适。而使用&amp;lt;section&amp;gt;用在整体布局是明显的错误。&lt;/p&gt;
&lt;p&gt;在XHTML或者HTML4中，我们常看到这样的代码：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- HTML 4-style code --&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;div&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;wrapper&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;div&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;header&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;  
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;My super duper page&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Header content --&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;div&lt;/span&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;div&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;main&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Page content --&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;div&lt;/span&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;div&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;secondary&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Secondary content --&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;div&lt;/span&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;div&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;footer&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Footer content --&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;div&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;div&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;而现在在HTML5中，会是这样：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Don’t copy this code! It’s wrong! --&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;section &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;wrapper&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;header&amp;gt;&lt;/span&gt;  
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;My super duper page&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Header content --&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;header&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;section &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;main&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Page content --&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;section&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;section &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;secondary&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Secondary content --&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;section&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;footer&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Footer content --&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;footer&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;section&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;
这样使用并不正确：&lt;strong&gt;&amp;lt;section&amp;gt;并不是样式容器&lt;/strong&gt;。&lt;a href=&quot;http://html5doctor.com/section&quot; target=&quot;_blank&quot;&gt;section元素&lt;/a&gt;表示的是内容中用来帮助构建&lt;a href=&quot;http://html5doctor.com/outline&quot; target=&quot;_blank&quot;&gt;文档概要&lt;/a&gt;的语义部分。它应该包含一个头部。如果你想找一个用作页面容器的元素(就像HTML或者XHTML的风格)，那么考虑如&lt;a href=&quot;http://camendesign.com/code/developpeurs_sans_frontieres&quot; target=&quot;_blank&quot;&gt;Kroc Camen&lt;/a&gt;所说，直接把样式写到body元素上吧。如果你仍然需要额外的样式容器，还是继续使用div吧。
&lt;/p&gt;
&lt;p&gt;基于上述思想，下面才是正确的使用HTML5和一些ARIA roles特性的例子（注意，根据你自己的设计，你也可能需要加入div）&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;body&lt;/span&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;header&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;My super duper page&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Header content --&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;header&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;div&lt;/span&gt; role&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;main&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Page content --&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;div&lt;/span&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;aside role&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;complementary&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Secondary content --&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;aside&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;footer&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Footer content --&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;footer&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;body&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;适合使用&amp;lt;section&amp;gt;标签的地方有：&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;文章的评论列表，有着整齐的结构；&lt;/li&gt;
&lt;li&gt;文章内容的目录，有着文章内部结构纲要；&lt;/li&gt;
&lt;li&gt;侧栏widget，在&lt;a href=&quot;http://webdesignerwall.com&quot;&gt;WebDesignWall&lt;/a&gt;中我看到了这样的设计，因为widget内容大都是评论列表、文章列表，有着清晰的结构且是独立完整的一部分；&lt;/li&gt;
&lt;li&gt;将页面分节为不同主题区域。&lt;/li&gt;
&lt;li&gt;把文章划分为各个章节，但要在编辑器完成，目前来看并不易用。&lt;/li&gt;
&lt;li&gt;随着标签越来越多样化，把标签用对本来就不是一件容易事，用得完全合理就更难了。好在目前这些东西用户是看不到的，产品经理也不会留意。如果没有强迫症，大可不必纠结与此。&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;article 与 section 的纠缠&lt;/h2&gt;
&lt;p&gt;上面我们说了要慎用section,不要把section当作div使用。&lt;/p&gt;
&lt;p&gt;div section article ，语义是从无到有，逐渐增强的。div 无任何语义，仅仅用作样式化或者脚本化的钩子(hook)，对于一段主题性（一类事物）的内容，比如博客的侧栏，由许多的模块组成，每一个模块是独立完整的一部分，就非常适合使用 section。article 是一个特殊的 section 标签，它比 section 具有更明确的语义, 它代表一个独立的、完整的相关内容块。一般来说， article 会有标题部分(通常包含在 header 内)，有时也会 包含 footer 。虽然 section 也是带有主题性的一块内容，但是无论从结构上还是内容上来说，article 本身就是独立的、完整的。假如这段内容可以脱离上下文，作为完整的独立存在的一段内容，则就适用 article。原则上来说，能使用 article 的时候，也是可以使用 section 的，但是实际上，假如使用 article 更合适，那么就不要使用 section 。虽然说section包含的内容也能算是独立的一块，但是它只能算是组成整体的一部分，article 才是一个完整的整体，例如：一篇篇幅很大的文章，就会有分出很多章节，也可以独立成块儿，并配有章节标题，这个时候使用 section 来包裹文章章节是最合适不过了。nav 和 aside 的使用也是如此，这两个标签也是特殊的 section，在使用 nav 和 aside 更合适的情况下，也不要使用 section 了。&lt;/p&gt;
&lt;h3&gt;当作有语义的模块使用时&lt;/h3&gt;
&lt;p&gt;例如，我博客的侧栏就是下面的组织方式：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;aside &lt;span style=&quot;color: #000066;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;sidebar&amp;quot;&lt;/span&gt; role&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;complementary&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;
       &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;section role&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;region&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;
           &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h3&lt;/span&gt;&amp;gt;&lt;/span&gt;About Me&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h3&lt;/span&gt;&amp;gt;&lt;/span&gt;
           &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;text,text,text,text&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;
       &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;section&amp;gt;&lt;/span&gt;
       &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;section role&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;region&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;
       		&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h3&lt;/span&gt;&amp;gt;&lt;/span&gt;Recent Posts&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h3&lt;/span&gt;&amp;gt;&lt;/span&gt;
            &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;ul&lt;/span&gt;&amp;gt;&lt;/span&gt;
            	&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;li&lt;/span&gt;&amp;gt;&lt;/span&gt;text,text,text,text&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;li&lt;/span&gt;&amp;gt;&lt;/span&gt;
                &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;li&lt;/span&gt;&amp;gt;&lt;/span&gt;text,text,text,text&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;li&lt;/span&gt;&amp;gt;&lt;/span&gt;
                &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;li&lt;/span&gt;&amp;gt;&lt;/span&gt;......&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;li&lt;/span&gt;&amp;gt;&lt;/span&gt;
            &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;ul&lt;/span&gt;&amp;gt;&lt;/span&gt;
       &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;section&amp;gt;&lt;/span&gt;
       &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;section role&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;region&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;
       		&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h3&lt;/span&gt;&amp;gt;&lt;/span&gt;Recent Comments&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h3&lt;/span&gt;&amp;gt;&lt;/span&gt;
            &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;ul&lt;/span&gt;&amp;gt;&lt;/span&gt;
            	&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;li&lt;/span&gt;&amp;gt;&lt;/span&gt;text,text,text,text&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;li&lt;/span&gt;&amp;gt;&lt;/span&gt;
                &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;li&lt;/span&gt;&amp;gt;&lt;/span&gt;text,text,text,text&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;li&lt;/span&gt;&amp;gt;&lt;/span&gt;
                &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;li&lt;/span&gt;&amp;gt;&lt;/span&gt;......&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;li&lt;/span&gt;&amp;gt;&lt;/span&gt;
            &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;ul&lt;/span&gt;&amp;gt;&lt;/span&gt;
       &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;section&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;aside&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;article 嵌套中section&lt;/h3&gt;
&lt;p&gt;html4中常见的文档&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
5
6
7
8
9
10
11
12
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;Rules for Munchkins&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h2&lt;/span&gt;&amp;gt;&lt;/span&gt;Yellow Brick Road&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h2&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;It is vital that Dorothy follows it—so no selling bricks
as “souvenirs”&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h2&lt;/span&gt;&amp;gt;&lt;/span&gt;Fan Club uniforms&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h2&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;All Munchkins are obliged to wear their “I’m a friend of
Dorothy!” t-shirt when representing the club&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;strong&lt;/span&gt;&amp;gt;&lt;/span&gt;Vital caveat about the information above:
does not apply on the first Thursday of the month.
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;strong&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;html5中的做法：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;article&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;Rules for Munchkins&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;section&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h2&lt;/span&gt;&amp;gt;&lt;/span&gt;Yellow Brick Road&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h2&lt;/span&gt;&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;It is vital that Dorothy follows it—so no selling bricks
        as “souvenirs”&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;section&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;section&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h2&lt;/span&gt;&amp;gt;&lt;/span&gt;Fan Club uniforms&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h2&lt;/span&gt;&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;All Munchkins are obliged to wear their “I’m a friend of
        Dorothy!” t-shirt when representing the club&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;strong&lt;/span&gt;&amp;gt;&lt;/span&gt;Vital caveat about the information above:
        does not apply on the first Thursday of the month.
        &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;strong&lt;/span&gt;&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;section&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;article&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;如上，html4中的文档结构，&amp;lt;h1&amp;gt;和&amp;lt;h2&amp;gt;就比较纠结，这篇文章到底是介绍&amp;lt;h1&amp;gt;以下的所有内容；还是说它只是指&amp;lt;h2&amp;gt;以下的信息。&lt;/p&gt;
&lt;p&gt;如果每个段落归那个&amp;lt;h2&amp;gt;管，html4从语义上就无从下手;在HTML5中,&amp;lt;section&amp;gt;元素就可以就可以使其语义明确。&lt;/p&gt;
&lt;p&gt;到这儿，也许有人会问，为什么这个内容块儿不使用&amp;lt;article&amp;gt;如果使用了&amp;lt;article&amp;gt;就无法像&amp;lt;section&amp;gt;这样正确地划分这篇文章了，因为这些内容块儿，不是独立的，离散的实体。&lt;/p&gt;
&lt;h3&gt;section 中嵌套 article&lt;/h3&gt;
&lt;p&gt;例如有这样的一篇文章，有多个完整独立的主题，一个是关于骆驼的，一个是关于植物的，都主题鲜明，都可以作为独立的专题，这个时候我们希望它们位于不同的栏目中或者是标签界面中不同的选项面板中。&lt;/p&gt;
&lt;p&gt;那又如何实现那？HTML4就不多说了，HTML5中是这样的：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;section&amp;gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;Articles about llamas&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;article&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h2&lt;/span&gt;&amp;gt;&lt;/span&gt;The daily llama: buddhism and South American camelids&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h2&lt;/span&gt;&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;blah blah&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;article&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;article&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h2&lt;/span&gt;&amp;gt;&lt;/span&gt;Shh! Do not alarm a llama&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h2&lt;/span&gt;&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;blah blah&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;article&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;section&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;section&amp;gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;Articles about root vegetables&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;article&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h2&lt;/span&gt;&amp;gt;&lt;/span&gt;Carrots: the orange miracle&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h2&lt;/span&gt;&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;blah blah&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;article&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;article&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h2&lt;/span&gt;&amp;gt;&lt;/span&gt;Eat more Swedes (the vegetables, not the people)&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h2&lt;/span&gt;&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;blah blah&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;article&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;section&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;为什么不把两个&amp;lt;section&amp;gt;写成&amp;lt;article&amp;gt;呢？因为在上面的例子中，每个&amp;lt;section&amp;gt;都是独立的实体的一个集合，其中每个实体都可以聚会，但你通常不会想把集合聚会成一个单独的实体。&lt;/p&gt;
&lt;p&gt;article 与 section 是互相纠缠的，但各自的职责是明确的，我们可以有父&amp;lt;section&amp;gt;,它可以嵌套&amp;lt;article&amp;gt;，而&amp;lt;article&amp;gt;反过来可以拥有一个或多个&amp;lt;section&amp;gt;。并非所有的页面都需要这样，但是以这种方式嵌套完全是可以接受的并且是正确的。&lt;/p&gt;
&lt;p&gt;正如这样一个例子“想想一份报纸。报纸分成版块。有体育版块，房地产版块，娱乐版块，军事版块，等等。每一个版块都包含文章，而这些文章又划分成小节。”&lt;/p&gt;
&lt;h2&gt;只在需要的时候使用header和hgroup&lt;/h2&gt;
&lt;p&gt;写不需要写的标签当然是毫无意义的。不幸的是，我经常看到header和hgroup被无意义的滥用。&lt;/p&gt;
&lt;p&gt;header元素表示的是一组介绍性内容或者导航性质的辅助文字。它通常包含了节（section）的标题（一个h1到h6的元素，或者一个hgroup元素），但不是必须的。&lt;/p&gt;
&lt;h3&gt;header的滥用&lt;/h3&gt;
&lt;p&gt;由于header可以在一个文档中使用多次，可能使得这样代码风格受到欢迎：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
5
6
7
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- 不要复制此代码!这里不需要header--&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;article&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;header&amp;gt;&lt;/span&gt;  
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;My best blog post&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;header&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Article content --&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;article&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;如果你的header元素只包含一个头部元素，那么丢弃header元素吧。既然article元素已经保证了头部会出现在文档概要中，而header又不能包含多个元素（如上文所定义的），那么为什么要写多余的代码。简单点写成这样就行了：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;article&amp;gt;&lt;/span&gt;  
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;My best blog post&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Article content --&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;article&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;&amp;lt;hgroup&amp;gt;不合理使用&lt;/h3&gt;
&lt;p&gt;hgroup 是HTML5中新定义的元素，用来将标题和副标题群组。在我们已经有header标签的情况下，为什么我们还要一个&amp;lt;hgroup&amp;gt;标签？&lt;/p&gt;
&lt;p&gt;下面是文档关于的描述 &amp;lt;hgroup&amp;gt;的描述：&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;hgroup一般被用作将一个或者更多的h1到h6的元素群组，比如，一个区块内的标题和它的副标题。&lt;/p&gt;
&lt;p&gt;The hgroup element is typically used to group a set of one or more h1-h6 elements — to group, for example, a section title and an accompanying subtitle.W3C Specification &lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;从定义中我们得知&amp;lt;hgroup&amp;gt;扮演着一个可以包含一个或者更多标题相关的容器的角色,这些标题可能在&amp;lt;header&amp;gt;元素中。它只能包含从h1-h6的标题元素，这些标题可能是副标题、二选一的标题或者标记标题。&lt;/p&gt;
&lt;p&gt;在&amp;lt;header&amp;gt;的使用过程中,我们经常会误使用&amp;lt;hgroup&amp;gt;.在下面这种情况下你不能将&amp;lt;header&amp;gt;标签和&amp;lt;hgroup&amp;gt;标签一起使用:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;这里只有一个标题,&lt;/li&gt;
&lt;li&gt;或者&amp;lt;hgroup&amp;gt;本身就够了(比如:不需要&amp;lt;hgroup&amp;gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;第一种情形看上去是下面的样子:&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
5
6
7
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Don’t copy this code! No need for hgroup here --&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;header&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;hgroup&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;My best blog post&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;hgroup&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;by Rich Clark&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;header&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;这种情况下,将&amp;lt;hgroup&amp;gt;移除,只保留标题就好.&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;header&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;My best blog post&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;by Rich Clark&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;header&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;第二种情况也是包含了他们并不需要的标签.&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
5
6
7
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Don’t copy this code! No need for header here --&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;header&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;hgroup&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;Article title&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h2&lt;/span&gt;&amp;gt;&lt;/span&gt;Article subtitle&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h2&lt;/span&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;hgroup&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;header&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;当&amp;lt;header&amp;gt;标签的子元素只有&amp;lt;hgroup&amp;gt;的时候,为什么我们还需要一个额外的&amp;lt;header&amp;gt;?  如果没有额外的元素放到&amp;lt;header&amp;gt;中(比如&amp;lt;hgroup&amp;gt;的兄弟元素),我们直接将&amp;lt;header&amp;gt;元素去  掉就好.&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;hgroup&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;Article title&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h2&lt;/span&gt;&amp;gt;&lt;/span&gt;Article subtitle&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h2&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;hgroup&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;当你的有一个标题有副标题或者其它的和section或者article有关系的元数据时，将&amp;lt;hgroup&amp;gt;和元数据放到一个单独的&amp;lt;header&amp;gt;元素容器中。&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
5
6
7
8
9
10
11
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- A heading which uses header and hgroup --&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;article&amp;gt;&lt;/span&gt;
     &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;header&amp;gt;&lt;/span&gt;
         &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;hgroup&amp;gt;&lt;/span&gt;
             &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;Article title&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;
             &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h2&lt;/span&gt;&amp;gt;&lt;/span&gt;Article subtitle&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h2&lt;/span&gt;&amp;gt;&lt;/span&gt;
         &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;hgroup&amp;gt;&lt;/span&gt;
         &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;(&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;time &lt;span style=&quot;color: #000066;&quot;&gt;datetime&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;2009-07-13&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;13th July, 2009&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;time&amp;gt;&lt;/span&gt;)&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;
     &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;header&amp;gt;&lt;/span&gt;
     &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;Content…&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;article&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;我们为什么要使用&amp;lt;hgroup&amp;gt;&lt;/h3&gt;
&lt;p&gt;我们用&amp;lt;hgroup&amp;gt;一切源起文档大纲(document outline).&lt;/p&gt;
&lt;p&gt;当群组的标题在&amp;lt;hgroup&amp;gt;元素的时候，大纲的算法将会覆盖掉群组中低等级的标题，而将最高等级的标题作为大纲。下面的就是一个例子：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
5
6
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;header&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;hgroup&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h1&lt;/span&gt;&amp;gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;a&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;/&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;Mini Apps&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;a&lt;/span&gt;&amp;gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h2&lt;/span&gt;&amp;gt;&lt;/span&gt;Web applications for iPhone, Android &lt;span style=&quot;color: #ddbb00;&quot;&gt;&amp;amp; other mobile platforms&amp;lt;/h2&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #ddbb00;&quot;&gt;    &amp;lt;/hgroup&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #ddbb00;&quot;&gt;&amp;lt;/header&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&amp;lt;hgroup&amp;gt;包含h1-h2的标题元素，但是在大纲中只包含&amp;lt;h1&amp;gt;.就像下图展示的那样子。&lt;/p&gt;
&lt;p&gt;我们可以从这个链接查看文档大纲：&lt;a href=&quot;http://gsnedders.html5.org/outliner/&quot;&gt;http://gsnedders.html5.org/outliner/&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;不要将所有的链接列表都放到&amp;lt;nav&amp;gt;标签&lt;/h2&gt;
&lt;p&gt;在HTML5新增的30个元素中(在我们写这篇文章的时候),我们在构建更具语义\结构化的标签的时候,我们的选择变得太丰富.也就是说我们对现在给我们提供的这些超级有语义的标签,我们可能会滥用.&amp;lt;nav&amp;gt;就是一个很悲剧的例子.在规范中的描述是这样的:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The nav element represents a section of a page that links   to other pages or to parts within the page: a section with navigation   links.&lt;/p&gt;
&lt;p&gt;Note: Not all groups of links on a page need to be in a nav element —   the element is primarily intended for sections that consist of major   navigation blocks. In particular, it is common for footers to have a   short list of links to various pages of a site, such as the terms of   service, the home page, and a copyright page. The footer element alone   is sufficient for such cases; while a nav element can be used in such   cases, it is usually unnecessary.&lt;br/&gt;&lt;br /&gt;
    WHATWG HTML spec&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;nav元素表示页面中链接到其他页面或者本页面其他部分的区块；包含导航连接的区块。&lt;/p&gt;
&lt;p&gt;注意：不是所有页面上的链接都需要放在nav元素中——这个元素本意是用作主要的导航区块。举个具体的例子，在footer中经常会有众多的链接，比如服 务条款，主页，版权声明页等等。footer元素自身已经足以应付这些情况，虽然nav元素也可以用在这里，但通常我们认为是不必要的。&lt;/p&gt;
&lt;p&gt;WHATWG HTML spec&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;这里面的关键词是&amp;rdquo;重要&amp;rdquo;导航.我们可能会对&amp;rdquo;重要&amp;rdquo;有不同的定义,但是我的理解是:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;主要导航&lt;/li&gt;
&lt;li&gt;网站搜索&lt;/li&gt;
&lt;li&gt;二级导航(这个能是有争议的)&lt;/li&gt;
&lt;li&gt;页面内链接(比如一篇很长的文章，目录区域)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;虽然并没有对错之分,但根据我的理解和一个民意投票让我觉得在下面这些情形下,我不会使用&amp;lt;nav&amp;gt;标签:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;翻页&lt;/li&gt;
&lt;li&gt;社交类的链接（虽然有些社交类的链接也是主要的链接，比如关于我&lt;a href=&quot;http://about.me&quot;&gt;About me&lt;/a&gt;和品味&lt;a href=&quot;http://flavours.me&quot;&gt;Flavours&lt;/a&gt; ）&lt;/li&gt;
&lt;li&gt;博客文章的标签&lt;/li&gt;
&lt;li&gt;博客文章的分类列表&lt;/li&gt;
&lt;li&gt;第三级导航&lt;/li&gt;
&lt;li&gt;大页脚&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;如果你不能确定是否使用&amp;lt;nav&amp;gt;，那就先对你问一下下面的几个问题：&amp;ldquo;者是否是一个主要链接？&amp;rdquo;，你可以根据下面的几个因素来回答你刚才的问题：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;如果用&amp;lt;section&amp;gt;和标题标签能够解决你的问题，那就不要去使用&amp;lt;nav&amp;gt;–&lt;a href=&quot;http://krijnhoetmer.nl/irc-logs/whatwg/20091209#l-480&quot;&gt;Hixie on IRC&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;你是不是为了增加可访问性而增加的一个快捷跳转链接呢？&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;如果上面的回答都是&amp;ldquo;不&amp;rdquo;，那可能就不适合使用&amp;lt;nav&amp;gt;.&lt;/p&gt;
&lt;h2&gt;&amp;lt;figure&amp;gt;元素的错误&lt;/h2&gt;
&lt;p&gt;&amp;lt;figure&amp;gt;和经常与它合伙作案的&amp;lt;figcaption&amp;gt;，是很难掌握的标签，下面是经常看到的一些小错误。&lt;/p&gt;
&lt;h4&gt;并不是所有的图片都是figure（注：比较难理解阿，image=图片，figure=图形）&lt;/h4&gt;
&lt;p&gt;之前，我曾经说过不要写那些不需要的标签。这个错误也是相同的。我经常看到一个网站上的每张图片都有&amp;lt;figure&amp;gt;标签。这些额外增加的标签并不会给你带来任何的益处，并且还增加了你自己的工作强度和让自己的内容变得更难理解。&lt;/p&gt;
&lt;p&gt;在规范中关于&amp;lt;figure&amp;gt;的解释如下：&amp;ldquo;一些文本流，可能包含标题——它们通常是作为文档的主要内容流中的一个自我包含的独立单元。&amp;rdquo;在那里有完美的表述，就是它可以被从主内容中移除–比如放到边拦，而对文档流没有影响。&lt;/p&gt;
&lt;p&gt;如果仅仅是一张表现类的图片而且和文档中其他的内容没有关系的话，那就不需要使用&amp;lt;figure&amp;gt;.&amp;rdquo;这张图片需要对上下文的内容作出解释吗？&amp;rdquo;，如果答案是&amp;rdquo;否&amp;rdquo;，那就可能不是&amp;lt;figure&amp;gt;(可能是&amp;lt;aside&amp;gt;),&amp;rdquo;我能把它移到附录里面吗？&amp;rdquo;，如果这两个问题的答案都是&amp;rdquo;是&amp;rdquo;，那就可能是&amp;lt;figure&amp;gt;.&lt;/p&gt;
&lt;h3&gt;你的标志不是一个&amp;lt;figure&amp;gt;&lt;/h3&gt;
&lt;p&gt;将上面的延伸开来，对你的logo也是这样。下面是两组我找到的有规律的代码片断：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Don’t copy this code! It’s wrong! --&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;header&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;figure&amp;gt;&lt;/span&gt;
      &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;img&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;/img/mylogo.png&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;alt&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;My company&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;hide&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;figure&amp;gt;&lt;/span&gt;
    My company name
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;header&amp;gt;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Don’t copy this code! It’s wrong! --&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;header&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;figure&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;img&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;/img/mylogo.png&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;alt&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;My company&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;figure&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;header&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;这里就不需要说啥了，这是很明显的错误，可能你认为我们说的是不是将logo放在H1标签里面，但是我们在这里并不讨论这个问题。让我们迷惑的  是&amp;lt;figure&amp;gt;元素。&amp;lt;figure&amp;gt;标签只用在当有上下文需要说明或者被&amp;lt;section&amp;gt;包围的时候。我这里要说的是你的logo可能很少会被这种情况下使用。很简单，那就不要去这样做，你需要的仅仅是下面的样子。&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;header&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;My company name&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;h1&lt;/span&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- More stuff in here --&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;header&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;figure只能用在标签上的误解&lt;/h3&gt;
&lt;p&gt;另一个对&amp;lt;figure&amp;gt;的误解就是我们通常认为它只能用在图片上面。事实上并不是这样子的，它可以被用在   &amp;lt;video&amp;gt;&amp;lt;audio&amp;gt;, 一个图标 (比如&amp;lt;SVG&amp;gt;, ), 一个引用, 一个表格, 一段代码,   一段散文, 或者任何和这些相关的组合.   不要把你的&amp;lt;figure&amp;gt;标签仅仅局限在图片上。我们网页制作师的任务就是用标签更准确的描述内容。&lt;/p&gt;
&lt;p&gt;这里有一篇更深入讲解 &amp;lt;figure&amp;gt;的文章&lt;a href=&quot;http://html5doctor.com/figure&quot;&gt;I wrote about &amp;amp;lt;figure&amp;amp;gt;&lt;/a&gt;，很值得阅读的。&lt;/p&gt;
&lt;h2&gt;不相关信息，&amp;lt;aside&amp;gt;&lt;/h2&gt;
&lt;p&gt;&amp;lt;aside&amp;gt;,通常用作页面的侧边栏。它表示与aside元素周围的内容无关的内容所组成的一个页面的节，也可以认为该内容与aside周围的内容是分开独立的。&lt;/p&gt;
&lt;p&gt;该元素可以用于摘录引用或者是边栏这样的排版效果，用于广告，用于一组导航元素，以及你认为是与页面主内容区分开来的其他内容体。&lt;/p&gt;
&lt;p&gt;例如,一个&amp;lt;article&amp;gt;中使用&amp;lt;aside&amp;gt;，是表示该文章的不相关信息或摘录引用的好办法，但是这不是放全页导航的好地方。&lt;/p&gt;
&lt;p&gt;&amp;lt;aside&amp;gt;有一个隐式的ARIA角色“note”，但是可以使用 role=&amp;#8221;complementary&amp;#8221; 或role=&amp;#8221;search&amp;#8221;（如果它包围着一个搜索表单）。&lt;/p&gt;
&lt;h2&gt;mark 与 em 和 strong&lt;/h2&gt;
&lt;h3&gt;mark的妙用&lt;/h3&gt;
&lt;p&gt;&amp;lt;mark&amp;gt; 用来高亮显式文字片断对于用户或页面内容的相关性。&lt;/p&gt;
&lt;p&gt;&amp;lt;mark&amp;gt; 元素允许我们标记所做的事情，相当于使用一支荧光笔在打印的纸张上标出一些文字。它与强调不同，对于强调，我们使用&amp;lt;em&amp;gt;。&lt;/p&gt;
&lt;p&gt;但是如果有一些已有的文本，并且想要让文本没有强调的内容处于显眼的位置，可以使用&amp;lt;mark&amp;gt; 并将其样式化为斜体，或者使用黄色的荧光笔背景色。&lt;/p&gt;
&lt;p&gt;&amp;lt;mark&amp;gt;用于搜索时，标记结果页中搜索关键词的信息是非常合适的。比较用strong 和 em 更合适，至少&amp;lt;mark&amp;gt;没有改变页面的内容的含义。 &lt;/p&gt;
&lt;h3&gt;&amp;lt;em&amp;gt;、&amp;lt;i&amp;gt;、&amp;lt;strong&amp;gt;、&amp;lt;b&amp;gt;的区别&lt;/h3&gt;
&lt;p&gt;&amp;lt;em&amp;gt;表示内容的着重点（stress emphasis），&amp;lt;strong&amp;gt;表示内容的重要性（strong importance）&amp;lt;strong&amp;gt;不会改变所在句子的语意，em 则会改变所在句子的语义。&lt;/p&gt;
&lt;p&gt;&amp;lt;em&amp;gt;是句意强调，加与不加会引起语义变化。&amp;lt;strong&amp;gt;是重要性强调，和局部还是全局无关，局部强调用&amp;lt;strong&amp;gt;也可以，&amp;lt;strong&amp;gt;强调的是重要性，不会改变句意。&lt;/p&gt;
&lt;p&gt;&amp;lt;b&amp;gt;和&amp;lt;i&amp;gt; 仅用来使文本呈现粗体和斜体，区别其它文本，不会产生任何语义的变化。&lt;/p&gt;
&lt;h2&gt;不要去使用那些不必要的type属性&lt;/h2&gt;
&lt;p&gt;这可能是我们最常见的一些问题，它们并不是真正的错误，但我觉得我们的最好实践还是尽量避免这种模式。&lt;br /&gt;
  在HTML5中，我们并不需要给&amp;lt;script&amp;gt;和&amp;lt;script&amp;gt;增加 type   属性，如果这些从CMS默认添加的内容中移出是很痛苦的事情，那当你手工编码的时候还写入它们或者你能完全的控制你的模板时候你完全可以删掉它们。因为所  有的浏览器都会将&amp;lt;script&amp;gt;解析成Javascript和&amp;lt;script&amp;gt;标签是CSS，你不再需要那个type属性了：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Don’t copy this code! It’s attribute overload! --&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;link&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text/css&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;rel&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;stylesheet&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;css/styles.css&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;script&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;js/scripts.js&amp;quot;&lt;/span&gt;&amp;gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;script&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;现在我们可以写成下面的样子：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;link&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;rel&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;stylesheet&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;css/styles.css&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;script&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;js/scripts.js&amp;quot;&lt;/span&gt;&amp;gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;script&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;你也能够对编码的设置作出省略。Mark Pilgrim在Dive into HTML5的语义化一章中作出了解释。&lt;/p&gt;
&lt;h2&gt;不要包含错误的标单属性&lt;/h2&gt;
&lt;p&gt;你可能发现&amp;lt;html5&amp;gt;引入了很多新的表单属性。现在我就给大家讲讲一些不合适的使用。&lt;/p&gt;
&lt;h3&gt;布尔值属性&lt;/h3&gt;
&lt;p&gt;新引入的标签属性有几个是布尔类型的，它们的标签行为基本接近。这些属性包括：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;autofocus&lt;/li&gt;
&lt;li&gt;autocomplete&lt;/li&gt;
&lt;li&gt;required&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;坦白的说，下面的这种情况对我来说并不常见，但我们从 required 作为例子，如下：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Don’t copy this code! It’s wrong! --&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;input&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;email&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;email&amp;quot;&lt;/span&gt; required &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Another bad example --&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;input&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;email&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;email&amp;quot;&lt;/span&gt; required &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;基本上看，这段代码并不会带来危害。客户端对 HTML的解析遇到 required 标签属性时，他的功能就会生效。但是当我们将代码修改，录入 required=&amp;rdquo;false&amp;rdquo; 的情况呢？&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Don’t copy this code! It’s wrong! --&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;input&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;email&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;email&amp;quot;&lt;/span&gt; required &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;解析的时候依然会遇到 required 属性，虽然你希望加入的行为是 假，它依然会被解析成 真。&lt;br /&gt;
  这里有三种合理的方法让布尔值生效。（第二种和第三种方案只有你在写 XHTML 解析的时候需要）&lt;/p&gt;
&lt;p&gt;我们上面的例子可以写成下面的样子：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;input&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;email&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;email&amp;quot;&lt;/span&gt; required &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;h6&gt;参考资料：&lt;/h6&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.cn-cuckoo.com/2010/10/21/the-design-of-html5-2151.html&quot;&gt;HTML5设计原理&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://html5doctor.com/avoiding-common-html5-mistakes/&quot;&gt;Avoiding common HTML5 mistakes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.qianduan.net/html5-differences-in-the-div-section-article.html&quot;&gt;HTML5 中 div section article 的区别&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;h3  class=&quot;related-posts-title&quot;&gt;相关日志 »&lt;/h3&gt;&lt;ul class=&quot;related-list&quot;&gt;&lt;li&gt;2011/03/21 -- &lt;a href=&quot;http://blog.moocss.com/code-snippets/html-css-code-snippets/1551.html&quot; title=&quot;一些有用的Web前端开发技巧&quot;&gt;一些有用的Web前端开发技巧&lt;/a&gt; (1)&lt;/li&gt;&lt;li&gt;2010/05/17 -- &lt;a href=&quot;http://blog.moocss.com/tutorials/html5-css3-tutorials/1287.html&quot; title=&quot;HTML5入门 之 新标签的解析 篇&quot;&gt;HTML5入门 之 新标签的解析 篇&lt;/a&gt; (5)&lt;/li&gt;&lt;li&gt;2010/05/13 -- &lt;a href=&quot;http://blog.moocss.com/tutorials/html5-css3-tutorials/1284.html&quot; title=&quot;HTML5入门 之 样板和兼容IE浏览器篇&quot;&gt;HTML5入门 之 样板和兼容IE浏览器篇&lt;/a&gt; (6)&lt;/li&gt;&lt;li&gt;2010/05/11 -- &lt;a href=&quot;http://blog.moocss.com/tutorials/html5-css3-tutorials/1278.html&quot; title=&quot;HTML5入门之标签篇《下》 &quot;&gt;HTML5入门之标签篇《下》 &lt;/a&gt; (0)&lt;/li&gt;&lt;li&gt;2010/05/11 -- &lt;a href=&quot;http://blog.moocss.com/tutorials/html5-css3-tutorials/1257.html&quot; title=&quot;HTML5入门之标签篇《上》&quot;&gt;HTML5入门之标签篇《上》&lt;/a&gt; (0)&lt;/li&gt;&lt;li&gt;2010/03/04 -- &lt;a href=&quot;http://blog.moocss.com/tutorials/html-css-tutorials/1137.html&quot; title=&quot;Web 设计中的 5 个最具争议性的话题&quot;&gt;Web 设计中的 5 个最具争议性的话题&lt;/a&gt; (0)&lt;/li&gt;&lt;li&gt;2009/09/15 -- &lt;a href=&quot;http://blog.moocss.com/tutorials/html5-css3-tutorials/718.html&quot; title=&quot;漫画：混乱的标记语言XHTML2/HTML5&quot;&gt;漫画：混乱的标记语言XHTML2/HTML5&lt;/a&gt; (0)&lt;/li&gt;&lt;li&gt;2011/12/11 -- &lt;a href=&quot;http://blog.moocss.com/tutorials/html-css-tutorials/1703.html&quot; title=&quot;如何定义IE的文档兼容模式&quot;&gt;如何定义IE的文档兼容模式&lt;/a&gt; (0)&lt;/li&gt;&lt;li&gt;2011/06/20 -- &lt;a href=&quot;http://blog.moocss.com/tutorials/html5-css3-tutorials/1596.html&quot; title=&quot; 解读 HTML5：建议、技巧和技术&quot;&gt; 解读 HTML5：建议、技巧和技术&lt;/a&gt; (2)&lt;/li&gt;&lt;li&gt;2011/06/12 -- &lt;a href=&quot;http://blog.moocss.com/tutorials/html5-css3-tutorials/1577.html&quot; title=&quot;HTML5与IE条件注释&quot;&gt;HTML5与IE条件注释&lt;/a&gt; (2)&lt;/li&gt;&lt;/ul&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/592291812/moocss/feedsky/s.gif?r=http://blog.moocss.com/tutorials/html5-css3-tutorials/1661.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</content:encoded><wfw:commentRss>http://blog.moocss.com/tutorials/html5-css3-tutorials/1661.html/feed</wfw:commentRss><slash:comments>10</slash:comments><fs:srclink>http://blog.moocss.com/tutorials/html5-css3-tutorials/1661.html</fs:srclink><fs:srcfeed>http://feed.moocss.com/</fs:srcfeed><fs:itemid>feedsky/cssrainbow/~8577171/592315288/5452281</fs:itemid><description>我记得2009年下半年的时候，我就开始尝试使用HTML5的新元素，具体的说应该是HTML5的结构性元素的使用。 我使用HTML5的结构性元素重构我的博客，刚开始，查看了大量老外博客，也归纳总结了一下使用场景，在什么情况下使用HTML5的新元素代替原有的没有语义性div，还有如何组织文档内容结构也是比较头疼的事情。 虽然看了一下HTML5新元素的名词解释，还是比较迷茫，毕竟是概念性的东西，没有应用于生产的案例来的真实。 当时遇到的问题: 如何让IE也支持HTML5的新元素？ 如何正确的使用HTML5的新元素代替HTML4中没有明确语义的标签？ section&gt;等于div吗？ section、article、div 的区别？ 如何构建正确的HTML5 Web页面？ 等等&amp;#8230;&amp;#8230; 但随着Firefox、Chrome、Opera、Safari和IE9+对HTML5的支持越来越好，也有一些比较知名站点已经开始大量的尝试HTML5新技术了，例如：淘宝，支付宝，去哪儿等站点，但是它们在HTML5结构性元素上的使用，我持有疑问，不敢苟同，我认为对于初学者最好不要模仿它们，会把大家引向误区，最好多看一些老外的网站和(W3C:HTML, WhatWG)，多分析人家是如何重构的，然后再慎重的应用于生产。 对于这些HTML5结构性元素，不单单是使用了语义化类名的div的替代品,更应该是它们使我们的网页更富于语义性、组织性、结构性、模块化&amp;#8230;，如果你还是喜欢那些如此缠绕的标签汤和冗余嵌套，我无话可说。如果我们不加思考盲目的使用HTML5结构性元素的话，会陷入结构不明了，主次不分，语义不确定的状态，那和狭义的使用div+css有啥区别。 我们的目标是使用HTML5的语义性标记，尽可能接近地定义内容的含义，并且不会描述表现。 HTML5的Web标准实战,就是我今天要说的“如何使用HTML5的新元素构建一个结构良好，语义丰富的Web页面”。 接下来，我就说一说我们在HTML5实战时的常见误区。 慎用section 不要把section当作div的替代品,人们在使用section的过程中，很容易把section等价于div，会直接用section代替div 。我想说的是“不要把&amp;#60;section&amp;#62;当&amp;#60;div&amp;#62;那样用。” W3C官方文档中是这样说的： The section element represents a generic section of a document or application. A section, in this context, is a thematic grouping of content, typically with a heading. &amp;#60;section&amp;#62;看起来像是有语义版的&amp;#60;div&amp;#62;，但实际的使用是用在一个专题性的版块，且通常带有一个标题。适合用于章节、标签切换效果的每一个tab容器或论文中有编号的地方，也可以用于网站主页中划分简介、新闻、联系信息等板块(多为一些公司主页的版块化区域，“新闻”版块可能只有简单文章列表而没有正文，此类版块多在主要区域展示.)。 官方还给了一个提示： The section element is [...]&lt;img src=&quot;http://www1.feedsky.com/t1/592291812/moocss/feedsky/s.gif?r=http://blog.moocss.com/tutorials/html5-css3-tutorials/1661.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>HTML5 入门</category><category>HTML5</category><category>HTML5/CSS3</category><category>hml5</category><category>HTML</category><pubDate>Fri, 07 Oct 2011 17:30:17 +0800</pubDate><author>Rainbow</author><comments>http://blog.moocss.com/tutorials/html5-css3-tutorials/1661.html#comments</comments><guid isPermaLink="false">http://blog.moocss.com/?p=1661</guid><dc:creator>Rainbow</dc:creator></item><item><title>你须知道的30个CSS选择器</title><link>http://item.feedsky.com/~feedsky/cssrainbow/~8577171/592315289/5452281/1/item.html</link><content:encoded>&lt;p&gt;你也许已经掌握了id、class、后台选择器这些基本的css选择器。但这远远不是css的全部。下面向大家系统的解析css中30个最常用的选择器，包括我们最头痛的浏览器兼容性问题。掌握了它们，才能真正领略css的巨大灵活性。&lt;/p&gt;
&lt;h2&gt;1. *&lt;/h2&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;*&lt;/span&gt; &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;margin&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;padding&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;星状选择符会在页面上的每一个元素上起作用。web设计者经常用它将页面中所有元素的margin和padding设置为0。&lt;/p&gt;
&lt;p&gt;*选择符也可以在子选择器中使用。&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;	&lt;span style=&quot;color: #cc00cc;&quot;&gt;#container&lt;/span&gt; &lt;span style=&quot;color: #00AA00;&quot;&gt;*&lt;/span&gt; &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;border&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;1px&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;solid&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;black&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;上面的代码中会应用于id为container元素的所有子元素中。&lt;/p&gt;
&lt;p&gt;除非必要，我不建议在页面中过的的使用星状选择符，因为他的作用域太大，相当耗浏览器资源。&lt;/p&gt;
&lt;p&gt;兼容浏览器：IE6+、Firefox、Chrome、Safari、Opera&lt;/p&gt;
&lt;h2&gt;2. #X&lt;/h2&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #cc00cc;&quot;&gt;#container&lt;/span&gt; &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;width&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;960px&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;margin&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;auto&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;井号作用域有相应id的元素。id是我们最常用的css选择器之一。id选择器的优势是精准，高优先级（优先级基数为100，远高于class的10），作为javascript脚本钩子的不二选择，同样缺点也很明显优先级过高，重用性差，所以在使用id选择器前，我们最好问下自己，真的到了非用id选择器的地步？&lt;/p&gt;
&lt;p&gt;兼容浏览器：IE6+、Firefox、Chrome、Safari、Opera&lt;/p&gt;
&lt;h2&gt;3. .X&lt;/h2&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #6666ff;&quot;&gt;.error&lt;/span&gt; &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;color&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;red&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;这是一个class(类)选择器。class选择器与id选择器的不同是class选择器能作用于期望样式化的一组元素。&lt;/p&gt;
&lt;p&gt;兼容浏览器：IE6+、Firefox、Chrome、Safari、Opera&lt;/p&gt;
&lt;h2&gt;4. X Y&lt;/h2&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;li a &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;text-decoration&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;none&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;这也是我们最常用的一种选择器——后代选择器。用于选取X元素下子元素Y，要留意的点是，这种方式的选择器将选取其下所有匹配的子元素，无视层级，所以有的情况是不宜使用的，比如上述的代码去掉li下的所有a的下划线，但li里面还有个ul，我不希望ul下的li的a去掉下划线。使用此后代选择器的时候要考虑是否希望某样式对所有子孙元素都起作用。这种后代选择器还有个作用，就是创建类似命名空间的作用。比如上述代码样式的作用域明显为li。&lt;/p&gt;
&lt;p&gt;兼容浏览器：IE6+、Firefox、Chrome、Safari、Opera&lt;/p&gt;
&lt;h2&gt;5. X&lt;/h2&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;a &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;color&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;red&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;  
ul &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;margin-left&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;标签选择器。使用标签选择器作用于作用域范围内的所有对应标签。优先级仅仅比*高。&lt;/p&gt;
&lt;p&gt;兼容浏览器：IE6+、Firefox、Chrome、Safari、Opera&lt;/p&gt;
&lt;h2&gt;6. X:visited和X:link&lt;/h2&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;a&lt;span style=&quot;color: #3333ff;&quot;&gt;:link &lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;color&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;red&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;   
a&lt;span style=&quot;color: #3333ff;&quot;&gt;:visted &lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;color&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;purple&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;使用:link伪类作用于未点击过的链接标签。:hover伪类作用于点击过的链接。&lt;/p&gt;
&lt;p&gt;兼容浏览器：IE7+、Firefox、Chrome、Safari、Opera&lt;/p&gt;
&lt;h2&gt;7. X+Y&lt;/h2&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;ul &lt;span style=&quot;color: #00AA00;&quot;&gt;+&lt;/span&gt; p &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;color&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;red&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;相邻选择器，上述代码中就会匹配在ul后面的第一个p，将段落内的文字颜色设置为红色。(只匹配第一个元素)&lt;/p&gt;
&lt;p&gt;兼容浏览器：IE7+、Firefox、Chrome、Safari、Opera&lt;/p&gt;
&lt;h2&gt;8. X&gt;Y&lt;/h2&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;div&lt;span style=&quot;color: #cc00cc;&quot;&gt;#container&lt;/span&gt; &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;gt;&lt;/span&gt; ul &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;border&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;1px&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;solid&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;black&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;


&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
5
6
7
8
9
10
11
12
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;div&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;”container”&amp;gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;ul&lt;/span&gt;&amp;gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;li&lt;/span&gt;&amp;gt;&lt;/span&gt; List Item
			&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;ul&lt;/span&gt;&amp;gt;&lt;/span&gt;
				&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;li&lt;/span&gt;&amp;gt;&lt;/span&gt; Child &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;li&lt;/span&gt;&amp;gt;&lt;/span&gt;
			&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;ul&lt;/span&gt;&amp;gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;li&lt;/span&gt;&amp;gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;li&lt;/span&gt;&amp;gt;&lt;/span&gt; List Item &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;li&lt;/span&gt;&amp;gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;li&lt;/span&gt;&amp;gt;&lt;/span&gt; List Item &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;li&lt;/span&gt;&amp;gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;li&lt;/span&gt;&amp;gt;&lt;/span&gt; List Item &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;li&lt;/span&gt;&amp;gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;ul&lt;/span&gt;&amp;gt;&lt;/span&gt; 
  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;div&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;子选择器。与后代选择器X Y不同的是，子选择器只对X下的直接子级Y起作用。在上面的css和html例子中，div#container&gt;ul仅对container中最近一级的ul起作用。从理论上来讲X &gt; Y是值得提倡选择器，可惜IE6不支持。&lt;/p&gt;
&lt;p&gt;兼容浏览器：IE7+、Firefox、Chrome、Safari、Opera&lt;/p&gt;
&lt;h2&gt;9. X ~ Y&lt;/h2&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;ul ~ p &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;color&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;red&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;相邻选择器，与前面提到的X+Y不同的是，X~Y匹配与X相同级别的所有Y元素，而X+Y只匹配第一个。&lt;/p&gt;
&lt;p&gt;兼容浏览器：IE7+、Firefox、Chrome、Safari、Opera&lt;/p&gt;
&lt;h2&gt;10. X[title]&lt;/h2&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;a&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#91;&lt;/span&gt;title&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;color&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;green&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;属性选择器。比如上述代码匹配的是带有title属性的链接元素。&lt;/p&gt;
&lt;p&gt;兼容浏览器：IE7+、Firefox、Chrome、Safari、Opera&lt;/p&gt;
&lt;h2&gt;11. X[title=&quot;foo&quot;]&lt;/h2&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;a&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#91;&lt;/span&gt;href&lt;span style=&quot;color: #00AA00;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://blog.moocss.com&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;color&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #cc00cc;&quot;&gt;#1f6053&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;属性选择器。 上面的代码匹配所有拥有href属性，且href为http://blog.moocss.com的所有链接。&lt;/p&gt;
&lt;p&gt;这个功能很好，但是多少又有些局限。如果我们希望匹配href包含css9.net的所有链接该怎么做呢？看下一个选择器。&lt;/p&gt;
&lt;p&gt;兼容浏览器：IE7+、Firefox、Chrome、Safari、Opera&lt;/p&gt;
&lt;h2&gt;12. X[href*=&quot;moocss&quot;]&lt;/h2&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;a&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#91;&lt;/span&gt;href&lt;span style=&quot;color: #00AA00;&quot;&gt;*=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;moocss&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;color&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #cc00cc;&quot;&gt;#1f6053&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;属性选择器。正如我们想要的，上面代码匹配的是href中包含”http://blog.moocss.com“的所有链接。&lt;/p&gt;
&lt;p&gt;兼容浏览器：IE7+、Firefox、Chrome、Safari、Opera&lt;/p&gt;
&lt;h2&gt;13. X[href^=&quot;http&quot;]&lt;/h2&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;a&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#91;&lt;/span&gt;href&lt;span style=&quot;color: #00AA00;&quot;&gt;^=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;background&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000; font-style: italic;&quot;&gt;path/to/external/icon.png&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;no-repeat&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;padding-left&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;10px&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;属性选择器。上面代码匹配的是href中所有以http开头的链接。&lt;/p&gt;
&lt;p&gt;兼容浏览器：IE7+、Firefox、Chrome、Safari、Opera&lt;/p&gt;
&lt;h2&gt;14. X[href$=&quot;.jpg&quot;]&lt;/h2&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;a&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#91;&lt;/span&gt;href&lt;span style=&quot;color: #00AA00;&quot;&gt;^=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;background&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000; font-style: italic;&quot;&gt;path/to/external/icon.png&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;no-repeat&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;padding-&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;left&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;10px&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;属性选择器。在属性选择器中使用$，用于匹配结尾为特定字符串的元素。在上面代码中匹配的是所有链接到扩展名为.jpg图片的链接。（注意，这里仅仅是.jpg图片，如果要作用于所有图片链接该怎么做呢，看下一个选择器。）&lt;/p&gt;
&lt;p&gt;兼容浏览器：IE7+、Firefox、Chrome、Safari、Opera&lt;/p&gt;
&lt;h2&gt;15. X[data-*=&quot;foo&quot;]&lt;/h2&gt;
&lt;p&gt;在上一个选择器中提到如何匹配所有图片链接。如果使用X[href$=&quot;.jpg&quot;]实现，需要这样做：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
5
6
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;a&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#91;&lt;/span&gt;href$&lt;span style=&quot;color: #00AA00;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;.jpg&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;,&lt;/span&gt;
a&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#91;&lt;/span&gt;href$&lt;span style=&quot;color: #00AA00;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;.jpeg&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;,&lt;/span&gt;
a&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#91;&lt;/span&gt;href$&lt;span style=&quot;color: #00AA00;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;.png&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;,&lt;/span&gt;
a&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#91;&lt;/span&gt;href$&lt;span style=&quot;color: #00AA00;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;.gif&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;color&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;red&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;看上去比较麻烦。另一个解决办法是为所有的图片链接加一个特定的属性，例如‘data-file’&lt;/p&gt;
&lt;p&gt;html代码&lt;/p&gt;
&lt;p&gt;&lt;a href=”path/to/image.jpg” data-filetype=”image”&gt; 图片链接 &lt;/a&gt;&lt;/p&gt;
&lt;p&gt;css代码如下：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;a&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#91;&lt;/span&gt;data-filetype&lt;span style=&quot;color: #00AA00;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;image&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;color&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;red&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;这样所有链接到图片的链接字体颜色为红色。&lt;/p&gt;
&lt;p&gt;兼容浏览器：IE7+、Firefox、Chrome、Safari、Opera&lt;/p&gt;
&lt;h2&gt;16. X[foo~=&quot;bar&quot;]&lt;/h2&gt;
&lt;p&gt;属性选择器。属性选择器中的波浪线符号可以让我们匹配属性值中用空格分隔的多个值中的一个。看下面例子：&lt;/p&gt;
&lt;p&gt;html代码&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;a&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;”path&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;to&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;image.jpg” data-info&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;”external image”&amp;gt;&lt;/span&gt; Click Me, Fool &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;a&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;css代码&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
5
6
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;a&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#91;&lt;/span&gt;data-info~&lt;span style=&quot;color: #00AA00;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;external&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;color&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;red&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;
a&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#91;&lt;/span&gt;data-info~&lt;span style=&quot;color: #00AA00;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;image&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;border&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;1px&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;solid&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;black&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;在上面例子中，匹配data-info属性中包含“external”链接的字体颜色为红色。匹配data-info属性中包含“image”的链接设置黑色边框。&lt;/p&gt;
&lt;p&gt;兼容浏览器：IE7+、Firefox、Chrome、Safari、Opera&lt;/p&gt;
&lt;h2&gt;17. X:checked&lt;/h2&gt;
&lt;p&gt;checked伪类用来匹配处于选定状态的界面元素，如radio、checkbox。&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;input&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#91;&lt;/span&gt;type&lt;span style=&quot;color: #00AA00;&quot;&gt;=&lt;/span&gt;radio&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #3333ff;&quot;&gt;:checked &lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;border&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;1px&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;solid&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;black&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;上面代码中匹配的是所有处于选定状态的单选radio，设置1px的黑色边框。&lt;/p&gt;
&lt;p&gt;兼容浏览器：IE9+、Firefox、Chrome、Safari、Opera&lt;/p&gt;
&lt;h2&gt;18. X:after和X:before&lt;/h2&gt;
&lt;p&gt;这两个伪类与content结合用于在元素的前面或者后面追加内容，看一个简单的例子：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;h1&lt;span style=&quot;color: #3333ff;&quot;&gt;:after &lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;content&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000; font-style: italic;&quot;&gt;/i/logo.gif&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;上面的代码实现了在h1标题的后面显示一张图片。&lt;/p&gt;
&lt;p&gt;我们也经常用它来实现清除浮动，写法如下：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
5
6
7
8
9
10
11
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #6666ff;&quot;&gt;.clearfix&lt;/span&gt;&lt;span style=&quot;color: #3333ff;&quot;&gt;:after &lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;content&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; “”&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;display&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;block&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;clear&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;both&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;visibility&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;hidden&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;font-size&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;height&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;      
&lt;span style=&quot;color: #6666ff;&quot;&gt;.clearfix&lt;/span&gt; &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #00AA00;&quot;&gt;*&lt;/span&gt;zoom&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;
&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;19. X:hover&lt;/h2&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;div&lt;span style=&quot;color: #3333ff;&quot;&gt;:hover &lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;background&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #cc00cc;&quot;&gt;#e3e3e3&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;:hover伪类设定当鼠标划过时元素的样式。上面代码中设定了div划过时的背景色。&lt;/p&gt;
&lt;p&gt;需要注意的是，在ie 6中，:hover只能用于链接元素。&lt;/p&gt;
&lt;p&gt;这里分享一个经验，在设定链接划过时出现下滑线时，使用border-bottom会比text-decoration显得更漂亮些。代码如下：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;a&lt;span style=&quot;color: #3333ff;&quot;&gt;:hover &lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;border-bottom&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;1px&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;solid&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;black&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;兼容浏览器：IE6+、Firefox、Chrome、Safari、Opera&lt;/p&gt;
&lt;h2&gt;20. X:not(selector)&lt;/h2&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;div&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt;not&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc00cc;&quot;&gt;#container&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;color&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;blue&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;否定伪类选择器用来在匹配元素时排除某些元素。在上面的例子中，设定除了id为container的div元素字体颜色为blue。&lt;/p&gt;
&lt;p&gt;兼容浏览器：IE9+、Firefox、Chrome、Safari、Opera&lt;/p&gt;
&lt;h2&gt;21. X::pseudoElement&lt;/h2&gt;
&lt;p&gt;::伪对象用于给元素片段添加样式。比如一个段落的第一个字母或者第一行。需要注意的是，这个::伪对象只能用于块状元素。&lt;/p&gt;
&lt;p&gt;下面的代码设定了段落中第一个字母的样式：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
5
6
7
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;p&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #3333ff;&quot;&gt;:first-letter &lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;float&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;left&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;font-size&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;2em&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;font-weight&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;bold&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;font-family&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;cursive&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;padding-right&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;2px&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;下面的代码中设定了段落中第一行的样式：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;p&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #3333ff;&quot;&gt;:first-line &lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;font-weight&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;bold&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;font-size&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;1.2em&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;兼容浏览器：IE6+、Firefox、Chrome、Safari、Opera&lt;/p&gt;
&lt;p&gt;（IE6竟然支持，有些意外啊。）&lt;/p&gt;
&lt;h2&gt;22. X:nth-child(n)&lt;/h2&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;li&lt;span style=&quot;color: #3333ff;&quot;&gt;:nth-&lt;/span&gt;child&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;color&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;red&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;这个伪类用于设定一个序列元素（比如li、tr）中的第n个元素（从1开始算起）的样式。在上面例子中，设定第三个列表元素li的字体颜色为红色。&lt;/p&gt;
&lt;p&gt;看一个更灵活的用法，在下面例子中设定第偶数个元素的样式，可以用它来实现隔行换色：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;tr&lt;span style=&quot;color: #3333ff;&quot;&gt;:nth-&lt;/span&gt;child&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#40;&lt;/span&gt;2n&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;background-color&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;gray&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;兼容浏览器：IE9+、Firefox、Chrome、Safari&lt;/p&gt;
&lt;h2&gt;23. X:nth-last-child(n)&lt;/h2&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;li&lt;span style=&quot;color: #3333ff;&quot;&gt;:nth-last-&lt;/span&gt;child&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;color&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;red&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;与X:nth-child(n)功能类似，不同的是它从一个序列的最后一个元素开始算起。上面例子中设定倒数第二个列表元素的字体颜色。&lt;/p&gt;
&lt;p&gt;兼容浏览器：IE9+、Firefox、Chrome、Safari、Opera&lt;/p&gt;
&lt;h2&gt;24. X:nth-of-type(n)&lt;/h2&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;ul&lt;span style=&quot;color: #3333ff;&quot;&gt;:nth-of-&lt;/span&gt;type&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;border&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;1px&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;solid&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;black&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;与X:nth-child(n)功能类似，不同的是它匹配的不是某个序列元素，而是元素类型。例如上面的代码设置页面中出现的第三个无序列表ul的边框。&lt;/p&gt;
&lt;p&gt;兼容浏览器：IE9+、Firefox、Chrome、Safari&lt;/p&gt;
&lt;h2&gt;25. X:nth-last-of-type(n)&lt;/h2&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;ul&lt;span style=&quot;color: #3333ff;&quot;&gt;:nth-last-of-&lt;/span&gt;type&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;border&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;1px&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;solid&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;black&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;与X:nth-of-type(n)功能类似，不同的是它从元素最后一次出现开始算起。上面例子中设定倒数第三个无序列表的边框。&lt;/p&gt;
&lt;p&gt;兼容浏览器：IE9+、Firefox、Chrome、Safari、Opera&lt;/p&gt;
&lt;h2&gt;26. X:first-child&lt;/h2&gt;
&lt;p&gt;:first-child伪类用于匹配一个序列的第一个元素。我们经常用它来实现一个序列的第一个元素或最后一个元素的上（下）边框，如：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;ul li&lt;span style=&quot;color: #3333ff;&quot;&gt;:first-child &lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;  
   &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;border-top&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;none&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;  
&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;兼容浏览器：IE7+、Firefox、Chrome、Safari、Opera&lt;/p&gt;
&lt;h2&gt;27. X:last-child&lt;/h2&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;ul &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;gt;&lt;/span&gt; li&lt;span style=&quot;color: #3333ff;&quot;&gt;:last-child &lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;border-bottom&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;none&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;与:first-child类似，它匹配的是序列中的最后一个元素。&lt;/p&gt;
&lt;p&gt;兼容浏览器：IE9+、Firefox、Chrome、Safari、Opera&lt;/p&gt;
&lt;h2&gt;28. X:only-child&lt;/h2&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;div p&lt;span style=&quot;color: #3333ff;&quot;&gt;:only-child &lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;color&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;red&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;这个伪类用的比较少。在上面例子中匹配的是div下有且仅有一个的p，也就是说，如果div内有多个p，将不匹配。&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
5
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;div&lt;/span&gt;&amp;gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt; My paragraph here. &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;div&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;div&lt;/span&gt;&amp;gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt; Two paragraphs total. &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt; Two paragraphs total. &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;div&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;在上面代码中第一个div中的段落p将会被匹配，而第二个div中的p则不会。&lt;/p&gt;
&lt;p&gt;兼容浏览器：IE9+、Firefox、Chrome、Safari、Opera&lt;/p&gt;
&lt;h2&gt;29. X:only-of-type&lt;/h2&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;li&lt;span style=&quot;color: #3333ff;&quot;&gt;:only-of-type &lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;font-weight&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;bold&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;这个伪类匹配的是，在它上级容器下只有它一个子元素，它没有邻居元素。例如上面代码匹配仅有一个列表项的列表元素。&lt;/p&gt;
&lt;p&gt;兼容浏览器：IE9+、Firefox、Chrome、Safari、Opera&lt;/p&gt;
&lt;h2&gt;30. X:first-of-type&lt;/h2&gt;
&lt;p&gt;:first-of-type伪类与:nth-of-type(1)效果相同，匹配出现的第一个元素。我们来看个例子：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
5
6
7
8
9
10
11
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;div&lt;/span&gt;&amp;gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt; My paragraph here. &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;p&lt;/span&gt;&amp;gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;ul&lt;/span&gt;&amp;gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;li&lt;/span&gt;&amp;gt;&lt;/span&gt; List Item 1 &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;li&lt;/span&gt;&amp;gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;li&lt;/span&gt;&amp;gt;&lt;/span&gt; List Item 2 &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;li&lt;/span&gt;&amp;gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;ul&lt;/span&gt;&amp;gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;ul&lt;/span&gt;&amp;gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;li&lt;/span&gt;&amp;gt;&lt;/span&gt; List Item 3 &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;li&lt;/span&gt;&amp;gt;&lt;/span&gt;
		&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;li&lt;/span&gt;&amp;gt;&lt;/span&gt; List Item 4 &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;li&lt;/span&gt;&amp;gt;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;ul&lt;/span&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;div&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;在上面的html代码中，如果我们希望仅匹配List Item 2列表项该如何做呢：&lt;/p&gt;
&lt;p&gt;方案一：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;ul&lt;span style=&quot;color: #3333ff;&quot;&gt;:first-of-type &lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;gt;&lt;/span&gt; li&lt;span style=&quot;color: #3333ff;&quot;&gt;:nth-&lt;/span&gt;child&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;font-weight&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;bold&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;方案二：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;p &lt;span style=&quot;color: #00AA00;&quot;&gt;+&lt;/span&gt; ul li&lt;span style=&quot;color: #3333ff;&quot;&gt;:last-child &lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;font-weight&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;bold&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;方案三：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;ul&lt;span style=&quot;color: #3333ff;&quot;&gt;:first-of-type &lt;/span&gt;li&lt;span style=&quot;color: #3333ff;&quot;&gt;:nth-last-&lt;/span&gt;child&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;font-weight&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;bold&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;兼容浏览器：IE9+、Firefox、Chrome、Safari、Opera。&lt;/p&gt;
&lt;p&gt;总结：&lt;/p&gt;
&lt;p&gt;如果你正在使用老版本的浏览器，如IE 6，在使用上面css选择器时一定要注意它是否兼容。不过，这不应成为阻止我们学习使用它的理由。在设计时，你可以参考浏览器兼容性列表，也可以通过脚本手段让老版本的浏览器也支持它们。&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;原文来自：&lt;a href=&quot;http://net.tutsplus.com/tutorials/html-css-techniques/the-30-css-selectors-you-must-memorize/&quot;&gt;The 30 CSS Selectors you Must Memorize&lt;/a&gt; &lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3  class=&quot;related-posts-title&quot;&gt;相关日志 »&lt;/h3&gt;&lt;ul class=&quot;related-list&quot;&gt;&lt;li&gt;2011/12/04 -- &lt;a href=&quot;http://blog.moocss.com/tutorials/html-css-tutorials/1701.html&quot; title=&quot;LESS的多种运行方式&quot;&gt;LESS的多种运行方式&lt;/a&gt; (0)&lt;/li&gt;&lt;li&gt;2011/08/09 -- &lt;a href=&quot;http://blog.moocss.com/code-snippets/html-css-code-snippets/1617.html&quot; title=&quot;DIV 高度100%&quot;&gt;DIV 高度100%&lt;/a&gt; (1)&lt;/li&gt;&lt;li&gt;2010/11/09 -- &lt;a href=&quot;http://blog.moocss.com/code-snippets/html-css-code-snippets/1406.html&quot; title=&quot;文字垂直排版&quot;&gt;文字垂直排版&lt;/a&gt; (1)&lt;/li&gt;&lt;li&gt;2010/11/04 -- &lt;a href=&quot;http://blog.moocss.com/tutorials/html-css-tutorials/1403.html&quot; title=&quot;CSS三角形的一些应用&quot;&gt;CSS三角形的一些应用&lt;/a&gt; (0)&lt;/li&gt;&lt;li&gt;2010/10/10 -- &lt;a href=&quot;http://blog.moocss.com/code-snippets/html-css-code-snippets/1390.html&quot; title=&quot;图片(水平垂直)居中&quot;&gt;图片(水平垂直)居中&lt;/a&gt; (0)&lt;/li&gt;&lt;li&gt;2010/09/16 -- &lt;a href=&quot;http://blog.moocss.com/tutorials/html-css-tutorials/1381.html&quot; title=&quot; 无JavaScript实现内容切换效果 &quot;&gt; 无JavaScript实现内容切换效果 &lt;/a&gt; (3)&lt;/li&gt;&lt;li&gt;2010/09/02 -- &lt;a href=&quot;http://blog.moocss.com/code-snippets/html-css-code-snippets/1375.html&quot; title=&quot;图像替换技术的最佳实战&quot;&gt;图像替换技术的最佳实战&lt;/a&gt; (3)&lt;/li&gt;&lt;li&gt;2010/04/15 -- &lt;a href=&quot;http://blog.moocss.com/code-snippets/html-css-code-snippets/1234.html&quot; title=&quot;CSS中区别IE6, IE7和 IE8  的4个非常有用的字符&quot;&gt;CSS中区别IE6, IE7和 IE8  的4个非常有用的字符&lt;/a&gt; (1)&lt;/li&gt;&lt;li&gt;2010/03/04 -- &lt;a href=&quot;http://blog.moocss.com/tutorials/html-css-tutorials/1137.html&quot; title=&quot;Web 设计中的 5 个最具争议性的话题&quot;&gt;Web 设计中的 5 个最具争议性的话题&lt;/a&gt; (0)&lt;/li&gt;&lt;li&gt;2010/01/26 -- &lt;a href=&quot;http://blog.moocss.com/tutorials/html-css-tutorials/1033.html&quot; title=&quot;网页设计中的面包屑导航：实例和最佳做法&quot;&gt;网页设计中的面包屑导航：实例和最佳做法&lt;/a&gt; (0)&lt;/li&gt;&lt;/ul&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/592291813/moocss/feedsky/s.gif?r=http://blog.moocss.com/code-snippets/html-css-code-snippets/1664.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</content:encoded><wfw:commentRss>http://blog.moocss.com/code-snippets/html-css-code-snippets/1664.html/feed</wfw:commentRss><slash:comments>5</slash:comments><fs:srclink>http://blog.moocss.com/code-snippets/html-css-code-snippets/1664.html</fs:srclink><fs:srcfeed>http://feed.moocss.com/</fs:srcfeed><fs:itemid>feedsky/cssrainbow/~8577171/592315289/5452281</fs:itemid><description>你也许已经掌握了id、class、后台选择器这些基本的css选择器。但这远远不是css的全部。下面向大家系统的解析css中30个最常用的选择器，包括我们最头痛的浏览器兼容性问题。掌握了它们，才能真正领略css的巨大灵活性。 1. * 1 * &amp;#123;margin: 0; padding: 0;&amp;#125; 星状选择符会在页面上的每一个元素上起作用。web设计者经常用它将页面中所有元素的margin和padding设置为0。 *选择符也可以在子选择器中使用。 1 #container * &amp;#123; border: 1px solid black;&amp;#125; 上面的代码中会应用于id为container元素的所有子元素中。 除非必要，我不建议在页面中过的的使用星状选择符，因为他的作用域太大，相当耗浏览器资源。 兼容浏览器：IE6+、Firefox、Chrome、Safari、Opera 2. #X 1 #container &amp;#123;width: 960px;margin: auto; &amp;#125; 井号作用域有相应id的元素。id是我们最常用的css选择器之一。id选择器的优势是精准，高优先级（优先级基数为100，远高于class的10），作为javascript脚本钩子的不二选择，同样缺点也很明显优先级过高，重用性差，所以在使用id选择器前，我们最好问下自己，真的到了非用id选择器的地步？ 兼容浏览器：IE6+、Firefox、Chrome、Safari、Opera 3. .X 1 .error &amp;#123;color: red;&amp;#125; 这是一个class(类)选择器。class选择器与id选择器的不同是class选择器能作用于期望样式化的一组元素。 兼容浏览器：IE6+、Firefox、Chrome、Safari、Opera 4. X Y 1 li a &amp;#123; text-decoration: none;&amp;#125; 这也是我们最常用的一种选择器——后代选择器。用于选取X元素下子元素Y，要留意的点是，这种方式的选择器将选取其下所有匹配的子元素，无视层级，所以有的情况是不宜使用的，比如上述的代码去掉li下的所有a的下划线，但li里面还有个ul，我不希望ul下的li的a去掉下划线。使用此后代选择器的时候要考虑是否希望某样式对所有子孙元素都起作用。这种后代选择器还有个作用，就是创建类似命名空间的作用。比如上述代码样式的作用域明显为li。 兼容浏览器：IE6+、Firefox、Chrome、Safari、Opera 5. X 1 2 [...]&lt;img src=&quot;http://www1.feedsky.com/t1/592291813/moocss/feedsky/s.gif?r=http://blog.moocss.com/code-snippets/html-css-code-snippets/1664.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>CSS</category><category>HTML/CSS</category><pubDate>Tue, 27 Sep 2011 22:10:23 +0800</pubDate><author>Rainbow</author><comments>http://blog.moocss.com/code-snippets/html-css-code-snippets/1664.html#comments</comments><guid isPermaLink="false">http://blog.moocss.com/?p=1664</guid><dc:creator>Rainbow</dc:creator></item><item><title>label标签的可访问性问题分析</title><link>http://item.feedsky.com/~feedsky/cssrainbow/~8577171/592315290/5452281/1/item.html</link><content:encoded>&lt;p&gt;最近对可访问性的研究比较多一些，有许多可访问性的实施细节，都是我们力所能及的，同时也是一些好的习惯和Web标准的最佳实战。&lt;/p&gt;
&lt;p&gt;我在上一篇文章《&lt;a href=&quot;http://blog.moocss.com/tutorials/accessibility/1627.html&quot; rel=&quot;bookmark&quot; title=&quot;Permanent Link to Accessibility,只需我们改变一点点儿&quot;&gt;Accessibility,只需我们改变一点点儿 &lt;/a&gt;》中说了许多关于可访问性的一些最佳实战，说道 &amp;#8220;表单控件元素要使用lable标签关联提示文本&amp;#8221;,这样可以有效的扩大表单控件元素的可点击区域，同时也很方便的获得表单控件元素的焦点。&lt;/p&gt;
&lt;p&gt;例如:单选框和复选框的操作就非常不方便，可点击的区域就非常小，如果用lable标签把提示文本与表单控件元素关联起来，可点击区域就扩大好几倍,操作起来当然就方便了。因此，label标签的使用对于提高页面的可访问性是很有帮助的。&lt;/p&gt;
&lt;p&gt;接下来，我就分析一下label标签的可访问性问题。&lt;/p&gt;
&lt;h2&gt;label的使用方式&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://dev.w3.org/html5/spec/forms.html#the-label-element&quot;&gt;HTML5草案&lt;/a&gt;中是这样说的：&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The label represents a caption in a user interface. The caption can be associated with a specific form control, known as the label element’s labeled control, either using for attribute, or by putting the form control inside the label element itself.&lt;/p&gt;
&lt;p&gt;label标签代表了用户界面上的一个标题，该标题可以与制定的表单控件相关联，即所谓的label元素标记控件。可以使用for属性，或是把表单控件放在label元素的里面实现该关联。&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;我们最常用的方式有两种，其一是使用label标签的for属性与控件元素的id相关联，其二就是使用label标签包裹控件元素，并且label标签的for属性与控件元素的id相关联。&lt;/p&gt;
&lt;h4&gt;The HTML Code:&lt;/h4&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;label&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;fullname&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;姓名:&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;label&lt;/span&gt;&amp;gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;input&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;fullname&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;fullname&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;h4&gt;The HTML Code:&lt;/h4&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;label&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;fullname&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;姓名:&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;input&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;fullname&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;fullname&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;label&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;我并不喜欢第二种写法，它在样式控制上非常不方便，例如全部标签等宽并且文本左对齐或右对齐,还有对读屏软件也不是很友好，有复读文本的副作用。&lt;/p&gt;
&lt;p&gt;差点忘了还有一种写法，就是label标签直接包裹控件元素,没有属性关联：&lt;/p&gt;
&lt;h4&gt;The HTML Code:&lt;/h4&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;label&lt;/span&gt;&amp;gt;&lt;/span&gt;姓名:&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;input&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;fullname&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;fullname&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;label&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href=&quot;http://www.topcss.org/?p=349&quot; target=&quot;_blank&quot;&gt;Jace&lt;/a&gt;老兄,给我们做了一下分类：显式label 和 隐式label。&lt;/p&gt;
&lt;h3&gt;显式label &lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;也就是说为label元素添加for属性，其属性值与表单控件的id属性值一致。&lt;/li&gt;
&lt;li&gt;重置和提交按钮(&amp;lt;input type=&amp;#8221;reset&amp;#8221;/&amp;gt; 、&amp;lt;input type=&amp;#8221;submit&amp;#8221;/&amp;gt;)， 图片按钮(&amp;lt;input type=&amp;#8221;img&amp;#8221;/&amp;gt;)以及脚本按钮 (&amp;lt;button&amp;gt;&amp;lt;/button&amp;gt;)不用使用显式label，因为它们已经有了隐式标签，如value 和 alt 属性值，button元素的内容。&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;label&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;fullname&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;姓名:&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;label&lt;/span&gt;&amp;gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;input&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;fullname&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;fullname&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;隐式label&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;根据HTML 4.01 规范， 通过label 元素包裹 表单控件和label包含的文本可创建&amp;rdquo;隐式label&amp;rdquo;。&lt;/li&gt;
&lt;li&gt;由于一些浏览器(IE6)不支持隐式label，WCAG2.0不建议使用。&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;label&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;fullname&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;姓名:&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;input&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;fullname&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;fullname&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;label&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;显式label 和 隐式label的混合体&lt;/h3&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;label&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;fullname&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;姓名:&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;input&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;fullname&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;fullname&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;label&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;ARIA States and Properties&lt;/h3&gt;
&lt;p&gt;使用&lt;a href=&quot;http://www.w3.org/TR/2010/WD-wai-aria-20100916/states_and_properties#aria-labelledby&quot;&gt;  aria-labelledby  &lt;/a&gt;属性。&lt;/p&gt;
&lt;h4&gt;The HTML Code:&lt;/h4&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;label&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;fullname&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;姓名:&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;label&lt;/span&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;input&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text&amp;quot;&lt;/span&gt; aria-labelledby&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;fullname&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;h4&gt;The HTML Code:&lt;/h4&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;label&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;fullname&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;姓名: &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;input&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text&amp;quot;&lt;/span&gt; aria-labelledby&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;fullname&amp;quot;&lt;/span&gt;&amp;gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;label&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href=&quot;http://blog.moocss.com/dw-content/demo37/form-control-labeling-tests.html&quot;&gt;&lt;img src=&quot;http://blog.moocss.com/dw-content/demo37/form-control-labeling-tests_1.png&quot; width=&quot;698&quot; height=&quot;395&quot; alt=&quot;text exposed by browsers as the form control name to accessibility APIs&quot;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://blog.moocss.com/dw-content/demo37/form-control-labeling-tests.html&quot;&gt;&lt;img src=&quot;http://blog.moocss.com/dw-content/demo37/form-control-labeling-tests_2.png&quot; width=&quot;672&quot; height=&quot;578&quot; alt=&quot;text announced by screen readers as the form control name&quot;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;看一个完整测试和结果：&lt;a href=&quot;http://blog.moocss.com/dw-content/demo37/form-control-labeling-tests.html&quot; class=&quot;button&quot;&gt;主流浏览器和屏幕阅读器控件标签化支持测试&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;得出的结论：&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;显式label是最健壮的方式,也是最佳实战。&lt;/li&gt;
&lt;li&gt;隐式label, 在屏幕阅读器&lt;a href=&quot;http://www.nvda-project.org/&quot;&gt;NVDA&lt;/a&gt; 中会重复内容，会带来没必要的干扰。&lt;/li&gt;
&lt;li&gt;aria-labelledby属性，在主流浏览器中可以获得更好的可访问性。&lt;/li&gt;
&lt;li&gt;显式label 和 隐式label的混合体，固然强大，隐式label的恶习留下了。&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;参考资料：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://yaccessibilityblog.com/library/form-labels-visible-and-hidden.html&quot;&gt;Form labels: visible and hidden&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.paciellogroup.com/blog/2011/07/html5-accessibility-chops-form-control-labeling/&quot;&gt;HTML5 Accessibility Chops: form control labeling&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;h3  class=&quot;related-posts-title&quot;&gt;相关日志 »&lt;/h3&gt;&lt;ul class=&quot;related-list&quot;&gt;&lt;li&gt;2011/08/10 -- &lt;a href=&quot;http://blog.moocss.com/tutorials/accessibility/1627.html&quot; title=&quot;Accessibility,只需我们改变一点点儿&quot;&gt;Accessibility,只需我们改变一点点儿&lt;/a&gt; (3)&lt;/li&gt;&lt;/ul&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/592291814/moocss/feedsky/s.gif?r=http://blog.moocss.com/tutorials/accessibility/1652.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</content:encoded><wfw:commentRss>http://blog.moocss.com/tutorials/accessibility/1652.html/feed</wfw:commentRss><slash:comments>0</slash:comments><fs:srclink>http://blog.moocss.com/tutorials/accessibility/1652.html</fs:srclink><fs:srcfeed>http://feed.moocss.com/</fs:srcfeed><fs:itemid>feedsky/cssrainbow/~8577171/592315290/5452281</fs:itemid><description>最近对可访问性的研究比较多一些，有许多可访问性的实施细节，都是我们力所能及的，同时也是一些好的习惯和Web标准的最佳实战。
我在上一篇文章《Accessibility,只需我们改变一点点儿 》中说了许多关于可访问性的一些最佳实战，说道 &quot;表单控件元素要使用lable标签关联提示文本&quot;,这样可以有效的扩大表单控件元素的可点击区域，同时也很方便的获得表单控件元素的焦点。&lt;img src=&quot;http://www1.feedsky.com/t1/592291814/moocss/feedsky/s.gif?r=http://blog.moocss.com/tutorials/accessibility/1652.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>Web可访问性</category><category>Accessibility</category><pubDate>Tue, 16 Aug 2011 22:31:56 +0800</pubDate><author>Rainbow</author><comments>http://blog.moocss.com/tutorials/accessibility/1652.html#comments</comments><guid isPermaLink="false">http://blog.moocss.com/?p=1652</guid><dc:creator>Rainbow</dc:creator></item><item><title>Accessibility,只需我们改变一点点儿</title><link>http://item.feedsky.com/~feedsky/cssrainbow/~8577171/592315291/5452281/1/item.html</link><content:encoded>&lt;p&gt;&lt;strong&gt;Accessibility&lt;/strong&gt;这个词频率这么高，但是一直没有深究过。通过&amp;#8221;&lt;a href=&quot;http://www.d2forum.org/&quot; target=&quot;_blank&quot;&gt;D2前端技术论坛&lt;/a&gt;&amp;#8220;这个平台，几个专题下来，我意识到它的重要性，我们在感受互联网带来幸福的同时，却把残障人士也应该得到幸福给无形的隔开了。&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;中国是全世界盲人最多的国家约500万盲人,占全世界盲人口的18%.每年在中国约有45万人失明,如果允许目前的趋势继续保持不变,到2020年预期中国盲人将增加4倍,如果让500万人口的盲人兄弟组成一个国家的话，他们在200多个国家中排名是110多位左右。&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;网页可访问性设计,只需我们改变一点点儿,盲人兄弟们也可以向我们一样畅游网络世界。&lt;/p&gt;
&lt;h2&gt;Accessibility是什么？&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;关于Accessibility，按照英语的构词法，&amp;#8221;可访问性&amp;#8221;没有任何问题。且&amp;#8221;性&amp;#8221;有&amp;#8221;能力&amp;#8221;的意思，因此&amp;#8221;可访问性&amp;#8221;即可被理解为&amp;#8221;网页可被访问的能力&amp;#8221;。而&amp;#8221;无障碍性&amp;#8221;则没有了&amp;#8221;访问&amp;#8221;的意思，如果要使用的话，也应该是&amp;#8221;无访问障碍性&amp;#8221;。综上，&amp;#8221;可访问性&amp;#8221;虽称不上完美，但仍差强人意。&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt; 可访问性(Accessibility)是互联网产品用户体验的指标之一，即网站的服务与内容能被用户访问到。&lt;/p&gt;
&lt;p&gt;主演能够解决的问题：&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;应付极端环境下的正常浏览需求；&lt;/li&gt;
&lt;li&gt;结构、表现、行为跨终端跨平台兼容支撑；&lt;/li&gt;
&lt;li&gt;保障残障人士无障碍信息获取；&lt;/li&gt;
&lt;li&gt;强化搜索引擎友好。&lt;/li&gt;
&lt;/ol&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;可访问性专题：&lt;/strong&gt;&lt;a href=&quot;http://rexsong.com/webdesign&quot; title=&quot;返回互联网设计实践&quot;&gt;页面的可访问性设计&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;ARIA (Accessible Rich Internet Applications)基础&lt;/h3&gt;
&lt;p&gt;WAI-ARIA( Web Accessibility Initiative &amp;#8211; Accessible Rich Internet Application)是W3C 的无障碍网页倡议（WAI）工作小组一直在倡导大家使用的无障碍网页应用技术。它是一套独立的规范，它弥补了HTML中的不足，帮助Web应用程序和Web页面变得更具可访问性。主要是用来解决应用了大量Ajax, HTML, Javascript和SVG等丰富前端技术的网页更具备可访问性的问题。所以说ARIA是web app 与AT(可访问性工具) 的桥梁。例如，我们经常见到的Dialog 、弹出层，模拟select 的下拉菜单等Web widget 小组件等都没有提供所需的语义作支持，辅助性技术很难做出分析和解读，当然残障人士也无法获取有效的信息流,可见它的重要性。&lt;/p&gt;
&lt;p&gt;屏幕读取器、语音识别软件和屏幕键盘均通过特定的语义标识（title、button~）读取网页组件本质信息，而WAI-ARIA 角色标准在语义化标识约定方面起至关重要的作用。&lt;/p&gt;
&lt;p&gt;ARIA的目标是，通过引入浏览器和辅助性技术能够识别的一系列的新属性，来弥补这种情况。&lt;/p&gt;
&lt;p&gt;ARIA对于开发者来说并不是万能药和救命稻草，我们应该正确的使用语义性的标签，来建立良好的文档结构，只有这样，我们再使用ARIA辅助语义，才能使我们的网页更具有可访问性。&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;ARIA规范说:&lt;/strong&gt;&amp;#8220;我们期望，随着时间的流逝，主语言将会通过改进，能够为之前只能使用WAI-ARIA声明的那些对象提供语义。当给定功能的本地语义变得可用时，开发者应该开始使用本地功能，并且停止使用WAI-ARIA来实现该功能&amp;#8221;。&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;WAI-ARIA技术主要包括三个方面：&lt;/h3&gt;
&lt;h4&gt;一. Role (描述区域作用或组件类型。侧重语义信息。) &lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;WAI-ARIA定义了几种角色，告诉辅助性技术一个文档的重要部分和结构。常见的一些如下：&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;role=&amp;#8221;application&amp;#8221; (Web App一些小控件)&lt;/li&gt;
&lt;li&gt;role=&amp;#8221;article&amp;#8221;&lt;/li&gt;
&lt;li&gt;role=&amp;#8221;banner&amp;#8221; (company logo和 site slogan)&lt;/li&gt;
&lt;li&gt;role=&amp;#8221;complementary&amp;#8221; (相当于主题内容的补充说明区域，包括，联系信息，Extra区域，博客的相关文章，博客和新闻的侧边栏)&lt;/li&gt;
&lt;li&gt;role=&amp;#8221;contentinfo&amp;#8221;  (版权信息区域，包括版权声明，链接隐私声明)&lt;/li&gt;
&lt;li&gt;role=&amp;#8221;document&amp;#8221; (整个页面)&lt;/li&gt;
&lt;li&gt;role=&amp;#8221;form&amp;#8221;&lt;/li&gt;
&lt;li&gt;role=&amp;#8221;heading&amp;#8221; (标题区域)&lt;/li&gt;
&lt;li&gt;role=&amp;#8221;main&amp;#8221; (内容主体区域)&lt;/li&gt;
&lt;li&gt;role=&amp;#8221;navigation&amp;#8221; (导航条或菜单区域，通常情况下，就是您的网站的各种功能的链接。)&lt;/li&gt;
&lt;li&gt;role=&amp;#8221;search&amp;#8221; (搜索区域),搜索框&lt;/li&gt;
&lt;li&gt;role=&amp;#8221;region&amp;#8221; (通用模块区域)&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://test.cita.uiuc.edu/aria/nav/nav1.html&quot;&gt;ARIA landmark role example 1&lt;/a&gt; (一个完整的页面是如何使用角色的)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.w3.org/WAI/PF/aria/roles&quot;&gt;http://www.w3.org/WAI/PF/aria/roles&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;strong&gt;HTML5结构元素，对应的WAI-ARIA role&lt;/strong&gt;&lt;/p&gt;
&lt;table border=&quot;1&quot; style=&quot;width:600px;&quot;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th width=&quot;200&quot;&gt;HTML5 Element &lt;/th&gt;
&lt;th&gt;WAI-ARIA Role &lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&amp;lt;article&amp;gt;&lt;/td&gt;
&lt;td&gt;article&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&amp;lt;aside&amp;gt;&lt;/td&gt;
&lt;td&gt;note, complementary, search&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&amp;lt;footer&amp;gt;&lt;/td&gt;
&lt;td&gt;contentinfo&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&amp;lt;header&amp;gt;&lt;/td&gt;
&lt;td&gt;banner&lt;br /&gt;
							(see note) &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&amp;lt;nav&amp;gt;&lt;/td&gt;
&lt;td&gt;navigation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&amp;lt;section&amp;gt;&lt;/td&gt;
&lt;td&gt;region, contentinfo, main, search&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h4&gt;二. State/property (描述状态与属性) &lt;/h4&gt;
&lt;p&gt;Web App 中 ARIA States and Properties的应用场景：&lt;/p&gt;
&lt;table border=&quot;1&quot; style=&quot;width:600px;&quot;&gt;
&lt;caption&gt;ARIA States and Properties&lt;/caption&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th width=&quot;200&quot;&gt;State&lt;/th&gt;
&lt;th&gt;Examples&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;activedescendant&lt;/td&gt;
&lt;td&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://test.cita.illinois.edu/aria/radio/radio3.php&quot;&gt;Radio 3&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;atomic&lt;/td&gt;
&lt;td&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a title=&quot;Live Regions&quot; href=&quot;http://test.cita.illinois.edu/aria/live/index.php&quot;&gt;Live Regions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;busy&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;checked&lt;/td&gt;
&lt;td&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://test.cita.illinois.edu/aria/checkbox/index.php&quot;&gt;Checkbox&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://test.cita.illinois.edu/aria/checkboxTriState/index.php&quot;&gt;Checkboxtristate&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title=&quot;Grid&quot; href=&quot;http://test.cita.illinois.edu/aria/grid/index.php&quot;&gt;E-mail grid&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;controls&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;datatype&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;describedby&lt;/td&gt;
&lt;td&gt;All Examples&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;disabled&lt;/td&gt;
&lt;td&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://test.cita.illinois.edu/aria/checkbox/checkbox4.php&quot;&gt;Checkbox 4&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://test.cita.illinois.edu/aria/checkboxTriState/checkboxTri1.php&quot;&gt;Checkboxtristate 1&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;expanded&lt;/td&gt;
&lt;td&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://test.cita.illinois.edu/aria/tree/index.php&quot;&gt;Tree&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;flowto&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;hasparent&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;haspopup&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;invalid&lt;/td&gt;
&lt;td&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://test.cita.illinois.edu/aria/tooltip/tooltip2.php&quot;&gt;Tooltip 2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;labelledby&lt;/td&gt;
&lt;td&gt;All Examples&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;multiselectable&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;pressed&lt;/td&gt;
&lt;td&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://test.cita.illinois.edu/aria/button/index.php&quot;&gt;Button&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;readonly&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;selected&lt;/td&gt;
&lt;td&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://test.cita.illinois.edu/aria/button/index.php&quot;&gt;Button&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title=&quot;Combobox&quot; href=&quot;http://test.cita.illinois.edu/aria/combobox/index.php&quot;&gt;Combobox&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;required&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;valuenow&lt;/td&gt;
&lt;td&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://test.cita.illinois.edu/aria/slider/index.php&quot;&gt;Slider&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;valuemax&lt;/td&gt;
&lt;td&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://test.cita.illinois.edu/aria/slider/index.php&quot;&gt;Slider&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;valuemin&lt;/td&gt;
&lt;td&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://test.cita.illinois.edu/aria/slider/index.php&quot;&gt;Slider&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;tabindex&lt;/td&gt;
&lt;td&gt;All examples&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;politeness&lt;/td&gt;
&lt;td&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a title=&quot;Live Regions&quot; href=&quot;http://test.cita.illinois.edu/aria/live/index.php&quot;&gt;Live Regions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;relevant&lt;/td&gt;
&lt;td&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a title=&quot;Live Regions&quot; href=&quot;http://test.cita.illinois.edu/aria/live/index.php&quot;&gt;Live Regions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;strong&gt;参考资料:&lt;/strong&gt;&lt;a href=&quot;http://test.cita.illinois.edu/&quot;&gt;http://test.cita.illinois.edu/aria/&lt;/a&gt;(ARIA(role ,states and properties)各种web app的完整测试例子)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4&gt;三. keydown + tabIndex (键盘操作的快捷方式)&lt;/h4&gt;
&lt;h3&gt;开发和测试可访问的 Web 应用主要有以下几个步骤：&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Webking 进行静态检查，通常由开发人员在单元测试时进行，检查 HTML 页面中不满足 CI162 所对应列表的项。目前由于 WebKing 不支持 ARIA，很多 ARIA 的标签不能被正确的识别，所以 WebKing 检查出的错误需要一一去检查区别是真正的违反 Checklist 还是由于 WebKing 不能识别 ARIA 的标签引起的。&lt;/li&gt;
&lt;li&gt;键盘支持，要求所有能通过鼠标完成的操作用键盘都能达到同样的效果。&lt;/li&gt;
&lt;li&gt;高对比度的支持：在高对比度模式下，屏幕只有黑白两色，要保证 Web 应用在这种模式下不丢失信息。&lt;/li&gt;
&lt;li&gt;读屏软件的支持，通常由测试人员完成。测试人员模拟盲人使用读屏软件，要保证页面上的内容基本都能为读屏软件所识别，并且能完成各种操作。&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;最佳实战：&lt;/h3&gt;
&lt;h4&gt;一. 正确使用&lt;strong&gt;语义化标签&lt;/strong&gt;,以获得完美文档结构。&lt;/h4&gt;
&lt;h5&gt;1. 表单元素要使用lable关联提示文本。&lt;/h5&gt;
&lt;h5&gt;2. img 标签&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;img标签在任何时候都必须拥有alt属性，这对读屏软件、搜索引擎、图片地址失效等都有好处的。&lt;/li&gt;
&lt;li&gt;嵌入图像中的文字必须包含在alt文本中。&lt;/li&gt;
&lt;li&gt;装饰性图片应该由CSS处理。&lt;/li&gt;
&lt;li&gt;链接中增强文本的图像，alt可以设置为空（一个alt属性值为空的图像和与图像配套的文本）。或者是用于装饰性的图片，则需设置 alt 为空，使得读屏软件可以忽略此元素。&lt;/li&gt;
&lt;li&gt;当链接内只有图像元素时，那么alt文本应描述链接的功能，而不是图像。&lt;/li&gt;
&lt;/ul&gt;
&lt;h5&gt;3. a标签&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;一个链接在脱离语境时仍然有意义。&lt;/li&gt;
&lt;li&gt;链接文本在它出现的页面上应该是唯一的（即不同资源不要使用相同的链接文本）。&lt;/li&gt;
&lt;li&gt;a标签一定要有href属性。&lt;/li&gt;
&lt;/ul&gt;
&lt;h5&gt;4. 像span等没有tab焦点的元素如果绑定onclick，要增加tabindex属性的控制。&lt;/h5&gt;
&lt;h4&gt;二. Tab键&lt;/h4&gt;
&lt;p&gt;Tabindex 属性的使用可以使得原本无法取得焦点的元素获取焦点。目的是为了使用户可以用键盘访问任何可以用鼠标访问的元素。我们知道，使用 Tab 键可以按文档顺序 tab 到所有可以获取焦点的元素。Tabindex 可以设置为 -1， 0 或者是任何自然数。&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Tabindex = 0 就使原本无法获取焦点的元素(例如span,em,strong,code等等)可以在用户 tab 的时候获取焦点，并且按照文档顺序排列。即，恢复到自然顺序。&lt;/li&gt;
&lt;li&gt;Tabindex = -1 使得元素可以获取焦点，但当用户用 tab 键访问的时候并不出现在 tab 的列表里面。可以方便的通过 JavaScript 设置上下左右键的响应事件。非常有利于应用小部件（widget）内部的键盘访问。&lt;/li&gt;
&lt;li&gt;Tabindex 设置小于 0 的值，将使得被设置的节点不再能够获得焦点。&lt;/li&gt;
&lt;li&gt;Tabindex 设置为大于 0 的数字则可以控制用户 Tab 时候的顺序，但是会打乱文档流中的正常顺序，一般很少用。&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;当用户使用 Tab 键浏览页面时，元素获取焦点的顺序是按照 HTML 代码里面元素出现的顺序排列的，有时跟实际看到的页面顺序并不一致。如浮动布局。&lt;/p&gt;
&lt;p&gt;杜绝非法中断Tab。&lt;a href=&quot;http://ued.taobao.com/blog/2011/04/15/onfocus-this-blur/&quot; title=&quot;盲人站长深恶痛绝的onfocus=”this.blur()”&quot; target=&quot;_blank&quot;&gt;盲人站长深恶痛绝的onfocus=&amp;rdquo;this.blur()&amp;rdquo;&lt;/a&gt;。&lt;/p&gt;
&lt;h4&gt;三. Title&lt;/h4&gt;
&lt;p&gt;自从w3c标准普及以后，出现了许多极端应用的例子，第一a标签内title不是必须使用的，第二title可以用在除了base, basefont, head, html, meta, param, script和title之外的所有标签上。&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;描述非文本内容(例如：icon图示的辅助说明)&lt;/li&gt;
&lt;li&gt;补充说明文本内容(例如：导航系统的各条中，使用title主要作用是做补充说明)&lt;/li&gt;
&lt;li&gt;操作指引 (例如：表单元素上使用title,可以为用户提供更精准、得体的操作指引,一定程度上可以代替文字说明。)&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;参考资料：&lt;/strong&gt;&lt;a href=&quot;http://blog.rexsong.com/?p=5959&quot; target=&quot;_blank&quot;&gt;使用Title提升可访问性&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4&gt;四. 替换文本(设置图片的Alt属性,Object对象的文本替换)&lt;/h4&gt;
&lt;p&gt;所有非文本内容呈现给用户时必须提供一个可供选择的替代文本去表达这些内容。&lt;/p&gt;
&lt;p&gt;所设置的替代文本必须具有语义，能够使用户清楚它所要传达的意义。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;每张图片都需要有替代文本:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;纯粹修饰性质的图片设置其为空&lt;/li&gt;
&lt;li&gt;与语义文本相邻的图片设置其为空&lt;/li&gt;
&lt;li&gt;组合图片只需为第一副图片设置替代文本，其他图片设置为空&lt;/li&gt;
&lt;/ol&gt;
&lt;h4&gt;五. 减少新开窗口提升可访问性&lt;/h4&gt;
&lt;h5&gt;1. 应该强制target=_blank :&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;文件下载链接&lt;/li&gt;
&lt;li&gt;文件打印链接&lt;/li&gt;
&lt;li&gt;非主线任务并打断进程的链接(需要前后对比的帮助，注册表单的隐私条款都有必要target=_blank)&lt;/li&gt;
&lt;/ul&gt;
&lt;h5&gt;2. 可选择target=_blank&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;跨域名链接&lt;/li&gt;
&lt;li&gt;跨应用平台链接&lt;/li&gt;
&lt;li&gt;布局改变链接&lt;/li&gt;
&lt;/ul&gt;
&lt;h5&gt;3. 不能强制target=_blank&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;导航链接&lt;/li&gt;
&lt;li&gt;面包屑导航&lt;/li&gt;
&lt;li&gt;tab条目链接&lt;/li&gt;
&lt;li&gt;返回操作链接&lt;/li&gt;
&lt;li&gt;翻页链接&lt;/li&gt;
&lt;li&gt;表单&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;参考资料:&lt;/strong&gt;&lt;a href=&quot;http://blog.rexsong.com/?p=6063&quot; rel=&quot;bookmark&quot; title=&quot;到《减少新开窗口提升可访问性》的永久链接&quot;&gt;减少新开窗口提升可访问性&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4&gt;六. 高度对比模式下注意事项:&lt;/h4&gt;
&lt;p&gt;CSS background 不可用。即,所有在CSS中设定的带有background属性都不可用。&lt;/p&gt;
&lt;p&gt;白色的图片在白色系高对比度模式下无法看到，黑色的图片在黑色系高对比度模式下无法看到。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;兼容高对比度模式的两种方式：&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;添加无background支持时将替代文本显示的CSS样式&lt;/li&gt;
&lt;li&gt;将部分background替换为image，将css sprite替换为image sprite&lt;/li&gt;
&lt;/ol&gt;
&lt;blockquote&gt;
&lt;p&gt; &lt;strong&gt;参考资料：&lt;/strong&gt; &lt;a href=&quot;http://www.artzstudio.com/2010/04/img-sprites-high-contrast/&quot; rel=&quot;bookmark&quot; title=&quot;Permanent Link: Foreground &amp;lt;img&amp;gt; Sprites – High Contrast Mode Optimization&quot;&gt;Foreground &amp;lt;img&amp;gt; Sprites – High Contrast Mode Optimization&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;辅助工具&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt; 无障碍在线测试工具（&lt;a href=&quot;http://wave.webaim.org/&quot;&gt;WAVE&lt;/a&gt;）
&lt;p&gt;无障碍软件安装：&lt;br /&gt;
      &lt;a href=&quot;http://firefox.cita.uiuc.edu/#install&quot;&gt;http://firefox.cita.uiuc.edu/#install&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;无障碍网站测试：&lt;br /&gt;
      &lt;a href=&quot;http://test.cita.uiuc.edu/aria/nav/nav1.php&quot;&gt;http://test.cita.uiuc.edu/aria/nav/nav1.php&lt;/a&gt;&lt;br /&gt;
      &lt;a href=&quot;http://www.gov.hk/sc/about/accessibility/assistivetools.htm&quot;&gt;http://www.gov.hk/sc/about/accessibility/assistivetools.htm&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;相关资料&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://yaccessibilityblog.com/library/tag/aria&quot;&gt;http://yaccessibilityblog.com/library/tag/aria&lt;/a&gt; and &lt;a href=&quot;http://yaccessibilityblog.com/&quot;&gt;http://yaccessibilityblog.com/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.ibm.com/developerworks/cn/web/1003_sunqy_access/&quot;&gt;开发和测试访问无障碍的 Web 应用&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3  class=&quot;related-posts-title&quot;&gt;相关日志 »&lt;/h3&gt;&lt;ul class=&quot;related-list&quot;&gt;&lt;li&gt;2011/08/16 -- &lt;a href=&quot;http://blog.moocss.com/tutorials/accessibility/1652.html&quot; title=&quot;label标签的可访问性问题分析&quot;&gt;label标签的可访问性问题分析&lt;/a&gt; (0)&lt;/li&gt;&lt;/ul&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/592291815/moocss/feedsky/s.gif?r=http://blog.moocss.com/tutorials/accessibility/1627.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</content:encoded><wfw:commentRss>http://blog.moocss.com/tutorials/accessibility/1627.html/feed</wfw:commentRss><slash:comments>3</slash:comments><fs:srclink>http://blog.moocss.com/tutorials/accessibility/1627.html</fs:srclink><fs:srcfeed>http://feed.moocss.com/</fs:srcfeed><fs:itemid>feedsky/cssrainbow/~8577171/592315291/5452281</fs:itemid><description>Accessibility这个词频率这么高，但是一直没有深究过。通过&amp;#8221;D2前端技术论坛&amp;#8220;这个平台，几个专题下来，我意识到它的重要性，我们在感受互联网带来幸福的同时，却把残障人士也应该得到幸福给无形的隔开了。 中国是全世界盲人最多的国家约500万盲人,占全世界盲人口的18%.每年在中国约有45万人失明,如果允许目前的趋势继续保持不变,到2020年预期中国盲人将增加4倍,如果让500万人口的盲人兄弟组成一个国家的话，他们在200多个国家中排名是110多位左右。 网页可访问性设计,只需我们改变一点点儿,盲人兄弟们也可以向我们一样畅游网络世界。 Accessibility是什么？ 关于Accessibility，按照英语的构词法，&amp;#8221;可访问性&amp;#8221;没有任何问题。且&amp;#8221;性&amp;#8221;有&amp;#8221;能力&amp;#8221;的意思，因此&amp;#8221;可访问性&amp;#8221;即可被理解为&amp;#8221;网页可被访问的能力&amp;#8221;。而&amp;#8221;无障碍性&amp;#8221;则没有了&amp;#8221;访问&amp;#8221;的意思，如果要使用的话，也应该是&amp;#8221;无访问障碍性&amp;#8221;。综上，&amp;#8221;可访问性&amp;#8221;虽称不上完美，但仍差强人意。 可访问性(Accessibility)是互联网产品用户体验的指标之一，即网站的服务与内容能被用户访问到。 主演能够解决的问题： 应付极端环境下的正常浏览需求； 结构、表现、行为跨终端跨平台兼容支撑； 保障残障人士无障碍信息获取； 强化搜索引擎友好。 可访问性专题：页面的可访问性设计 ARIA (Accessible Rich Internet Applications)基础 WAI-ARIA( Web Accessibility Initiative &amp;#8211; Accessible Rich Internet Application)是W3C 的无障碍网页倡议（WAI）工作小组一直在倡导大家使用的无障碍网页应用技术。它是一套独立的规范，它弥补了HTML中的不足，帮助Web应用程序和Web页面变得更具可访问性。主要是用来解决应用了大量Ajax, HTML, Javascript和SVG等丰富前端技术的网页更具备可访问性的问题。所以说ARIA是web app 与AT(可访问性工具) 的桥梁。例如，我们经常见到的Dialog 、弹出层，模拟select 的下拉菜单等Web widget 小组件等都没有提供所需的语义作支持，辅助性技术很难做出分析和解读，当然残障人士也无法获取有效的信息流,可见它的重要性。 屏幕读取器、语音识别软件和屏幕键盘均通过特定的语义标识（title、button~）读取网页组件本质信息，而WAI-ARIA 角色标准在语义化标识约定方面起至关重要的作用。 ARIA的目标是，通过引入浏览器和辅助性技术能够识别的一系列的新属性，来弥补这种情况。 ARIA对于开发者来说并不是万能药和救命稻草，我们应该正确的使用语义性的标签，来建立良好的文档结构，只有这样，我们再使用ARIA辅助语义，才能使我们的网页更具有可访问性。 ARIA规范说:&amp;#8220;我们期望，随着时间的流逝，主语言将会通过改进，能够为之前只能使用WAI-ARIA声明的那些对象提供语义。当给定功能的本地语义变得可用时，开发者应该开始使用本地功能，并且停止使用WAI-ARIA来实现该功能&amp;#8221;。 WAI-ARIA技术主要包括三个方面： 一. Role (描述区域作用或组件类型。侧重语义信息。) WAI-ARIA定义了几种角色，告诉辅助性技术一个文档的重要部分和结构。常见的一些如下： role=&amp;#8221;application&amp;#8221; (Web App一些小控件) role=&amp;#8221;article&amp;#8221; role=&amp;#8221;banner&amp;#8221; (company logo和 site slogan) [...]&lt;img src=&quot;http://www1.feedsky.com/t1/592291815/moocss/feedsky/s.gif?r=http://blog.moocss.com/tutorials/accessibility/1627.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>Web可访问性</category><category>ARIA</category><category>WAI-ARIA</category><category>Accessibility</category><pubDate>Wed, 10 Aug 2011 22:27:55 +0800</pubDate><author>Rainbow</author><comments>http://blog.moocss.com/tutorials/accessibility/1627.html#comments</comments><guid isPermaLink="false">http://blog.moocss.com/?p=1627</guid><dc:creator>Rainbow</dc:creator></item><item><title>DIV 高度100%</title><link>http://item.feedsky.com/~feedsky/cssrainbow/~8577171/592315292/5452281/1/item.html</link><content:encoded>&lt;p&gt;DIV 高度100%,也是我们比较常用的一个做法，那么如何高度100%自适应和兼容所有的浏览器是我们今天要讨论的小技巧。&lt;/p&gt;
&lt;p&gt;一个简单的应用场景是：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
5
6
7
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;    &lt;span style=&quot;color: #00bbdd;&quot;&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;html&lt;/span&gt;&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;head&lt;/span&gt;&amp;gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;head&lt;/span&gt;&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;body&lt;/span&gt;&amp;gt;&lt;/span&gt;
             &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;div&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;content&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;内容&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;div&lt;/span&gt;&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;body&lt;/span&gt;&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;html&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;根据上面的场景，我们要实现，ID为content的DIV高度100%，我们首先想到的做法是&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;html&lt;span style=&quot;color: #00AA00;&quot;&gt;,&lt;/span&gt;body&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;height&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #933;&quot;&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;100&lt;/span&gt;%&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #cc00cc;&quot;&gt;#content&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;height&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #933;&quot;&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;100&lt;/span&gt;%&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;内容满一屏或小于一屏的时候正常以上做法还能用，相反内容超过一屏的时候，ID为content的DIV设置的背景色或背景图片时就不是那么完美了，这个时候它只有一屏背景色或背景图片，超出一屏在第二屏显示的就没有背景色或背景图片了，被截取了。&lt;/p&gt;
&lt;p&gt;这个时候，通过测试发现IE6坚挺着，没问题，满足需求。而其它的ie7+ 和 moz &amp;#038; webkit 核心的浏览器都无法满足需求。&lt;/p&gt;
&lt;p&gt;接下来，就需要我们补救了。&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1
2
3
4
5
6
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;html&lt;span style=&quot;color: #00AA00;&quot;&gt;,&lt;/span&gt;body&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;height&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #933;&quot;&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;100&lt;/span&gt;%&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #cc00cc;&quot;&gt;#content&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;height&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;auto&lt;/span&gt;!important&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/*for ie6 bug and ie7+,moz,webkit 正确*/&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;height&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #933;&quot;&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;100&lt;/span&gt;%&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/*修复IE6,all browser*/&lt;/span&gt;
	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;min-height&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #933;&quot;&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;100&lt;/span&gt;%&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/*for ie6 bug and ie7+,moz,webkit 正确*/&lt;/span&gt;
&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;就这样,DIV 高度100% 自适应完美的实现了。&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;放出另一个案例,&amp;#8221;用Div模仿Frame框架（&lt;a href=&quot;http://moocss.com/styleguide/dpl/widget/simple-system-layout/index.html&quot;&gt;简单的&lt;/a&gt;，&lt;a href=&quot;http://moocss.com/styleguide/dpl/widget/cool-system-layout/index.html&quot;&gt;酷的&lt;/a&gt;）&amp;quot;,就是“DIV 高度100%”的集中应用。&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3  class=&quot;related-posts-title&quot;&gt;相关日志 »&lt;/h3&gt;&lt;ul class=&quot;related-list&quot;&gt;&lt;li&gt;2010/11/09 -- &lt;a href=&quot;http://blog.moocss.com/code-snippets/html-css-code-snippets/1406.html&quot; title=&quot;文字垂直排版&quot;&gt;文字垂直排版&lt;/a&gt; (1)&lt;/li&gt;&lt;li&gt;2010/11/04 -- &lt;a href=&quot;http://blog.moocss.com/tutorials/html-css-tutorials/1403.html&quot; title=&quot;CSS三角形的一些应用&quot;&gt;CSS三角形的一些应用&lt;/a&gt; (0)&lt;/li&gt;&lt;li&gt;2010/10/10 -- &lt;a href=&quot;http://blog.moocss.com/code-snippets/html-css-code-snippets/1390.html&quot; title=&quot;图片(水平垂直)居中&quot;&gt;图片(水平垂直)居中&lt;/a&gt; (0)&lt;/li&gt;&lt;li&gt;2010/09/16 -- &lt;a href=&quot;http://blog.moocss.com/tutorials/html-css-tutorials/1381.html&quot; title=&quot; 无JavaScript实现内容切换效果 &quot;&gt; 无JavaScript实现内容切换效果 &lt;/a&gt; (3)&lt;/li&gt;&lt;li&gt;2010/09/02 -- &lt;a href=&quot;http://blog.moocss.com/code-snippets/html-css-code-snippets/1375.html&quot; title=&quot;图像替换技术的最佳实战&quot;&gt;图像替换技术的最佳实战&lt;/a&gt; (3)&lt;/li&gt;&lt;li&gt;2009/04/29 -- &lt;a href=&quot;http://blog.moocss.com/articles/front-end-resources/172.html&quot; title=&quot;84个超级有用的CSS技巧与资源&quot;&gt;84个超级有用的CSS技巧与资源&lt;/a&gt; (0)&lt;/li&gt;&lt;li&gt;2011/12/04 -- &lt;a href=&quot;http://blog.moocss.com/tutorials/html-css-tutorials/1701.html&quot; title=&quot;LESS的多种运行方式&quot;&gt;LESS的多种运行方式&lt;/a&gt; (0)&lt;/li&gt;&lt;li&gt;2011/09/27 -- &lt;a href=&quot;http://blog.moocss.com/code-snippets/html-css-code-snippets/1664.html&quot; title=&quot;你须知道的30个CSS选择器&quot;&gt;你须知道的30个CSS选择器&lt;/a&gt; (5)&lt;/li&gt;&lt;li&gt;2010/08/17 -- &lt;a href=&quot;http://blog.moocss.com/code-snippets/html-css-code-snippets/1360.html&quot; title=&quot;IE CSS Bug Table&quot;&gt;IE CSS Bug Table&lt;/a&gt; (1)&lt;/li&gt;&lt;li&gt;2010/04/15 -- &lt;a href=&quot;http://blog.moocss.com/code-snippets/html-css-code-snippets/1234.html&quot; title=&quot;CSS中区别IE6, IE7和 IE8  的4个非常有用的字符&quot;&gt;CSS中区别IE6, IE7和 IE8  的4个非常有用的字符&lt;/a&gt; (1)&lt;/li&gt;&lt;/ul&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/592291816/moocss/feedsky/s.gif?r=http://blog.moocss.com/code-snippets/html-css-code-snippets/1617.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</content:encoded><wfw:commentRss>http://blog.moocss.com/code-snippets/html-css-code-snippets/1617.html/feed</wfw:commentRss><slash:comments>1</slash:comments><fs:srclink>http://blog.moocss.com/code-snippets/html-css-code-snippets/1617.html</fs:srclink><fs:srcfeed>http://feed.moocss.com/</fs:srcfeed><fs:itemid>feedsky/cssrainbow/~8577171/592315292/5452281</fs:itemid><description>DIV 高度100%,也是我们比较常用的一个做法，那么如何高度100%自适应和兼容所有的浏览器是我们今天要讨论的小技巧。 一个简单的应用场景是： 1 2 3 4 5 6 7 &amp;#60;!DOCTYPE html&amp;#62; &amp;#60;html&amp;#62; &amp;#60;head&amp;#62;&amp;#60;/head&amp;#62; &amp;#60;body&amp;#62; &amp;#60;div id=&amp;#34;content&amp;#34;&amp;#62;内容&amp;#60;/div&amp;#62; &amp;#60;/body&amp;#62; &amp;#60;/html&amp;#62; 根据上面的场景，我们要实现，ID为content的DIV高度100%，我们首先想到的做法是 1 2 html,body&amp;#123;height:100%;&amp;#125; #content&amp;#123;height:100%;&amp;#125; 内容满一屏或小于一屏的时候正常以上做法还能用，相反内容超过一屏的时候，ID为content的DIV设置的背景色或背景图片时就不是那么完美了，这个时候它只有一屏背景色或背景图片，超出一屏在第二屏显示的就没有背景色或背景图片了，被截取了。 这个时候，通过测试发现IE6坚挺着，没问题，满足需求。而其它的ie7+ 和 moz &amp;#038; webkit 核心的浏览器都无法满足需求。 接下来，就需要我们补救了。 1 2 3 4 5 6 html,body&amp;#123;height:100%;&amp;#125; #content&amp;#123; height:auto!important; /*for ie6 bug and ie7+,moz,webkit 正确*/ height:100%; /*修复IE6,all browser*/ min-height:100%; /*for ie6 bug and [...]&lt;img src=&quot;http://www1.feedsky.com/t1/592291816/moocss/feedsky/s.gif?r=http://blog.moocss.com/code-snippets/html-css-code-snippets/1617.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>CSS</category><category>CSS技巧</category><category>HTML/CSS</category><pubDate>Tue, 09 Aug 2011 17:18:53 +0800</pubDate><author>Rainbow</author><comments>http://blog.moocss.com/code-snippets/html-css-code-snippets/1617.html#comments</comments><guid isPermaLink="false">http://blog.moocss.com/?p=1617</guid><dc:creator>Rainbow</dc:creator></item><item><title>Scala学习资源</title><link>http://item.feedsky.com/~feedsky/cssrainbow/~8577171/592315293/5452281/1/item.html</link><content:encoded>&lt;p&gt;国外经典的Scala教程，Scala与Java的语法对比和异同，还有Scala语法指南。&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.artima.com/scalazine/articles/steps.html&quot;&gt;First Steps to Scala&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.codecommit.com/blog/scala/roundup-scala-for-java-refugees&quot;&gt;Roundup: Scala for Java Refugees&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.naildrivin5.com/scalatour/wiki_pages/MainPage&quot;&gt;Another tour of Scala&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://blogs.oracle.com/sundararajan/entry/scala_for_java_programmers&quot;&gt;Scala for Java programmers &amp;#8211; Part 1&lt;/a&gt; ,&lt;br /&gt;
&lt;a href=&quot;http://blogs.oracle.com/sundararajan/entry/scala_for_java_programmers_part&quot;&gt;Scala for Java programmers &amp;#8211; Part 2&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.slideshare.net/adamrabung/introduction-to-scala-for-java-programmers&quot;&gt;Introduction to Scala for Java Programmers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://davetron5000.github.com/scala-style/index.html&quot;&gt;Scala Style Guide(Scala语法指南)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://harrah.github.com/browse/samples/index.html&quot;&gt;http://harrah.github.com/browse/samples/index.html(源码查看器)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3  class=&quot;related-posts-title&quot;&gt;相关日志 »&lt;/h3&gt;&lt;ul class=&quot;related-list&quot;&gt;&lt;li&gt;暂无相关日志&lt;/li&gt;&lt;/ul&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/592291817/moocss/feedsky/s.gif?r=http://blog.moocss.com/tutorials/scala-tutorials/1607.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</content:encoded><wfw:commentRss>http://blog.moocss.com/tutorials/scala-tutorials/1607.html/feed</wfw:commentRss><slash:comments>0</slash:comments><fs:srclink>http://blog.moocss.com/tutorials/scala-tutorials/1607.html</fs:srclink><fs:srcfeed>http://feed.moocss.com/</fs:srcfeed><fs:itemid>feedsky/cssrainbow/~8577171/592315293/5452281</fs:itemid><description>国外经典的Scala教程，Scala与Java的语法对比和异同，还有Scala语法指南。 First Steps to Scala Roundup: Scala for Java Refugees Another tour of Scala Scala for Java programmers &amp;#8211; Part 1 , Scala for Java programmers &amp;#8211; Part 2 Introduction to Scala for Java Programmers Scala Style Guide(Scala语法指南) http://harrah.github.com/browse/samples/index.html(源码查看器) 相关日志 »暂无相关日志&lt;img src=&quot;http://www1.feedsky.com/t1/592291817/moocss/feedsky/s.gif?r=http://blog.moocss.com/tutorials/scala-tutorials/1607.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>scala</category><category>Scala</category><pubDate>Sun, 17 Jul 2011 21:11:35 +0800</pubDate><author>Rainbow</author><comments>http://blog.moocss.com/tutorials/scala-tutorials/1607.html#comments</comments><guid isPermaLink="false">http://blog.moocss.com/?p=1607</guid><dc:creator>Rainbow</dc:creator></item></channel></rss>
