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.
new RunProperties(
new Color
{
Val = "4472C4",
ThemeColor = ThemeColorValues.Accent1,
ThemeShade = "50" // 50% darker
});
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>
new RunProperties(
new Color { Val = "000000" }); // Black text
<!-- Gray for secondary text -->
<w:rPr>
<w:color w:val="808080"/>
</w:rPr>
new RunProperties(
new Color { Val = "808080" }); // Gray text
<!-- Light gray for disabled -->
<w:rPr>
<w:color w:val="C0C0C0"/>
</w:rPr>
new RunProperties(
new Color { Val = "C0C0C0" }); // Light gray text
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.
Privacy Notice
This site stores your theme preference and this acknowledgement in localStorage — no cookies, no tracking. When you use the contact form, your message is sent via Formspree (USA) to reach us.