Assume the following HTML:
body {
margin: 0;
padding: 0;
background-color: fuchsia;
}
#item {
position: absolute;
top: 0;
left: 0;
margin-top: 20px;
margin-left: 10px;
background-color: aqua;
}
<div id="item">
Hello
</div>
Since the element is absolutely positioned, I'm expecting the margin-top
and margin-left
properties to be ignored here. However, I find the element aligned 20px to the top and 10px to the left. (Using Chrome 77 here)
Can someone provide an explanation as to why/how the margin are taken into account here ?