w:placeholder (SDT Placeholder Text)
Specifies a building block (document part) whose content is used as placeholder text in a structured document tag when no value has been entered.
Description
w:placeholder references a document part (building block) that supplies the placeholder/hint text shown inside an SDT when it is empty or when w:showingPlcHdr is true. The placeholder is typically styled differently (e.g. greyed out) to indicate that no actual value has been entered yet.
It is defined in ECMA-376 Part 1 §17.5.2.26.
The child w:docPart element holds the name of the building block in the document’s glossary part (glossary/document.xml). The special value DefaultPlaceholder_-1854013440 is used for the default Word placeholder text.
Attributes
None. The placeholder content is specified via the child w:docPart.
Child Elements
| Element | Description |
|---|---|
w:docPart |
References the building block by name. |
Examples
<w:sdtPr>
<w:alias w:val="Company Name"/>
<w:tag w:val="companyName"/>
<w:placeholder>
<w:docPart w:val="DefaultPlaceholder_-1854013440"/>
</w:placeholder>
<w:showingPlcHdr/>
<w:richText/>
</w:sdtPr>
using DocumentFormat.OpenXml.Wordprocessing;
var sdtPr = new SdtProperties(
new SdtAlias { Val = "Company Name" },
new Tag { Val = "companyName" },
new SdtPlaceholder(
new DocPart { Val = "DefaultPlaceholder_-1854013440" }
),
new ShowingPlaceholder(),
new SdtContentText()
);
Notes
- The building block referenced by
w:docPartmust exist in the document’s glossary part; if missing, applications fall back to a generic placeholder string. - When the user types into the SDT and replaces the placeholder,
w:showingPlcHdrshould be removed.