I’m working on a site where I want to make different styles for different sets of links. I’ve read tutorials and I still can’t get my code to work. So here’s the code.
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<style type="text/css">
a.test: link {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: 1em;
color: #C00;
}
a.test: hover {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: 1em;
color: #6F0;
}
a.test: active {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: 1em;
color: #90F;
}
a.test: visited {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: 1em;
color: #FF0;
}
</style>
</head>
<body>
Emily
<p>sdlkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjlsdkf
sdlkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjlsdkf
sdlkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjlsdkf
sdlkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjlsdkf
<p><span class="test"><a href="http://www.ehow.com/how_2080242_style-link-css.html">rose</a>
<a href="http://www.ehow.com/how_2080242_style-link-css.html" class="test"> daisy</a>
<a href="http://www.ehow.com/how_2080242_style-link-css.html" class="test">tulip</a>
<a href="http://www.ehow.com/how_2080242_style-link-css.html" class="test"> cactus</a> </span>
<p>ldkfjsldkfjlsdkfsdlkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjs ldkfjsldkfjlsdkfsdlkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsld
</body>
</html>
From what I’ve read, I understand I need to incorporate a class into the link style like this: a.test:link
And to incorporate the style into the link you give it a class like this,
cactus
And I can’t figure out why this isn’t working.
Thanks for your help!
Try to omit the spaces in your rules:
I don’t expect that this pseudo classes allows a space in their names.
By the way you can reduce you CSS to this: