Welcome to WebmasterWorld Guest from 54.196.214.35

Forum Moderators: not2easy

Message Too Old, No Replies

Spacing between paragraphs

Any reason not to using css padding?

     
10:04 am on Apr 26, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Oct 25, 2000
posts:663
votes: 0


I'm trying to neaten up the spacing between paragraphs on a site. Instead of using table cellpadding, is there any reason not to do this:

<p class="linespace">bla bla bla.</p>
<p class="linespace">more bla bla bla.</p>

and :

.linespace { margin: 0px; padding: 0px 0px 8px; }

?

10:16 am on Apr 26, 2003 (gmt 0)

Preferred Member

10+ Year Member

joined:July 6, 2001
posts:410
votes: 0


If this is a standard throughout all your <p>'s you could simply declare that as your <p> style rather than assigning the class to each paragraph. It would save on code bloat. Then, if you had an alternative <p> style you could create a class or classes just for those.

And, no, there wouldn't be any reason to set your paragraphs in table cells unless you are displaying data. You can use margins or padding, depending on how your page is set up.

11:18 am on Apr 26, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Oct 25, 2000
posts:663
votes: 0


Many thanks for your reply - no, this isn't a line spacing that I'd want to declare as standard throughout the site, so I definitely want to set it up as a separate style and not modify my <p> throughout the site -
8:14 pm on Apr 29, 2003 (gmt 0)

New User

10+ Year Member

joined:Jan 27, 2003
posts:28
votes: 0


Or, if it is only a certain section where you want the modified <p> spacing, you could use a contextual selector:

div.tightp {display:block;}
div.tightp p {margin: .5em 0;}/*1/2 normal spacing*/
###############
<div class="tightp">
<p>The spacing is tight</p>
<p>'Cuz that's how it looks right.</p>
</div>
<p>And now we have default spacing.</p>

More planning, less writing - always works for me. :)

DE

8:27 pm on Apr 29, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Dec 31, 2001
posts:1238
votes: 0


The more you allow normal page flow to carry the work load, the more control you actually have. Yeah, it's kinda of a 'Zen' thing.. but you really have to think about it to understand the underlying truth.

There is no reason at all why you cannot control your paragraphs with margins and/or padding.. but do you really need to? Does it truly add to your design and function.

One example where it IS needed is in the new found trailing paragarph bug present in Opera 7.10 (Opera repeats the trailing default bottom-margin and will break through parent bottom margins.

Here is my own fix:

p.o7 { /* Oprea 7.10 has a paragraph bottom margin bug */
margin-bottom: 0;
padding-bottom: 20px;
}

8:29 pm on Apr 29, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member nick_w is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Feb 4, 2002
posts:5044
votes: 0



the more you allow normal page flow to carry the work load, the more controll you actually exert. Yeah, it's kinda of a 'Zen' thing.. but you really have to think about it to understand the underlying truth.

*Sniffle* - Brings tears to my eyes reading this kind of stuff again. - *Sniffle*

Nick

8:42 pm on Apr 29, 2003 (gmt 0)

New User

10+ Year Member

joined:Jan 27, 2003
posts:28
votes: 0


Absolutely.

While the example class "tightp" could be used, I tend to code semantically (sp?) with different tags taking on different characteristics depending on what #id they reside within. So if I have an div #legalese I might have #legalese p {font-size:0.8em, margin:0.5em 0;} to create the "fine-print" section.

As a rule, I dislike creating divs purely to give me certain presentation characteristics. There should be something about the section that makes it a div in its own right and the presentational characteristics flow from that. Am I making sense?

DE

8:58 pm on Apr 29, 2003 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member pageoneresults is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Apr 27, 2001
posts:12166
votes: 51


*Sniffle* - Brings tears to my eyes reading this kind of stuff again. - *Sniffle*

Yeah, back to the sleepless nights experimenting with code and solutions that papabaer posts! Not that I've gotten much sleep with Nick_W around. ;)