w:pgBorders (Page Borders)

Specifies borders drawn around each page in a section, with control over which sides display a border and their offset from the page or text edges.

Parent elements

Child elements

Description

w:pgBorders defines decorative borders around the pages of a section. Unlike paragraph borders (w:pBdr), page borders are drawn at the page margin level and can extend to the edge of the page.

It is defined in ECMA-376 Part 1 §17.6.10.

Attributes

Attribute Type Possible Values Description
w:zOrder ST_PageBorderZOrder front, back Whether the border is drawn in front of or behind page content.
w:display ST_PageBorderDisplay allPages, firstPage, notFirstPage Which pages in the section display the border.
w:offsetFrom ST_PageBorderOffset page, text Whether border distances are measured from the page edge or from the text margins.

Child Elements

Each side is represented by its own child element (w:top, w:left, w:bottom, w:right) with the following attributes:

Attribute Description
w:val Border style (ST_Border): single, double, dashSmallGap, apples, etc. (including art borders).
w:color Six-digit hex RGB or auto.
w:sz Width in eighths of a point.
w:space Distance from text/page edge in points.

Examples

<w:sectPr>
  <w:pgBorders w:offsetFrom="page">
    <w:top    w:val="single" w:color="000000" w:sz="24" w:space="24"/>
    <w:left   w:val="single" w:color="000000" w:sz="24" w:space="24"/>
    <w:bottom w:val="single" w:color="000000" w:sz="24" w:space="24"/>
    <w:right  w:val="single" w:color="000000" w:sz="24" w:space="24"/>
  </w:pgBorders>
  <!-- pgSz, pgMar omitted -->
</w:sectPr>

Notes

  • Art borders (w:val art border types like apples, babyPacifier, etc.) are only supported by certain renderers; use with caution for cross-application compatibility.
  • If only certain sides should have borders, omit the other side child elements.
  • w:space is measured in points when w:offsetFrom="page", and in twentieths-of-a-point when w:offsetFrom="text".