Hello
World
Hello World
Hello World
Hello World«=e 0 iy
CSS Margins
This element has a margin of 70px.
CSS Margins
his element has a margin of
(70px.or > |
Using individual margin properties
This div element has a top margin of
100px, a right margin of 150px, a bottom margin
of 100px, and a left margin of 80px.
Using individual margin
properties
his div element has
la top margin of
(LOOpx, a right margin|
lof 150px, a bottom
argin of 100px, and
la left margin of 80px.mv GSS BEE Ne dae SQL PYTHON
Margin - Shorthand Property
To shorten the code, it is possible to specify all the margin
properties in one property.
The margin property is a shorthand property for the
following individual margin properties:
¢ margin-top
¢ margin-right
« margin-bottom
¢ margin-left
So, here is how it works:
If the margin property has four values:
¢ margin: 25px 50px 75px 100px;
© top margin is 25px
o right margin is 50px
© bottom margin is 75px
o left margin is 100px
Example
Use the margin shorthand property with four values:¢5e 0 Ey
The margin] shorthand property - 4
values
This div element has a top margin of 25px,
a right margin of 50px, a bottom margin of
75px, and a left margin of 100px.
The margin shorthand property
- 4 values
is div element has a top
argin of 25px, a right margin
lof SOpx, a bottom margin of
|75px, and a left margin of
(LOOpx.
Use of margin: auto
You can set the margin property to auto to
horizontally center the element within its
container.
This div will be horizontally centered because
it has margin: auto;
Use of margin: auto
You can set the margin property to auto to
horizontally center the element within its
container.
his div be horizontally centered
ecause it has margin: auto;