15. How Do I Use XHTML in Headers and Footers?

It is possible to add formatted XHTML as generated content to page margin boxes by using the non-standard CSS function xhtml().

The xhtml() function takes a string representing a formatted XHTML document or document fragment as argument, e.g.:

/*document fragment*/
content: xhtml("<table>...</table>");

/*complete document*/
content: xhtml("<html><head>...</head><body>...</body></html>");

Important:

When using the xhtml() function in an XML document (e.g. inside the HTML "style" element) you have to place it inside an XML comment:

<!-- 
content: xhtml("<table>...</table>");
-->

Instead of specifying the XHTML directly you can also use the url() function to specify an external document. Example:

/*external document*/
content: xhtml(url("header.html"));

It is possible to refer to counters and named strings defined in the document containing the embedded document, however it is not possible to manipulate counters or named strings defined outside the embedded document within it.

How can I prevent that the embedded document uses styles from the main document? 

The -ro-passdown-styles property controls the amount of CSS styles the embedded document receives from the main document.

Currently there are two supported values:

The following example demonstrates how to prevent that the embedded document receives CSS styles from the main document:

@page {
  -ro-passdown-styles: none;
}

The -ro-passdown-styles property does not influence counters or named strings.