Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Borders, Outlines and Shadows

The outline-offset property

Reference for the CSS outline-offset property: move an outline away from or inside the border edge, with positive and negative values for better focus rings.

The outline-offset property sets the gap between an element's border edge and its outline. A positive value pushes the outline outward and leaves a visible gap; a negative value pulls it inward, over the element's own box.

This is a feature borders do not have. A small positive offset makes focus rings easier to see, and a negative offset keeps the outline inside a container whose parent clips overflow.

CSS
.card:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 4px;
}

Try it

Outline offset

Syntax

CSS
outline-offset: <length>;
  • Initial value: 0
  • Applies to: all elements
  • Inherited: no
  • Animatable: yes, as a length
  • Computed value: an absolute length

Values

Value Description
0 The outline touches the border edge.
Positive length Moves the outline outward from the border edge, creating a gap.
Negative length Moves the outline inward, so it overlaps the element's border and padding.

Percentages are not accepted.

Usage notes

  • Not part of the outline shorthand. You must set it separately; outline: 2px solid red 4px is invalid.
  • Visible gaps help. A 2px to 4px positive offset separates the ring from the element and is easier to see against a similarly coloured background.
  • Clipped outlines. If a parent has overflow: hidden (or a scroll container), a positive offset may be cut off at the edge. A negative offset avoids this.
  • Hover effects. Because outline does not affect layout, animating outline-offset on hover gives a smooth "expanding ring" effect without shifting content.
  • Rounded corners. Current browsers curve the outline along border-radius; the offset scales the curve accordingly.

Browser support

Supported in every current browser.