Contents | < Floats | Tables >
We have seen that XSL-FO documents have flow layout, that is, the content flows from one page to the next one, according to the rules imposed by page breaks, spacing, widows and orphans properties. However, sometimes it may be useful to position elements at absolute coordinates. You can achieve this by using fo:block-container element. In the example below, we have two fragments of text positioned under and over the main flow text.
<fo:flow flow-name="xsl-region-body" font-family="Verdana" font-size="10pt">
<fo:block-container position="absolute"
top="10pt" left="30pt" height="14pt" width="100%" >
<fo:block font="72pt Arial" color="silver">Under</fo:block>
</fo:block-container>
<fo:block>
<fo:block>
Text Text Text Text Text Text Text Text Text Text Text ...
</fo:block>
<fo:block-container position="absolute"
top="20pt" left="40pt" height="14pt" width="100%">
<fo:block font="72pt Arial" color="red">Over</fo:block>
</fo:block-container>
</fo:block>
<fo:block break-before="page"/>
<fo:block-container position="absolute"
top="10pt" left="30pt" height="14pt" width="100%">
<fo:block font="72pt Arial" color="silver">Under</fo:block>
</fo:block-container>
<fo:block>
<fo:block>
Text Text Text Text Text Text Text Text Text Text Text ...
</fo:block>
<fo:block-container position="absolute"
top="10pt" left="30pt" height="14pt" width="100%">
<fo:block font="72pt Arial" color="red">Over</fo:block>
</fo:block-container>
</fo:block>
</fo:flow>
![]() | For the complete source code for this code example see "Tutorial/Absolute Positioning.fo" located under XML Documents Samples/Tutorial folder. |

Figure 1
The important points in this document are:
position attribute is set to absolute
top, bottom, left and right coordinates are specified explicitly.
To change the order in which the elements are rendered, use z-index attribute:

Figure 2
All elements are considered to have a z-index of 0, therefore, if you want an element to be displayed on the background (like a watermark) use a negative z-index, while for a foreground element (like a stamp) use a positive z-index.
![]() | For the complete source code for this code example see "Tutorial/ZIndex.fo" located under XML Documents Samples/Tutorial folder. |
Contents | < Floats | Tables >