The margin-top property
The margin-top property sets a margin
at the top of an element. The value of the
property is any
size units
or the key property auto, which allows
the browser to independently calculate
the element margin.
Syntax
selector {
margin-top: value;
}
Example
Let's give the block the 50px
top margin:
<div id="parent">
<div id="elem"></div>
</div>
#parent {
border: 1px solid green;
display: inline-block;
}
#elem {
margin-top: 50px;
border: 1px solid red;
width: 100px;
height: 100px;
}
:
See also
-
the
margin-bottomproperty,
that sets a bottom margin -
the
margin-leftproperty
that sets a left margin -
the
margin-rightproperty
that sets a right margin -
the
marginproperty
that is a shorthand for a margin -
the
paddingproperty
that sets a padding