Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

CSS property `outline-offset`

`outline-offset` sets the distance between the border edge and outline of a visible outline painted outside the border.

Version: CSS modules; captured CSSWG editor index includes draft and obsolete features requiring review

Syntax

<length>

outline-offset sets the distance between the border edge and outline of a visible outline painted outside the border.

The example establishes a solid contrasting outline with nonzero width, applies the tested component, and reports the complete computed outline.

Grammar: <length>.

An outline does not change layout dimensions and may overlap neighbors; outline-style:none means a computed width produces no visible paint.

Examples

<!doctype html><html lang="en"><meta charset="utf-8"><title>CKTIS CSS example</title><body><pre id="result"></pre><script>const x=document.createElement("button");document.body.prepend(x);x.textContent="focus";x.style.cssText="width:80px;height:40px;outline:4px solid rgb(0 0 0)";const before=x.getBoundingClientRect();x.style.setProperty("outline-offset","6px");const after=x.getBoundingClientRect(),s=getComputedStyle(x);document.querySelector("#result").textContent="outline="+s.outlineWidth+" "+s.outlineStyle+" "+s.outlineColor+"; offset="+s.outlineOffset+"; layout="+Math.round(before.width)+"x"+Math.round(before.height)+"->"+Math.round(after.width)+"x"+Math.round(after.height);</script></body></html>

Result

outline=4px solid rgb(0, 0, 0); offset=6px; layout=80x40->80x40

The example was executed locally in an isolated, network-free Chrome session; the result comes from the browser CSS API.

Sources