Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
Old 05-10-2005, 01:35 AM CSS Problem
Extreme Talker

Posts: 172
Location: Milwaukee, WI
Trades: 0
Hi, I've got a problem with css using link colours.

I've used white for my links a:active, a:visited...

But the thing is that at some places i want the link to be red. How can I do this using classes, if possible? I tried using classes but it didnt work, maybe my coding was wrong. And then if i use <font> then during validation, it returns as a deprecated thing, so i really want to stay away from that as well.

Thanks in advance.
shashank_hi is offline
Reply With Quote
View Public Profile Visit shashank_hi's homepage!
 
 
Register now for full access!
Old 05-10-2005, 05:29 AM
praveen's Avatar
Life is a Dream

Posts: 3,591
Name: Praveen
Location: Chennai, India
Trades: 0
whereever you want the links to be red. create a div tag around it and assign it a id..

and then you can say #idname a:link { color : red }

this will work.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
praveen is offline
Reply With Quote
View Public Profile
 
Old 05-10-2005, 07:01 AM
Novice Talker

Posts: 13
Location: Sydney Australia
Trades: 0
no don't use div tags.


<style type="text/css">
.myclass:link{
color: blue:
}
.myclass:hover{
color: red;
}
</style>


<a href="#" class="myclass">something</a>
__________________

Please login or register to view this content. Registration is FREE
rimian is offline
Reply With Quote
View Public Profile Visit rimian's homepage!
 
Old 05-10-2005, 12:13 PM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
why not use divs?

It's the simplest and correct way to style a group of elements, especially anchors. using your method, which is incorrectly coded by the way. Every link on the page would need a class assigning to it, adding duplicated text to each <a> tag.
The name is Cascading style sheets which is what the first example by praveen is using. The style cascades down from the parent container.
You define once and assign once.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-10-2005, 01:37 PM
CasaPages's Avatar
SillyPhilly

Posts: 758
Location: between here an somewhere else
Trades: 0
becasue you can only use <div> ids ONCE..... so if you have red links scaterd through out the page with blue links each one of those red links would need a different <div id="?">......

however using something like class="Red" and class="Blue" you could use it everywhere......

and your css would look like this
Code:
 a.Red:link, a.Red:visited {color: red; text-decoration: none;}
 a.Red:hover {color: red; text-decoration: underline;}
Remember <div> ids are unique and can only be used ONCE where as classes can be used over and over and over.......

Quote:
Every link on the page would need a class assigning to it, adding duplicated text to each <a> tag.
How so you can style make your generic link tag

a:link, a:visited, a:hover, a:active and those wont need a class...well unless you want the link to be Red or Blue or Yellow or whatever you want.....

Making a div id would require you to make a new id every time you wanted a Red link in another section......

you would then have

#Red , #Red1, #Red3...... it would just get messy using Div ids.... I recomend classes for this...

Just my 2 cents
__________________
It Happens

Please login or register to view this content. Registration is FREE
CasaPages is offline
Reply With Quote
View Public Profile Visit CasaPages's homepage!
 
Old 05-10-2005, 03:33 PM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Yes. if you are going to use the style more than once use a class, If for a specific block then use an ID.
However the same still applies. if it is a group of links, it is sensible both for code overhead and site maintenance to use a parent container, be it <p>, <ul>, <div>, <span> and apply the class or ID to that. If you want one specific link to be different then assign the class for that in the element.

A whatif scenario. You have all your links with a class directly in the element say "red", what happens in 6 months time and you now want them yellow, are you going to go through every page and change the classname to yellow, lot of work there possibly, or would you redefine the colors in .red to be yellows? Hmm! very confusing when you revisit the design in a few weeks and everything with a class="red" are now yellow.

CSS is a very flexible medium, why make it hard for yourself? Use it as it is meant to be used, that is to cascade properties down the elements.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-10-2005, 03:52 PM
CasaPages's Avatar
SillyPhilly

Posts: 758
Location: between here an somewhere else
Trades: 0
Ok you took the name literal for the class..... you could call the class for the different links whatever you want.... then you wont have red and blue...

you could say have class "L1" and "L2" etc etc..... so then you can just go right ahead and change them to whatever your little heart desires...... it all depends on what you are doing..... but making divs isnt going to save you any time if you want to change the whole site...since in doingit that way you have already created different div IDs for each different style and each different group even if the group has the same style you need a different div ID now you have gotten yourself into A LOT of work and lots of the "same" things only with different IDs because they are grouped in different sections of the page....do you see what im getting at......

You really need to use both in a whole site that is why they exist.... Im not saying never use divs im saying that it seems like he would want to make a few different class types of different link styles he wants to use on the site and he can use div, ul , li, etc tags to organize them to organize them through out the site.......

and personally I dont use one CSS file for a whole site.....
__________________
It Happens

Please login or register to view this content. Registration is FREE
CasaPages is offline
Reply With Quote
View Public Profile Visit CasaPages's homepage!
 
Old 05-11-2005, 05:12 AM
praveen's Avatar
Life is a Dream

Posts: 3,591
Name: Praveen
Location: Chennai, India
Trades: 0
Quote:
personally I dont use one CSS file for a whole site.....
Ahh, then what will you do if u need to change the site colors/fonts etc... will u change the whole site just cos u want to modify one value??

as chris points out the same thing

Quote:
A whatif scenario. You have all your links with a class directly in the element say "red", what happens in 6 months time and you now want them yellow, are you going to go through every page and change the classname to yellow, lot of work there possibly, or would you redefine the colors in .red to be yellows? Hmm! very confusing when you revisit the design in a few weeks and everything with a class="red" are now yellow.
shashank, i would advise you to stick with assigning ids to the block where you want to change the link colors to red and leave the others as it is. it is very easy.

next time you want to change them or you feel you dont need them, you just simply give the same values as your normal link.

if u r going to use class, then you will have go to the particular location and change the values by hand which is time consuming..

i can give you some tips/websites where it is explained in much more detail.

thanks chris for the support
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
praveen is offline
Reply With Quote
View Public Profile
 
Old 05-11-2005, 01:32 PM
CasaPages's Avatar
SillyPhilly

Posts: 758
Location: between here an somewhere else
Trades: 0
Quote:
personally I dont use one CSS file for a whole site.....


Ahh, then what will you do if u need to change the site colors/fonts etc... will u change the whole site just cos u want to modify one value??
No I use individual style sheets for each sub section....so I have like 4 css files...and all the styling that stays the same (main menu stuff...) is on the top of the sheet...I like this since then I have a few small CSS files instead of one HUGE long one that is a pain to find things in......
__________________
It Happens

Please login or register to view this content. Registration is FREE

Last edited by CasaPages; 05-11-2005 at 01:36 PM..
CasaPages is offline
Reply With Quote
View Public Profile Visit CasaPages's homepage!
 
Reply     « Reply to CSS Problem
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.29416 seconds with 12 queries