Search code examples
cssheading

Line high between heading and paragraph


I have the problem that my headings overlap. Here an example. I know that the problem is the line high that is set to 0:

h3 {
line-height:0;
letter-spacing:1px;
}

If I use line high:1 the problem disappears, but the space between the heading and the paragraph becomes too large and the page does not look very nice.

So what I would like to do is to have line high:1 for the heading and line high:0 for the space between the heading and the paragraph.

I hope anybody has a solution.

Thank you!


Solution

  • Just add margin-bottom of about 5px to your h3 heading

    p {
    margin:0; 
    padding:0; 
    line-height:1em;
    }
    
    h3 {
    line-height:1;
    letter-spacing:1px;
    margin-bottom: 5px;
    }
    <h3>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</h3>
    <p style="text-align: justify;">Lorem ipsum dolor sit amet, consetetur sadipscing elitr,  sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr,  sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</p>
    <br>
    <h3>Ut wisi enim ad minim veniam</h3>
    <p style="text-align: justify;">Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</p>