ContextualSpacing Class

Defines the ContextualSpacing Class.When the object is serialized out as xml, its qualified name is w:contextualSpacing.

Inheritance Hierarchy


Namespace:  DocumentFormat.OpenXml.Wordprocessing
Assembly:  DocumentFormat.OpenXml (in DocumentFormat.OpenXml.dll)


Public Class ContextualSpacing _
    Inherits OnOffType
Dim instance As ContextualSpacing
public class ContextualSpacing : OnOffType


[ISO/IEC 29500-1 1st Edition] contextualSpacing (Ignore Spacing Above and Below When Using Identical Styles)

This element specifies that any space specified before or after this paragraph, specified using the spacing element (§, should not be applied when the preceding and following paragraphs are of the same paragraph style, affecting the top and bottom spacing respectively. [Example: This value is typically used for paragraphs in lists, in which any space between subsequent list items, even if inherited from another style, is not desirable. end example]

If this element is omitted on a given paragraph, its value is determined by the setting previously set at any level of the style hierarchy (i.e. that previous setting remains unchanged). If this setting is never specified in the style hierarchy, then spacing is not ignored. If it is present, then the spacing above or below on this paragraph is subtracted from the spacing which would have been present if contextual spacing was off, never going below zero.

[Example: Consider two paragraphs defined as follows:

    <w:pStyle w:val="TestParagraphStyle" />
    <w:spacing w:after="200"/>
    <w:pStyle w:val="TestParagraphStyle" />
    <w:spacing w:before="240"/>

The first paragraph specifies a spacing after of 10 points, and the second paragraph specifies a spacing before of 12 points, therefore according to the rules on the spacing element, the net paragraph spacing should be 12 points. However, since the first paragraph specifies that its spacing should be omitted between paragraphs of the same style, and the two paragraphs use the same TestParagraphStyle, that value is subtracted from the total, therefore the paragraphs are spaced by 2 points. end example]

Parent Elements

pPr (§; pPr (§; pPr (§; pPr (§; pPr (§17.9.23); pPr (§

This element’s content model is defined by the common boolean property definition in §17.17.4.

© ISO/IEC29500: 2008.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also


ContextualSpacing Members

DocumentFormat.OpenXml.Wordprocessing Namespace