XML technologies / CSS / Advanced websites with CSS / CSS property reference / margin-bottom, margin-top, margin-left, margin-right
(Excerpt from “CSS − Advanced websites with Cascading Stylesheets” by Rachel Andrew & Dan Shafer)
The properties margin-bottom, margin-top, margin-left, and margin-right describe the size of an element’s margin on each side.
Inherited: no
See also: margin
Values
Valid values are CSS measurements, percentages of the parent element’s width or height, or the constant auto. With auto the browser calculates margins so all elements can occupy their default or assigned widths.
Default value: 0 (Note: This default applies to generic HTML elements. For some elements, such as headings, paragraphs, quotations and lists, a browser’s internal stylesheet usually provides various other default values for margin.)
Compatibility
CSS version: 1
Works in all CSS-capable browsers, including Internet Explorer 4 and Netscape 4.
Example
The following rules set the top and bottom margins of all headings so they have more space before them than after them:
h1, h2, h3, h4, h5, h6 {
margin-bottom: 0;
margin-top: 12pt;
}
p {
margin-top: 0;
margin-bottom: 6px;
}
Copyright © 2006 of the German translation, dpunkt.verlag GmbH
You may print the online version for your private use.
Otherwise, this chapter from “CSS − Anspruchsvolle Websites mit Cascading Stylesheets” is subject to the same conditions as the bound edition: the work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
dpunkt.verlag GmbH, Ringstraße 19, 69115 Heidelberg