CSS Reference ยท Borders, Outlines and Shadows
The outline-color property
Reference for the CSS outline-color property: set the color of an element's outline, use currentcolor, and keep focus rings visible with enough contrast.
The outline-color property sets the color of an element's outline. The outline only appears when its outline-style is something other than none, so setting the color alone changes nothing visible.
The initial value is auto, which lets the browser pick a color for its default focus ring. In practice it behaves like currentcolor or a browser-chosen accent, depending on the browser and the style in use.
CSS
a:focus-visible { outline-style: solid; outline-color: #db2777; }
Try it
Syntax
CSS
outline-color: auto | <color>;
- Initial value:
auto - Applies to: all elements
- Inherited: no
- Animatable: yes, as a color
- Computed value: the computed color, or
auto
Values
| Value | Description |
|---|---|
<color> |
Any CSS color: names, hex, rgb(), hsl(), oklch() and so on. Alpha is allowed. |
currentcolor |
Uses the element's color value, so the outline follows the text color. |
auto |
The browser's own default focus color. |
Usage notes
- Contrast matters. A focus ring should be clearly visible against both the element and the page behind it. A common target is a contrast ratio of at least 3:1 with adjacent colors.
- Translucent outlines can vanish on busy backgrounds. For focus rings, use a solid color, or pair a light and a dark ring.
- Use
currentcolorfor themes. The outline then adapts automatically when text color changes between light and dark mode. - Forced colors mode (Windows High Contrast) overrides authored colors with system colors, so do not rely on a specific hue to convey state.
- Older articles mention an
invertvalue; it was removed from the standard and should not be used.
Browser support
Supported in every browser.
Related
outlineโ the shorthandoutline-style,outline-width,outline-offset:focus-visible- Lesson: CSS Outlines