Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 322221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:55:07+00:00 2026-05-12T08:55:07+00:00

This page I have is super simple, this should be a breeze but I’m

  • 0

This page I have is super simple, this should be a breeze but I’m stumped.

I have two DIVs, one inside the other. In the first DIV, I have the margins set so that it lays at the top of the page, centered. The second DIV should lay inside the first, centered, but with a 50px margin at top. However, the 50px margin is being applied to the parent DIV and not the child. If I add a border to the parent DIV, it behaves like I expect it to, but not without.

Can anyone offer me any insight to this? Thanks in advance.

<div id="pageWrapper">
    <div id="mainWrapper">
    <p>foo</p>
     </div>
</div>

*{
    margin:0px;
    padding:0px;    
}
body{
    background-color:#034375;
}
#pageWrapper{
    width:960px;
    margin:0px auto 0px auto;
    background:url('i/blue-gradient.jpg') top left no-repeat;
}
#mainWrapper{
    width:500px;
    margin:50px auto 0 auto;    
    border:1px solid #000000;
    background-color:#eeeeee;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T08:55:08+00:00Added an answer on May 12, 2026 at 8:55 am

    This issue has to do with the CSS spec on rendering adjacent margins. Essentially, because there’s nothing “in between” the margins of the containing div and the margins on the inner div, the larger value is used for both.

    You’ll see this mainly in Firefox, and although the behavior seems to follow the letter of the law, I’m not sure this particular case behaves as intended by the spec writers.

    Fortunately, it’s easy to fix — put something “between” the margins. You’ve already noticed that putting a border on the parent div works. You can make this border transparent, and reduce the inner margin by 1px, and it will appear functionally the same as your above case. Another option is to apply one pixel of padding-top to the parent div. A third option is to use padding-top: 50px on the parent div instead of applying a top margin to the child div.

    More information on collapsing margins.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This really should be so very simple... I have an asp.net master page which
I have looked at this page for some time now. Amazing, really. But I
I want to have some divs stacked on top of one another, but act
This would seem to be super simple but I cannot get it to work
I have an ASPX page and on this page I have a control that
So I have this page here: http://www.eminentmedia.com/development/powercity/ As you can see when you mouse
i have this page . login: fer password: m Note: after login you will
I have three tables: page, attachment, page-attachment I have data like this: page ID
I have a page, with ajax URL on it, ofcourse this page is applying
He, I have this page where i have checkboxes next to every item in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.