§ ITPOW >> 文档 >> CSS

如何为 a 的 class 写样式

作者:chilleen 来源:ITPOW(原创) 日期:2006-12-25

如果直接把 class 写在标签 a 里面,又如何为伪类 visited、hover 写样式呢?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>标签 a 中的 class 样式</title>
<style type="text/css">
a.ac:link
{
    color:#FF0000;
    text-decoration:none;
}
a.ac:visited
{
    color:#0000FF;
    text-decoration:underline;
}
a.ac:hover
{
    color:#00FFFF;
    text-decoration:underline;
}
</style>
</head>
<body>

<a href="http://www.itpow.com/" class="ac">超链接样式</a>

</body>
</html>

也可以写作:
a:link.ac
{
    color:#FF0000;
    text-decoration:none;
}
a:visited.ac
{
    color:#0000FF;
    text-decoration:underline;
}
a:hover.ac
{
    color:#00FFFF;
    text-decoration:underline;
}

相关文章