views:

33

answers:

3

Hi, I would like to have paragraph text right under the headline. I set margin and padding to 0 for both, but there is still small gap between them. Why? Thanks.

A: 

Make sure that you remove the bottom padding and margin for the heading above and you should be set

<style>
.h2 { margin-bottom:0px; padding-bottom:0px; }
p { margin:0px; padding:0px 0px 15px 0px; }
</style>

I've added a padding-bottom to the paragraph tags so you can have separation between each <p> tag.

Jon Harding
Don't put a global P margin like that, it will affect all P tags. Instead focus on a rule for that particular paragraph, or use selectors to select the next element. See where this can become tricky?
drachenstern
+1  A: 
line-height:1em;

also add a border for testing:

border:1px solid #f00;
revaxarts
+1  A: 

It is from the line-height property of the headline.

Try it like this:

<h1 style="margin:0; padding:0; line-height:1em;">Heading</h1>
<p style="margin:0;">Paragraph</p>
Parkyprg