• Welcome to Valhalla Legends Archive.
 

[HTML/CSS] Specific class for certain links

Started by warz, August 16, 2005, 10:45 PM

Previous topic - Next topic

warz

Sorry for the repost. I didn't see the web dev forum.

Ok, I've got a few links on my page I want to use their own class. I've got it setup like so..


a.HL, a.HL:link, a.HL:visited {
font-family: Arial, sans-serif;
color: #7DCF12;
font-size: 12px;
text-decoration: none;
}

a.HL:active, a.HL:hover {
color: #B1FF4B;   
font-size: 12px;   
}

<a class="HL" href="...">link</a>


im not very good at CSS. Anyone know why these links aren't adopting their styles?

Akamas

Worked for me.....

My code

<style>
a.HL, a.HL:link, a.HL:visited {
font-family: Arial, sans-serif;
color: #7DCF12;
font-size: 12px;
text-decoration: none;
}

a.HL:active, a.HL:hover {
color: #B1FF4B;   
font-size: 12px;   
}
</style>
<a class="HL" href="...">link</a>


The only thing I added was, <style> and </style> around your CSS.
Quote from: Arta[vL] on August 14, 2006, 04:57 PM
Well, I want some too. Greedy Yoni should stop hogging it.

Spht

You should use ID selectors for this type of thing.

ID selector applies to an element that have an id set.  Note that an id is unique.  The ID selector contains a '#' immediately followed by the ID value.

a#HL, a:link#HL, a:visited#HL
{
     font-family: Arial, sans-serif;
     color: #7DCF12;
     font-size: 12px;
     text-decoration: none;
}

a:active#HL, a:hover#HL
{
     color: #B1FF4B;   
     font-size: 12px;   
}


<a id="HL" href="...">link</a>

R.a.B.B.i.T


FrOzeN

#4
@Rabbit, your way is good.. but better used if that link is only a One off. If you have alot of links using that style and ID would be more suited.
---

With the <style></style> shouldn't it be declared as.. <style="test/css"></style> ?

[EDIT] I mean, <style type="text/css"></style>.
~ FrOzeN

venox

If this is just 1 single link on the page, you could use what spht suggests and it would still be valid source.  However, the same ID should not  be refered to twice (or more) in one page.  That's a no no.

If you are planning on using this color/style for more than one link on any given page... use the following CSS:


.HL a:link, .HL a:visited {
     font-family: Arial, sans-serif;
     color: #7DCF12;
     font-size: 12px;
     text-decoration: none;
}

.HL a:active, .HL a:hover {
     color: #B1FF4B;   
     font-size: 12px;   
}

<a class="HL" href="...">Link</a>

JTN Designer

Personally, I just use:

.class1 a:link / .class2 a:link

<span class="class1"><a href=link>link</a></span>
(advertising deleted by forum administrator)

R.a.B.B.i.T

Quote from: FrOzeN on August 28, 2005, 12:18 AM
@Rabbit, your way is good.. but better used if that link is only a One off. If you have alot of links using that style and ID would be more suited.
---

With the <style></style> shouldn't it be declared as.. <style="test/css"></style> ?

[EDIT] I mean, <style type="text/css"></style>.
Personally I use a <link /> to include my CSS docs, but that's just me.  I prefer to superclass everything and then just either subclass or template what I need/want to change.