A Link question

M

[Mystic]

Hey guys

Bascially, I have set the link styles to a white font, but I was wondering,
what if the text is on a white background? You cannot see it. Is there away
to set two link colors?

Is there a way around this?

Thanks
 
S

saz

Hey guys

Bascially, I have set the link styles to a white font, but I was wondering,
what if the text is on a white background? You cannot see it. Is there away
to set two link colors?

Is there a way around this?

Thanks
Use CSS, set each group of links as different div classes dependent upon
the color of the background.

Brief example:

div.white a { color: #000000; }

div.black a { color: #ffffff; }
 
O

Oli Filth

Hey guys

Bascially, I have set the link styles to a white font, but I was wondering,
what if the text is on a white background? You cannot see it. Is there away
to set two link colors?

Is there a way around this?

Don't set both the text and background to white? ;)

You probably want to define some CSS styles, e.g.

HTML, BODY
{
background: red;
}

A:link
{
color: white;
}

DIV.white_bg
{
background: white;
}

DIV.white_bg A:link
{
color: black;
}

Now when a link is in a "normal" area, its text will be white, and when
it falls within a "white_bg" area, its text will be black.
e.g.

The background colour for this area is red.
<A href="xyz">This link text will be white.</A>

<DIV class="white_bg">
The background colour for this area is white.
<A href="abc">This link text will be black.</A>
</DIV>


Hope this helps.
 
N

Neal

Hey guys

Bascially, I have set the link styles to a white font, but I was
wondering,
what if the text is on a white background? You cannot see it. Is
there away
to set two link colors?

Is there a way around this?

Rule - when you set the color, also set the background-color.

I suppose your situation is when you have one div with a black
background and another with a white background, how do you have the
colors work?

Assuming HTML:

<div id="foo">This is a <a href="zip.html">link</a>.</div>
<div id="bar">This is a <a href="nut.html">link</a>.</div>

Here's CSS:

#foo {background-color: black; color: white;}
#foo a:link {color: #77f;}
/* etc. with more #foo a:pseudos */
#bar {background-color: white; color: black;}
#bar a:link {color: #007;}
/* etc. with more #bar a:pseudos */
 
N

Neal

saz said:
Use CSS, set each group of links as different div classes dependent
upon
the color of the background.

Brief example:

div.white a { color: #000000; }

div.black a { color: #ffffff; }

1) Rather than class all the links, since in CSS you'll assign the
background-color to the ancestor element anyway, use the descendent
selector method and keep unneeded id's and classes out of your HTML.
(See my post for an example.)

2) I know this is just an example, but for the record class and ID
names should be descriptive of the content, not the style. What if you
want to change the color scheme later? Won't it be confusing if stuff
that is classed "white" and "black" are NOT a color matching the word?
 
S

saz

1) Rather than class all the links, since in CSS you'll assign the
background-color to the ancestor element anyway, use the descendent
selector method and keep unneeded id's and classes out of your HTML.
(See my post for an example.)

2) I know this is just an example, but for the record class and ID
names should be descriptive of the content, not the style. What if you
want to change the color scheme later? Won't it be confusing if stuff
that is classed "white" and "black" are NOT a color matching the word?
Like I said, very brief description. I used colors so he/she would know
which background color I was referring to.

The OP really needs to learn some css - this is simple stuff.
 
R

rf

saz said:
Like I said, very brief description. I used colors so he/she would know
which background color I was referring to.

The OP really needs to learn some css - this is simple stuff.

Then the OP should be shown how to do the simple stuff *correctly* :)
 
T

Toby Inkster

Neal said:
Rule - when you set the color, also set the background-color.

#foo {background-color: black; color: white;}
#foo a:link {color: #77f;}
^^^

So then you go and break your own rule! You have not set a background
colour for this link. An explicit "background-color:transparent" would do.
 
S

SpaceGirl

Neal said:
Rule - when you set the color, also set the background-color.

Bad rule. What if you have a background image? You could set the
background of the link to transparent I guess, but still... it's not
really needed in most cases.

--


x theSpaceGirl (miranda)

# lead designer @ http://www.dhnewmedia.com #
# remove NO SPAM to email, or use form on website #
 
D

David Håsäther

SpaceGirl said:
Bad rule. What if you have a background image? You could set the
background of the link to transparent I guess, but still... it's
not really needed in most cases.

It's very much needed since you can't possible know the default style.
Both the UAs default and the users own stylesheet can collide with your
own styles if you don't set both.
 
E

Els

SpaceGirl said:
Bad rule. What if you have a background image? You could
set the background of the link to transparent I guess, but

What if you have images turned off?
I'd say, if you have a background-image, make sure the
background-color of the element that has the background-image
is set to the most prominent colour in that image.
Then set background-color:transparent to the link in front of
that image.
still... it's not really needed in most cases.

better safe than sorry :)
 
J

Jukka K. Korpela

SpaceGirl said:
Bad rule.

No, the rule is good, but insufficient.
What if you have a background image?

A good question. That's why authors should set background (i.e. use this
shorthand property) rather than background-color.
You could set the
background of the link to transparent I guess,

That's one option. Another is a declaration like background: black,
which sets background-color to black and background-image to none.
but still... it's not
really needed in most cases.

You mean we shouldn't do things the right way since we so often get away
with the consequences if we do them wrong? A key point is: the author does
not really know how often sloppy CSS coding breaks the page on users'
screens. Another point: if you adopt habits of sloppy coding, you will be
very confused when you see the problems caused, since you have no idea of
what's happening, and (being presumably human) you will try hard explaining
it someone else's mistake rather than your own.
 
S

SpaceGirl

Els said:
What if you have images turned off?

Ah :)
I'd say, if you have a background-image, make sure the
background-color of the element that has the background-image
is set to the most prominent colour in that image.
Then set background-color:transparent to the link in front of
that image.

I considered this with a site I've been working on, but it looked BAD...
the image in the background is a faint photo and it just didn't work
design-wise when links had backgrounds. But, the site wouldn't work well
without images anyway :)
better safe than sorry :)

Meh... but less fun!


--


x theSpaceGirl (miranda)

# lead designer @ http://www.dhnewmedia.com #
# remove NO SPAM to email, or use form on website #
 
E

Els

SpaceGirl said:
I considered this with a site I've been working on, but it
looked BAD... the image in the background is a faint photo
and it just didn't work design-wise when links had
backgrounds. But, the site wouldn't work well without
images anyway :)

How can it look bad if you set background-color to transparent
so you can see the images behind it?
Meh... but less fun!

Goes for a lot of things, yes, not for webdesign though (afaics)
;-)
 
S

SpaceGirl

Els said:
How can it look bad if you set background-color to transparent
so you can see the images behind it?




Goes for a lot of things, yes, not for webdesign though (afaics)
;-)

Can a colour be transparent??? It's not a colour if it's transparent.
What colour is air? :D

*hides*

--


x theSpaceGirl (miranda)

# lead designer @ http://www.dhnewmedia.com #
# remove NO SPAM to email, or use form on website #
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top