Forum Moderators: not2easy

Message Too Old, No Replies

space between elements (paragraphs)

         

futureknight

7:23 pm on Jun 21, 2004 (gmt 0)

10+ Year Member



what is the command to control the space between elements. I would surmise that the space between two paragraphs is equal to the line-height. How do I decrease the space between elements without effecting the paragraph (or any other kind) of element boxes.

I've got some pretty detail oriented writers working with me, and they aren't happy with the space that occurs between a paragraph and an ordered list, for example..

thanks,

Birdman

8:04 pm on Jun 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Margin will control the space.

p{margin: 5px 20px 5px 20px;}

The order is top-right-bottom-left. Also, there are shorthand methods. If your top/bottom and left/right margins are to be equal, you could shorten it to:

p{margin: 5px 20px;}

If all four margins are to be equal, you may use:

p{margin: 5px;}

By the way, welcome to Webmaster World!

Birdman

Wizcrafts

8:05 pm on Jun 21, 2004 (gmt 0)

10+ Year Member



Here is a style that assigns a fixed space of 10 pixels from the bottom of one paragraph to the top of the next one.Change the 10px to whatever spacing you want, or make it in EMs, to control the distance based on font size changes.

<p style="margin-bottom:10px"> text ...</p>

As Birdman states you can apply this to all P elements, or you can create a class and wrap all affected Ps inside a DIV containing that CLASS; ie:
CSS Rule:
.10 {margin: 5px 0px} /*this assigns a margin of 5px to both the top and bottom */

<div class="10">
<p>...
<p>...
<p>...
</div>

Wiz

futureknight

8:11 pm on Jun 21, 2004 (gmt 0)

10+ Year Member



thanks for the help. I appreciate it!

Birdman

1:41 am on Jun 22, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Be careful about naming classes with a numeral as the first character.

[webmasterworld.com...]

But yes, Wizcrafts is correct about using classes if you don't want ALL the paragraphs to inherit the margin.

There are other clever ways to apply the rules to certain paragraphs without having to add the class="foo" to every p tag.

Suppose you have an article with 15 paragraphs. It's easier(IMO) to just wrap the article in a <div id="article">, and then use this in your stylesheet:

#article p{rules...}

Any paragraphs within that div will have those rules applied to them.

Birdman