w:contextualSpacing (Contextual Spacing)
Suppresses the space before or after a paragraph when the adjacent paragraph uses the same style.
Parent elements
Description
w:contextualSpacing suppresses the w:spacing before or after value on a paragraph when the adjacent paragraph uses the same paragraph style. It is an on/off toggle property defined in ECMA-376 Part 1 §17.3.1.9.
This prevents double-spacing between consecutive list items or body-text paragraphs that share the same style, while preserving visual separation when the style changes. The spacing suppression applies to the smaller of the two adjacent spacing values.
Attributes
| Attribute | Type | Possible Values | Description |
|---|---|---|---|
w:val |
ST_OnOff |
true, 1, on (enabled) / false, 0, off (disabled). Omitting the attribute is equivalent to true. |
Toggles contextual spacing on or off. |
Examples
<w:pPr>
<w:contextualSpacing/>
</w:pPr>
new ParagraphProperties(
new ContextualSpacing());
Notes
- The “Normal” body-text style in Word has
w:contextualSpacingenabled by default. - Contextual spacing is applied per-paragraph; both adjacent paragraphs need not have the property set — only the one whose spacing is being suppressed.