html伪选择子的顺序问题

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html> 

<head> 
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" /> 

<title> </title> 
<style>
a:link
{text-decoration:none;}
a:visited
{text-decoration:none;}
/*link和visited一定要放在active和hover的前面,因为这四个属性特殊性相同且link和visited包含active和hover状态,如果放在后面会覆盖active和hover的共有CSS属性(比如此例中,如果将link和visited放在active和hover的后面,link和visited的text-decoration属性设置会覆盖active和hover的text-decoration属性设置,使链接下划线始终不出现)*/

a:hover
{text-decoration:underline;color:black;}
a:active
{text-decoration:underline;color:red;}
/*此外active一定要放在hover后面,因为hover属性也包含active属性且他们特殊性相同,如果hover出现在active后面,hover将覆盖active的共有CSS属性(比如本例中如果a:hover在a:active后面,a:hover的color属性设置将覆盖a:active的color属性设置,将导致鼠标点击链接时还是显示黑色字体而不是红色)*/
/*
因此官方推荐的设置顺序是:link visited hover active
*/
</style>
</head> 

<body> 
<href="#">Click</a>
</body> 
</html> 
原文地址:https://www.cnblogs.com/OpenCoder/p/1564209.html