Possible Duplicate:
Why does this CSS margin-top style not work?
Let's say I have two DIVs, one inside the other (DIV1 -> DIV2), and I define a marginTop property on the inner DIV, it should move DIV2 within DIV1. Instead it moves DIV1 and DIV2 by the # of pixels from the top. Yet marginLeft properly moves DIV2 within DIV1.
    // DIV1
    var x = document.createElement("div");
    x.style.width = "200px";
    x.style.height = "200px";
    x.style.backgroundColor = "red";
    // DIV2
    var y = document.createElement("div");
    y.style.width = "50px";
    y.style.height = "50px";
    y.style.backgroundColor = "black";
    y.style.marginTop = "10px";
    y.style.marginLeft = "10px"
    document.body.appendChild(x);
    x.appendChild(y);

Why does this happen?
 
     
    