CSS margin-topProperty


Example

Set the top margin of a p element:

p { margin-top:2cm; }

Try it Yourself »

Property definition and usage instructions

The margin-top property sets the top margin of an element.

Note:Negative values are allowed.

Default value: 0
Inherited: no
version: CSS1
JavaScript Syntax: object.style.marginTop="10px"


Browser Support

The numbers in the table indicate the first browser version number that supports the property.

Property
margin-top 1.0 6.0 1.0 1.0 3.5

Property value

Value Description
auto The top margin set by the browser.
length Defines a fixed top margin. The default value is 0.
% Defines a percentage top margin based on the total width of the parent object.
inherit Specifies that the top margin should be inherited from the parent element.


Related Articles

CSS Tutorial:CSS Margin

other extensions