A paragraph, w:p, holds runs: stretches of text with the same formatting.
Text never sits directly in a paragraph; it is always in a w:t inside a
w:r.
An example
<w:p>
<w:pPr>
<w:pStyle w:val="Heading1"/>
<w:jc w:val="center"/>
</w:pPr>
<w:r>
<w:t xml:space="preserve">A plain and </w:t>
</w:r>
<w:r>
<w:rPr>
<w:b/>
<w:color w:val="C00000"/>
</w:rPr>
<w:t>bold red</w:t>
</w:r>
<w:r>
<w:t xml:space="preserve"> heading</w:t>
</w:r>
</w:p>
Paragraph properties: w:pPr
w:pPr is the first child of the paragraph. Its children have a fixed order
in the schema; the most used are:
| Element | Meaning |
|---|---|
w:pStyle | The paragraph’s style, by style ID. |
w:keepNext, w:keepLines | Keep with the next paragraph; keep the paragraph’s lines together. |
w:pageBreakBefore | Start a new page. |
w:framePr | Text frame properties. |
w:widowControl | Prevent widows and orphans. |
w:numPr | List membership: w:ilvl and w:numId. |
w:suppressLineNumbers | Do not number these lines. |
w:pBdr | Borders: w:top, w:left, w:bottom, w:right, w:between, w:bar. |
w:shd | Shading. |
w:tabs | Custom tab stops: w:tab with w:val and w:pos. |
w:spacing | w:before, w:after (twips), w:line, w:lineRule (auto, in 240ths of a line, exact or atLeast, in twips). |
w:ind | Indents: w:left, w:right (w:start, w:end in Strict), w:hanging, w:firstLine. |
w:contextualSpacing | Ignore spacing between paragraphs of the same style. |
w:mirrorIndents | Swap indents on facing pages. |
w:jc | Alignment: left, center, right, both and others (start, end in Strict). |
w:outlineLvl | Outline level, 0 to 8 for headings; 9 for body text. |
w:rPr | The formatting of the paragraph mark, and w:ins or w:del when the paragraph mark is tracked. |
w:sectPr | This paragraph ends a section. |
w:pPrChange | The previous paragraph properties, under tracked changes. |
Inside a paragraph
Besides runs, a paragraph can contain:
| Element | Meaning |
|---|---|
w:hyperlink | A hyperlink around runs. |
w:fldSimple | A simple field around its result runs. |
w:ins, w:del, w:moveFrom, w:moveTo | Runs under tracked changes. |
w:sdt | A content control around runs. |
w:smartTag | Runs recognised as a smart tag. |
w:bookmarkStart, w:bookmarkEnd | Bookmarks. |
w:commentRangeStart, w:commentRangeEnd | Comment anchors. |
m:oMath, m:oMathPara | Equations. |
w:proofErr | Spelling or grammar marks. |
Run properties: w:rPr
w:rPr is the first child of the run. Elements present set a property on the
run, and they override what the styles give.
| Element | Meaning |
|---|---|
w:rStyle | A character style, by style ID. |
w:rFonts | Fonts: w:ascii, w:hAnsi, w:eastAsia, w:cs, and theme fonts. |
w:b, w:bCs | Bold, for ordinary text and complex-script text. |
w:i, w:iCs | Italic. |
w:caps, w:smallCaps | Display capitals, or small capitals. |
w:strike, w:dstrike | Struck through, once or twice. |
w:outline, w:shadow, w:emboss, w:imprint | Text effects. |
w:vanish | Hidden text. |
w:color | Text colour: w:val (RGB hex or auto), optionally a theme colour. |
w:spacing | Character spacing in twips. |
w:position | Raised or lowered, in half-points. |
w:sz, w:szCs | Font size in half-points: 24 is 12 point. |
w:highlight | Highlight: a named colour. |
w:u | Underline: w:val single, double, dotted, none and others. |
w:shd, w:bdr | Shading and border of the run. |
w:vertAlign | superscript, subscript or baseline. |
w:lang | The language of the text, for proofing. |
w:rtl, w:cs | Right-to-left; complex script. |
w:rPrChange | The previous run properties, under tracked changes. |
On/off properties such as w:b follow one rule: the element alone means on,
and w:val can be 1, true or on for on, and
0, false or off for off. An element set to off is
different from an absent one: it turns off what a style would turn on. See
style resolution.
Run content
| Element | Meaning |
|---|---|
w:t | Text. xml:space="preserve" keeps leading and trailing spaces. |
w:delText, w:instrText, w:delInstrText | Deleted text, field instructions and deleted field instructions. |
w:tab, w:ptab | A tab; an absolute position tab. |
w:br | A break: w:type textWrapping (the default), page or column. |
w:cr | A carriage return, as a line break. |
w:noBreakHyphen, w:softHyphen | A non-breaking and an optional hyphen. |
w:sym | A symbol by font and character code: w:font, w:char. |
w:fldChar | The start, separator or end of a complex field. |
w:drawing, w:pict, w:object | Pictures and shapes, in DrawingML or VML, and OLE objects. |
w:footnoteReference, w:endnoteReference | A note reference by ID. |
w:commentReference | Where a comment is anchored. |
w:ruby | Phonetic guide text: w:rt above w:rubyBase. |
w:lastRenderedPageBreak | A note of where a page ended when the file was last laid out. It is not a break. |
A run’s elements are read in order: one run can hold text, tabs and line breaks. Word
splits text across several runs wherever formatting, spell-checking or editing history
differ, so the same word can appear in pieces, and a reader must join them. The
w:rsidR and w:rsidRPr attributes record the editing session
that last changed a run; they do not affect the text.