Forum Moderators: not2easy

Message Too Old, No Replies

Heading Links

         

newdude

4:11 am on Nov 10, 2009 (gmt 0)

10+ Year Member



i have an H3 that is also a hyperlink. Although the h3 is coded in my CSS to turn red, when i add the hyperlink to it, it turns black. how do i keep it red? i tried the below css but that didnt work. please advise. thanks!


h3 {
font-size: 36px;
color: red;
margin: 0px;
padding: 0px;
text-align: center;
}
h3 a:link {
color: red;
}
h3 a:visited {
color: red;
}
h3 a:hover {
color: black;
}

D_Blackwell

5:00 am on Nov 10, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I see no problem.

1) The <h3> is not a link, but presumably contains a link.

It is only black on :hover - as specified.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<meta http-equiv="content-style-type" content="text/css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<style type="text/css" media="screen">
h3 {
font-size: 36px;
color: red;
margin: 0;
padding: 0;
text-align: center;
}
h3 a:link {
color: red;
}
h3 a:visited {
color: red;
}
h3 a:hover {
color: black;
}
</style>
</head>
<body>
<h3>
<a href="http://www.example.com">LINK</a>
</h3>
<!--##########
i have an H3 that is also a hyperlink. Although the h3 is coded in my CSS to turn red, when i add them hyperlink to it, it turns black. how do i keep it red? i tried the below css but that didnt work. please advise.
-->
</body>
</html>

andyodey

5:31 pm on Nov 13, 2009 (gmt 0)

10+ Year Member



you could always try doing the following:

h3 {
font-size: 36px;
color: red !important;
margin: 0px;
padding: 0px;
text-align: center;
}
h3 a:link {
color: red !important;
}
h3 a:visited {
color: red !important;
}
h3 a:hover {
color: black !important;
}

D_Blackwell

6:15 pm on Nov 13, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



!important; has its place, but excessive use as patching does not identify or correct the problem which is then merely masked.

Fotiman

6:45 pm on Nov 13, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You have a CSS rule that is explicitly setting it to black on hover:


h3 a:hover {
color: black;
}

If you want to keep it red, just change the color value to be red.

h3 a:hover {
color: red;
}

swa66

7:05 pm on Nov 13, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Another thing that could be is some other rule in your CSS that selects the <a> with a higher specificity and hence wins over your "h3 a" and "h3 a:link" etc.

Easiest to find it is to use e.g. the web developer toolbar in Firefox, and use the CSS/View style information to click on such an element and see what CSS it gets from where.