Little Web Hut

CSS 2.1 Reference: margin-top Property

CSS margin-top Property
Syntax
selector {margin-top: value ;}
  • value is specified by using a length, percentage, or one of the following keywords: auto or inherit.
Usage

The margin-top property is used to specify the width of the top side margin. See the Box Model for a description of the boxes that are generated for elements and the relative position of the margins.

This property is specified by using a length, percentage, or keyword, according to the syntax shown above. If a percentage value is used, the value will be a percentage of the containing block's width.


CSS Example: The margin-top property is set using a length value.
  img {margin-top: 20px;}
Test It HTML StyleTest It XHTML StyleTest It HTML5 Style

Keywords
  • auto - The margin width is automatically determined by the browser.
  • inherit - The inherit keyword is used to specify that the value for this property should be taken from the parent element. If inherit is used with the root element, then the initial value for this property will be used.
Applies To All elements except elements with the following display types: table-row-group, table-header-group, table-footer-group, table-row, table-column-group, table-column, table-cell.
Inherited No
Initial Value 0


margin-top Property Examples
Test It HTML StyleTest It HTML StyleTest It HTML5 StyleThe margin-top property is set using a length value.