Welcome to Dream.In.Code
Become an Expert!

Join 149,521 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,389 people online right now. Registration is fast and FREE... Join Now!




Changing links in CSS

 
Reply to this topicStart new topic

Changing links in CSS

Mila
21 May, 2007 - 08:36 AM
Post #1

D.I.C Head
Group Icon

Joined: 28 Oct, 2006
Posts: 94


Dream Kudos: 25
My Contributions
I know the basics for changing links (ie: a:hover {color:#000000; text-decoration:underline;} etc), but what I want to know is if there is a way to change the links within a certain section of a document using css. Like having all of the links in my menu look a certain way, but look a different way on the rest of the page. Can I do this in CSS?

Mila
User is offlineProfile CardPM
+Quote Post

Oaty
RE: Changing Links In CSS
21 May, 2007 - 08:49 AM
Post #2

New D.I.C Head
*

Joined: 10 May, 2007
Posts: 28


My Contributions
QUOTE(Mila @ 21 May, 2007 - 09:36 AM) *

I know the basics for changing links (ie: a:hover {color:#000000; text-decoration:underline;} etc), but what I want to know is if there is a way to change the links within a certain section of a document using css. Like having all of the links in my menu look a certain way, but look a different way on the rest of the page. Can I do this in CSS?

Mila


Have you tried declaring a class for each of the different types of links?
For example for the menu you could declare:
CODE
a.menu:hover {color:#000000; text-decoration:underline;}

and for default links:
CODE
a:hover {color:#000000; text-decoration:underline;}

specify the class in the HTML with
CODE
<a href="foo.html" class="menu">a menu link</a>

or don't include a class attribute to use the default style.

User is offlineProfile CardPM
+Quote Post

no2pencil
RE: Changing Links In CSS
21 May, 2007 - 08:53 AM
Post #3

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 7,123



Thanked: 76 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
QUOTE(Mila @ 21 May, 2007 - 09:36 AM) *

I know the basics for changing links (ie: a:hover {color:#000000; text-decoration:underline;} etc), but what I want to know is if there is a way to change the links within a certain section of a document using css. Like having all of the links in my menu look a certain way, but look a different way on the rest of the page. Can I do this in CSS?

Mila


Rather than change all text links, you can give them an ID. Then you can referance that text link ID.

CODE

a:link { color: red }

a.external:link { color: blue }
<a class=external HREF="http://website/">external link</a>



User is online!Profile CardPM
+Quote Post

Mila
RE: Changing Links In CSS
21 May, 2007 - 12:44 PM
Post #4

D.I.C Head
Group Icon

Joined: 28 Oct, 2006
Posts: 94


Dream Kudos: 25
My Contributions
That seems so easy now I feel a bit stupid. tongue.gif Thanks so much!
User is offlineProfile CardPM
+Quote Post

no2pencil
RE: Changing Links In CSS
21 May, 2007 - 01:42 PM
Post #5

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 7,123



Thanked: 76 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
QUOTE(Mila @ 21 May, 2007 - 01:44 PM) *

That seems so easy now I feel a bit stupid. tongue.gif Thanks so much!


I actually had to look it up myself, to double check for accuracy. It had been awhile, but I knew I had it in code lying around!


User is online!Profile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 08:29PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month