w:pStyle (Paragraph Style Reference)
References a named paragraph style by its styleId, applying all properties of that style.
Parent elements
Description
w:pStyle references a named paragraph style by its styleId, applying all paragraph and run properties defined in that style. It is defined in ECMA-376 Part 1 §17.3.1.27.
The w:val must match the w:styleId attribute of a w:style element with w:type="paragraph" in styles.xml. Direct properties in w:pPr take precedence over those from the referenced style.
Attributes
| Attribute | Type | Possible Values | Description |
|---|---|---|---|
w:val |
ST_String |
Any paragraph style ID, e.g. Normal, Heading1, ListParagraph, Caption. |
References the paragraph style to apply. |
Examples
<w:p>
<w:pPr>
<w:pStyle w:val="Heading1"/>
</w:pPr>
<w:r>
<w:t>Introduction</w:t>
</w:r>
</w:p>
new Paragraph(
new ParagraphProperties(
new ParagraphStyleId { Val = "Heading1" }),
new Run(new Text("Introduction")));
<!-- List paragraph style (often includes automatic numbering/bullets) -->
<w:p>
<w:pPr>
<w:pStyle w:val="ListParagraph"/>
</w:pPr>
<w:r><w:t>First list item</w:t></w:r>
</w:p>
new Paragraph(
new ParagraphProperties(
new ParagraphStyleId { Val = "ListParagraph" }),
new Run(new Text("First list item")));
<!-- Style with direct property override: heading with custom alignment -->
<w:p>
<w:pPr>
<w:pStyle w:val="Heading2"/>
<w:jc w:val="center"/> <!-- Override style's default alignment -->
</w:pPr>
<w:r><w:t>Centered Heading</w:t></w:r>
</w:p>
new Paragraph(
new ParagraphProperties(
new ParagraphStyleId { Val = "Heading2" },
new Justification { Val = JustificationValues.Center }), // Overrides style
new Run(new Text("Centered Heading")));
Built-in Paragraph Styles
| Style ID | Display Name | Use Case |
|---|---|---|
Normal |
Normal | Default body text |
Heading1 - Heading9 |
Heading 1-9 | Hierarchical section headings |
Title |
Title | Document title (first page) |
Subtitle |
Subtitle | Document subtitle |
Quote |
Quote (Intense) | Block quotations |
ListParagraph |
List Paragraph | Paragraph within bulleted/numbered list |
Caption |
Caption | Figure/table captions |
FootnoteText |
Footnote Text | Footnote body |
EndnoteText |
Endnote Text | Endnote body |
Header |
Header | Page header content |
Footer |
Footer | Page footer content |
Style Priority and Inheritance
- Highest Priority: Direct run/paragraph properties in
w:pPr(direct formatting) - Medium Priority: Properties from paragraph style (
w:pStyle) - Lowest Priority: Properties from the built-in “Normal” style (fallback default)
Notes
- Style IDs are locale-independent internal identifiers; the display name in the UI is stored in
w:style/w:name. - Missing Style: If
w:valreferences a non-existent style, Word applies the default paragraph style (usually “Normal”). - Style Inheritance: Paragraph styles can be built on other styles; base style properties inherit downward.
- Direct Override: Direct properties in
w:pPralways override style properties; useful for one-off formatting exceptions. - Best Practice: Use styles consistently; direct formatting should be rare and intentional.
- Document Default: If no style specified, the paragraph uses the document’s default style (typically “Normal”).
- Linked Styles: Some styles (like “Heading 1”) are “linked” — they define both paragraph and character formatting.
- Quick Styles: Built-in styles like “Heading 1” appear in Word’s Quick Styles gallery for easy access.
- Custom Styles: Documents can define custom paragraph styles in styles.xml with custom style IDs.