In CSS, margins are used to create space around elements, outside of any defined borders. Margins can be set for the top, right, bottom, and left sides of an element, and they can be specified in various units such as pixels, ems, rems, percentages, and more.
div {
margin-top: 20px;
margin-right: 10%;
margin-bottom: 20px;
margin-left: 10%;
}
In CSS, margins are used to create space around an element, outside of any defined borders. The CSS margin properties are used to create space around elements, outside of any defined borders. With CSS, you have full control over the margins. There are properties for setting the margin for each side of an element (top, right, bottom, and left). You can specify the margin for each side of an element using the following properties:
margin-top
margin-right
margin-bottom
margin-left