CSS outline-color Property

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The outline-color property sets the color of an element’s outline — the line drawn outside the border. It does not change layout. Pair it with outline-style (and usually outline-width) or use the outline shorthand.

The initial value is auto, which computes to currentColor today. Choose colors that keep strong contrast against both the page background and the element when used as a focus ring.

Baseline · Widely available.

Not deprecated. <color> values are universal. Author-set auto is not supported yet. The old invert keyword is not supported in modern browsers.

CSS Syntax

syntax.css
outline-color: <color> | auto | initial | inherit;

Example: outline-color: #2563eb; Prefer a concrete <color> for reliable focus styles.

Property Values

ValueDescriptionTry it
<color>Named, hex, rgb(), hsl(), and other CSS colorsTry it
currentColorUses the element’s computed text colorTry it
autoSpec keyword; as an author value it is not supported yet (initial computes like currentColor)Try it
initialResets to the property’s initial valueTry it
inheritUses the parent’s outline-colorTry it

How to Use outline-color

Make the outline visible first, then pick a color with enough contrast.

  1. Set outline-style (for example solid) and a width if needed.
  2. Set outline-color to a named color, hex, rgb(), hsl(), or currentColor.
  3. For keyboard focus, apply it under :focus or :focus-visible.
  4. Check contrast against the backgrounds around the ring (WCAG non-text contrast aims for at least 3:1).
PieceRequired?Role
outline-styleYes (to see color)Without a style, color alone does nothing
outline-widthRecommendedMakes the colored ring easy to notice
<color>Yes for custom lookPaints the outline
ContrastYes for a11yFocus rings must stay readable on their backgrounds

Live Preview

Width and style stay fixed. Change only outline-color on the sample box.

The thin gray border is the box edge. The thicker ring is the outline.

Box

outline-color: #2563eb

CSS Examples

Each snippet sets a style and width so the color is visible, then changes only outline-color. Use Try It Yourself for a live editor.

Example 1 — Hex Outline Color

Paint a solid outline with an explicit hex color.

CSS
<style>
  div {
    outline-style: solid;
    outline-width: 3px;
    outline-color: #2563eb;
    border: 1px solid #cbd5e1;
    padding: 12px;
  }
</style>

<div>Blue outline</div>
Try It Yourself

How It Works

  1. Show the outline. outline-style: solid turns the ring on.
  2. Give it thickness. outline-width: 3px makes the color easy to see.
  3. Set the color. outline-color: #2563eb paints only the outline, not the border.
  4. Border stays gray. The thin border marks the box edge; the blue ring sits outside.

Example 2 — currentColor

Let the outline follow the text color automatically.

CSS
<style>
  div {
    color: #0f766e;
    outline: 3px solid;
    outline-color: currentColor;
    border: 1px solid #cbd5e1;
    padding: 12px;
  }
</style>

<div>Matches text color</div>
Try It Yourself

How It Works

  1. Set text color. color: #0f766e is teal.
  2. Draw an outline. outline: 3px solid sets width and style in one go.
  3. Link the color. outline-color: currentColor reuses that teal.
  4. Change once. Updating color updates both the words and the ring.

Example 3 — Focus Outline Color

Use a high-contrast color on keyboard focus.

CSS
<style>
  button {
    outline: none;
  }
  button:focus {
    outline-style: solid;
    outline-width: 3px;
    outline-color: #d97706;
    outline-offset: 3px;
  }
</style>

<button type="button">Tab to focus</button>
Try It Yourself

How It Works

  1. Replace the default. Resting outline: none is fine only if focus draws a new ring.
  2. Turn style and width on under :focus.
  3. Pick a clear color. outline-color: #d97706 stands out on light UIs.
  4. Add offset. outline-offset keeps the ring from hugging the label too tightly.

Edge Cases & Pitfalls

If the color seems ignored, one of these is usually why.

style

Color alone is not enough

With outline-style: none, there is nothing to paint. Set a style (or use the outline shorthand).

a11y

Contrast against both sides of the ring

Focus outlines sit over page background and often the control itself. Aim for at least 3:1 non-text contrast (WCAG 1.4.11).

invert

invert is obsolete in practice

Modern browsers do not support outline-color: invert. Use an explicit color or currentColor.

auto

Author auto is not ready

The spec lists auto, but browsers do not treat an authored auto value yet. Rely on concrete colors for teaching and production.

shorthand

Shorthand can reset color

Writing outline: 2px solid after a custom color may restore the default color. Set outline-color again if needed.

Browser Support

outline-color is a browser CSS property for outline painting. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available

outline-color

Color values work in all modern browsers (Chrome, Firefox, Safari, Edge, IE 8+). Prefer explicit colors over invert or auto.

99% Color value support
Google Chrome All modern versions
Full support
Mozilla Firefox All modern versions
Full support
Apple Safari All modern versions
Full support
Microsoft Edge All modern versions
Full support
Opera All modern versions
Full support
Samsung Internet Supported
Full support
Internet Explorer 8+
Full support
outline-color Widely supported

Bottom line: Safe for production focus colors. Do not depend on invert or authored auto. This is not a JavaScript runtime API.

Key Takeaways

  • Role: set only the color of the outline ring outside the border.
  • Needs a style: without outline-style, the color never appears.
  • Default feel: initial auto acts like currentColor in practice.
  • Focus: pick colors with enough contrast for keyboard users.

One line: outline-color paints the ring — only after style (and width) make that ring exist.

Frequently Asked Questions

It sets only the color of an element’s outline. You still need a visible outline-style (and usually a width) or the outline will not show.
The initial value is auto, which computes to currentColor in browsers today. So the outline usually matches the element’s text color unless you set another color.
No. If outline-style is none (the default), changing only the color has no visible effect for most elements.
Yes. Any CSS <color> works: named colors, hex, rgb(), hsl(), and currentColor.
No. Set it on each element that needs a custom outline color, or use the outline shorthand.
It is Baseline Widely available. The old invert keyword is not supported in modern browsers. The auto keyword as an author value is not widely implemented yet. It is a browser CSS property, not a Node.js feature.

Next: outline-offset

Space the outline away from the border without changing layout.

outline-offset tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful