CSS margin-top Property


The margin-top CSS property is used to specify an element's top margin. It places the margin-area on the element's top. The margin-top property has a value of 0 by default.

Syntax

Example

Preview

Property Values

Value Description
length Specifies a fixed top margin in pixels, points, centimeters, and so on. 0px is the default value. Negative values are permitted. Learn more about length units.
% Sets the top margin as a percentage of the width of the containing element.
auto A top margin is calculated by the browser.
initial This property is set to its default value.
inherit This property is inherited from its parent element.

Supported Browsers

Property Chrome Firefox Safari Edge / IE Opera
margin-top 1.0 1.0 1.0 6.0 3.5