w:ftr (Footer)
Root element of a footer part (footer1.xml, etc.), containing block-level content rendered at the bottom of each page.
Child elements
Description
w:ftr is the root element of a footer part (footer{n}.xml). It is defined in ECMA-376 Part 1 §17.10.2.
The footer part is a separate XML file linked from the main document part via a w:footerReference relationship inside w:sectPr. Like w:hdr, it may contain any combination of paragraphs (w:p) and tables (w:tbl), and must contain at least one paragraph. Footer content is rendered at the bottom of each page. Common uses include page numbers, document titles, dates, and copyright notices.
Multiple footer parts can exist (e.g., footer1.xml, footer2.xml) for different sections or page types (default, first, even/odd). The footer is typically placed below the document margins, with its distance from the page edge defined by w:pgMar w:footer in w:sectPr.
Attributes
| Attribute | Type | Possible Values | Description |
|---|---|---|---|
| (none) | — | — | Content is expressed entirely via child paragraphs and tables. |
Footer Reference Types
| Type | Usage | Purpose |
|---|---|---|
default |
Standard footer | Applies to all pages (or odd pages if evenAndOddHeaders is set) |
first |
First page footer | Applies to first page only when w:titlePg is active |
even |
Even-page footer | Applies to even pages when w:evenAndOddHeaders is active |
Examples
Centered page number footer
<!-- footer1.xml: centered page number -->
<w:ftr xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:p>
<w:pPr>
<w:jc w:val="center"/>
</w:pPr>
<w:r>
<w:fldChar w:fldCharType="begin"/>
</w:r>
<w:r>
<w:instrText> PAGE </w:instrText>
</w:r>
<w:r>
<w:fldChar w:fldCharType="end"/>
</w:r>
</w:p>
</w:ftr>
var footerPart = mainPart.AddNewPart<FooterPart>();
footerPart.Footer = new Footer(
new Paragraph(
new ParagraphProperties(new Justification { Val = JustificationValues.Center }),
new Run(new FieldChar { FieldCharType = FieldCharValues.Begin }),
new Run(new FieldCode(" PAGE ")),
new Run(new FieldChar { FieldCharType = FieldCharValues.End })));
“Page X of Y” footer
<!-- footer1.xml: page X of Y format -->
<w:ftr xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:p>
<w:pPr>
<w:jc w:val="center"/>
</w:pPr>
<w:r><w:t>Page </w:t></w:r>
<w:r>
<w:fldChar w:fldCharType="begin"/>
</w:r>
<w:r>
<w:instrText> PAGE </w:instrText>
</w:r>
<w:r>
<w:fldChar w:fldCharType="end"/>
</w:r>
<w:r><w:t> of </w:t></w:r>
<w:r>
<w:fldChar w:fldCharType="begin"/>
</w:r>
<w:r>
<w:instrText> NUMPAGES </w:instrText>
</w:r>
<w:r>
<w:fldChar w:fldCharType="end"/>
</w:r>
</w:p>
</w:ftr>
var footerPart = mainPart.AddNewPart<FooterPart>();
footerPart.Footer = new Footer(
new Paragraph(
new ParagraphProperties(new Justification { Val = JustificationValues.Center }),
new Run(new Text("Page ")),
new Run(new FieldChar { FieldCharType = FieldCharValues.Begin }),
new Run(new FieldCode(" PAGE ")),
new Run(new FieldChar { FieldCharType = FieldCharValues.End }),
new Run(new Text(" of ")),
new Run(new FieldChar { FieldCharType = FieldCharValues.Begin }),
new Run(new FieldCode(" NUMPAGES ")),
new Run(new FieldChar { FieldCharType = FieldCharValues.End })));
Footer with document info and border
<!-- footer1.xml: document info with border -->
<w:ftr xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:tbl>
<w:tblPr>
<w:tblW w:w="5000" w:type="pct"/>
<w:tblBorders>
<w:top w:val="single" w:sz="6" w:space="1" w:color="808080"/>
</w:tblBorders>
</w:tblPr>
<w:tr>
<w:tc>
<w:p>
<w:pPr><w:jc w:val="left"/></w:pPr>
<w:r><w:t>Document Title</w:t></w:r>
</w:p>
</w:tc>
<w:tc>
<w:p>
<w:pPr><w:jc w:val="right"/></w:pPr>
<w:r><w:t>Page </w:t></w:r>
<w:r><w:fldChar w:fldCharType="begin"/></w:r>
<w:r><w:instrText> PAGE </w:instrText></w:r>
<w:r><w:fldChar w:fldCharType="end"/></w:r>
</w:p>
</w:tc>
</w:tr>
</w:tbl>
</w:ftr>
var footerPart = mainPart.AddNewPart<FooterPart>();
footerPart.Footer = new Footer(
new Table(
new TableProperties(
new TableWidth { Width = "5000", Type = TableWidthUnitValues.Pct },
new TableBorders(
new TopBorder { Val = BorderValues.Single, Sz = 6, Space = 1, Color = "808080" })),
new TableRow(
new TableCell(
new Paragraph(
new ParagraphProperties(new Justification { Val = JustificationValues.Left }),
new Run(new Text("Document Title")))),
new TableCell(
new Paragraph(
new ParagraphProperties(new Justification { Val = JustificationValues.Right }),
new Run(new Text("Page ")),
new Run(new FieldChar { FieldCharType = FieldCharValues.Begin }),
new Run(new FieldCode(" PAGE ")),
new Run(new FieldChar { FieldCharType = FieldCharValues.End }))))));
Common Footer Fields
| Field Code | Output | Purpose |
|---|---|---|
PAGE |
Page number | Current page number (e.g., “5”) |
NUMPAGES |
Total pages | Total page count (e.g., “10”) |
DATE \\@ "MM/dd/yyyy" |
Today’s date | Current date (formatted) |
TIME \\@ "hh:mm:ss" |
Current time | Time (formatted) |
FILENAME |
File name | Document file name (without path) |
TITLE |
Document title | From document properties |
Notes
- Footer part file: Each footer is stored in its own XML file (e.g.,
footer1.xml,footer2.xml) in theword/directory; linked fromdocument.xml.rels. - Minimum content: A footer must contain at least one
w:pparagraph; empty footers may cause compatibility issues. - Footer types: Reference type (
default,first,even) is determined byw:footerReference w:typeinw:sectPr, not by content in the footer itself. - Section-specific footers: Different sections can have different footers; each
w:sectPrcontainsw:footerReferenceelements pointing to its respective footer parts. - Field codes: Use
w:fldCharwith typesbegin,separate(for result text), andend; the actual field instruction is inw:instrTextorw:instrCode. - Field updates: Fields update when the document is opened in Word, when Print Preview is used, or when using “Update Fields” command.
- Distance from page edge: Footer distance from page edge is defined by
w:pgMar w:footerinw:sectPr; typically 720 twips (0.5 inches). - Accessibility: Footers are often excluded from accessibility readers; ensure critical content is in the main body if needed for screen readers.
- Different first page: Use
w:titlePginw:sectPrwith separatew:footerReference w:type="first"to have different footers on first page vs. subsequent pages.