w:p (Paragraph)
Container element for one paragraph in WordprocessingML.
Parent elements
Description
w:p (paragraph) is the fundamental block-level container in a WordprocessingML document. Every piece of flowing body text lives inside a paragraph. The element is defined in ECMA-376 Part 1 §17.3.1.22 and maps to ISO/IEC 29500-1 §17.3.1.22.
The contents of a paragraph can be any combination of the following four kinds of content (in document order):
- Paragraph properties (
w:pPr) — exactly zero or one, always the first child when present. Controls alignment, indentation, spacing, numbering, style, and other paragraph-level formatting. - Annotations — bookmarks (
w:bookmarkStart/w:bookmarkEnd), comment anchors, revision markup (w:ins,w:del), and permission ranges. - Custom markup — inline custom XML (
w:customXml) and structured document tags (w:sdt). - Run-level content — text runs (
w:r), hyperlinks (w:hyperlink), simple fields (w:fldSimple), bidirectional overrides (w:bdo/w:dir), Office Math (w:oMath/w:oMathPara), and subdocument anchors (w:subDoc).
Paragraph mark
Every w:p element implicitly ends with a paragraph mark — the non-printing glyph that Word stores as the last character. Run properties applied to that glyph are held in w:pPr/w:rPr (not in a separate w:r). Consumers must treat the paragraph mark as carrying the default character formatting for any trailing whitespace in the paragraph.
Empty paragraphs
A w:p element with no w:r children (and no other run-level content) is a valid, empty paragraph. Such paragraphs are used as paragraph separators and to carry blank lines, page breaks inserted via w:br, or section properties (w:sectPr inside w:pPr).
Paragraph identity and revision tracking
Each w:p carries up to five rsid* attributes that allow applications to correlate edits across save sessions. These are informational only; consumers are not required to preserve or honour them.
Attributes
| Attribute | Type | Possible Values | Description |
|---|---|---|---|
w:rsidR |
ST_LongHexNumber |
8-digit uppercase hex string, e.g. 00AB1234 |
Revision identifier recording the editing session in which this paragraph was added to the document. |
w:rsidRDefault |
ST_LongHexNumber |
8-digit uppercase hex string, e.g. 00AB1234 |
Default revision identifier applied to runs inside this paragraph that do not declare their own w:rsidR. Allows producers to omit redundant per-run attributes. |
w:rsidP |
ST_LongHexNumber |
8-digit uppercase hex string, e.g. 00AB1234 |
Revision identifier recording the editing session in which the paragraph’s properties were last changed. |
w:rsidRPr |
ST_LongHexNumber |
8-digit uppercase hex string, e.g. 00AB1234 |
Revision identifier recording the editing session in which the paragraph mark glyph formatting was last changed. |
w:rsidDel |
ST_LongHexNumber |
8-digit uppercase hex string, e.g. 00AB1234 |
Revision identifier recording the editing session in which this paragraph was deleted (used in revision-tracking scenarios). |
w14:paraId |
ST_HexColorAuto |
8-digit hex string (non-zero), e.g. 1A2B3C4D. Must be unique within the document. |
A unique paragraph identifier introduced in OOXML strict (Office 2010+). Used by applications to stably reference paragraphs across edits. |
w14:textId |
ST_HexColorAuto |
8-digit hex string (non-zero), e.g. 5E6F7A8B. Must be unique within the document. |
A unique text-content identifier introduced in Office 2010+. |
w14:noSpellErr |
xsd:boolean |
0 (false) or 1 (true) |
When 1, instructs the application not to spell-check the contents of this paragraph (Office 2010+). |
Examples
Minimal paragraph
<w:p>
<w:r>
<w:t>Hello OOXML</w:t>
</w:r>
</w:p>
new Paragraph(
new Run(
new Text("Hello OOXML")));
Paragraph with properties (centred, Heading 1 style)
<w:p>
<w:pPr>
<w:pStyle w:val="Heading1"/>
<w:jc w:val="center"/>
</w:pPr>
<w:r>
<w:t>Chapter One</w:t>
</w:r>
</w:p>
new Paragraph(
new ParagraphProperties(
new ParagraphStyleId { Val = "Heading1" },
new Justification { Val = JustificationValues.Center }),
new Run(
new Text("Chapter One")));
Paragraph containing both a run and a simple field
<w:p>
<w:r>
<w:t xml:space="preserve">Prepared by: </w:t>
</w:r>
<w:fldSimple w:instr="AUTHOR">
<w:r>
<w:t>Jane Smith</w:t>
</w:r>
</w:fldSimple>
</w:p>
new Paragraph(
new Run(new Text("Prepared by: ") { Space = SpaceProcessingModeValues.Preserve }),
new SimpleField(
new Run(new Text("Jane Smith"))) { Instruction = "AUTHOR" });
Empty paragraph (blank line)
<w:p/>
new Paragraph();
Paragraph with page break and mixed content
<w:p>
<w:pPr>
<w:pageBreakBefore/>
<w:pStyle w:val="Heading2"/>
</w:pPr>
<w:r>
<w:b/>
<w:t>New Section</w:t>
</w:r>
</w:p>
new Paragraph(
new ParagraphProperties(
new PageBreakBefore(),
new ParagraphStyleId { Val = "Heading2" }),
new Run(
new RunProperties(new Bold()),
new Text("New Section")));
Paragraph Content Model
| Child Element Type | Elements | Purpose | Max Count |
|---|---|---|---|
| Properties | w:pPr |
Paragraph formatting (alignment, spacing, indentation, style) | 1 (first) |
| Inline Content | w:r, w:hyperlink, w:fldSimple |
Text runs and hyperlinked runs | Unlimited |
| Annotations | w:bookmarkStart, w:bookmarkEnd, w:commentRangeStart, w:commentRangeEnd, w:permStart, w:permEnd |
Bookmarks, comments, permissions | Unlimited |
| Revisions | w:ins, w:del |
Change tracking (inserted/deleted content) | Unlimited |
| Structured Markup | w:sdt, w:customXml |
Structured document tags, custom XML | Unlimited |
| Complex Content | w:oMath, w:oMathPara |
Office Math (equations) | Unlimited |
| Special | w:dir, w:bdo, w:proofErr, w:subDoc |
Bidirectional text, proofing errors, subdocuments | Unlimited |
Paragraph Mark Behavior
- Implicit Mark: Every
<w:p>implicitly ends with a paragraph mark (non-printing glyph) - Mark Formatting: Formatting for the mark lives in
<w:pPr><w:rPr>, not in a separate<w:r> - Trailing Whitespace: The mark carries default character properties for any trailing space/soft returns
- Copy/Paste: The mark copies with the paragraph; pasting paragraphs includes mark properties
RSID Attributes (Revision Tracking)
| Attribute | Tracks | Purpose |
|---|---|---|
w:rsidR |
Paragraph insertion | Session ID when paragraph was added |
w:rsidRDefault |
Default for all runs | Fallback ID for runs without their own w:rsidR |
w:rsidP |
Paragraph properties change | Session ID when properties were last modified |
w:rsidRPr |
Mark formatting change | Session ID when paragraph mark glyph formatting changed |
w:rsidDel |
Paragraph deletion | Session ID when paragraph was deleted (in tracked changes) |
Notes
- Hierarchical constraint:
w:pmust appear as a direct child ofw:body,w:tc,w:hdr,w:ftr,w:comment,w:footnote,w:endnote,w:sdtContent,w:docPartBody, or an inlinew:customXml. It is not valid inside anotherw:p. - Property ordering: When
w:pPris present it must be the first child element; placing it after run content is invalid and violates the OOXML schema. - Paragraph Mark Glyph: The invisible mark at paragraph end carries properties from
w:pPr/w:rPr; users see it as ¶ in Word’s formatting view. - Empty Paragraphs: A
<w:p/>with no children is a valid empty paragraph, useful for spacing and blank lines. - Runs vs. Properties: Properties apply to entire paragraph; runs apply character-level formatting inside runs.
- Unique IDs:
w14:paraIdandw14:textIdmust be unique within document for cross-reference stability during editing. - Style Inheritance: If no
w:pStylespecified, paragraph inherits from “Normal” style (typically defined in styles.xml). - Bidirectional Text: Use
w:bdo(bidirectional override) orw:dir(direction) for mixed LTR/RTL content (Arabic, Hebrew). - Revision Tracking: RSID attributes allow Word to correlate edits across save sessions and user machines.
- Office Math:
w:oMathParais for block-level equations;w:oMathis inline (insidew:r). - Revision tracking attributes: The
rsid*attributes are round-trip attributes — a conforming producer may omit them, and a conforming consumer must not fail if they are absent. They track which editing session modified the paragraph. - Section break behavior: A paragraph that carries a
w:sectPrinside itsw:pPracts as a section break paragraph. The section properties apply to the section that ends at this paragraph; the paragraph’s own text (if any) belongs to the new section. - Spell-check suppression: Spell-check and grammar-check suppression for an entire paragraph can be achieved via
w:pPr/w:rPr/w:noProof(affects the paragraph mark) together withw:noProofon each constituent run. - Paragraph mark properties: The paragraph mark (implicit last character) carries formatting from
w:pPr/w:rPr; this is where run properties for the mark itself live, separate from run properties inw:rchildren. - Empty paragraphs: An empty
<w:p/>(or<w:p><w:pPr>.../></w:p>) is valid and represents a blank line or spacing element; they are essential for layout and should not be removed when processing documents. - Style inheritance: Paragraph-level properties can be applied via style (
w:pStyle) or direct properties inw:pPr; direct properties override style properties. - Content ordering: Paragraphs in the body flow sequentially; each paragraph is independent, but their
w:pPrproperties (especially spacing) can create visual grouping. - Table cell requirements: Every table cell (
w:tc) must end with at least onew:p; paragraphs cannot be omitted from cell content even if the cell appears visually empty. - Field codes in paragraphs: Complex fields are constructed using
w:fldChar(begin/separate/end) withw:instrText; simple fields usew:fldSimplewith thew:instrattribute.