The outline
CSS property is a shorthand property for setting one or more of the individual outline properties outline-style
, outline-width
, and outline-color
in a single declaration.
/* width | style | color */ outline: 1px solid white; /* Global values */ outline: inherit; outline: initial; outline: unset;
Outlines differ from borders in the following ways:
Initial value | as each of the properties of the shorthand:
|
---|---|
Applies to | all elements |
Inherited | no |
Media | visual, interactive |
Computed value | as each of the properties of the shorthand:
|
Animation type | as each of the properties of the shorthand:
|
Canonical order | order of appearance in the formal grammar of the values |
The outline
property is specified as one, two, or three values from the list below. The order of the values does not matter.
outline-width
outline-style
outline-color
color
property (foreground color) is used as the default.[ <'outline-color'> || <'outline-style'> || <'outline-width'> ]
outline: solid; | outline: dashed red; | outline: dotted 1px; | outline: ridge thick violet; | outline: custom 5px;
/* Two identical declarations */ :link:hover { outline: 1px solid #000; } :link:hover { outline: solid black 1px; }
Specification | Status | Comment |
---|---|---|
CSS Basic User Interface Module Level 3 The definition of 'outline' in that specification. | Candidate Recommendation | No change. |
CSS Level 2 (Revision 1) The definition of 'outline' in that specification. | Recommendation | Initial definition. |
Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | 1 | Yes |
1.51 1 —? -moz- |
8 | 7 | 1.2 |
Feature | Android webview | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
---|---|---|---|---|---|---|---|
Basic support | 1 | ? | Yes | 4 | 8 | 7 | 3.1 |
1. Firefox includes absolutely positioned elements inside the outline (see bug 687311).
© 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