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 6990815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:24:26+00:00 2026-05-27T19:24:26+00:00

This is my code : HTML <div class=’father’> <div class=’son’>Son</div> </div> CSS .father {

  • 0

This is my code :

HTML

<div class='father'>
    <div class='son'>Son</div>
</div>

CSS

.father
{
    background-color:blue;  
}

.son
{
    margin-top:50px;
    background-color:red;
    height:50px;
}

Where is the background-color blue of the father?
I know how to fix this problem (putting padding-top:1px to the father) but I’d like to know why of this behaviour!

For me it doesnt make sense, because on every browsers, not only IE, this is the behaviour.

  • 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-27T19:24:27+00:00Added an answer on May 27, 2026 at 7:24 pm

    This is a result of Collapsing Margins. You can read a good article by Eric Meyer on this topic where he illustrates this exact behavior. The following image is from his article.

    enter image description here

    Here’s what the CSS2 specification has to say about it.

    8.3.1 Collapsing margins

    If the top and bottom margins of a box are adjoining, then it is
    possible for margins to collapse through it. In this case, the
    position of the element depends on its relationship with the other
    elements whose margins are being collapsed.

    • If the element’s margins are collapsed with its parent’s top margin, the top border edge of the box is defined to be the same as
      the parent’s.
    • Otherwise, either the element’s parent is not taking part in the margin collapsing, or only the parent’s bottom margin is involved.
      The position of the element’s top border edge is the same as it
      would have been if the element had a non-zero bottom border.

    Note that the positions of elements that have been collapsed through
    have no effect on the positions of the other elements with whose
    margins they are being collapsed; the top border edge position is only
    required for laying out descendants of these elements.

    Source: http://www.w3.org/TR/CSS2/box.html#collapsing-margins

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

Sidebar

Related Questions

Hello i have an HTML Code like this <div id=top> <div class=panel> <h1>toppanel</h1> <p>Content
I have this HTML code: <div id=content> <div class=profile_photo> <img style=float:left;margin-right:7px; src=http://gravatar.com/avatar/53566ac91a169b353a78b329bdd35c95?s=50&d=identicon class=profile_img alt={username}/>
I have this HTML code: <div class='com_box'> <div class='com_box_c'> <div class='com_box_info'> <a id='quote'>quote</a> </div>
Say I have jquery code like this: html += '<div class=index>' + item.index +
Hi I have this HTML code <th scope=col class= style=width: 13px;> <div class=some-handle></div> <a
I have this html code: <body> <div class=CodeRay> <div class=code><pre><span class=no> 1</span> require <span
I have this html-code: <div class=im> <div style=height:220px>HELLO WORLD! <a class=close>X</a> <a class=open style=display:none;>V</a>
What am I doing wrong in this HTML code: <html> <head> </head> <body> <div
I have HTML code like this : <div> <a>Link A1</a> <a>Link A2</a> <a>Link A3</a>
i have this code $(function() { $('#ans_vote a span').click(function(){alert('working');return false;});}); and this html <div

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.