Changing colors

  • Thread starter Anders Christiansen
  • Start date
A

Anders Christiansen

This is most likely dead simple.. i just can't get it to work.

I want difrent color highlight on diffrent parts of my text. I want the
color of the text to be the same..

I hope someone can help me.

Regards Anders Christiansen
 
A

Andrew Urquhart

Anders said:
This is most likely dead simple.. i just can't get it to work.

I want difrent color highlight on diffrent parts of my text. I want
the color of the text to be the same..

I hope someone can help me.

Regards Anders Christiansen

Markup:
<p>This sentence <em>contains highlighted content</em> and makes sense
semantically</p>

CSS:
body {
color: #000000;
background-color: #ffffff;
}
p em {
color: #000000;
background-color: #fbe54f;
}
 
R

Ryan Stewart

Anders Christiansen said:
This is most likely dead simple.. i just can't get it to work.

I want difrent color highlight on diffrent parts of my text. I want the
color of the text to be the same..

I hope someone can help me.

Regards Anders Christiansen
<p style="color: red;">This is <span style="background-color: blue;">some
blue stuff and this is</span> <span style="background-color: green;">some
green stuff.</span>
 
C

Chris Morris

Ryan Stewart said:
<p style="color: red;">This is <span style="background-color: blue;">some
blue stuff and this is</span> <span style="background-color: green;">some
green stuff.</span>

Remember that not every browser can display colour (and not every
person can distinguish colours well), so make sure if it's used for
essential information, there's another way to get at the information
too.
 
A

Anders Christiansen

I think i was misunderstood.

What i want is a text all in black, that when i mark it with the mouse shows
diffrent colors.. e.g.

this is a test <br><br>

When marked with the mouse it should look like this<br><br>

<span style="background-color: blue;"> <font color=red>this is <font color=
white>a test </span>
 
T

Toby A Inkster

Anders said:
What i want is a text all in black, that when i mark it with the mouse shows
diffrent colors.. e.g.

Can't be done. Mouse selection colour is entirely chosen by the visitor.

CSS3 may change that (it's introducing a few irritating things along those
lines, though I've not searched for that specifically.)
 
B

Bernhard Sturm

Anders said:
I think i was misunderstood.

What i want is a text all in black, that when i mark it with the mouse shows
diffrent colors.. e.g.

this is a test <br><br>

When marked with the mouse it should look like this<br><br>

<span style="background-color: blue;"> <font color=red>this is <font color=
white>a test </span>

I don't know exactly why you want to achieve this, but you could set
some dummy link in order to achieve this (it's quirk however):

a.highlight {
text-decoration:none;
}
a.highlight:link {
color:red;
}
a.highlight:hoover {
color:white;
}

<span style="background-color:blue;color=red;">this is<a
href="javascript:;" class="highlight">a test</a></span>

but I don't know if it's what you want :)


bernhard
 
L

Leif K-Brooks

Ryan said:
<p style="color: red;">This is <span style="background-color: blue;">some
blue stuff and this is</span> <span style="background-color: green;">some
green stuff.</span>

Browsers may default paragraphs to having a red background, in which
case your text would become invisible. You should always set background
when setting color, and always set color when setting background.
 
R

Ryan Stewart

Leif K-Brooks said:
Browsers may default paragraphs to having a red background, in which
case your text would become invisible. You should always set background
when setting color, and always set color when setting background.

I'd assumed he would account for that, but yes, it's good to point out.
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top