Log in

View Full Version : Text Link Color



NADB
05-11-2006, 04:43 AM
I am searching for a code that would make a sentence or a word have one link color seperate from another word or sentence with antoher link color. Other words, I don't want to have all of my links visible in one color.

Thanks in advance,
NADB

djr33
05-11-2006, 04:49 AM
Just change the color of text? (Yes, within a link.)

Well... depending on your use of css (style sheet... formatting) or just a body tag with default colors OR even nothing and using the default blue, you will have some predefined color for links... probably blue.
(Note: the blue is good because beginning web users might not understand another color to be a link if it's not clear.)

so... what you need to do is override that.

the a tags (<a href=....>clickme</a>) set the color automatically to the color that is the default, as above, probably blue.
All you need to do is set the color like any other text, but INSIDE that.


<a href="link.htm"><font color="#FF0000">red link</font></a>

Note that putting the font tag outside the link will not set the color. (<font color=...><a href=...>text is the default color still</a></font>)


That should do it!


Or, if you want the whole page:
<body text="#00FF00"> would give you green.

Or, you could use css:
In the head section of your page:
<html>
<head>
<style type="text/css">
a {color:#00FF00}
</style>
</head>
<body>
....
</body>
</html>

Twey
05-11-2006, 06:18 AM
<a href="link.htm"><font color="#FF0000">red link</font></a>Urgh, yuck.
Never use <font> elements.


<style type="text/css">
.linkone a {
color: red;
}

.linktwo a {
color: lime;
}

.linkthree a {
color: blue;
}
</style>

<p><span class="linkone">This bit has <a href="google.com">red links</span>; <span class="linktwo">this has <a href="fsf.org">lime</a>;</span> and</p>
<p class="linkthree">... this whole paragraph will have <a href="dynamicdrive.com">blue</a> links.</p>

djr33
05-11-2006, 07:18 PM
Never use <font> elements.
This guy just wants to change font color a single link.
Surely css isn't needed. It's more to learn and more to mess with.
<font> is plenty valid and works just fine.

css is better if you're using the same setup more than once though.

Twey
05-11-2006, 07:25 PM
<font> is plenty valid and works just fine.It may "work fine," but, like table layouts, it should never have been invented. It causes the unwary developer to mix content and presentation, causing code that lacks semantics and is difficult to read and maintain.

jscheuer1
05-11-2006, 09:35 PM
I'm still picking out font tags from a site I inherited about three years ago. They're just about all gone now, and it is so much easier to maintain. Now, if I could just get everything to validate.

djr33
05-11-2006, 11:25 PM
like table layouts...tables are bad too?!
So useful.

I get that CSS is nice. But only if you need to automate all of it. for a single link/line of text, it's so easy to use that.


I agree, though, for larger automated sites, css, and external css at that, is a must. But not for one tag.

Twey
05-12-2006, 06:25 AM
But not for one tag.You're telling me seriously that you've ever designed a site that uses just one fomatting tag? :)

djr33
05-12-2006, 06:50 AM
Sure. One occurance of a particular color, size, etc. for a font.

ONE time on the page there should be red text. Or big text. Whatever.

css can still be used, but doesn't help/save time for that particular element... actually wastes space.

Twey
05-12-2006, 01:57 PM
Sure. One occurance of a particular color, size, etc. for a font.Oh, you mean something totally out-of-sync with the rest of the site's theme? :)

djr33
05-12-2006, 06:27 PM
Yeah, exactly :)

I know CSS is better for the whole page, but the OP seemed to be asking about a single link (or just a few at least)... no need to setup a class and set that single link to "class="class"".

Twey
05-12-2006, 06:58 PM
But the code will eventually be part of a page, surely. Even if it's only going to be used once, creating a CSS class makes for easier maintenence.

djr33
05-13-2006, 02:04 AM
If you want red, sometimes you will always want red. In that case, no need.

If you'll be updating a lot, sure, do css.