CSS outline-style Property

Beginner
6 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The outline-style property sets the line style of an element’s outline. An outline is drawn around the element, outside the border, and does not take up layout space.

The initial value is none, so nothing shows until you pick a visible style such as solid, dashed, or dotted. Pair it with outline-width and outline-color, or use the outline shorthand. For focus rings, solid is usually the clearest choice.

Baseline · Widely available.

Not deprecated and not experimental. Standard-track CSS Basic User Interface property. Safe for focus and emphasis styling in modern browsers.

CSS Syntax

syntax.css
outline-style: auto | none | dotted | dashed | solid | double | groove | ridge | inset | outset | initial | inherit;

Property Values

ValueDescriptionTry it
noneNo outline. Initial valueTry it
autoBrowser draws its own outline style, often a platform focus lookTry it
solidA continuous straight line. Best default for focus ringsTry it
dashedA series of short dashesTry it
dottedA series of dotsTry it
doubleTwo parallel lines. Needs enough width to show bothTry it
groove / ridgeCarved or extruded 3D look. Opposites of each otherTry it
inset / outsetEmbedded or embossed look. Opposites of each otherTry it
initialResets to the initial value, noneTry it
inheritTakes the value from the parent elementTry it

How to Use outline-style

Pick a visible style first, then add width and color when you want them explicit.

  1. Choose the element that needs an outline (often a button, link, or input on focus).
  2. Set outline-style to a keyword such as solid or dashed. Without this, nothing draws.
  3. Optionally set outline-width and outline-color, or use the outline shorthand.
  4. Add outline-offset if you want a gap between the border and the outline.
PieceRequired?Role
Style keywordYes (to show a line)Default is none, which hides the outline
WidthRecommendedMakes the outline easy to see; use with style
ColorRecommendedDefaults to currentColor if omitted
OffsetOptionalMoves the outline away from the border edge

Live Preview

Change outline-style on a box that already has width and color. Watch the line pattern update.

Width and color stay fixed. Only the style keyword changes. The thin border is the element edge; the outline sits outside it.

Box

outline-style: solid

CSS Examples

Each snippet focuses on outline-style. Use Try It Yourself for a live editor.

Example 1 — Solid Outline

Draw a continuous outline outside a box.

CSS
<style>
  div {
    outline-style: solid;
    outline-width: 3px;
    outline-color: #2563eb;
    border: 1px solid #cbd5e1;
    padding: 12px;
  }
</style>

<div>Solid outline</div>
Try It Yourself

How It Works

  1. Set the style. solid draws a continuous outline line.
  2. Give it thickness. outline-width: 3px makes the ring easy to see.
  3. Set the color. Blue paints the outline. Without a visible style, width and color alone would still look empty.
  4. Border stays separate. The thin gray border marks the box edge. The outline sits outside it and does not change layout.

Example 2 — Dashed Focus Ring

Show a dashed outline only when the button is focused with a keyboard.

CSS
<style>
  button:focus-visible {
    outline-style: dashed;
    outline-width: 2px;
    outline-color: #2563eb;
    outline-offset: 2px;
  }
</style>

<button type="button">Save</button>
Try It Yourself

How It Works

  1. Target keyboard focus. :focus-visible styles focus for keyboard users without always showing a ring on mouse click.
  2. Pick a dashed style. outline-style: dashed draws short segments instead of a solid ring.
  3. Keep width and color clear. A 2px blue outline stays readable on most backgrounds.
  4. Add a small offset. outline-offset: 2px lifts the ring away from the button edge so it does not collide with the border.

Example 3 — Double Outline

Use two parallel lines. Give the outline enough width so both lines show.

CSS
<style>
  div {
    outline-style: double;
    outline-width: 6px;
    outline-color: #0f766e;
    border: 1px solid #cbd5e1;
    padding: 12px;
  }
</style>

<div>Double outline</div>
Try It Yourself

How It Works

  1. Choose double. outline-style: double draws two parallel lines.
  2. Share the width. The total outline-width covers both lines and the gap between them.
  3. Use a thicker width. 6px leaves room for both strokes. A thin width can look like one line.
  4. Color both lines. Teal applies to the whole outline stroke.

Edge Cases & Pitfalls

If the outline disappears or looks wrong, check these first.

none

Default style hides everything

The initial value is none. Setting only outline-width or outline-color will not draw a line until style is visible.

a11y

Do not remove focus outlines blindly

Setting outline-style: none on :focus without a replacement makes keyboard navigation hard to follow. Keep a clear ring or provide another visible indicator.

double

double needs enough width

Two lines share the total outline-width. A thin width can make double look like a single line. Try 6px or more while learning.

layout

Outline does not affect layout

Unlike border-style, an outline never changes the element’s size. Neighboring content will not shift when the outline appears.

3D

Groove, ridge, inset, and outset depend on color

Those keywords fake a 3D edge from the outline color. On a light background with a light color they can look flat. Prefer solid for accessibility-critical focus.

Browser Support

outline-style is a browser CSS property for drawing outlines. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available

outline-style

Supported in Chrome 4+, Firefox 2+, Safari 3.1+, Edge 12+, and Internet Explorer 8+. Common values including auto are widely available.

97% Global browser support
Google Chrome 4+
Full support
Mozilla Firefox 2+
Full support
Apple Safari 3.1+
Full support
Microsoft Edge 12+
Full support
Opera 15+ (Chromium)
Full support
Samsung Internet 4+
Full support
Internet Explorer 8+
Full support
outline-style Widely supported

Bottom line: Safe for focus and emphasis styling in current browsers. Prefer solid for keyboard focus rings. It is not a runtime API.

Key Takeaways

  • Role: sets the line style of an outline drawn outside the border.
  • Initial value: none. A visible style is required for an outline to appear.
  • No layout shift: outlines never change the element’s size, unlike borders.
  • Focus tip: prefer solid for keyboard rings; do not remove outlines without a replacement.

One line: set a style keyword first — without it, the outline stays invisible.

Frequently Asked Questions

It sets the line style of an element's outline, such as solid, dashed, or dotted. The outline is drawn outside the border and does not take up layout space.
The initial value is none, so nothing draws until you set a visible style. Also check that outline-width is greater than zero, or use the outline shorthand.
They accept similar keywords, but outlines sit outside the border box and never change the element's size. Borders are part of the box model.
auto lets the browser draw its own outline style, often the platform focus look. It can look richer than a simple CSS keyword.
No. Setting outline-style: none on :focus without another visible focus indicator harms keyboard users. Prefer a clear solid outline, or replace it with an equally visible style.
It is Baseline Widely available: Chrome 4+, Firefox 2+, Safari 3.1+, Edge 12+, and Internet Explorer 8+. It is a browser CSS property, not a Node.js feature.

Next: outline-width

Learn how to control the thickness of an outline.

outline-width tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful