XML technologies / XSL-FO / Reference / Attributes in XSL-FO / margin

(Excerpt from "XSL-FO ― Die Referenz" by Manuel Montero Pineda & Steffen Herkert, 2016, dpunkt.verlag)

A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

Recommendation section: 7.31.14

Category: 7.31 Shorthand Properties

Description

This attribute sets all four margins of an area relative to its immediate parent block. One value applies to left (margin-left), right (margin-right), top (margin-top), and bottom (margin-bottom). With two values, the first applies to top and bottom (margin-top and margin-bottom), the second to left and right (margin-left and margin-right). With three, the first applies to top (margin-top), the second to left and right (margin-left and margin-right), and the third to bottom (margin-bottom). Four values follow this order: top (margin-top), right (margin-right), bottom (margin-bottom), left (margin-left).

Values

Relative length

The margins on all four sides relative to the immediate parent area can be specified together as percentages (%), in em (relative to the width of the uppercase letter "M" in the font used), or in ex (relative to the height of the lowercase letter "x").

Absolute length

The margins on all four sides relative to the immediate parent area can be specified together using an absolute measurement.

Inherited:

yes

XSL-FO version: 1.0

Allowed in:

<fo:basic-link> , <fo:block> , <fo:block-container> , <fo:character> , <fo:external-graphic> , <fo:inline> , <fo:inline-container> , <fo:instream-foreign-object> , <fo:leader> , <fo:list-block> , <fo:list-item> , <fo:page-number> , <fo:page-number-citation> , <fo:page-number-citation-last> , <fo:region-body> , <fo:scaling-value-citation> , <fo:simple-page-master> , <fo:table> , <fo:table-and-caption> and <fo:title>

Support:

Conformance level

Antenna House

FOP

RenderX XEP

Altsoft XML2PDF

Compart DocBridge

Complete

Y

Y

Y

Y

Y

XSL-FO example:

<fo:root font-family="Arial" font-size="10pt" line-height="1.2em" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:cpfo="http://www.compart.net/xmlns/cpfo" xmlns:svg="http://www.w3.org/2000/svg" xmlns:axf="http://www.antennahouse.com/names/XSL/Extensions">
<fo:layout-master-set>
<fo:simple-page-master master-name="Inhalt-Seiten" margin="0mm
                        0mm 0mm
                    0mm" page-height="297mm" page-width="210mm">
<fo:region-body margin="26mm
                        55mm 41mm 55mm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="Inhalt-Seiten">
<fo:flow flow-name="xsl-region-body">
<fo:block>
<fo:block-container>
<fo:block margin="0pt
                        50pt" text-align="justify">
»Was ist mit mir
                geschehen?«, dachte er. Es war kein Traum. Sein Zimmer, ein richtiges, nur etwas zu
                kleines Menschenzimmer, lag ruhig zwischen den vier wohlbekannten Wänden.
</fo:block>
</fo:block-container>
<fo:block-container>
<fo:block margin="3em
                        0pt
                    3pt" text-align="justify">
 Über dem Tisch, auf dem eine auseinandergepackte Musterkollektion von Tuchwaren
                ausgebreitet war - Samsa war Reisender - hing das Bild, das er vor kurzem aus einer
                illustrierten Zeitschrift ausgeschnitten und in einem hübschen, vergoldeten Rahmen
                untergebracht hatte.
</fo:block>
</fo:block-container>
<fo:block-container>
<fo:block margin="0pt
                        -10pt 0pt
                    -20pt" text-align="justify">
 Es stellte eine
                Dame dar, die mit einem Pelzhut und einer Pelzboa versehen, aufrecht dasaß und einen
                schweren Pelzmuff, in dem ihr ganzer Unterarm verschwunden war, dem Beschauer
                entgegenhob.
</fo:block>
</fo:block-container>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>

Download the examples

In the output:

Excerpt from the W3C Recommendation:

More information online about

Property description in the CSS reference "margin"

Rendering of the property in the XSL-FO reference

back to top