Enjoy an ad free experience by logging in. Not a member yet?
Register .
03-05-2007, 12:50 AM
PM User |
#1
Regular Coder
Join Date: Apr 2006
Location: UK, England
Posts: 268
Thanks: 2
Thanked 0 Times in 0 Posts
Different Hyperlink CSS on a page
I have implemented two different CSS rules for one page, but I cant make them work at the same time. They are
Code:
.footerlinks
A {font-family:Arial, Helvetica, sans-serif; font-size:small;}
A:link {color: #666666;}
A:visited {color: #666666;}
A:hover {text-decoration: none; color: #000000;}
.emaillinks
A {font-family:Arial, Helvetica, sans-serif; font-size:small;}
A:link {color: #6633CC;}
A:visited {color: #6633CC;}
A:hover {color: #000000;}
Evertime I set the selected text to .emaillinks, the .footerlinks changes to .emaillinks too. It seems to be one or the other.
How can I use them both?
03-05-2007, 12:57 AM
PM User |
#2
The fat guy next door
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,600
Thanks: 5
Thanked 865 Times in 842 Posts
Looks like you're confusing CSS with JavaScript… (or is it just me because I've just studied JS the whole day?)
The correct way of writing it is:
Code:
.footerlinks a {font-family:Arial, Helvetica, sans-serif; font-size:small;color: #666;}
.footerlinks a:visited {color: #666;}
.footerlinks a:hover {text-decoration: none; color: #000;}
.emaillinks a {font-family:Arial, Helvetica, sans-serif; font-size:small; color: #63C;}
.emaillinks a:visited {color: #63C;}
.emaillinks a:hover {color: #000;}
Not the shorter/longer code is the problem but you have to specify a selector for every rule.
__________________
Don’t click this link !
03-05-2007, 01:02 AM
PM User |
#3
Senior Coder
Join Date: Mar 2006
Location: Splendora, Texas, United States of America
Posts: 2,887
Thanks: 5
Thanked 186 Times in 183 Posts
Your current (effective) code:
Code:
.footerlinks A {font-family:Arial, Helvetica, sans-serif; font-size:small;}
A:link {color: #666;}
A:visited {color: #666;}
A:hover {text-decoration: none; color: black;}
.emaillinks A {font-family:Arial, Helvetica, sans-serif; font-size:small;}
A:link {color: #63C;}
A:visited {color: #63C;}
A:hover {color: black;}
Probably what you want:
Code:
.footerlinks A {font-family:Arial, Helvetica, sans-serif; font-size:small;}
.footerlinks A:link {color: #666;}
.footerlinks A:visited {color: #666;}
.footerlinks A:hover {text-decoration: none; color: black;}
.emaillinks A {font-family:Arial, Helvetica, sans-serif; font-size:small;}
.emaillinks A:link {color: #63C;}
.emaillinks A:visited {color: #63C;}
.emaillinks A:hover {color: black;}
Increased efficiency:
Code:
A {font-family:Arial, Helvetica, sans-serif; font-size:small;}
.footerlinks A:link, .footerlinks A:visited {color: #666;}
.footerlinks A:hover {text-decoration: none; color: black;}
.emaillinks A:link, .emaillinks A:visited {color: #63C; }
.emaillinks A:hover {color: black;}
Context: VIPStephan beat me to the post. Posting anyway since I feel it’s still informative.
__________________
Please for the love of god stop making IE. You current "browser"s cause me to cry every day. —Phil *
03-05-2007, 10:07 AM
PM User |
#4
Regular Coder
Join Date: Apr 2006
Location: UK, England
Posts: 268
Thanks: 2
Thanked 0 Times in 0 Posts
Thanks alot!
What method should I use to implement it to my text. What I am doing now is highlighting the text, selecting the class, emaillinks for eg, and then linking it. But sometimes I still get the footerlinks CSS.
My page properties have my footerlink CSS applied to it, I think thats the problem, but it wont let me change it. It tells me its controlled by an external CSS sheet.
Last edited by J1mmy; 03-05-2007 at 01:25 PM ..
03-05-2007, 02:33 PM
PM User |
#5
Regular Coder
Join Date: May 2006
Posts: 127
Thanks: 0
Thanked 0 Times in 0 Posts
It could also be
Code:
a.footerlinks {font-family:Arial, Helvetica, sans-serif; font-size:small;}
a.footerlinks:link {color: #666;}
a.footerlinks:visited {color: #666;}
a.footerlinks:hover {text-decoration: none; color: black;}
a.emaillinks {font-family:Arial, Helvetica, sans-serif; font-size:small;}
a.emaillinks:link {color: #63C;}
a.emaillinks:visited {color: #63C;}
a.emaillinks:hover {color: black;}
And you html would be
Code:
<a href="..." class="footerlinks">linky</a>
or
<a href="..." class="emaillinks">email link</a>
03-05-2007, 04:38 PM
PM User |
#6
The fat guy next door
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,600
Thanks: 5
Thanked 865 Times in 842 Posts
Quote:
Originally Posted by
J1mmy
Thanks alot!
What method should I use to implement it to my text. What I am doing now is highlighting the text, selecting the class, emaillinks for eg, and then linking it. But sometimes I still get the footerlinks CSS.
My page properties have my footerlink CSS applied to it, I think thats the problem, but it wont let me change it. It tells me its controlled by an external CSS sheet.
What program are you using? Can we see your entire code please?
__________________
Don’t click this link !
03-05-2007, 04:59 PM
PM User |
#7
Regular Coder
Join Date: Apr 2006
Location: UK, England
Posts: 268
Thanks: 2
Thanked 0 Times in 0 Posts
I am using Dreamweaver.
The page code is as follows:
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=iso-8859-1" />
<title>Untitled Document</title>
<link href="New/CSSmail.css" rel="stylesheet" type="text/css" />
<link href="New/CSS.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
a:link {
color: 595959;
text-decoration: underline;
}
a:visited {
text-decoration: underline;
}
a:hover {
text-decoration: none;
color: 000000;
}
a:active {
text-decoration: underline;
color: #6633CC;
}
-->
</style></head>
<body>
<table width="850" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="51" height="15"></td>
<td width="230"></td>
<td width="65"></td>
<td width="228"></td>
<td width="72"></td>
<td width="130"></td>
<td width="74"></td>
</tr>
<tr>
<td height="73"></td>
<td valign="top" class="emaillinks"><a href="http://google.com" class="footerlinks">emaillinks go here</a></td>
<td> </td>
<td valign="top" class="footerlinks"><a href="html://google.com">footerlinks go here</a> </td>
<td> </td>
<td valign="top"><a href="http://google.com" class="emaillinks">link2</a></td>
<td> </td>
</tr>
<tr>
<td height="56"></td>
<td> </td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</body>
</html>
My CSS
Code:
.footerlinks A {font-family:Arial, Helvetica, sans-serif; font-size:small;}
.footerlinks A:link {color: #666;}
.footerlinks A:visited {color: #666;}
.footerlinks A:hover {text-decoration: none; color: black;}
.emaillinks A {font-family:Arial, Helvetica, sans-serif; font-size:small;}
.emaillinks A:link {color: #63C;}
.emaillinks A:visited {color: #63C;}
.emaillinks A:hover {text-decoration: none; color: black;}
03-05-2007, 05:15 PM
PM User |
#8
Regular Coder
Join Date: May 2006
Posts: 127
Thanks: 0
Thanked 0 Times in 0 Posts
You have
Code:
<td valign="top" class="emaillinks" ><a href="http://google.com" class="footerlinks" >emaillinks go here</a></td>
footerlinks is overriding the emaillinks in this instance.
03-06-2007, 07:44 PM
PM User |
#9
Regular Coder
Join Date: Apr 2006
Location: UK, England
Posts: 268
Thanks: 2
Thanked 0 Times in 0 Posts
Is this code written properly?
Code:
<a href="http://paypal.com/" class="weblinks">contact us</a>.
03-06-2007, 07:47 PM
PM User |
#10
Regular Coder
Join Date: May 2006
Posts: 127
Thanks: 0
Thanked 0 Times in 0 Posts
looks ok to me. why?
03-06-2007, 07:54 PM
PM User |
#11
Regular Coder
Join Date: Apr 2006
Location: UK, England
Posts: 268
Thanks: 2
Thanked 0 Times in 0 Posts
Becuase the CSS rule isnt working when I try to preview the page in the browser. I think something is overriding it somewhere. How can I find out if I have a CSS rule for links on the page already?
03-06-2007, 07:59 PM
PM User |
#12
Regular Coder
Join Date: May 2006
Posts: 127
Thanks: 0
Thanked 0 Times in 0 Posts
Do you have something like a.weblinks in your CSS?
Do you have a link we can see?
03-06-2007, 08:09 PM
PM User |
#13
Regular Coder
Join Date: Apr 2006
Location: UK, England
Posts: 268
Thanks: 2
Thanked 0 Times in 0 Posts
The CSS is on a seperate CSS file, I think there might be a CSS on that actual page though. How can I find this out?
Yes, the .weblink is there, in the CSS:
Code:
.weblinks A {font-family:Arial, Helvetica, sans-serif; font-size:small;}
.weblinks A:link {color: #3567cc;}
.weblinks A:visited {color: #3567cc;}
.weblinks A:hover {text-decoration: none; color: black;}
I dont have a link to the page Im afraid
03-06-2007, 08:11 PM
PM User |
#14
Regular Coder
Join Date: May 2006
Posts: 127
Thanks: 0
Thanked 0 Times in 0 Posts
No ... it needs to be
Code:
a.weblinks {font-family:Arial, Helvetica, sans-serif; font-size:small;}
a.weblinks :link {color: #3567cc;}
a.weblinks :visited {color: #3567cc;}
a.weblinks :hover {text-decoration: none; color: black;}
03-06-2007, 08:12 PM
PM User |
#15
Regular Coder
Join Date: Apr 2006
Location: UK, England
Posts: 268
Thanks: 2
Thanked 0 Times in 0 Posts
So, this isnt right either, posted by Arbitrator? This is where I got it from in the first place.
Code:
.footerlinks A {font-family:Arial, Helvetica, sans-serif; font-size:small;}
.footerlinks A:link {color: #666;}
.footerlinks A:visited {color: #666;}
.footerlinks A:hover {text-decoration: none; color: black;}
Jump To Top of Thread
Thread Tools
Rate This Thread
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
All times are GMT +1. The time now is 11:16 PM .
Advertisement
Log in to turn off these ads.