4 replies [Last post]
eskimo
eskimo's picture
Offline
Regular
Last seen: 11 years 48 weeks ago
Joined: 2007-04-24
Posts: 26
Points: 0

I have an ID rule which sets a default colour for all links.
I also have one link contained in this ID which I would like to set to a different colour - but I can't.

Is this right?

Thanks

-------------
Bo' Selecta

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 5 years 37 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

Show us how you have used an

Show us how you have used an ID to set anchor link colors, an ID may only be used once per page so I'm confused as to how you have used one to set all page links, have you used a descendent selector rule where the anhors are styles as nested elements of a antecedent ID element?

Normally one would set the general lnk colors then if wanting specific changes either target those specific anchors via a antecedent id or class or by giving the specific anchors a class or id.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

eskimo
eskimo's picture
Offline
Regular
Last seen: 11 years 48 weeks ago
Joined: 2007-04-24
Posts: 26
Points: 0

Hi HugoI've pasted my code

Hi Hugo

I've pasted my code below. I could avoid declaring the link colour in the id class, but I just wanted to check the current behaviour was normal. Any advice appreciated.

Untitled Document

this is some text and and a red link and this is a green link more text
this is a green link

-------------
Bo' Selecta

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 5 years 37 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

An ID carries more

An ID carries more importance than a class, it has a higher specificity, the rules as they stand will always result in red anchors as the #red a trumps a.green for the green class to apply just match the selector descendent group i.e

#red a.green {}

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

eskimo
eskimo's picture
Offline
Regular
Last seen: 11 years 48 weeks ago
Joined: 2007-04-24
Posts: 26
Points: 0

Thanks Hugo,That works a

Thanks Hugo,

That works a treat and it fits in with my somewhat sketchy grasp on CSS - now I just have to remember it for next time.

Thanks again!!!

-------------
Bo' Selecta