Welcome to WebmasterWorld Guest from

Forum Moderators: not2easy

Message Too Old, No Replies

changing line break height for <h1> or <p>

block elements creating too much space with line breaks



8:48 pm on Aug 29, 2005 (gmt 0)

10+ Year Member

Quick question folks...

how do you alter how large the line break is between something like <h1> and whatever comes after it? My design is leaving too much space between the heading element and the element below it. I attempted to change line-height value of the <h1> tag, but that didn't work.


8:52 pm on Aug 29, 2005 (gmt 0)

10+ Year Member

h1,h2,h3,h4 {margin:0;}


8:53 pm on Aug 29, 2005 (gmt 0)

10+ Year Member


If you are talking about the vertical space between the H1 and the line below it, then the following should do the trick:

<H1 style="margin-bottom:3px;">stuff</h1>

The default for H1 tags is about a 21px margin, you can set this to whatever you want.



11:25 pm on Aug 29, 2005 (gmt 0)

10+ Year Member

Ah. I was under the impression that adding a margin would simply add more space to the default whitespace set up by headings... if anything, I wouldve thought that a negative margin would be the answer.

But apparently, it is not.

Thanks for your help, both'uh'yous!


11:41 pm on Aug 29, 2005 (gmt 0)

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

Right -- browsers already applying a default margin to those elements, so you just need to override it with your css.

One key is that both an element and its following element may already have default margins, so you may need to override BOTH the margin-bottom for the first element and the margin-top for the following element.Otherwise the margin collapsing rules that browsers use will still apply the larger of those two margins.


Featured Threads

Hot Threads This Week

Hot Threads This Month