w:divId (HTML Division Association)
Associates a paragraph with an HTML div element, preserving document structure information from HTML round-trips.
Description
w:divId stores an integer identifier that links the paragraph (or table row) to an entry in the document’s w:divs collection in w:webSettings. This mapping preserves structural information from HTML <div> elements when an HTML document is converted to OOXML and allows round-trip conversion back to HTML.
It is defined in ECMA-376 Part 1 §17.3.1.10.
Attributes
| Attribute | Type | Possible Values | Description |
|---|---|---|---|
w:val |
xsd:integer |
Positive integer | ID matching an entry in w:divs within w:webSettings. |
Examples
<!-- Paragraph belonging to HTML div id=1 -->
<w:p>
<w:pPr>
<w:divId w:val="1"/>
</w:pPr>
<w:r><w:t>Content from an HTML div block.</w:t></w:r>
</w:p>
using DocumentFormat.OpenXml.Wordprocessing;
var para = new Paragraph(
new ParagraphProperties(
new DivId { Val = 1 }
),
new Run(new Text("Content from an HTML div block."))
);
Notes
- This property is typically generated automatically when importing HTML. It is rarely authored by hand.
- The referenced div entry in
w:webSettingscarries the margin, border, and padding information that corresponds to the original HTML<div>. - If the referenced
w:divIdvalue has no matching entry inw:webSettings, the property is ignored.