CSS Portal

CSS outline-offset Property

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The outline-offset property shifts an element's outline away from or toward the element's border edge, creating a visible gap (or overlap) between the outline and the element itself. Because outlines are painted outside the element's box and do not contribute to the box model, adjusting that offset changes only the visual spacing; it does not affect layout, element size, or document flow. This makes the property particularly useful when you need decorative or accessibility-focused indicators that must remain visually distinct without altering surrounding layout.

You can use outline-offset together with the element's outline settings to control how that indicator sits relative to borders and adjacent content. It complements the element's outline (which controls the outline’s style, color and width) and the element's border (which is part of the box model). Keep in mind that outlines are painted and composited differently than borders and shadows: they may be clipped by container clipping and can render in subtly different ways across implementations, so visual testing in context is recommended.

Practically, designers rely on outline-offset for clearer focus rings and layered effects - letting a focus outline sit outside an existing border or move closer to the element for tighter highlighting - without causing reflow. If you need a softer, blurred, or inset effect that interacts with stacking and painting differently, consider using box-shadow instead. Also be mindful that outlines are painted over nearby content when they extend beyond the element, so choose offsets carefully to avoid unintended overlaps.

Definition

Initial value
0
Applies to
All elements
Inherited
No
Computed value
[length] value in absolute units (px or physical)
Animatable
No
JavaScript syntax
object.style.outlineOffset

Interactive Demo

The rusty swing set creaked a lonely lullaby in the twilight, shadows lengthening like grasping fingers across the dew-kissed grass. A lone dandelion seed, adrift on the breeze, whispered secrets of faraway fields, of dandelion suns and galaxies spun from fluff.

Syntax

outline-offset: <length> | inherit

Values

  • <length>Floating-point number, followed by an absolute units designator (cm, mm, in, pt, or pc) or a relative units designator (em, ex, or px).
  • inherit

Example

<div class="container">
<div class="styled-box">
Outline Offset Example
</div>
</div>
/* Container for centering the example */
.container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 200px;
}

/* The actual element with the offset */
.styled-box {
  padding: 20px;
  background-color: #f0f4f8;
  border: 2px solid #2d3748; /* The solid inner border */
  
  /* Outline properties */
  outline: 4px dashed #ed8936; /* The dashed outer line */
  
  /* This is the key property */
  outline-offset: 15px; 
  
  font-family: sans-serif;
  font-weight: bold;
}

Browser Support

The following information will show you the current browser support for the CSS outline-offset property. Hover over a browser icon to see the version that first introduced support for this CSS property.

This property is supported by all modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 1st January 2026

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!