Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove gap between header and container div in HTML5 Boilerplate

I'm keen to use Paul Irish's HTML5 boilerplate but I've encountered a css problem.

I want the header to be flush at the top of the page but I can't the container div adds a gap that I'm unable to get rid of.

I think this has something to do with the clearfix for the footer. I've tried experimenting with different padding sizes for the footer and container div but to no avail.

This is the html code:

<header>
  <p> header content </p>
</header>

<div id="main" role="main">

</div>
<footer>
  <p> footer content </p>
</footer>

My custom CSS:

#container {
    background-color:orange;
    padding:1px; /* can't be zero */
    margin:0; 
}

footer {
    margin: 1px 0;
}

body {
    width:960px;
    margin:0 auto;
    background:blue;
    padding:0;
}
like image 720
techjacker Avatar asked Sep 18 '11 11:09

techjacker


People also ask

How do I remove space between header and body in HTML?

Just set margin:0 in your h1 tag. Save this answer. Show activity on this post.

How do I remove a space between my header and page?

On the Tools menu, click Options. Click the View tab and then click to select or clear the White space between pages check box.

How do I get rid of the extra space at the top in HTML?

HTML. Approach 2: We can also eliminate the extra space using the margin-top property. The margin-top property sets the top margin of an element. When we use margin-top we have to apply it on the tag, such that we have to eliminate extra space above it.

How do I get rid of the white space between divs?

There are two methods for removal of space between two divs or two elements. First one is, assign the font size of the parent of the inline block element to 0px and then assign the proper font-size to the inline block element. and Second is, Make the display of the parent element to flex.


2 Answers

@techjacker; may be you have to write like this:

 header{display:block}
    p{margin:0;padding:0}
like image 124
sandeep Avatar answered Oct 14 '22 11:10

sandeep


This sometimes help:

  • Set margins, and padding to 0.
  • And make sure that encoding is set to: UTF-8 without BOM.
like image 1
Kerim Avatar answered Oct 14 '22 09:10

Kerim