/    Sign up×
Community /Pin to ProfileBookmark

Content Div separating from header, Please help!

Alright I have a simple header/content/footer css layout that i have used on other sites and worked fine. But for some reason this time while using it in a site to be made in HTML5 it isnt working quite right. When i just have the layout setup with no text or content it looks fine, the header, content, and footer areas bump up agaisnt each other like they should with no space between them. But as soon as i go into the content div(id=”body” in my css) and put a <p>(paragraph) in with some text, it makes the content section including the background image move down creating a space between it and the header? I dont know what to do… Below is my CSS and Html.

Heres the URL to the page, youll notice the space above the white content area that shows when i enter any text using a tag such as <p> or <h1>

[url]http://jason-storey.com/Smock-Etling/index.html[/url]

CSS–
html {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-color: #1f4c65;
height: 100&#37;;
padding: 0;

}
#container {
min-height:100%;
position:relative;
}
#header {
background-image:url(banner.png);
width:800px;
height:120px;
margin-left:auto;
margin-right:auto;

}

#body {

background-image:url(content.jpg);
width:800px;
height: 700px;
margin-left:auto;
margin-right:auto;
padding-bottom:60px;
/* Height of the footer */

}
#footer {

margin-left:auto;
margin-right:auto;
bottom:0;
width:800px;
height:60px; /* Height of the footer */
background-image:url(footer.jpg);
}

HTML–
<body>
<div id=”container”>
<header id=”header”>

</header>

<div id=”body”>

</div>
<footer id=”footer”>

</footer>

</div>
</body>
</html>

to post a comment
CSS

3 Comments(s)

Copy linkTweet thisAlerts:
@Big_O_1_Jun 03.2011 — it's because the <p> in your body section has a top and bottom margin of 16 pixels. That's what's pushing it lower. It's always a good idea to use a CSS reset to remove margin, padding, and other styling that browsers apply differently. This way you can start from a common, clean slate before applying your styling.
Copy linkTweet thisAlerts:
@jasonhr13authorJun 03.2011 — Well when i do that and add that to my css, it still doesnt work. The point isnt the margins used by the <p> tag, The point is that i should be able to position that div in that spot, then have it not move down when i put in a paragraph.

Using that reset now when i enter my text it just puts it in that space between my header and body, thousands and thousands of websites use this simple layout. There must be a simple fix that im missing or just dont know about
Copy linkTweet thisAlerts:
@jasonhr13authorJun 03.2011 — the whole content div shouldnt move down when i input a paragraph, thats my point.
×

Success!

Help @jasonhr13 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...