Difference between revisions of "CSS GUIDE MARGIN TOP"

From CDOT Wiki
Jump to: navigation, search
 
 
Line 1: Line 1:
<span style="margin:0;background:#ffff33;font-size:120%;font-weight:bold;border:1px solid #a3b0bf;text-align:left;color:#000;padding:0.2em 0.4em;">This document is a work in progress and is subject to change.</span><br /><br />
 
 
 
== Summary ==
 
== Summary ==
 
'''margin-top''' property sets the top margin of an element.
 
'''margin-top''' property sets the top margin of an element.

Latest revision as of 15:37, 13 December 2006

Summary

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

  • Initial value: depends on user agent
  • Applies to: all elements
  • Inherited: no
  • Percentages: yes, refers to the width of containing block
  • Media: visual
  • Computed value: as specified

Syntax

h1 { margin-top: value }

Legal Values

auto

The browser sets a top margin.

length

Defines a fixed top margin.

percentage

Defines a top margin in % of the total height of the document.

Mozilla Recommended Values

Usage Examples

h1 { margin-top: 10px }
h2 { margin-top: -20px }
h3 { margin-top: 1em }
<p style="margin-top : 2em;">
This paragraph has a 2 em margin top.
</p>

Notes

  • Negative values are allowed

Specification Conformance

Browser Compatibility

  • Netscape 4, 6, 7
  • Mozilla 1
  • Firefox 1, 1.5, 2
  • Internet Explorer 3, 4, 5, 6
  • Opera 3, 4, 5, 6, 7, 8
  • Safari 1

See Also