在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知足這個條件的第一個元素。