Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

background colour 1

Status
Not open for further replies.

rufc

Programmer
Nov 20, 2001
47
0
0
GB
Is there a way to put a background colour under a block of text with css?

I can use a table cell with bg color but would prefer not to if css would do the same thing
 
How about using span or div to enclose the text, then use CSS to specify the bg color of the span/div.

span.mytext { background: #ff0000 }
or
div.mytext { background: #00008d }

or if your text is in a table
td.mytext { background: #00cc00 }


<div class=&quot;mytext&quot;>This is my text</div>
etc
<td class=&quot;mytext&quot;>Text



É

enzo@endamcg.com
 
Hi rufc,

Try this:

<P style=&quot;background-color:green;&quot;>
1st sentence<br>
2nd sentence<br>
</P>

or put the style in your style sheet:

.textbg
{
background-color:green;
}

<P class=&quot;textbg
&quot;>
1st sentence<br>
2nd sentence<br>
</P>

Hope this helps,
Erik

<!-- My sport: Boomerang throwing !!
This year I will participate at the World Championships in Germany. (!! Many Happy Returns !! -->
 
Thanks boomerang, that`s what I was looking for, it will only be in one place on the entire site so no need to clutter up my style sheet.
 
Can you help again with another prob I`m having with css??

I have an external stylesheet which has a style:

A { text-decoration: none; color : #000000; }

My question is, would this overwrite all other link styles i.e.

A.bodywh:hover { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; color: #000000}
A.bodywh:active { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; color: #FFFFFF}
A.bodywh:link { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; color: #FFFFFF}
A.bodywh:visited { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; color: #FFFFFF}

Im` asking because I have a style that I need to change to a different colour to the rest of the links in the site, but it isn`t working!
 
sorry, it`s the

A:hover { text-decoration: underline; color : #31659C ; }

that is overriding it and changing the link to blue, but I need it to change to white cos it`s on the blue background doh!
 
put this in the tag that should be overwritting:

!IMPORTANT

It increases the weight of the declaration.
This is how you implement it:
P{COLOR: BLUE !IMPORTANT;} for example.

I hope this helps, BobbaFet

Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com

&quot;<beer brand> is like making love in a cano...
it's <f-word + ing> close to water !!!&quot;
- Monty Python's Flying Circus, 1969/70
 
Thanks guys, those things worked, just one last request :eek:)

I want to have two styles (margin and background) in one p tag, how do I seperate them to make them both work, here`s what I have but doesn`t work:-

<p class=&quot;body&quot; style=&quot;margin-left: 5&quot; &quot;background-color:FFCC33;&quot;>
 
just replace the &quot; &quot; in the middle with a ;

<p class=&quot;body&quot; style=&quot;margin-left:5; background-color:FFCC33;&quot;>

Erik <!-- My sport: Boomerang throwing !!
This year I will participate at the World Championships in Germany. (!! Many Happy Returns !! -->
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top