473,396 Members | 2,033 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Override CSS Link Color?

Have a web site which uses a CSS file. There is one link which I would like
to change the colors for the A:link, A:visited, and A:hover. Is there
something I can put in the HTML code to override the CSS values?
Jul 24 '05 #1
2 69742
Al Franz wrote:
Have a web site which uses a CSS file. There is one link which I would
like
to change the colors for the A:link, A:visited, and A:hover. Is there
something I can put in the HTML code to override the CSS values?


These changes do not belong into the HTML code. The purpose of external CSS
files is to keep such presentational stuff seperate from the document.

The only thing you need to change in your HTML is adding a 'class' attribute
to this special link, e.g.
<a class="specialLink" href="...">...</a>

Then add rules in your CSS file like

a.specialLink:link { color: white; }
a.specialLink:visited { color: black; }
a.specialLink:hover { color: red; }

--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
Jul 24 '05 #2
On Mon, 20 Jun 2005 14:20:20 -0700, "Al Franz"
<al****@nospam.netmation.com> wrote:
Is there something I can put in the HTML code to override the CSS values?


The "C" in "CSS" stands for "Cascading". The whole protocol is designed
to allow this to be done easily.

Use an in-line stylesheet like this:

<html><head>

< ... existing stuff .. >

<style type="text/css" >

a:link {
}
a:visited {
}
a:hover {
}
a:active {
}

</style>

</head>

More stuff....

With CSS' default behaviour, you'll still use the existing external
stylesheet, but you'll overwrite these specific rules with the internal
stylesheet. This obviously only applies to a page which contains this
internal stylesheet.

If you don't want to do this to all links, start using a class attribute
on them. If you want to do it to multiple pages, also consider using
class, with an external stylesheet.

The order of the pseudo-classes :hover etc. is significant.

Go read a good book, like Lie & Bos, on CSS
Jul 24 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: jfburr | last post by:
very simple thing (I hope) I've got a css style sheet that starts like this: ______________ A:link { color: cc9933; }
0
by: Andrea | last post by:
Hi everyone. I'm working on a navigation menu (in a frameset) that I want to set the "active" link to black (the link that corresponds to the page displayed in the right side of the frame) to...
3
by: Mason A. Clark | last post by:
This link is given in another thread: http://www.ccmeonline.org/agenda.html My Opera 7.23 in Windows XP will only show the links as black on gray. Not recognizable as links, although they...
1
by: kj | last post by:
I want to specify the color of certain style sheet element (say p.foo) to match the color of (unvisited) hyperlinks: p.foo { color: ??? } What should I replace ??? with to ensure that the...
4
by: crhaynes | last post by:
I'm having trouble with my CSS. My links are black, my hover is orange and my active link is red. When I select a link it turns red but i does not retain that color when the selected page loads. ...
2
by: Sheila King | last post by:
I have a test/mock-up page here: http://mathxy.com/dev/index.htm and I've set one link on the dark-blue menu bar the "Home" link that comes first and it is blue font, but should not be. ...
3
by: SStory | last post by:
I have a style sheet for my site. It has various classes in it. It has <A: styles defined for all anchor tags. I have a datagrid in ASP.NET with a stylesheet linked to the page. It defines...
1
beacon
by: beacon | last post by:
I'm looking to reset the visited link color once another link is selected. Also, once that link takes me to a particular page, I want the font-weight for that page to be bold to indicate that it's...
2
by: Garima12 | last post by:
There is htm page. In its body I am calling a class from stylesheet called TaskbarStyle(classname). Now I want to change the color of hyperlink in this page as well as their active link color. I am...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.