在a标签中运用最多:css
一、a:link
{color: #FF0000} /* 未访问的连接 */html
二、a:visited
{color: #00FF00} /* 已访问的连接 */spa
三、a:hover
{color: #FF00FF} /* 鼠标移动到连接上 */3d
四、a:active
{color: #0000FF} /* 选定的连接 */code
:first-child 伪类:选择元素的第一个子元素。orm
<div> <p>These are the necessary steps:</p> <ul> <li>Intert Key</li> <li>Turn key <strong>clockwise</strong></li> <li>Push accelerator</li> </ul> <p>Do <em>not</em> push the brake at the same time as the accelerator.</p> </div>
给定如下规则:htm
p:first-child {font-weight: bold;}
li:first-child {text-transform:uppercase;}
效果:第一个规则将做为某元素第一个子元素的全部 p 元素设置为粗体。第二个规则将做为某个元素(在 HTML 中,这确定是 ol 或 ul 元素)第一个子元素的全部 li 元素变成大写。blog
提示:最多见的错误是认为 p:first-child 之类的选择器会选择 p 元素的第一个子元素。get
在下面的例子中,选择器匹配全部 <p> 元素中的第一个 <i> 元素:it
<html> <head> <style type="text/css"> p > i:first-child { font-weight:bold; } </style> </head> <body> <p>some <i>text</i>. some <i>text</i>.</p> <p>some <i>text</i>. some <i>text</i>.</p> </body> </html>
注释:p>i这是选择p的直接子代中的i标签。以后是:first-child知足这个条件的第一个元素。