filmov
tv
margin property
Показать описание
he margin property in CSS is used to control the amount of space between an HTML element and its surrounding elements. It can be set to a specific length or percentage value, or it can be set to the auto keyword to center an element horizontally within its container.
Here's a basic example that sets the top and bottom margins of a paragraph element to 20 pixels, and the left and right margins to 40 pixels using the margin property.
p {
margin: 20px 40px;
}
In this example, the p selector targets the p element, and the margin: 20px 40px; declaration sets the top and bottom margins to 20 pixels, and the left and right margins to 40 pixels.
You can also set individual margins for each side of an element's box using the margin-top, margin-right, margin-bottom, and margin-left properties. For example:
div {
margin-top: 10px;
margin-right: 20px;
margin-bottom: 30px;
margin-left: 40px;
}
In this example, the div selector targets the div element, and the margin-top: 10px; declaration sets the top margin to 10 pixels, margin-right: 20px; sets the right margin to 20 pixels, margin-bottom: 30px; sets the bottom margin to 30 pixels, and margin-left: 40px; sets the left margin to 40 pixels.
Here's a basic example that sets the top and bottom margins of a paragraph element to 20 pixels, and the left and right margins to 40 pixels using the margin property.
p {
margin: 20px 40px;
}
In this example, the p selector targets the p element, and the margin: 20px 40px; declaration sets the top and bottom margins to 20 pixels, and the left and right margins to 40 pixels.
You can also set individual margins for each side of an element's box using the margin-top, margin-right, margin-bottom, and margin-left properties. For example:
div {
margin-top: 10px;
margin-right: 20px;
margin-bottom: 30px;
margin-left: 40px;
}
In this example, the div selector targets the div element, and the margin-top: 10px; declaration sets the top margin to 10 pixels, margin-right: 20px; sets the right margin to 20 pixels, margin-bottom: 30px; sets the bottom margin to 30 pixels, and margin-left: 40px; sets the left margin to 40 pixels.