6 replies [Last post]
Homeboy
Offline
Enthusiast
Last seen: 15 years 14 weeks ago
Joined: 2004-08-17
Posts: 96
Points: 0

Hi,

I was wondering how can I have two different syle links? Meaning I have a link style for this one partcular thing then I make a different one for another link.

How would I do that?

Thanks

Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 3 days 13 hours ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5344
Points: 2965

make two different link style

Hi Homeboy,
You could give the links classes

<a href="#" class="yourclass">test</a> 
 
a.yourclass {color:red;} 


Hope that helps

Root
Offline
Enthusiast
Brighton UK
Last seen: 15 years 33 weeks ago
Brighton UK
Joined: 2004-09-08
Posts: 76
Points: 0

make two different link style

I would use CSS selectors.

The first style would be ul myfirstlinks ul

The second style would be ul mysecondlinks ul

That way each list can be styled independently within a common framework. It is a very handy and powerful CSS selector.

No class, little style and a lotta division.

roytheboy
roytheboy's picture
Offline
Guru
North Wales, UK
Last seen: 9 years 9 weeks ago
North Wales, UK
Timezone: GMT+1
Joined: 2004-09-18
Posts: 2233
Points: 41

make two different link style

Root's suggestion is neater but Tony's suggestion is easier to get to grips with if you're new to CSS. One step at a time an' all that!

Life's a b*tch and then you die!

Root
Offline
Enthusiast
Brighton UK
Last seen: 15 years 33 weeks ago
Brighton UK
Joined: 2004-09-08
Posts: 76
Points: 0

make two different link style

Well one solution would in theory style each individual link by assigning a class. The other would permit whole lists of links to be styled together in for example 2 or 3 different ways. Of course my solution presumes that the said links are in a nested list to start with. Link styling though is a big subject and always produces interesting questions so thanks Smile

No class, little style and a lotta division.

roytheboy
roytheboy's picture
Offline
Guru
North Wales, UK
Last seen: 9 years 9 weeks ago
North Wales, UK
Timezone: GMT+1
Joined: 2004-09-18
Posts: 2233
Points: 41

make two different link style

One method is adding much more XHTML code to the page than the other so, depending upon the specific needs of the specific page, your method (Root) is probably the best. My point is that when you're new to CSS and trying to grasp the principles (as I was not so long ago), it's sometimes easier to stick to simple concepts.

Life's a b*tch and then you die!

Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 3 days 13 hours ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5344
Points: 2965

make two different link style

Hi Guy's,
To tell the truth when I first started to post a solution I was going to have both solutions.
Then I found it hard to explain quickly, the concept of descendant selectors in a way someone new to css would find easy to understand so decide to stick with just the classes.

Sometimes it's better to learn one step at a time, specially when the teacher is lazy :?