homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / CSS
Forum Library, Charter, Moderators: not2easy

CSS Forum

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)

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)

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


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


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)

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)

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.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / CSS
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved