CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignCSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 3rd, 2003, 11:36 PM
colpaarm's Avatar
colpaarm colpaarm is offline
300lb Bench!
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2001
Location: New York
Posts: 2,343 colpaarm User rank is Sergeant Major (2000 - 5000 Reputation Level)colpaarm User rank is Sergeant Major (2000 - 5000 Reputation Level)colpaarm User rank is Sergeant Major (2000 - 5000 Reputation Level)colpaarm User rank is Sergeant Major (2000 - 5000 Reputation Level)colpaarm User rank is Sergeant Major (2000 - 5000 Reputation Level)colpaarm User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 5 Days 10 h 50 m 4 sec
Reputation Power: 60
Having problems defining CSS tags in context

I'm trying to make a simple href definition work in two different situations. In other words, when I create an href in most situations, I want it to have one definition, when I create it within a <p> tag, I want it to have a different one. So I read up and came up with

a:link {
text-decoration: none;
font: 12px verdana, sans-serif;
color: #000000
}

p a:link {
color: #000000;
text-decoration: none;
font: 11px verdana, sans-serif;
}

which works fine, except that when I hover over a link I want to be able to control that style as well. For whatever reason, I'm having problems doing this. I've noticed that the order of things seems to affect things. So

a:link {
text-decoration: none;
font: 12px verdana, sans-serif;
color: #000000
}
a:visited {
text-decoration: none;
font: 12px verdana, sans-serif;
color: #000000
}
a:hover {
text-decoration: underline;
font: 12px verdana, sans-serif;
color: #000000
}

may work fine, but if I put the visited tag first, it may not. For whatever reason, I can only control the <p> version of a:link (can't control a:hover or a:visited). Any help would be greatly appreciated. Thanks in advance.

Reply With Quote
  #2  
Old February 4th, 2003, 03:30 AM
MJEggertson MJEggertson is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2002
Location: Seattle WA
Posts: 863 MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 22 sec
Reputation Power: 13
Re: Having problems defining CSS tags in context

Quote:
Originally posted by colpaarm
...when I create an href in most situations, I want it to have one definition, when I create it within a <p> tag, I want it to have a different one...

CSS does define a way to do this, it's called selectors, but it isn't supported in any of the old browsers (Netscape6, any flavor of Explorer...). So for now, you'd best use two different classes.
Code:
<html>
  <head>
    <style type="text/css">
      a.one:hover{color:red;}
      a.two:hover{color:green;}
    </style>
  </head>
  <body>
    <a href="http://google.com" class="one">google</a><br />
    <a href="http://google.com" class="two">google</a>
  </body>
</html>

Just define your hover, visited, etc pseudo-classes for each class of anchor and you'll be fine.

Reply With Quote
  #3  
Old February 4th, 2003, 09:04 AM
Tuxie Tuxie is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Inside the GNU/Hurd kernel
Posts: 492 Tuxie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 1 m
Reputation Power: 12
CSS selectors work just fine in Opera,Konqueror,IE for Mac and Mozilla.IE's support for CSS just sucks,just use the CSS 2 selectors and it will work in all the decent browsers.

Reply With Quote
  #4  
Old February 4th, 2003, 05:07 PM
MJEggertson MJEggertson is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2002
Location: Seattle WA
Posts: 863 MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 22 sec
Reputation Power: 13
Point is though, that it won't work for 90% of the people who visit your page.

Use code that works, not necessarily what is best.

Reply With Quote
  #5  
Old February 4th, 2003, 05:20 PM
adios adios is offline
Senior Citizen
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2001
Location: leftcoast
Posts: 2,019 adios User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 15
Quote:
CSS does define a way to do this, it's called selectors....
Might want to read this...

Reply With Quote
  #6  
Old February 4th, 2003, 05:54 PM
MJEggertson MJEggertson is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2002
Location: Seattle WA
Posts: 863 MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 22 sec
Reputation Power: 13
I've often wondered, what is the difference between a child selector and descendant selector? That is,
Code:
body a{color: red;}
body>a{color: red;}

Seem to define the same thing to me, save for the second one only works in the newer browsers.

Reply With Quote
  #7  
Old February 4th, 2003, 06:03 PM
jkd jkd is offline
CF sMod
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Location: Maine, USA (a.k.a. Boonies)
Posts: 242 jkd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 43 sec
Reputation Power: 13
Send a message via ICQ to jkd Send a message via AIM to jkd Send a message via Yahoo to jkd
body>a selects only immediate descendants, while body a selects all descendants.
__________________
Jason Contact Me
Super moderator @ CodingForums

Reply With Quote
  #8  
Old February 4th, 2003, 07:16 PM
MJEggertson MJEggertson is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2002
Location: Seattle WA
Posts: 863 MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 22 sec
Reputation Power: 13
Right...thanks.

Reply With Quote
  #9  
Old February 5th, 2003, 10:17 AM
colpaarm's Avatar
colpaarm colpaarm is offline
300lb Bench!
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2001
Location: New York
Posts: 2,343 colpaarm User rank is Sergeant Major (2000 - 5000 Reputation Level)colpaarm User rank is Sergeant Major (2000 - 5000 Reputation Level)colpaarm User rank is Sergeant Major (2000 - 5000 Reputation Level)colpaarm User rank is Sergeant Major (2000 - 5000 Reputation Level)colpaarm User rank is Sergeant Major (2000 - 5000 Reputation Level)colpaarm User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 5 Days 10 h 50 m 4 sec
Reputation Power: 60
Thanks immensely for the help guys!

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignCSS Help > Having problems defining CSS tags in context

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap