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();
Notes
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.- When
w:pPris present it must be the first child element; placing it after run content is invalid. - The
rsid*attributes are round-trip attributes — a conforming producer may omit them, and a conforming consumer must not fail if they are absent. - 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 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.