Headers and Footers

As described above, header and footer information is stored in one or more header or footer parts within the package.

The <hdr> element defines a single header for the document, while the <ftr> element defines a single footer for the document. Headers and footers are just another document story in WordprocessingML. Within the root element of the header or footer, the content of the element is similar to the content of the <body> element, and contains what is referred to as block-level markup —markup that can exist as a sibling element to paragraphs in a WordprocessingML document.

Within each section of a document there can be up to three different types of headers and footers:

  • First page header/footer

  • Odd page header/footer

  • Even page header/footer

First page headers and footers specify a unique header or footer that shall appear on the first page of a section. Odd page headers and footers specify a unique header and footer that shall appear on all odd numbered pages for a given section. Even page headers and footers specify a unique header and footer that shall appear on all even numbered pages in a given section.

Different headers or footers can be useful for bounded documents like books, as shown in the figure below.

Consider the following simple one-page document with one header:

This document defines one header with the text Header. The header's content is stored in a unique Header part. The resulting header is represented by the following WordprocessingML:

<w:hdr>
  <w:p>
    <w:r>
      <w:t>Header</w:t>
    </w:r>
  </w:p>
</w:hdr>

Since headers are containers of block level contents, all block level contents can be used within them. In this particular example, the content is a single paragraph.

Consider a more complex three-page document with different first, odd, and even page headers defined:

This document defines three headers stored in three different header parts. The resulting headers are represented by the following WordprocessingML:

First page header part:

<w:hdr>
  <w:p>
    <w:r>
      <w:t>First</w:t>
    </w:r>
  </w:p>
</w:hdr>

Even page header part:

<w:hdr>
  <w:p>
    <w:r>
      <w:t>Even</w:t>
    </w:r>
  </w:p>
</w:hdr>

Odd page header part:

<w:hdr>
  <w:p>
    <w:r>
      <w:t>Odd</w:t>
    </w:r>
  </w:p>
</w:hdr>