outline

Sets the outline of an element. Unlike border, it does not affect layout and is primarily used as a focus indicator.

Class List

ClassCSSDescription
olnoutline: nonefully removes outline; used to remove focus indicator
olssoutline-style: solidsolid outline; primarily used for custom focus styles
olsdoutline-style: dasheddashed outline; for drag/drop area indicators
olsdtoutline-style: dotteddotted outline; auxiliary visual hint
olsdboutline-style: doubledouble outline; strong emphasis
olsgoutline-style: groovegroove 3D effect
olsroutline-style: ridgeridge 3D effect
olsioutline-style: insetinset 3D effect
olsooutline-style: outsetoutset 3D effect
olsnoutline-style: nonesets only outline-style to none

Visual Comparison

Compares how each outline-style value affects an element.

solid — olss

solid

dashed — olsd

dashed

dotted — olsdt

dotted

double — olsdb

double

groove — olsg

groove

ridge — olsr

ridge

none — oln

none

inset — olsi

inset

outline vs border — Layout Impact Comparison

outline does not affect layout, while border is included in the element's size.

outline (no layout impact)

Spacing between adjacent elements does not change even with outline

border (included in layout)

Element size increases by border thickness, affecting spacing

outline-width & outline-offset Patterns

Use ow{N}px for thickness and oo{N}px for the gap between the outline and the element.

PatternCSSExample
ow{N}pxoutline-width: {N}pxow2px
ow{N}remoutline-width: {N}remow0-3rem
oo{N}pxoutline-offset: {N}pxoo4px
oo{N}remoutline-offset: {N}remoo0-2rem
neg-oo{N}pxoutline-offset: -{N}pxneg-oo4px

Class Details

olnoutline: none

Completely removes the element's outline. Used to remove the browser's default focus indicator, but accessibility must always be considered.

<!-- Remove default focus outline + custom focus style -->
<button class="oln focus-visible-olss focus-visible-ow2px py8px px16px bg6366F1 cFFFFFF br8px bn cp">
  Accessible button
</button>

<!-- Caution: Using oln alone causes accessibility issues! -->
<input class="oln py8px px16px bg18181B cFFFFFF br4px b1pxsolid27272A" />

Accessibility caution

Using oln makes it impossible for keyboard users to see the focus position. Always provide a custom focus style using the focus-visible- prefix.

olssoutline-style: solid

Applies a solid outline style. The most common outline style, primarily used for creating custom focus indicators.

<!-- Custom focus indicator -->
<button class="oln focus-visible-olss focus-visible-ow2px oo2px py8px px16px bg18181B cFFFFFF br8px bn cp">
  Solid outline on focus
</button>

<!-- outline-width, outline-offset Combination -->
<div class="olss ow2px oo4px p2rem bg18181B br4px cFFFFFF">
  solid outline + offset
</div>

olsdoutline-style: dashed

Applies a dashed outline style. Used to visually distinguish drag areas, drop targets, etc.

<!-- Drop zone indicator -->
<div class="olsd ow2px p3-2rem bg18181B br8px df jcc aic cA1A1AA">
  Drop files here
</div>

olsdtoutline-style: dotted

Applies a dotted outline style. Used for auxiliary visual hints or debugging.

<!-- Helper hint area -->
<div class="olsdt ow2px p2rem bg18181B br4px cA1A1AA">
  Dotted outline area
</div>

olsdboutline-style: double

Applies a double outline style. Used for elements requiring emphasis; outline-width must be at least 3px for the double line to be visible.

<!-- Emphasis area (minimum 3px required) -->
<div class="olsdb ow4px p2rem bg18181B br4px cFFFFFF">
  Double outline emphasis
</div>

olsgolsrolsiolsogroove / ridge / inset / outset

3D effect outline styles. Rendering may vary across browsers and is rarely used in modern web development.

<!-- 3D style outline -->
<div class="olsg ow3px p2rem bg18181B cA1A1AA mb8px">groove</div>
<div class="olsr ow3px p2rem bg18181B cA1A1AA mb8px">ridge</div>
<div class="olsi ow3px p2rem bg18181B cA1A1AA mb8px">inset</div>
<div class="olso ow3px p2rem bg18181B cA1A1AA">outset</div>
olsggroove — carved-in 3D effect
olsrridge — raised 3D effect (opposite of groove)
olsiinset — inward-pressed 3D effect
olsooutset — outward-pushed 3D effect (opposite of inset)

olsnoutline-style: none

Sets outline-style to none. Similar to oln but used when controlling outline-style individually.

<!-- Individual control of outline-style only -->
<div class="olsn p2rem bg18181B cA1A1AA">
  outline-style: none
</div>

Tips &amp; Notes

Accessibility alternative required when using oln

Removing the default focus with oln makes it impossible for keyboard users to see their current position. Always provide custom styles with focus-visible-.

Outline has no layout impact

Unlike border, outline does not affect element size or position. This is advantageous for providing focus feedback without layout shifts.

Adjusting gap with outline-offset

Use oo{N}px to add a gap between the outline and the element. Negative values are also possible, drawing the outline inside the element.