w:color (Text Color)

Sets the foreground (font) color of the run using an RGB hex value or the 'auto' keyword.

Parent elements

Description

w:color sets the foreground (font) colour of the text in the run. It is defined in ECMA-376 Part 1 §17.3.2.6.

The primary value is either a 6-digit RGB hex string (e.g. FF0000 for red) or the keyword auto, which instructs the renderer to choose an automatic colour — typically black unless the background requires contrast. Theme colours can optionally be layered on top via the w:themeColor, w:themeTint, and w:themeShade attributes.

Attributes

Attribute Type Possible Values Description
w:val ST_HexColorAuto 6-digit uppercase hex RGB string (e.g. FF0000, 008000) or auto. The font colour. auto lets the application choose based on context.
w:themeColor ST_ThemeColor dark1, light1, dark2, light2, accent1accent6, hyperlink, followedHyperlink Maps the colour to a theme slot so it updates when the document theme changes.
w:themeTint ST_UcharHexNumber 00FF (hex). FF = full theme colour, 00 = white. Lightens the theme colour by blending it toward white.
w:themeShade ST_UcharHexNumber 00FF (hex). FF = full theme colour, 00 = black. Darkens the theme colour by blending it toward black.

Examples

Explicit RGB colour

<w:rPr>
  <w:color w:val="FF0000"/>
</w:rPr>

Theme colour with tint

<w:rPr>
  <w:color w:val="4472C4" w:themeColor="accent1" w:themeTint="BF"/>
</w:rPr>

Notes

  • w:val="auto" is the default and renders as black on white backgrounds.
  • When w:themeColor is set, w:val should still contain the resolved RGB for consumers that do not support themes.