Gaps between header, content and footer divs in Firefox

Posted on 2007-12-01
Last Modified: 2013-12-07

I'm trying to convert my table design to CSS tableless; so far I've managed to get the main content div & background image to expand down as needed. It looks right in IE but there are gaps between the header div/content div in Firefox when I use <p> tags and <h1> tags, and there's also a gap between the content div and the footer div that I don't know how to get rid of. Can someone please take a look and maybe help me figure this out? the page is here: www. . The css is included in the page code. Thank you!!
Question by:Angelz22
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
LVL 29

Accepted Solution

Göran Andersson earned 500 total points
ID: 20390211
As always, when a page is rendered differently in IE and Firefox, Firefox gets it right.

The gaps you see comes from margin-collapsing:

As the header and paragraph tags have a margin by default, this margin will extend outside the parent element, so that there will be a margin between your containing divs.

The solution is simple; use padding instead. Like:

h1, p { margin: 0; padding: 5px 0; }

Author Comment

ID: 20390225
Thank you, GreenGhost, that corrected the problem with the gap between the header div and the content div, but I am still having the problem with the gap between the content div and the footer div; also, is it possible to set the padding in the content div without wrecking the design, so I do not have to use a separate div within the content div like I'm doing now? Thank you!
LVL 29

Expert Comment

by:Göran Andersson
ID: 20390902
I was going to take a look at the html code, but I quickly gave up when I saw it... It's virtually unreadable, how do you maintain code like that?

Anyhow, an extra div is one way of handling margin-collapsing, but it's not the only way.
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 20391707
The code is more easily read now; sorry about that, I forgot; I'm so used to getting rid of extra white space. Frankly it's much easier for me to maintain the way it was, but I guess that's because I'm used to it. Anyway, if someone could help me figure this out it would be very much appreciated...thanks :)

Author Comment

ID: 20391775
Hmmm, I seem to have corrected the gaps issue; there is still an issue with setting the margins (padding?) within the div though. It's not a huge problem but I would rater be able to just set the left and right margins within the div itself so the text is aligned where it currently is without having to use an extra div for that-any suggestions?

Author Closing Comment

ID: 31412153
Thanks! still have the other question but that wasn't part of the original question and you did help me figure this out :)
LVL 29

Expert Comment

by:Göran Andersson
ID: 20391872
When I look at the code it still looks horrible, but now I realise where it comes from. I use "Edit HTML" in Devloper Toolbar, and then I also get the html code that your navigation scripts write, and that is what makes it unreadable. The rest of it doesn't look that bad.

If you add padding to an element, that adds to the specified size. When you add horisontal padding you have to reduce the width to keep the total size the same. Do like this in the #web-design-3 class, and you don't need another div inside it:

padding: 0 67px 0 70px;

Author Comment

ID: 20391950
Beautiful, thank you so much!!!

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Curious Trouble with and Inability to Access a Single Site 24 51
How to build a web site 17 60
Google Chrome GPO Not Applying 5 36
Web content filtering solution 6 34
SSL stands for “Secure Sockets Layer” and an SSL certificate is a critical component to keeping your website safe, secured, and compliant. Any ecommerce website must have an SSL certificate to ensure the safe handling of sensitive information like…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question