Click here to get back home

Links colors in xhtml.

 HomeNewsGroups | Search | About
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Links colors in xhtml. opt_inf_env 03-23-2005
Posted by opt_inf_env on March 23, 2005, 1:56 pm
Please log in for more thread options


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">

However, I would like to use xhtml with css. In css-file I have the
next line:

body {background-color: black; color: blue;}

which define color of usual text and background. Do you know how one
need to modify this line to specify colors of visited and active links?
Another question is whether on can change not only colors of text in
link, but also background of link, i.e. background behind one word or
sentence which corespond to link?

Thank you.



Posted by Beauregard T. Shagnasty on March 23, 2005, 6:26 pm
Please log in for more thread options


opt_inf_env@yahoo.com wrote:

> body {background-color: black; color: blue;}

I hope the above is just a sample for posting here. Blue text on a
black background is virtually unreadable.


--
-bts
-This space intentionally left blank.


Posted by Darin McGrew on March 23, 2005, 10:15 pm
Please log in for more thread options


> 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">

If you specify one color, then you should specify them all. In the above
example, your text and link colors will show against the browser's default
background, which may not provide sufficient contrast. You should include
the BGCOLOR attribute too.

> However, I would like to use xhtml with css.

Why XHTML? Why not HTML with CSS?

See also http://www.spartanicus.utvinternet.ie/no-xhtml.htm

> In css-file I have the next line:
>
> body {background-color: black; color: blue;}
>
> which define color of usual text and background. Do you know how one
> need to modify this line to specify colors of visited and active links?

a:link {background: black; color: white;}
a:visited {background: black; color: silver;}
a:active {background: black; color: red;}

See also http://www.w3.org/TR/CSS21/selector.html#link-pseudo-classes

I used background rather than background-color because using the background
shortcut like this also sets the background-image property to none. It
helps avoid the unlikely situation where the user's default background
image is used, rather than the document's background color.

Also, you might want to check out a good CSS tutorial, such as
http://westciv.com/style_master/academy/css_tutorial/

> Another question is whether on can change not only colors of text in
> link, but also background of link, i.e. background behind one word or
> sentence which corespond to link?

Sure. You can use the link pseudo-class selectors to set whatever
properties you want.
--
Darin McGrew, mcgrew@stanfordalumni.org, http://www.rahul.net/mcgrew/
Web Design Group, darin@htmlhelp.com, http://www.HTMLHelp.com/

"The handwriting on the wall may mean you need a notepad by the phone."


Posted by opt_inf_env on March 23, 2005, 3:11 pm
Please log in for more thread options


I just read answer of Steve Pugh and found that he already answered on
my last question. One need to use "hover".



Posted by Steve Pugh on March 23, 2005, 10:20 pm
Please log in for more thread options


opt_inf_env@yahoo.com wrote:

>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">

Yep that's the 90s way of doing it.

>However, I would like to use xhtml with css.

Why not HTML with CSS? Any particular reason to use XHTML, or just
personal fancy?

>In css-file I have the next line:
>
>body {background-color: black; color: blue;}
>
>which define color of usual text and background. Do you know how one
>need to modify this line to specify colors of visited and active links?

You don't. You set the properties of the links for the links
themselves, not for the body.
a:link {color: #0000FF; background-color: #FFFFFF;}
a:visited {color: #00FF0; background-color: #FFFFFF;}
a:hover {color: #FFFF00; background-color: #FFFFFF;}
a:active {color: #FFFF00; background-color: #FFFFFF;}

>Another question is whether on can change not only colors of text in
>link, but also background of link, i.e. background behind one word or
>sentence which corespond to link?

Same as for any other element.
See the CSS spec: http://www.w3.org/tr/css21/

        Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor



Similar ThreadsPosted
HTML safe colors July 20, 2007, 4:23 pm
change link colors in p class September 30, 2004, 6:18 pm
Composition of text and background colors. March 28, 2005, 9:58 am
IE6 link colors & CSS override (vs. Firefox) October 20, 2005, 9:06 pm
Overflow: scroll scrollbar colors? November 19, 2005, 11:49 pm
Do you know of 6 clearly distinct colors that show up well on a white background? October 11, 2004, 5:40 pm
Printing table cell background colors? June 10, 2005, 4:24 pm
CSS: Problems with doubly defined colors (according to validator) May 20, 2007, 5:26 pm
Transparent colors (for table bg's and stuff) November 18, 2007, 5:43 am
How do you swap foreground & background colors for a link (or any element)? September 20, 2005, 1:41 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap