Keeps, Orphans, and Widows

In this lesson of the XSL-FO tutorial, you will learn...
  1. To keep lines of text together.
  2. To manage orphans and widows.

Keep Constraints

Often you will want to make sure that certain content is kept together. For example, a paragraph following a heading should stay with that heading. This type of thing is handled with the keep attributes described below.

keep-with-previous and keep-with-next

The keep-with-previous attribute instructs the processor to try to keep an FO on the same page, column and line as the previous FO. Similarly, the keep-with-next attribute instructs the processor to try to keep an FO on the same page, column and line as the following FO. You can be more specific by appending .within-line, .within-column, or .within-page to the attribute (e.g, keep-with-next.within-page). Possible values for these attributes are shown below:

  • An integer (e.g, 10) - specifies the strength of the constraint, so that the processor knows how to handle conflicting constraints. The higher the number, the stronger the constraint.
  • always - specifies a strength value of infinity (e.g., greater than any integer).
Syntax
<fo:block font-weight="bold" keep-with-next="always">
 Header
</fo:block>
<fo:block>
 Body
</fo:block>

keep-together

The keep-together attribute is used to keep chunks of content together.

Syntax
<fo:block keep-together="always">
 <fo:block font-weight="bold">
  Header
 </fo:block>
 <fo:block>
  Body
 </fo:block>
</fo:block>

Note that breaks take precedence over keeps.

Orphans and Widows

Orphans are lines of text left at the end of a page. Widows are lines of text that carry over to the next page. The orphans and widows attributes are used to enforce a minimum number of orphans and widows in a block. For example, the code below specifies that the content should have no fewer than three orphans and three widows.

Syntax
<fo:block widows="3" orphans="3">
 Content
</fo:block>

Keeps, Orphans, and Widows Conclusion

In this lesson of the XSL-FO tutorial, you have learned how to keep content together with keep FOs and the orphans and widows attributes.

To continue to learn XSL-FO go to the top of this page and click on the next lesson in this XSL-FO Tutorial's Table of Contents.

Use of this website implies agreement to the following:

Copyright Information

All pages and graphics on this Web site are the property of Webucator, Inc. unless otherwise specified.

None of the content on this website may be redistributed or reproduced in any way, shape, or form without written permission from Webucator, Inc.

No Printing or saving of web pages

This content may not be printed or saved. It is for online use only.


Linking to this website

You may link to any of the pages on this website; however, you may not include the content in a frame or iframe without written permission from Webucator, Inc.


Warranties

This website is provided without warranty of any kind. There are no guarantees that use of the site will not be subject to interruptions. All direct or indirect risk related to use of the site is borne entirely by the user. All code and explanations provided on this site are provided without warranties to correctness, performance, fitness, merchantability, and/or any other warranty (whether expressed or implied).

For individual private use only

You agree not to use this online manual to deliver or receive training. If you are delivering or attending a class that is making use of this online manual, you are in violation of our terms of service. Please report any abuse to courseware@webucator.com. If you would like to deliver or receive training using this manual, please fill out the form at http://www.webucator.com/Contact.cfm.