Css margin-top vs margin-bottom

Depends on context. But, generally margin-top is better because you can use :first-child to remove it. Like so:

div.block {
    margin-top: 10px;
}

div.block:first-child {
    margin-top: 0;
}

This way, the margins are only in between the blocks.

Only works for more modern browsers, obviously.

Leave a Comment