If the element above the element in
question is floated, or absolutely positioned, the top margin will pass through the
floated element, because floats and absolute elements are removed from the flow.
The margin will only be affected by static elements (or elements for which position
is set to relative, and which have no coordinates) in the normal flow of the
document??”this includes the containing block itself.
Example
This style rule assigns a margin of 20 pixels
to the tops of paragraphs within the
element with ID "example":
#example p {
margin-top: 20px;
}
Refer to the sections on the CSS box model (p. 142), collapsing margins (p. 148),
containing blocks (p. 147), and floating and clearing (p. 180) to understand exactly
SPEC
version initial inherited
CSS1 0 NO
BROWSER SUPPORT
Op9.2+ Saf1.3+ FF1+ IE5.5+
FULL FULL FULL BUGGY
how margins work for all elements. The section on inline formatting (p. 166) also
explains how margins affect inline elements.
Value
The property takes a CSS length (px, pt, em, and so on), the keyword auto, or a
percentage of the width of the element??™s containing block (p.
Pages:
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306