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


margin-top: <length> | <percentage> | auto | inherit
Initial: 0
Applies To: all elements except elements with table display types other than table-caption, table and inline-table
Inherited: no
Percentages: refer to width of containing block
Media: visual


margin-top: value
Value Initial Description
auto Specifies an automatically generated value
length 0 Specifies a fixed length
percentage Specifies a percentage of the containing block


[window.]document.getElementById("element-id").style.marginTop = "margin-top";

Example | auto

Example | length

Example | percentage

Example | DOM


W3C Cascading Style Sheets, level 1

W3C Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification

W3C CSS basic box model