CSS outline-color Property

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 4 Examples
Borders & Focus

What You’ll Learn

The outline-color property controls the color of an element’s outline. It is a key piece of focus styling and visual emphasis for interactive elements.

01

Outline Color

Set ring color.

02

Color Values

Named, hex, rgb, hsl.

03

currentColor

Default behavior.

04

Focus Rings

Keyboard highlight.

05

Longhand Part

Works with outline.

06

Contrast

Accessibility matters.

Introduction

The outline-color property in CSS allows developers to set the color of an element’s outline. The outline is a line drawn around elements, outside the border edge, which can be used to emphasize or distinguish elements on the page.

By customizing the outline-color, you can enhance the visibility of interactive elements like buttons and form fields.

Definition and Usage

outline-color is one part of the outline system. You usually combine it with outline-width and outline-style, or use the outline shorthand.

Choose colors with strong contrast for focus states so keyboard users can clearly see which element is active.

💡
Beginner Tip

Start with outline: 2px solid; and then add outline-color: red; to see how color is controlled separately.

📝 Syntax

The syntax for the outline-color property is simple. You can specify a color using any valid CSS color value.

syntax.css
element {
  outline-color: color;
}

Here, the color can be a named color, a hexadecimal value, an RGB value, an HSL value, or any other valid CSS color value.

Basic Example

outline-color.css
button {
  outline: 2px solid;
  outline-color: red;
}

Syntax Rules

  • Any valid CSS color value works, including currentColor.
  • The outline must have a visible style and width to show the color.
  • You can set color separately when width and style come from another rule.
  • Use :focus-visible to apply outline colors only when needed.

🎯 Default Value

The default value of the outline-color property is currentColor. If no outline-color is specified, the outline uses the current text color of the element.

That makes outlines automatically match text color unless you override them.

⚡ Quick Reference

QuestionAnswer
Initial valuecurrentColor
Applies toAll elements
InheritedNo
AnimatableYes, as a color
Common useFocus rings and outline emphasis

💎 Property Values

ValueExampleDescription
Named coloroutline-color: blue;A color keyword such as blue, red, or green
Hexadecimaloutline-color: #ff5733;A hex code representing a color
RGBoutline-color: rgb(255, 87, 51);An RGB color value
HSLoutline-color: hsl(9, 100%, 60%);An HSL color value
currentColoroutline-color: currentColor;Uses the element’s current text color
red — named color #2563eb — hex rgb() — RGB currentColor — default

👀 Live Preview

Boxes with the same outline width and style but different outline-color values:

Examples Gallery

Set outline colors with named colors, hex values, focus states, and currentColor.

🎨 Color Basics

Apply named and hex colors to outlines.

Example 1 — Button with Red Outline Color

In this example, we change the outline color of a button to bright red.

red-outline.html
<style>
  button {
    outline: 2px solid;
    outline-color: red;
  }
</style>

<button>Click Me</button>
Try It Yourself

How It Works

The width and style come from outline, while outline-color sets the red ring.

Example 2 — Using Hexadecimal Color

Here’s how to apply a hexadecimal color to the outline of an input field.

hex-outline.html
<style>
  input {
    outline: 3px solid;
    outline-color: #33cc33;
  }
</style>

<input type="text" placeholder="Type here">
Try It Yourself

How It Works

Hex colors give precise brand-friendly outline colors for form controls.

♿ Focus & currentColor

Use outline colors for accessibility and inherited text color.

Example 3 — Brand Focus Outline Color

Apply a high-contrast brand color when a link receives keyboard focus.

focus-color.css
a:focus-visible {
  outline: 3px solid;
  outline-color: #2563eb;
  outline-offset: 2px;
}
Try It Yourself

How It Works

A distinct focus color helps keyboard users identify the active element quickly.

Example 4 — currentColor Outline

Let the outline match the element’s text color automatically.

currentcolor-outline.css
.tag {
  color: #9333ea;
  outline: 2px solid;
  outline-color: currentColor;
}
Try It Yourself

How It Works

currentColor keeps the outline synchronized with the element’s text color.

Part of the outline shorthand

outline-color is the color component of the outline shorthand. You can also set outline-width and outline-style separately, or move the ring outward with outline-offset.

outline-shorthand.css
/* Same result in one line */
button {
  outline: 2px solid #2563eb;
}

/* Or split into longhand */
button {
  outline-width: 2px;
  outline-style: solid;
  outline-color: #2563eb;
}

♿ Accessibility

  • Use high contrast — Focus outline colors should stand out against the background.
  • Do not remove focus color — Replace default outlines with a visible custom color instead of removing them.
  • Prefer :focus-visible — Apply strong outline colors when keyboard focus is shown.
  • Test with real backgrounds — A color that works on white may fail on images or dark sections.

🧠 How outline-color Works

1

An outline exists

Width and style must be set so the outline can render.

Outline
2

You choose a color

outline-color sets the ring’s color value.

Color
3

Browser draws the ring

The colored outline appears outside the border without changing layout.

Render
=

Visible colored highlight

Interactive elements become easier to see and identify.

Browser Compatibility

The outline-color property is widely supported across modern browsers, including Chrome, Firefox, Safari, Edge, and Opera. Test in various browsers to ensure consistent appearance.

Baseline · Universal support

Excellent support everywhere

outline-color works reliably in all major browsers for focus and highlight styling.

99% Global browser support
Google Chrome 1+ · All versions
Full support
Mozilla Firefox 1.5+ · All versions
Full support
Apple Safari 1.2+ · macOS & iOS
Full support
Microsoft Edge 12+ · All versions
Full support
Opera 7+ · All versions
Full support
outline-color property 99% supported

Bottom line: outline-color is safe to use for focus and emphasis in modern projects.

Conclusion

The outline-color property is a useful tool for enhancing the visibility and accessibility of elements on your webpage.

By customizing the color of the outline, you can make interactive elements stand out and improve the overall user experience. Experiment with different colors and styles to achieve the desired effect for your design.

💡 Best Practices

✅ Do

  • Use high-contrast outline colors for focus states
  • Combine with outline-width and outline-style
  • Use hex or hsl for brand-consistent rings
  • Try currentColor for simple matching outlines
  • Test outline colors on different backgrounds

❌ Don’t

  • Set color without a visible outline style
  • Remove focus outlines without a replacement color
  • Use low-contrast colors on busy backgrounds
  • Assume outline color alone creates a visible ring
  • Forget outline-offset when rings feel too tight

Key Takeaways

Knowledge Unlocked

Five things to remember about outline-color

Use these points when styling colored focus rings and outlines.

5
Core concepts
02

currentColor

Default behavior.

Default
📝 03

Any CSS Color

Named, hex, rgb, hsl.

Values
04

Focus Rings

Keyboard highlight.

Use case
🔲 05

Outline Family

Part of outline set.

Companion

❓ Frequently Asked Questions

outline-color sets the color of an element's outline, which is the line drawn outside the border edge.
The default is currentColor, which means the outline uses the element's text color unless you set another value.
Yes. An outline is visible only when outline-style is not none and outline-width is greater than zero.
Yes. You can use named colors, hex, rgb(), hsl(), and currentColor.
Yes. A high-contrast outline color on :focus or :focus-visible helps keyboard users see which element is active.

Practice in the Live Editor

Open the HTML editor and experiment with different outline-color values on buttons and inputs.

HTML Editor →

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.

5 people found this page helpful