outline-offset
The outline-offset
CSS property sets the amount of space between an outline and the edge or border of an element.
Syntax
/* <length> values */
outline-offset: 3px;
outline-offset: 0.2em;
/* Global values */
outline-offset: inherit;
outline-offset: initial;
outline-offset: revert;
outline-offset: unset;
Values
<length>
-
The width of the space between the element and its outline. A negative value places the outline inside the element. A value of
0
places the outline so that there is no space between it and the element.
Description
An outline is a line that is drawn around an element, outside the border edge. The space between an element and its outline is transparent. In other words, it is the same as the parent element's background.
Formal definition
Initial value | 0 |
---|---|
Applies to | all elements |
Inherited | no |
Computed value | as specified, but with relative lengths converted into absolute lengths |
Animation type | a length |
Formal syntax
Examples
Setting outline offset in pixels
HTML
<p>Gallia est omnis divisa in partes tres.</p>
CSS
p {
outline: 1px dashed red;
outline-offset: 10px;
background: yellow;
border: 1px solid blue;
margin: 15px;
}
Result
Specifications
Specification |
---|
CSS Basic User Interface Module Level 4 # outline-offset |
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
outline-offset | ChromeFull support1 | EdgeFull support15 | FirefoxFull support1.5 | Internet ExplorerNo supportNo | OperaFull support9.5 | SafariFull support1.2 | WebView AndroidFull support37 | Chrome AndroidFull support18 | Firefox for AndroidFull support4 | Opera AndroidFull support14 | Safari on iOSFull support1 | Samsung InternetFull support1.0 |
Legend
- Full support
- Full support
- No support
- No support
- See implementation notes.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.