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.
Fundamentals
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.
Foundation
📝 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.
Defaults
🎯 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.
Cheat Sheet
⚡ Quick Reference
Question
Answer
Initial value
currentColor
Applies to
All elements
Inherited
No
Animatable
Yes, as a color
Common use
Focus rings and outline emphasis
Reference
💎 Property Values
Value
Example
Description
Named color
outline-color: blue;
A color keyword such as blue, red, or green
Hexadecimal
outline-color: #ff5733;
A hex code representing a color
RGB
outline-color: rgb(255, 87, 51);
An RGB color value
HSL
outline-color: hsl(9, 100%, 60%);
An HSL color value
currentColor
outline-color: currentColor;
Uses the element’s current text color
red — named color#2563eb — hexrgb() — RGBcurrentColor — default
Preview
👀 Live Preview
Boxes with the same outline width and style but different outline-color values:
Hands-On
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.
currentColor keeps the outline synchronized with the element’s text color.
Companion
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;}
A11y
♿ 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.
Compatibility
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 Chrome1+ · All versions
Full support
Mozilla Firefox1.5+ · All versions
Full support
Apple Safari1.2+ · macOS & iOS
Full support
Microsoft Edge12+ · All versions
Full support
Opera7+ · All versions
Full support
outline-color property99% supported
Bottom line:outline-color is safe to use for focus and emphasis in modern projects.
Wrap Up
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.