Easy Tutorial
❮ Func Attr Pr Text Unicode Bidi ❯

CSS margin-top Property

Example

Set the top margin of a p element:

p {
    margin-top: 2cm;
}

Property Definition and Usage

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 specify the first browser version that fully supports the property.

Property
margin-top 1.0 6.0 1.0 1.0 3.5

Property Values

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

Related Articles

CSS Tutorial: CSS Margin

❮ Func Attr Pr Text Unicode Bidi ❯