Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > CSS background colors in paragraphs

CSS background colors in paragraphs
Thread Tools
Dedicated MacNNer
Join Date: Nov 2000
Location: Netherlands
Status: Offline
Reply With Quote
Dec 10, 2001, 06:05 AM
 
I would like to know how I could use background color in paragraphs (headings, lists, p) and to have the background color connected without whitespace between different paragraphs. Is this possible?

Here is an example:

<font face = "courier">
Styles:
body { background-color: white; }
p { background-color: green; }

HTML:
&lt;p&gt; paragraph 1 &lt;/p&gt;
&lt;p&gt; paragraph 2 &lt;/p&gt;
</font>
"Chance is irrelevant. We will succeed."
== 7 of 9 ==
     
Mac Elite
Join Date: Mar 2001
Status: Offline
Reply With Quote
Dec 10, 2001, 11:11 AM
 
Originally posted by ervier:
<STRONG>I would like to know how I could use background color in paragraphs (headings, lists, p) and to have the background color connected without whitespace between different paragraphs. Is this possible?

Here is an example:

&lt;font face = "courier"&gt;
Styles:
body { background-color: white; }
p { background-color: green; }

HTML:
&lt;p&gt; paragraph 1 &lt;/p&gt;
&lt;p&gt; paragraph 2 &lt;/p&gt;
&lt;/font&gt;</STRONG>
put the paragraphs in a table and make the td background what you wanted to make your p background.
     
ervier  (op)
Dedicated MacNNer
Join Date: Nov 2000
Location: Netherlands
Status: Offline
Reply With Quote
Dec 11, 2001, 02:06 AM
 
Originally posted by Raman:
<STRONG>put the paragraphs in a table and make the td background what you wanted to make your p background.</STRONG>
Raman,

I know this solution, and have used it, and should have made it clear that I did, but I want to know whether there is one without using a table.
"Chance is irrelevant. We will succeed."
== 7 of 9 ==
     
Administrator
Join Date: Mar 2000
Location: Land of the Easily Amused
Status: Offline
Reply With Quote
Dec 11, 2001, 02:47 AM
 
another way is this:
if your text is 11, then use a line height of 12 or less.

<font face = "courier">font-size : 11px; line-height : 12px;</font>

that should make for a solid color over the text without spaces in-between the lines. you could also draw boxes using stylesheets, but i wouldn't recommend it.

[ 12-11-2001: Message edited by: Demonhood ]
     
ervier  (op)
Dedicated MacNNer
Join Date: Nov 2000
Location: Netherlands
Status: Offline
Reply With Quote
Dec 11, 2001, 06:19 AM
 
Originally posted by Demonhood:
<STRONG>another way is this:
if your text is 11, then use a line height of 12 or less.
</STRONG>
Thanks for the tip, but I found a better way when trying yours. Accidentally I had margins set for this heading, and the whitespace was still there. Then I removed the margins, but the whitespace became bigger. So then I set top- and bottom-margins to 0px, et voila! Just what I wanted!
"Chance is irrelevant. We will succeed."
== 7 of 9 ==
     
Clinically Insane
Join Date: Nov 1999
Status: Offline
Reply With Quote
Dec 11, 2001, 09:06 AM
 
That technique works, but it can also make your text look somewhat jammed together. So you may want to adjust the top and bottom padding on your paragraphs to compensate. That should get some space between them again.
You are in Soviet Russia. It is dark. Grue is likely to be eaten by YOU!
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:41 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2