The outline-color
CSS property sets the color of an element's outline. An outline is a line that is drawn around an element, outside the border
. Unlike the element's border, the outline is drawn outside the element's frame, and may overlap other content. The border, on the other hand, will actually alter the page's layout to ensure that it fits without overlapping anything else (unless you explicitly set it to overlap).
It is often more convenient to use the shorthand property outline
when defining the appearance of an outline.
/* <color> values */ outline-color: #f92525; outline-color: rgb(30,222,121); outline-color: blue; /* Keyword value */ outline-color: invert; /* Global values */ outline-color: inherit; outline-color: initial; outline-color: unset;
Initial value |
invert , for browsers supporting it, currentColor for the other |
---|---|
Applies to | all elements |
Inherited | no |
Media | visual, interactive |
Computed value | For the keyword invert , the computed value is invert . For the color value, if the value is translucent, the computed value will be the rgba() corresponding one. If it isn't, it will be the rgb() corresponding one. The transparent keyword maps to rgba(0,0,0,0) . |
Animation type | a color |
Canonical order | the unique non-ambiguous order defined by the formal grammar |
The outline-color
property is specified as any one of the values listed below.
<color>
<color>
.invert
<color> | invertwhere
<color> = <rgb()> | <rgba()> | <hsl()> | <hsla()> | <hex-color> | <named-color> | currentcolor | <deprecated-system-color>where
<rgb()> = rgb( [ [ <percentage>{3} | <number>{3} ] [ / <alpha-value> ]? ] | [ [ <percentage>#{3} | <number>#{3} ] , <alpha-value>? ] )
<rgba()> = rgba( [ [ <percentage>{3} | <number>{3} ] [ / <alpha-value> ]? ] | [ [ <percentage>#{3} | <number>#{3} ] , <alpha-value>? ] )
<hsl()> = hsl( [ <hue> <percentage> <percentage> [ / <alpha-value> ]? ] | [ <hue>, <percentage>, <percentage>, <alpha-value>? ] )
<hsla()> = hsla( [ <hue> <percentage> <percentage> [ / <alpha-value> ]? ] | [ <hue>, <percentage>, <percentage>, <alpha-value>? ] )where
<alpha-value> = <number> | <percentage>
<hue> = <number> | <angle>
<p>My outline is blue, as you can see.</p>
p { outline: 2px solid; /* Set the outline width and style */ outline-color: #0000FF; /* Make the outline blue */ margin: 5px; }
Specification | Status | Comment |
---|---|---|
CSS Basic User Interface Module Level 3 The definition of 'outline-color' in that specification. | Candidate Recommendation | No change. |
CSS Transitions The definition of 'outline-color' in that specification. | Working Draft | Defines outline-color as animatable. |
CSS Level 2 (Revision 1) The definition of 'outline-color' in that specification. | Recommendation | Initial definition. |
Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | 1 | Yes |
1.5 1 —? -moz- |
8 | 7 | 1.2 |
invert |
No | ? | Yes — 3 | 8 | 7 — 15 | No |
Feature | Android webview | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
---|---|---|---|---|---|---|---|
Basic support | ? | ? | Yes | ? | ? | ? | ? |
invert |
? | ? | ? | ? | ? | ? | ? |
<color>
data typecolor
, background-color
, border-color
, text-decoration-color
, text-emphasis-color
, text-shadow
, caret-color
, and column-rule-color
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/outline-color