ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

CSS To Increase the Vertical Space Between Two <p> Elements?

December 28, 2007 12:56pm

Subscribe [0]
  • #1 / Dec 28, 2007 12:56pm

    Vik

    209 posts

    What’s the correct CSS to increase the vertical space between two elements?

    For example, say a comment contains this:

    <div id="comment-container">line one
    line two</div>

    ...what’s the correct CSS to increase the vertical space between line one and line two?

    Thanks in advance for the info.

  • #2 / Dec 28, 2007 1:20pm

    Daniel Walton

    553 posts

    I usually apply margin-top to textual elements. So

    p {margin: 1em 0 0 0;}
  • #3 / Dec 28, 2007 1:31pm

    Crssp-ee

    572 posts

    I usually apply margin-top to textual elements. So

    p {margin: 1em 0 0 0;}

    margin-top:1.5em;
    Etc. would also work if you aren’t familiar with CSS shorthand properties.

  • #4 / Dec 28, 2007 5:27pm

    Vik

    209 posts

    I tried adding this to my CSS:

    #comments-container p
        {
            margin-top:1.5em;
        }

    ...but it seemed to have no effect. Here’s the markup:

    <div id="comment_content">
        <div class="comments-container">
            Line 1
            
            
            Line 2
            
            Line 3
            
            Line 4
                
        </div>
    </div>

    What am I missing?

  • #5 / Dec 28, 2007 5:32pm

    Crssp-ee

    572 posts

    You’ve confused using ID and class.
    In the Div your showing ID so the # would be correct.
    To use class the css would be preceeded with a dot.
    .comments-container p
      {
    margin-top:1.5em;
    }

  • #6 / Dec 28, 2007 5:33pm

    Rob Allen

    3114 posts

    You have got extra tags in there… here’s the corrected code…

    <div id="comment_content">
      <div class="comments-container">
        Line 1
        Line 2
        Line 3
        Line 4    
        </div>
    </div>

    I’d suggest making the top margin as zero and defining a bottom margin…

    .comments-container p {
    margin: 0 0 1em 0;
    }
  • #7 / Dec 28, 2007 5:42pm

    Crssp-ee

    572 posts

    Is the inner div necessary, it’s kind of looking like something that should be handled with a list semantically, if the text isn’t actual paragraphs?

  • #8 / Dec 28, 2007 8:00pm

    Vik

    209 posts

    Thanks very much for the help.  I see I have one more anomaly than I thought, on top of the ones you’ve helped me correct - TinyMCE isn’t inserting tags where I thought it would - instead it’s just using
    tags.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases