Search code examples
htmlxhtmlspaceparagraph

Make a space between paragraph (X)HTML and CSS


I want space between my <p>content</p> tags. Not before and not after <p> tags. For example, my code is:

<div>
   <h1>A headline</h1>
   <p>Some text</p>
   <p>Some text</p>
</div>
Something

I don't want space between h1 and p which is done with zero margin on h1. But I don't want space after the last <p> tag. Is this possible without :last-child or some JavaScript/jQuery?

I can't set class="last" on the last tag because it is a CMS system.


Solution

  • p + p {
      margin-top: 1.5em;
    }
    

    (Although this requires a browser with better support for CSS than IE6.)