473,320 Members | 2,003 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,320 software developers and data experts.

How do I get links that do NOT have a different color.

Okay, IE and Netscape have a default link style with "color: blue;"
and "text-decoration: underline". That's fine, but for what I am
doing I need to turn OFF the default styling.

I know how to change it so that it is another color, or force it to
NOT have underlining, or make it bold, or italics, or whatever. The
problem is, how do I get it to turn the syling OFF completely. How do
I get it NOT to change the color or text-decoration of the text?

For example: consider the following HTML example:
<html>
<style type="text/css">
#sheep { color: black; }
#fox { color: brown; }
#boy { color: blue; }
</style>
<body>
<span id="sheep">Baa Baa <a href="#black">Black</aSheep</
span><br/>
<span id="fox">The quick <a href="#brown">brown</afox jumped
over the lazy dog.</span><br/>
<span id="boy">Little boy <a href="#blue">blue</acome blow
your horn.</span><br/>
</body>
</html>

If you render this in a browser the links "Black", "brown", and "blue"
are all blue with an underline. I don't want the links to change
color. I want the color to be the same as that of the sentence it is
in. i.e. For this example the link in the first line should be black,
the second should be brown, and the third it should be blue, just like
the rest of the surrounding text.

Adding this to the style section doesn't work (didn't figure it would,
but it was worth a shot):

a:link { color:none; }
a:visited { color:none; }
a:hover { color:none; }
a:active { color:none; }

And adding this to the style section doesn't work either:

a:link { color:inherit; }
a:visited { color:inherit; }
a:hover { color:inherit; }
a:active { color:inherit; }

I have the same basic question about the text-decoration. I can force
the text-decoration to be a specific way (i.e. text-decoration:
underline or text-decoration: none) but what if I want the text
decoration to be whatever the the parent elements text-decoration
is?

Any ideas?
-alan

May 31 '07 #1
11 2427
Alan wrote:
Okay, IE and Netscape have a default link style with "color: blue;"
and "text-decoration: underline". That's fine, but for what I am
doing I need to turn OFF the default styling.
Interesting that you would "need" that. How is a visitor supposed to
find the link?
>
I know how to change it so that it is another color, or force it to
NOT have underlining, or make it bold, or italics, or whatever. The
problem is, how do I get it to turn the syling OFF completely. How do
I get it NOT to change the color or text-decoration of the text?
Set the surrounding text to be blue and underlined. Then no change will
occur for the link (until it's been /visited/, that is.)
>
For example: consider the following HTML example:
<html>
<style type="text/css">
#sheep { color: black; }
#fox { color: brown; }
#boy { color: blue; }
</style>
<body>
<span id="sheep">Baa Baa <a href="#black">Black</aSheep</
span><br/>
<span id="fox">The quick <a href="#brown">brown</afox jumped
over the lazy dog.</span><br/>
<span id="boy">Little boy <a href="#blue">blue</acome blow
your horn.</span><br/>
</body>
</html>
Try modifying your CSS like so:

#sheep, #sheep a { color: black; }
#fox, #fox a { color: brown; }
#boy, #boy a { color: blue; }

User stylesheets, where used, will thwart your scheme, but that's as it
should be.

Also, your <span>s look like they really ought to be <p>s or <div>s.
Even if you keep them as spans, you could set them to display:block and
specify appropriate margins. In any case, you can get rid of the <br>s.

HTH
--
John
May 31 '07 #2
Alan wrote:
I know how to change it so that it is another color, or force it to
NOT have underlining, or make it bold, or italics, or whatever. The
problem is, how do I get it to turn the syling OFF completely. How do
I get it NOT to change the color or text-decoration of the text?
a { color: inherit; text-decoration: inherit; }

--
David
Stardate 7411.5
May 31 '07 #3
Alan <ar*****@gmail.comwrites:
Okay, IE and Netscape have a default link style with "color: blue;"
and "text-decoration: underline". That's fine, but for what I am
doing I need to turn OFF the default styling.
You don’t explain what you are doing, so instead of proposing a
dysfunctional solution you could just have said

“I want to turn off the default styling for links.”
I know how to change it so that it is another color, or force it to
NOT have underlining, or make it bold, or italics, or whatever. The
problem is, how do I get it to turn the syling OFF completely. How do
I get it NOT to change the color or text-decoration of the text?
Removing the HREF attribute works pretty good. Removing the
corresponding tags works even better.
Adding this to the style section doesn't work (didn't figure it would,
but it was worth a shot):

