w:spacing (Spacing)

Controls space before and after a paragraph and the line spacing rule and value.

Parent elements

Description

w:spacing controls the whitespace before and after a paragraph and the spacing between lines within it. It is defined in ECMA-376 Part 1 §17.3.1.33.

When applied inside w:rPr, w:spacing instead controls character spacing (tracking/kerning offset) for the run, using a different set of attributes from the paragraph variant.

Attributes (paragraph context — inside w:pPr)

Attribute Type Possible Values Description
w:before ST_TwipsMeasure Non-negative integer in twips (e.g. 240 = 12 pt). Space added above the paragraph.
w:after ST_TwipsMeasure Non-negative integer in twips. Space added below the paragraph.
w:beforeLines xsd:integer Percentage in fiftieths of a line (e.g. 100 = 1 line). Takes precedence over w:before. Space above in line units.
w:afterLines xsd:integer Percentage in fiftieths of a line. Takes precedence over w:after. Space below in line units.
w:line ST_SignedTwipsMeasure Integer in twips (for exact/atLeast) or in twips × 240 units for auto (e.g. 276 ≈ single line at 12 pt). Line spacing value; interpretation depends on w:lineRule.
w:lineRule ST_LineSpacingRule auto (proportional, default), exact (fixed height), atLeast (minimum height) Governs how w:line is interpreted.
w:beforeAutospacing ST_OnOff true / false When true, overrides w:before with automatic spacing.
w:afterAutospacing ST_OnOff true / false When true, overrides w:after with automatic spacing.

Attributes (run context — inside w:rPr)

Attribute Type Possible Values Description
w:val ST_SignedHpsMeasure Integer in twentieth-points (e.g. 20 = 1 pt additional spacing). Negative values compress character spacing. Character spacing adjustment applied uniformly between all characters in the run.

Examples

12 pt before, 6 pt after, 1.5× line spacing

<w:pPr>
  <w:spacing w:before="240" w:after="120" w:line="360" w:lineRule="auto"/>
</w:pPr>

Notes

  • For w:lineRule="auto", w:line is in units of 1/240 of a line (240 = single, 360 = 1.5×, 480 = double).
  • For w:lineRule="exact" or atLeast", w:line is in twips (240 twips = 12 pt).