w:body (Document Body)

Container for the block-level content that forms the main story of the document.

Parent elements

Child elements

Description

w:body is the content container within w:document, holding all the visible content of the document. It is defined in ECMA-376 Part 1 §17.2.2.

w:body contains an ordered sequence of block-level elements: w:p (paragraphs), w:tbl (tables), w:sdt (structured document tags), w:bookmarkStart, w:bookmarkEnd, and revision elements. Its final child must be a w:sectPr that defines the last (or only) section’s layout properties.

Attributes

Attribute Type Possible Values Description
(none) — — All content is expressed via child elements.

Common Child Elements

Child Purpose Example
w:p Paragraph container <w:p>...</w:p>
w:tbl Table container <w:tbl>...</w:tbl>
w:sdt Structured document tag (content control) <w:sdt>...</w:sdt>
w:sectPr Section properties (final child, required) <w:sectPr>...</w:sectPr>
w:bookmarkStart / w:bookmarkEnd Bookmark anchors <w:bookmarkStart w:id="0" w:name="MyBookmark"/>
w:commentRangeStart / w:commentRangeEnd Comment anchors <w:commentRangeStart w:id="0"/>
w:ins / w:del Tracked changes (insertions/deletions) <w:ins w:id="0" ...>

Examples

Simple body with paragraphs and section

<w:body>
  <w:p>
    <w:r><w:t>First paragraph</w:t></w:r>
  </w:p>
  <w:p>
    <w:r><w:t>Second paragraph</w:t></w:r>
  </w:p>
  <w:sectPr>
    <w:pgSz w:w="12240" w:h="15840"/>
    <w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440"/>
  </w:sectPr>
</w:body>

Body with tables and mixed content

<w:body>
  <w:p>
    <w:pPr><w:pStyle w:val="Heading1"/></w:pPr>
    <w:r><w:t>Document Title</w:t></w:r>
  </w:p>
  <w:tbl>
    <w:tblPr><w:tblW w:w="5000" w:type="pct"/></w:tblPr>
    <w:tblGrid><w:gridCol w:w="2500"/><w:gridCol w:w="2500"/></w:tblGrid>
    <w:tr>
      <w:tc><w:p><w:r><w:t>Cell 1</w:t></w:r></w:p></w:tc>
      <w:tc><w:p><w:r><w:t>Cell 2</w:t></w:r></w:p></w:tc>
    </w:tr>
  </w:tbl>
  <w:p>
    <w:r><w:t>Text after table</w:t></w:r>
  </w:p>
  <w:sectPr>
    <w:pgSz w:w="12240" w:h="15840"/>
  </w:sectPr>
</w:body>

Body with bookmarks and tracked changes

<w:body>
  <w:bookmarkStart w:id="0" w:name="Introduction"/>
  <w:p>
    <w:r><w:t>Introduction text</w:t></w:r>
  </w:p>
  <w:bookmarkEnd w:id="0"/>
  <w:ins w:id="0" w:author="John" w:date="2024-01-15T10:00:00Z">
    <w:p>
      <w:r><w:t>Added content</w:t></w:r>
    </w:p>
  </w:ins>
  <w:sectPr/>
</w:body>

Body Child Elements

Element Purpose Multiple Order
w:p Paragraph Yes Body content (2nd+)
w:tbl Table Yes Body content (2nd+)
w:sdt Structured Document Tag Yes Body content (2nd+)
w:bookmarkStart Bookmark start anchor Yes Annotation (2nd+)
w:bookmarkEnd Bookmark end anchor Yes Annotation (2nd+)
w:commentRangeStart Comment start Yes Annotation (2nd+)
w:commentRangeEnd Comment end Yes Annotation (2nd+)
w:commentRangeStart Comment range (complex) Yes Annotation (2nd+)
w:ins Inserted content (tracked changes) Yes Revision (2nd+)
w:del Deleted content (tracked changes) Yes Revision (2nd+)
w:permStart Permission range start Yes Permission (2nd+)
w:permEnd Permission range end Yes Permission (2nd+)
w:sectPr Section properties (final) No (exactly 1) Last element

Typical Document Structure

<w:body>
  <w:p>...</w:p>                <!-- Title/heading -->
  <w:p>...</w:p>                <!-- Body paragraphs -->
  <w:tbl>...</w:tbl>            <!-- Tables -->
  <w:p>...</w:p>                <!-- More content -->
  <w:bookmarkStart/>            <!-- Anchors for cross-refs -->
  <w:p>...</w:p>
  <w:bookmarkEnd/>
  <w:sectPr>...</w:sectPr>      <!-- Final section properties (REQUIRED) -->
</w:body>

Section Model

  • Single Section: A document with one w:sectPr at the end uses identical layout for all content.
  • Multiple Sections: Section breaks (inserted via w:sectPr inside w:pPr) create multiple sections with different page layouts.
  • Last Section: The w:body/w:sectPr always defines the final section; intermediate sections have w:sectPr in w:pPr of the last paragraph in that section.

Notes

  • Required final element: w:body must contain exactly one w:sectPr as its last child; this defines section properties for the entire document (or the final section if there are section breaks).
  • Block-level content: w:body contains only block-level elements (paragraphs, tables, SDTs); inline elements like w:r are invalid as direct children.
  • No nested bodies: A w:body cannot be nested inside another w:body; each document has exactly one body in the main part.
  • Content ordering: Paragraphs and tables flow in document order; the visual appearance depends on paragraph properties and table properties.
  • Empty document: A valid document can contain an empty w:body with only a w:sectPr; this would display as a blank page.
  • Bookmarks and comments: Use w:bookmarkStart/w:bookmarkEnd and w:commentRangeStart/w:commentRangeEnd to mark regions for cross-references or comments; they do not display but are part of document structure.
  • Tracked changes: Wrap paragraphs or tables in w:ins or w:del elements to record insertions and deletions for revision tracking.
  • Structured content: Use w:sdt elements for content controls, allowing conditional visibility, placeholder content, and form-like document regions.
  • Performance: Documents with very large bodies (>10,000 paragraphs) may experience rendering performance issues; consider splitting into subdocuments if needed.
  • Accessibility: The body structure directly affects accessibility; screen readers depend on logical paragraph/table nesting and proper heading hierarchies defined via styles.
  • Footnotes/Endnotes: Footnotes and endnotes are defined elsewhere (endnotes.xml, footnotes.xml); body contains only w:footnoteReference and w:endnoteReference runs.