a:link { color:none; }
a:visited { color:none; }
a:hover { color:none; }
a:active { color:none; }
It depends on the cost per shot. One could point to the CSS spec, but
I’d rather point to the last chapter of “Surely You're Joking,
Mr. Feynman!”.
And adding this to the style section doesn't work either:

a:link { color:inherit; }
a:visited { color:inherit; }
a:hover { color:inherit; }
a:active { color:inherit; }
And you tried that with … ?

You are looking for inherit (no need for the pseudo-classes), but you
are looking with the wrong software.

If you want to err on the safe side,

body,
table,
a
{
color: /* insert RGB value or keyword */;
text-decoration: none;
}

should do the trick with a single rule set.

Most people tend to forget to add

cursor: text

and

outline: none;

to that.

To make it bulletproof you should add something like

<script type="text/javascript">
window.onload = function () {
var a = document.getElementsByTagName('A'), l = a.length;
while (l--) {
a[l].onclick = function () {
return false;
}
}
}
</script>

(some visitors just won’t give up, no matter how hard you try to
discourage them)
--
||| hexadecimal EBB
o-o decimal 3771
--oOo--( )--oOo-- octal 7273
205 goodbye binary 111010111011
May 31 '07 #4
In article <46********@news.bluewin.ch>,
John Hosking <Jo**@DELETE.Hosking.name.INVALIDwrote:
Alan wrote:
Okay, IE and Netscape have a default link style with "color: blue;"
and "text-decoration: underline". That's fine, but for what I am
doing I need to turn OFF the default styling.

Interesting that you would "need" that. How is a visitor supposed to
find the link?
Might be some sort of game? With a prize?

<http://members.optushome.com.au/droovies/test/findTheLink.html>

(I notice more sophistication in later posts after yours John,
which I have not incorporated.

Also I had hoped to get a css equiv to the blink tag.

--
dorayme
May 31 '07 #5
rf
"dorayme" <do************@optusnet.com.auwrote in message
news:doraymeRidThis-427C72.13034031052007@news-
Might be some sort of game? With a prize?

<http://members.optushome.com.au/droovies/test/findTheLink.html>
As you do not provide a background colour for the page it is immediately
apparent which "here" is the link. The white one. All the others have my
default pink background :-)

--
Richard.
May 31 '07 #6
In article <gy*****************@news-server.bigpond.net.au>,
"rf" <rf@invalid.comwrote:
"dorayme" <do************@optusnet.com.auwrote in message
news:doraymeRidThis-427C72.13034031052007@news-
Might be some sort of game? With a prize?

<http://members.optushome.com.au/droovies/test/findTheLink.html>

As you do not provide a background colour for the page it is immediately
apparent which "here" is the link. The white one. All the others have my
default pink background :-)
God dammit and dammit and dammit. I did think at the time, can I
be bothered, and thought nah... But here you are with your own
stylesheet! And not just plain white. You get an edge in these
find the link comps!

Anyway... now I am wondering like JH, what OP's reason really
was? Perhaps we should pass the hat around and see if he will
reveal it for a small payment?

--
dorayme
May 31 '07 #7
Scripsit Eric B. Bednarz:
You don’t explain what you are doing, so instead of proposing a
dysfunctional solution you could just have said

“I want to turn off the default styling for links.”
Apart from games and tricks, there’s a context where such a request makes
sense: in a print stylesheet. It’s usually pointless to indicate links as
links on paper, at least using the default styling.

In a print stylesheet, you normally don’t have the problem of inheriting
color. Instead, you can set the color to a specific value.

The following should work reasonably:

@media print {
* { color: black !important;
background: white !important;
text-decoration: none !important; }}

Any user style sheet that trumps that with !important probably does that
with a reason, and in any case, it’s up to the user then.

If you don’t want to use !important (which _is_ often too powerful a
weapon), you can use

*, a:link, a:visited
{ color: black;
background: white;
text-decoration: none; }}
--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

May 31 '07 #8
rf

"dorayme" <do************@optusnet.com.auwrote in message
news:do**********************************@news-vip.optusnet.com.au...
In article <gy*****************@news-server.bigpond.net.au>,
"rf" <rf@invalid.comwrote:
>"dorayme" <do************@optusnet.com.auwrote in message
news:doraymeRidThis-427C72.13034031052007@news-
Might be some sort of game? With a prize?

<http://members.optushome.com.au/droovies/test/findTheLink.html>

As you do not provide a background colour for the page it is immediately
apparent which "here" is the link. The white one. All the others have my
default pink background :-)

