Margins using CSS

An element has four sides: right, left, top and bottom. The margin is the distance from each side to the neighboring element (or the borders of the document).

The CSS code for defining margins for the document:

body {
margin-top: 100px;
margin-right: 40px;
margin-bottom: 10px;
margin-left: 70px;

You can use a more elegant compilation:

body {
margin: 100px 40px 10px 70px;

You can set the margins in the same way on almost every element.