Forum How do I...?

How to insert element when list breaks across pages?

ikaruga1111
Given the following layout:

ul 
   li
   li
<!-- page break -->
   li
   li


I'd like to be able to insert a header whenever the list breaks but of course only when the list breaks. A use case would be an "Experience" list that when broken across pages shows an "Experience (cont.)" header.
mikeday
Currently this is a bit tricky. The easiest way is probably to put it inside a table with a repeating caption, like this:
<table cellspacing="0" cellpadding="0" width="100%">
<caption>Experience</caption>
<caption style="prince-caption-page: following">Experience (cont.)</caption>
<tr>
<td>
<ul>
<li>First</li>
<li>Second</li>
<li style="page-break-before: always">Third</li>
<li>Fourth</li>
</ul>
</td>
</tr>
</table>

(Support for multiple table captions is a Prince extension to HTML and CSS).