God dammit and dammit and dammit. I did think at the time, can I
be bothered, and thought nah... But here you are with your own
stylesheet! And not just plain white. You get an edge in these
find the link comps!
Not a user style sheet. Just browser settings.

--
Richard.
May 31 '07 #9
rf

"Harlan Messinger" <hm*******************@comcast.netwrote in message
news:5c*************@mid.individual.net...
John Hosking wrote:
>Alan wrote:
>>Okay, IE and Netscape have a default link style with "color: blue;"
and "text-decoration: underline". That's fine, but for what I am
doing I need to turn OFF the default styling.

Interesting that you would "need" that. How is a visitor supposed to find
the link?

Well, "need" may be a misstatement, but if the links are in a readily
identifiable navigation bar, then cues are present other than the ones
used to make links stand out within paragraph text.
<quote src=OP>
I don't want the links to change
color. I want the color to be the same as that of the sentence it is
in.
</quote>

Mystery meat navigation?

--
Richard.
Jun 1 '07 #10
"Jukka K. Korpela" <jk******@cs.tut.fiwrites:
Apart from games and tricks, there’s a context where such a request
makes sense: in a print stylesheet. It’s usually pointless to indicate
links as links on paper, at least using the default styling.
Sure, but we still don’t know what (and why) the OP is trying to
achieve. I don’t know any real dumb clients IRL either, they are just
happy to disregard common sense (and scientific research) because this
time it is about *them*, and they are special, after all.
In a print stylesheet, you normally don’t have the problem of
inheriting color. Instead, you can set the color to a specific value.
You can always do that, and I think the OP already knows how. I can
sympathize with the idea of maintainability, though (it’s not too
difficult to manage color and background values programmatically even
for more or less complex screen scenarios, but it shouldn’t be
necessary).
--
||| hexadecimal EBB
o-o decimal 3771
--oOo--( )--oOo-- octal 7273
205 goodbye binary 111010111011
Jun 1 '07 #11
Jukka K. Korpela wrote:
Apart from games and tricks, there’s a context where such a request makes
sense: in a print stylesheet. It’s usually pointless to indicate links as
links on paper, at least using the default styling.
Another use: on my company's internal website, I maintain some
information pages. Where a topic coincides with something that exists at
Homestar Runner, I put in a hidden link, for anyone lucky enough to
notice it. Just for fun.

If you think that's of no practical value, consider this: pulling stuff
like this makes me much more willing to maintain the pages!

--
David
Stardate 7416.4
Jun 1 '07 #12

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

Similar topics

7
by: Chris | last post by:
I'm using eight links listed horizontally as a menu on my site. I'm using font-variant:small-caps and they are padded so that they mimic buttons. My gripe is with the way IE handles the focus...
4
by: Isabelle | last post by:
Hello all, I want two sets of links to do different things; one set within *content* and the other *navigational* elements. In particular I want the *hover* rollover effect to work differently...
32
by: Mark Johnson | last post by:
You have an, a, anchor with href link. Can you use a stylesheet to effectively disable the link, so that you can't click on it; that it will appear simply as text?
18
by: Jan Tuxen | last post by:
Jakob Nielsen in his most recent Alertbox (http://www.useit.com/alertbox/20040503.html) tells web authors to change the color of visited links. I agree to his purpose: Help users understand...
7
by: Will Hartung | last post by:
I have this: <a class="pink_link" href="faq.html#q1">Go to question 1</a> And the CSS is simply: ..pink_link {color: #fa61b7; font-weight: bold;} So, I'm curious why my links are blue and...
6
by: Pasi Kovanen | last post by:
How do I define for example link inside H1 style to be of different color than other links in the same page: <a href="blah">this is some color</a> <h1><a href="blahblah">this is different...
19
by: opt_inf_env | last post by:
Hello all, I know that in html to set colors of visited and activ links one need to use line in the following format: <BODY text="#FF0000" link="#0000FF" alink="#FFFF00" vlink="#00FF00"> ...
4
by: Fred | last post by:
I want to insert DHL and FedEx tracking links with the waybill numbers in the body of emails I am sending using sendobject. I am not sending attachments. DHL and FedEx use long links that...
15
by: Roedy Green | last post by:
I seem to recall reading about a feature so that you could apply different styles to different kinds of link. e.g. local and offsite or to automatically put a logo beside some domain links. I...
7
by: Cate Archer | last post by:
I want to have a border around an image that changes color when the mouse hovers over it. The following code works perfectly in FireFox but not in Internet Exploiter. The text link changes color...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Shllpp 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.