w:pgMar (Page Margins)
Defines top, bottom, left, right, header, footer, and gutter margins for the page.
Parent elements
Description
w:pgMar defines the page margins for a section. It is defined in ECMA-376 Part 1 §17.6.11.
All values are in twips (1/20 of a point; 1440 twips = 1 inch). The w:header and w:footer values control the distance from the page edge to the header/footer band, not to the main text area.
Attributes
| Attribute | Type | Possible Values | Description |
|---|---|---|---|
w:top |
ST_SignedTwipsMeasure |
Integer (twips, may be negative). | Top margin (from page edge to main text area). |
w:right |
ST_TwipsMeasure |
Positive integer (twips). | Right margin. |
w:bottom |
ST_SignedTwipsMeasure |
Integer (twips, may be negative). | Bottom margin. |
w:left |
ST_TwipsMeasure |
Positive integer (twips). | Left margin. |
w:header |
ST_TwipsMeasure |
Positive integer (twips). | Distance from top edge to top of header. |
w:footer |
ST_TwipsMeasure |
Positive integer (twips). | Distance from bottom edge to bottom of footer. |
w:gutter |
ST_TwipsMeasure |
Positive integer (twips). | Gutter margin added to binding side. |
Examples
<!-- Standard 1-inch margins all around -->
<w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440"
w:header="708" w:footer="708" w:gutter="0"/>
new PageMargin
{
Top = 1440, // 1 inch
Right = 1440, // 1 inch
Bottom = 1440, // 1 inch
Left = 1440, // 1 inch
Header = 708, // 0.5 inch from top to header
Footer = 708, // 0.5 inch from bottom to footer
Gutter = 0 // No gutter
};
<!-- Narrow margins with binding gutter -->
<w:pgMar w:top="720" w:right="720" w:bottom="720" w:left="720"
w:header="360" w:footer="360" w:gutter="360"/>
new PageMargin
{
Top = 720, // 0.5 inch
Right = 720, // 0.5 inch
Bottom = 720, // 0.5 inch
Left = 720, // 0.5 inch (base)
Header = 360, // 0.25 inch
Footer = 360, // 0.25 inch
Gutter = 360 // 0.25 inch added to binding side
};
Measurement Conversions
| Margin | Twips | Inches | mm |
|---|---|---|---|
| 0.25” | 360 | 0.25 | 6.35 |
| 0.5” | 720 | 0.5 | 12.7 |
| 0.75” | 1080 | 0.75 | 19.05 |
| 1” | 1440 | 1 | 25.4 |
| 1.5” | 2160 | 1.5 | 38.1 |
| 2” | 2880 | 2 | 50.8 |
Margin Profiles
Standard Academic (1” all sides)
<w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440"
w:header="720" w:footer="720" w:gutter="0"/>
Narrow (0.75” all sides)
<w:pgMar w:top="1080" w:right="1080" w:bottom="1080" w:left="1080"
w:header="540" w:footer="540" w:gutter="0"/>
Bound Document (1” left, 0.75” others, 0.5” gutter)
<w:pgMar w:top="1080" w:right="1080" w:bottom="1080" w:left="1440"
w:header="720" w:footer="720" w:gutter="720"/>
Book Style (Mirror Margins + Gutter)
<w:pgMar w:top="1440" w:right="1080" w:bottom="1440" w:left="1440"
w:header="720" w:footer="720" w:gutter="360"/>
<!-- With w:mirrorMargins enabled, odd/even pages swap left/right -->
Letterhead (Small Top/Bottom for Logo)
<w:pgMar w:top="360" w:right="1440" w:bottom="1440" w:left="1440"
w:header="1440" w:footer="720" w:gutter="0"/>
Twips Conversion Table
| Inches | mm | Twips |
|---|---|---|
| 0.25” | 6.35 | 360 |
| 0.5” | 12.7 | 720 |
| 0.75” | 19.05 | 1080 |
| 1.0” | 25.4 | 1440 |
| 1.5” | 38.1 | 2160 |
| 2.0” | 50.8 | 2880 |
Header/Footer Spacing Logic
The w:header and w:footer attributes define distance from page edge to the header/footer band:
Page Edge
↓
[w:header] = 0.5"
↓
┌───────────────────┐
│ Header Content │ ← Renders within header band
└───────────────────┘
↓ (Header ends)
┌───────────────────┐
│ Main Text Area │ ← Body text starts here
│ (bounded by │ Left: w:left, Right: w:right,
│ top/bottom) │ Top: below header, Bottom: above footer
└───────────────────┘
↓ (Body ends)
┌───────────────────┐
│ Footer Content │ ← Renders within footer band
└───────────────────┘
↓
[w:footer] = 0.5"
↓
Page Edge
Gutter Margins
Purpose: Extra margin on binding edge (left for LTR, right for RTL) for book/document binding.
Without Gutter:
- Left margin = 1.5”
- Text column width = page width - 1.5” - 1.5” (right)
With Gutter (0.5”):
- Left margin = 1.5” (base) + 0.5” (gutter) = 2.0”
- Text column width = page width - 2.0” - 1.5” (right)
- Gutter space remains blank (for binding hole, punch)
Notes
- Twips Conversion: 1440 twips = 1 inch. Divide twips by 1440 for inches; by 56.7 for millimeters.
- Header/Footer vs Margins:
w:header/w:footerare separate fromw:top/w:bottom; both constrain text area. - Gutter Function: Gutter is added to the left margin (LTR) or right margin (RTL) for binding space; shifts entire text column.
- Mirror Margins: When
w:mirrorMarginsis enabled, left/right margins alternate on odd/even pages; gutter follows binding edge. - Negative Margins:
w:topandw:bottomcan be negative (overflow into page edge), though uncommon; other margins typically positive. - Default Values: Omitting
w:pgMaruses Word’s defaults (typically 1 inch all sides with 0.5” header/footer). - Section-Specific: Each
w:sectPrcan define different margins; sections change margin values mid-document. - Effective Text Area: Main text = page width - left - right - gutter; height = page height - top - bottom; header/footer are separate bands.
- RTL Compatibility: Margin semantics mirror in right-to-left documents; left becomes right semantically, though XML remains unchanged.
- Printing: Printers have physical margins (non-printable edge); keep document margins > printer margin for visibility.
- Rendering Consistency: Margin values render consistently across all Office versions and export formats.
- Accessibility: Large margins reduce effective text area; balance readability vs. printability.