This is an interesting option.
When the container has a border, the margin of the second inner div starts from the border - that is, the margin is applied from the front to the front. This is because the border is the last element that is applied before measuring the margin.
When the container has no border, the edge of the second inner div runs through the last element, which is now the body. Thus, the margin is now outside the container, so the container is now actually further than the page - the first inner div does not matter and is located directly at the top of the container - this is the container itself, which moved to the second case.
If you add a background color to your example, you will see that when you have a border, the field is inside the container, and when you have no border, the margin is outside the container. See an example on JSFiddle .
source share