w:shd (Shading)

Applies a background fill color and optional pattern to a paragraph, run, or table cell.

Parent elements

Description

w:shd applies a background fill (shading) to a paragraph, run, or table cell. It is defined in ECMA-376 Part 1 §17.3.5 (paragraphs/runs) and §17.4.33 (table cells).

The background is composed of a fill colour (w:fill) and an optional pattern colour (w:color) combined via a shading pattern (w:val). For a solid fill with no pattern, use w:val="clear" and set w:fill to the desired colour.

Attributes

Attribute Type Possible Values Description
w:val ST_Shd clear (solid fill), nil (no shading), solid, horzStripe, vertStripe, diagStripe, reverseDiagStripe, thinHorzStripe, thinVertStripe, pct5, pct10, … pct90, pct95 Shading pattern. clear with w:fill gives a plain background colour.
w:color ST_HexColorAuto 6-digit hex RGB or auto Foreground (pattern) colour.
w:fill ST_HexColorAuto 6-digit hex RGB or auto Background fill colour.
w:themeColor ST_ThemeColor Theme colour slot names (e.g. accent1) Theme colour for the pattern foreground.
w:themeFill ST_ThemeColor Theme colour slot names Theme colour for the background fill.
w:themeFillTint ST_UcharHexNumber 00–FF Lightens the theme fill colour.
w:themeFillShade ST_UcharHexNumber 00–FF Darkens the theme fill colour.

Examples

<!-- Solid yellow background on paragraph -->
<w:pPr>
  <w:shd w:val="clear" w:color="auto" w:fill="FFFF00"/>
</w:pPr>
<!-- Horizontal stripe pattern: blue stripes on light yellow -->
<w:rPr>
  <w:shd w:val="horzStripe" w:color="0000FF" w:fill="FFFFCC"/>
</w:rPr>
<!-- Table cell: light blue background with theme color -->
<w:tcPr>
  <w:shd w:val="clear" w:fill="E8F4F8" w:themeFill="accent1" w:themeFillTint="9F"/>
</w:tcPr>

Solid Fill Colors

Color Hex Code Use Case
Yellow FFFF00 Highlighting, emphasis
Light blue E8F4F8 Calm background
Light green E2EFDA Success, completion
Light red F4CCCC Warning, error
Light gray F3F3F3 Neutral background

Shading Patterns

Pattern Description Use Case
clear Solid fill (no pattern) Standard highlighting, backgrounds
nil No shading applied Reset/transparent
horzStripe Horizontal lines Emphasis, table headers
vertStripe Vertical lines Emphasis, column markers
diagStripe Diagonal lines (TL→BR) Pattern emphasis
reverseDiagStripe Reverse diagonal (TR→BL) Pattern emphasis
thinHorzStripe Thin horizontal lines Subtle emphasis
thinVertStripe Thin vertical lines Subtle emphasis
pct5 – pct95 Dot density 5% to 95% Gray scale: pct5=light gray, pct95=dark gray

Pattern Examples

Horizontal Stripe (blue on yellow):

<w:shd w:val="horzStripe" w:color="0000FF" w:fill="FFFF00"/>

Gray 50% Solid (using dot pattern):

<w:shd w:val="pct50" w:color="808080" w:fill="FFFFFF"/>

Light Tint (5% dots, subtle background):

<w:shd w:val="pct5" w:color="000000" w:fill="E8E8E8"/>

Common Highlighting Colors

Color Hex RGB Mood Use
Yellow FFFF00 (255,255,0) Attention Highlighting, warnings
Light Green E2EFDA (226,239,218) Positive Success, approval
Light Blue D9E1F2 (217,225,242) Info Information, notes
Light Red F4CCCC (244,204,204) Warning/Error Errors, rejections
Light Gray F3F3F3 (243,243,243) Neutral Subtle backgrounds
Light Orange FCE4D6 (252,228,214) Caution Cautions, holds

Theme-Based Shading

Using theme colors ensures consistency across document themes:

<!-- Light accent1 tint for flexible theming -->
<w:shd w:val="clear" w:themeFill="accent1" w:themeFillTint="9F"/>

When document theme changes, shading updates automatically.

Advanced Patterns

Diagonal Stripe (pattern emphasis):

<w:shd w:val="diagStripe" w:color="FF0000" w:fill="FFFFFF"/>

Combined Foreground/Background (transparency effect via dots):

<w:shd w:val="pct20" w:color="0000FF" w:fill="FFFFFF"/>
<!-- Result: 20% blue dots on white = light blue tint -->

| vertStripe | Vertical lines | Emphasis, tables | | diagStripe | Diagonal lines (left-to-right) | Emphasis, patterns | | reverseDiagStripe | Diagonal lines (right-to-left) | Emphasis, patterns | | pct5–pct95 | Percentage fill (5% to 95% solid) | Gray scales, tints |

Notes

  • Solid Fill: Use w:val="clear" with w:fill for plain background color.
  • Pattern + Color: Pattern uses w:color for foreground (pattern) and w:fill for background.
  • Context Scope: Applies to paragraphs, runs (characters), or table cells depending on parent.
  • Theme Colors: w:themeFill and w:themeFillTint link to document theme; update automatically.
  • Tint Effect: w:themeFillTint lightens toward white; w:themeFillShade darkens toward black.
  • Nil Pattern: w:val="nil" removes any shading (useful to override style).
  • RGB Format: Hex values are RRGGBB (e.g., FF0000 = red).
  • Print Preview: Shading may appear lighter in print preview than on screen.
  • Accessibility: Ensure shading color has sufficient contrast with text color.
  • Compatibility: Shading renders consistently across all Office versions.