w:richText (Rich Text Content Control)
Declares that a structured document tag is a rich-text content control, allowing its content to contain mixed formatting runs and block elements.
Parent elements
Description
w:richText is an empty element that, when present in w:sdtPr, classifies the SDT as a rich-text content control. This is the most general SDT type — its w:sdtContent can contain any valid block or inline content including paragraphs, runs, tables, and inline images, each with independent formatting.
It is defined in ECMA-376 Part 1 §17.5.2.28.
The presence of w:richText is mutually exclusive with other SDT type elements such as w:date, w:comboBox, w:dropDownList, or w:text.
Attributes
None. This is a marker element with no attributes.
Examples
<w:sdt>
<w:sdtPr>
<w:alias w:val="Executive Summary"/>
<w:tag w:val="execSummary"/>
<w:richText/>
</w:sdtPr>
<w:sdtContent>
<w:p>
<w:r><w:t>Enter summary here.</w:t></w:r>
</w:p>
</w:sdtContent>
</w:sdt>
using DocumentFormat.OpenXml.Wordprocessing;
var sdtPr = new SdtProperties(
new SdtAlias { Val = "Executive Summary" },
new Tag { Val = "execSummary" },
new SdtContentText() // SdtContentText represents w:richText in the SDK
);
Notes
- In the Open XML SDK,
w:richTextis modelled bySdtContentText(confusingly named — it is used for rich text controls). - When no SDT type element is present,
w:richTextis the implied default. - To restrict an SDT to plain text (no formatting), use
w:textwithw:multiLineas appropriate, rather thanw:richText.