w:pPr (Paragraph Properties)

Container for all formatting properties applied to a paragraph.

Description

w:pPr is the paragraph properties container, grouping all formatting properties for a w:p element. It is defined in ECMA-376 Part 1 §17.3.1.26.

When w:pPr appears inside a w:style element, it defines the default paragraph properties for that style. When inside w:lvl, it defines properties for a particular list level. The w:pPr element acts as the control center for all block-level formatting, including indentation, spacing, borders, shading, alignment, and outline level.

Unlike inline formatting (handled by w:rPr), paragraph properties apply to the entire paragraph and take effect from the paragraph mark. The ordering of child elements matters for schema validation; properties should follow the ECMA-376 specification order.

Attributes

Attribute Type Possible Values Description
(none) — — All paragraph properties are expressed via child elements; w:pPr itself has no attributes.

Child Elements by Category

Style & Formatting

| Element | Purpose | Example | |———|———|———-| | w:pStyle | Named paragraph style | <w:pStyle w:val="Heading1"/> | | w:shd | Background/fill color | <w:shd w:fill="FFFF00"/> | | w:pBdr | Paragraph borders | <w:pBdr><w:top .../></w:pBdr> |

Alignment & Indentation

| Element | Purpose | Example | |———|———|———-| | w:jc | Horizontal alignment | <w:jc w:val="center"/> | | w:ind | Left/right/first-line indent | <w:ind w:left="720" w:firstLine="360"/> | | w:tabs | Tab stop positions | <w:tabs><w:tab .../></w:tabs> |

Spacing

| Element | Purpose | Example | |———|———|———-| | w:spacing | Before/after/line spacing | <w:spacing w:before="240" w:line="360"/> | | w:contextualSpacing | Context-aware spacing | <w:contextualSpacing/> |

Numbering & Outline

| Element | Purpose | Example | |———|———|———-| | w:numPr | Bullet/numbering properties | <w:numPr><w:ilvl w:val="0"/></w:numPr> | | w:outlineLvl | Outline/heading level | <w:outlineLvl w:val="0"/> |

Page & Line Control

| Element | Purpose | Example | |———|———|———-| | w:keepNext | Keep paragraph with next | <w:keepNext/> | | w:keepLines | Keep lines together | <w:keepLines/> | | w:pageBreakBefore | Force page break before | <w:pageBreakBefore/> |

Character Formatting

| Element | Purpose | Example | |———|———|———-| | w:rPr | Paragraph mark formatting | <w:rPr><w:b/></w:rPr> |

Sections

| Element | Purpose | Example | |———|———|———-| | w:sectPr | Section properties (final para) | <w:sectPr><w:pgSz .../></w:sectPr> |

Examples

Basic paragraph with heading style and center alignment

<w:p>
  <w:pPr>
    <w:pStyle w:val="Heading1"/>
    <w:jc w:val="center"/>
  </w:pPr>
  <w:r><w:t>Chapter Title</w:t></w:r>
</w:p>

Complex paragraph: styled, indented, spaced, with shading

<w:p>
  <w:pPr>
    <w:pStyle w:val="BodyText"/>
    <w:jc w:val="left"/>
    <w:ind w:left="720" w:right="360" w:firstLine="720"/>
    <w:spacing w:before="120" w:after="120" w:line="360" w:lineRule="auto"/>
    <w:shd w:fill="E8F4F8"/>
    <w:pBdr>
      <w:top w:val="single" w:sz="12" w:space="1" w:color="0070C0"/>
    </w:pBdr>
  </w:pPr>
  <w:r>
    <w:rPr><w:b/></w:rPr>
    <w:t>Important note:</w:t>
  </w:r>
  <w:r><w:t> This paragraph has multiple formatting properties applied.</w:t></w:r>
</w:p>

Bulleted list item with paragraph properties

<w:p>
  <w:pPr>
    <w:pStyle w:val="ListBullet"/>
    <w:numPr>
      <w:ilvl w:val="0"/>
      <w:numId w:val="1"/>
    </w:numPr>
    <w:ind w:left="720" w:hanging="360"/>
    <w:spacing w:after="0"/>
  </w:pPr>
  <w:r><w:t>First bullet point</w:t></w:r>
</w:p>

Notes

  • Child element order: ECMA-376 specifies a strict order for w:pPr children. When building programmatically, the OpenXml SDK enforces this order automatically.
  • Style inheritance: When a paragraph applies a style via w:pStyle, the paragraph properties defined in the style are inherited. Direct properties in w:pPr override the style’s properties.
  • Paragraph mark properties: The w:rPr child (if present) defines the formatting of the paragraph mark itself, which affects certain behaviors like line spacing calculations.
  • Toggle properties: Elements like w:keepNext, w:keepLines, w:pageBreakBefore are on/off flags; their presence means true, absence means false.
  • Measurement units: All distance attributes use twentieths of a point (twips); 1 inch = 1440 twips, 1 cm ≈ 567 twips.
  • Performance: Complex paragraph properties with many borders, shading, and nested formatting can impact document rendering performance when applied to thousands of paragraphs.
<w:p>
  <w:pPr>
    <w:pStyle w:val="Heading1"/>
    <w:jc w:val="center"/>
  </w:pPr>
  <w:r><w:t>Chapter Title</w:t></w:r>
</w:p>