w:document (Root Document Element)

Root element of the WordprocessingML main document part (document.xml).

Child elements

Description

w:document is the root element of the main document part (word/document.xml) in an Office Open XML WordprocessingML package. It is defined in ECMA-376 Part 1 §17.2.3.

The element must contain exactly one w:body child, which holds all of the document’s content. The mc:Ignorable attribute (Markup Compatibility) lists namespace prefixes whose elements should be ignored by processors that do not understand them.

Attributes

Attribute Type Possible Values Description
mc:Ignorable xsd:string Space-separated list of namespace prefixes (e.g. "w14 w15 w16se") Prefixes of elements/attributes that non-understanding processors should ignore.
w:conformance ST_ConformanceClass strict, transitional Declares the conformance class of the document against the OOXML schema. Strict = pure OOXML; Transitional = compatible with legacy formats.

Examples

Minimal document with text

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:document xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas"
            xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
            mc:Ignorable="w14 w15">
  <w:body>
    <w:p>
      <w:r><w:t>Hello World</w:t></w:r>
    </w:p>
    <w:sectPr/>
  </w:body>
</w:document>

Document with heading and paragraphs

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
            mc:Ignorable="w14 w15"
            w:conformance="transitional">
  <w:body>
    <w:p>
      <w:pPr><w:pStyle w:val="Heading1"/></w:pPr>
      <w:r><w:t>Chapter 1</w:t></w:r>
    </w:p>
    <w:p>
      <w:r><w:t>Body text of the chapter</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>
</w:document>

Document with XML declaration and namespace declarations

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:document xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas"
            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
            xmlns:o="urn:schemas-microsoft-com:office:office"
            xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
            xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
            xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml"
            xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml"
            mc:Ignorable="w14 w15"
            w:conformance="strict">
  <w:body>
    <w:p><w:r><w:t>Content</w:t></w:r></w:p>
    <w:sectPr/>
  </w:body>
</w:document>

Document with strict conformance

<w:body>
    <w:p><w:r><w:t>Document with strict conformance</w:t></w:r></w:p>
    <w:sectPr/>
  </w:body>
</w:document>

Document Structure

<w:document>              <!-- Root element -->
  <w:body>                <!-- Required single child -->
    <w:p>...</w:p>        <!-- Paragraphs -->
    <w:tbl>...</w:tbl>    <!-- Tables -->
    <w:sectPr>...</w:sectPr> <!-- Final section (required) -->
  </w:body>
</w:document>

Namespace Reference

Prefix Namespace URI Purpose
w http://schemas.openxmlformats.org/wordprocessingml/2006/main Core WordprocessingML namespace (required)
r http://schemas.openxmlformats.org/officeDocument/2006/relationships Relationships for r:id references
mc http://schemas.openxmlformats.org/markup-compatibility/2006 Markup Compatibility and ignorable extensions
w14 http://schemas.microsoft.com/office/word/2010/wordml Word 2010 extensions
w15 http://schemas.microsoft.com/office/word/2012/wordml Word 2013+ extensions
w16se http://schemas.microsoft.com/office/word/2015/wordml/symex Word 2016+ extensions
wp http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing Inline and anchored drawing shapes
a http://schemas.openxmlformats.org/drawingml/2006/main DrawingML shapes and charts
pic http://schemas.openxmlformats.org/drawingml/2006/picture Picture elements
o urn:schemas-microsoft-com:office:office Legacy Office namespace (VML, etc.)

Conformance Classes

Class Strictness Compatibility Use Case
strict Strict OOXML (ISO/IEC 29500 Part 1) No legacy compatibility Standards-compliant documents; may not open in older Word versions
transitional Transitional OOXML (ISO/IEC 29500 Part 2) Compatible with legacy binary formats Maximum compatibility; can open/edit in Word 97-2003

Notes

  • Root element: w:document must be the root of word/document.xml; each main document part has exactly one root and every .docx has exactly one document.xml.
  • Body requirement: The document element must contain exactly one w:body child; an empty body with a section definition is valid and displays as a blank page.
  • Conformance: The w:conformance attribute indicates strict or transitional conformance. Strict conformance follows ISO/IEC 29500; transitional supports legacy compatibility and is used by most real-world documents.
  • Namespace declarations: The root declares prefixes and their namespace URIs. Only w: is strictly required, but declaring the standard namespaces supports extensions and tool compatibility.
  • Ignorable namespaces: mc:Ignorable lists prefixes (such as w14 and w15) that older processors can skip, allowing newer Office versions to add extensions compatibly.
  • XML declaration: The <?xml ... ?> processing instruction is optional in the specification; when included, use UTF-8 encoding.
  • Relationships: References such as r:id point to entries in document.xml.rels; external resources are not defined inline in w:document.
  • Part separation: Styles, numbering, themes, and font definitions belong in separate parts such as styles.xml, numbering.xml, theme1.xml, and fontTable.xml.
  • Package structure: The main document part is located at word/document.xml relative to the OOXML package root.
  • Extensibility: Namespaces such as w14, w15, and w16 support extensions without breaking older parsers when mc:Ignorable is set.
  • Validation: Strict or transitional conformance can be checked with ECMA-376 schema validators.
  • Performance: document.xml size depends on content volume; typical files range from 10 KB to 100 MB, and very large documents may need splitting.
  • Accessibility: Semantic heading and table markup in the body affects document accessibility.
  • Macro-enabled documents: A .docm package can contain macro-related parts in addition to its single main document part.