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, accent1–accent6, hyperlink, followedHyperlink Maps the colour to a theme slot so it updates when the document theme changes.
w:themeTint ST_UcharHexNumber 00–FF (hex). FF = full theme colour, 00 = white. Lightens the theme colour by blending it toward white.
w:themeShade ST_UcharHexNumber 00–FF (hex). FF = full theme colour, 00 = black. Darkens the theme colour by blending it toward black.

Examples

<!-- Explicit red text -->
<w:rPr>
  <w:color w:val="FF0000"/>
</w:rPr>
<!-- Theme-based accent color with tint (lightened) -->
<w:rPr>
  <w:color w:val="4472C4" w:themeColor="accent1" w:themeTint="BF"/>
</w:rPr>
<!-- Auto color: picks black on light, white on dark -->
<w:rPr>
  <w:color w:val="auto"/>
</w:rPr>

Common Colors Reference

Color Hex Code RGB
Red FF0000 (255, 0, 0)
Green 008000 (0, 128, 0)
Blue 0000FF (0, 0, 255)
Black 000000 (0, 0, 0)
White FFFFFF (255, 255, 255)
Yellow FFFF00 (255, 255, 0)
Cyan 00FFFF (0, 255, 255)
Magenta FF00FF (255, 0, 255)
Dark Blue 0070C0 (0, 112, 192)
Dark Green 00B050 (0, 176, 80)

Theme Colors

Slot Purpose Typical Use
dark1 Primary dark text Normal text
light1 Primary light background Light text on dark
dark2 Secondary dark text Alternative text
light2 Secondary light background Light alternative
accent1–accent6 Accent colors Emphasis, links, highlights
hyperlink Hyperlink color Links
followedHyperlink Visited link color Visited links

Color Themes & Tinting

Theme Color Tinting Strategy

Theme colors provide flexibility and automatic updates:

<!-- Light tint of accent color (90% lighter) -->
<w:rPr>
  <w:color w:val="4472C4" w:themeColor="accent1" w:themeTint="E6"/>
</w:rPr>
<!-- Medium tint (50% lighter) -->
<w:rPr>
  <w:color w:val="4472C4" w:themeColor="accent1" w:themeTint="80"/>
</w:rPr>
<!-- Dark shade (50% darker) -->
<w:rPr>
  <w:color w:val="4472C4" w:themeColor="accent1" w:themeShade="50"/>
</w:rPr>

Tint Range: 00 (white) to FF (full color) Shade Range: 00 (black) to FF (full color)

Visual Hierarchy Using Color Depth

Element Tint/Shade Visual Effect
Light text (headings) Tint: E6 (90%) Very light accent
Emphasized text Tint: 80 (50%) Medium accent
Normal text FF (full) Strong accent
Subtle text Shade: 80 (50%) Darkened, subtle
Disabled text Shade: E6 (90%) Very dark, faded

Palette Design

Monochrome Safety (Black/Gray/White)

<!-- Black for primary text -->
<w:rPr>
  <w:color w:val="000000"/>
</w:rPr>
<!-- Gray for secondary text -->
<w:rPr>
  <w:color w:val="808080"/>
</w:rPr>
<!-- Light gray for disabled -->
<w:rPr>
  <w:color w:val="C0C0C0"/>
</w:rPr>

Accessible Color Combinations

Foreground Background Contrast Ratio
Black (#000000) White (#FFFFFF) 21:1 (AAA)
Dark Blue (#000066) White (#FFFFFF) 12.6:1 (AAA)
Dark Gray (#333333) White (#FFFFFF) 12.6:1 (AAA)
Dark Green (#006600) White (#FFFFFF) 10.5:1 (AAA)
Dark Red (#660000) White (#FFFFFF) 10.5:1 (AAA)
Blue (#0000FF) Yellow (#FFFF00) 19.56:1 (AAA)

WCAG Compliance: Aim for 4.5:1 contrast for body text (Level AA); 7:1 (Level AAA)

Theme Color Reference

Theme Slot Typical Purpose Update Behavior
dark1 Primary dark text Updates with theme
light1 Light background Updates with theme
dark2 Secondary dark text Updates with theme
light2 Light secondary background Updates with theme
accent1–accent6 Accent colors Updates with theme
hyperlink Hyperlink color Updates with theme
followedHyperlink Visited link color Updates with theme

RGB to Hex Conversion Examples

Color RGB Hex
Red (255, 0, 0) FF0000
Green (0, 128, 0) 008000
Blue (0, 0, 255) 0000FF
Yellow (255, 255, 0) FFFF00
Orange (255, 165, 0) FFA500
Purple (128, 0, 128) 800080
Cyan (0, 255, 255) 00FFFF
Magenta (255, 0, 255) FF00FF
Gray (128, 128, 128) 808080
Dark Gray (64, 64, 64) 404040

Notes

  • Format: 6-digit uppercase hex RGB (e.g., FF0000 for red).
  • Auto Color: Default; renderer picks best contrast against background.
  • Theme Precedence: Theme attributes override w:val when document theme is active; updating theme automatically updates text.
  • Tint (Lighten): themeTint value FF = full color, 00 = white; useful for creating visual hierarchy.
  • Shade (Darken): themeShade value FF = full color, 00 = black; for emphasis and depth.
  • RGB Hex Order: Format is RRGGBB (Red, Green, Blue).
  • Theme Advantage: Theme colors auto-update when document theme changes.
  • Fallback: Always include w:val hex for consumers that don’t support themes.
  • Transparency: OpenXML colors don’t support alpha channel; use background shading for opacity.
  • Color Blindness: Avoid red-green only combinations; include blue or gray for accessibility.
  • Contrast: Use WCAG contrast ratio calculators to ensure readability.
  • Print Stability: RGB colors may print differently; test on target printer.
  • Localization: Color meaning varies by culture; red = danger in West, prosperity in China.
  • Accessibility: Don’t rely on color alone for meaning; combine with text, icons, or patterns.
  • Compatibility: RGB colors render consistently; theme colors work best in modern Office.