CSS outline-style Property

Beginner
⏱️ 6 min read
📚 Updated: Jun 2026
🎯 4 Examples
Borders & Focus

What You’ll Learn

The outline-style property controls the line style of an outline. It is essential for focus rings and visual emphasis without changing layout.

01

Line Style

solid, dashed, dotted.

02

Default none

Hidden by default.

03

Focus Rings

Keyboard highlight.

04

3D Styles

groove, ridge, inset.

05

Longhand Part

With width & color.

06

No Layout Shift

Unlike borders.

Introduction

The outline-style property in CSS is used to define the style of an outline that is drawn around an element.

Unlike borders, outlines do not take up space and are not part of the element’s layout, but they are useful for creating visual emphasis or focus indicators.

This property is commonly used in conjunction with outline-width and outline-color to fully customize the appearance of an outline.

Definition and Usage

Set outline-style to anything other than none when you want a visible outline. Pair it with width and color for a complete focus or highlight effect.

For most accessibility-focused designs, solid is the clearest and most common choice.

💡
Beginner Tip

If your outline does not appear, check that outline-style is not none and that outline-width is greater than zero.

📝 Syntax

The syntax for the outline-style property is simple. It specifies the style of the outline to be used.

syntax.css
element {
  outline-style: style;
}

Here, style can be one of the predefined keyword values that define the outline’s appearance.

Basic Example

outline-style.css
button {
  outline-style: solid;
  outline-width: 2px;
  outline-color: #ff5733;
}

Syntax Rules

  • Use keyword values such as solid, dashed, and dotted.
  • none hides the outline even if width or color is set.
  • 3D styles like groove and ridge are less common for focus rings.
  • The outline shorthand can set style, width, and color together.

🎯 Default Value

The default value of the outline-style property is none. This means that if you don’t explicitly set a value, no outline will be drawn around the element.

Browsers may still show their own default focus outline on interactive elements until you style focus yourself.

⚡ Quick Reference

QuestionAnswer
Initial valuenone
Applies toAll elements
InheritedNo
AnimatableNo
Common useFocus indicators and outline emphasis

💎 Property Values

ValueExampleDescription
noneoutline-style: none;No outline is drawn
solidoutline-style: solid;A solid line outline
dottedoutline-style: dotted;A dotted outline
dashedoutline-style: dashed;A dashed outline
doubleoutline-style: double;A double line outline
grooveoutline-style: groove;A 3D grooved outline
ridgeoutline-style: ridge;A 3D ridged outline
insetoutline-style: inset;A 3D inset outline
outsetoutline-style: outset;A 3D outset outline
solid — focus rings dashed — broken line dotted — dots none — hidden

👀 Live Preview

Same width and color, different outline-style values:

Examples Gallery

From solid button outlines to dashed inputs and style comparisons.

🔲 Basic Styles

Combine outline-style with width and color.

Example 1 — Button with Solid Outline Style

In this example, we set a solid outline style for a button element.

solid-outline.html
<style>
  button {
    outline-style: solid;
    outline-width: 2px;
    outline-color: #ff5733;
  }
</style>

<button>Click Me</button>
Try It Yourself

How It Works

All three longhand properties work together to create a visible solid outline.

Example 2 — Dashed Outline on an Input

Use a dashed style for a softer emphasis effect on form fields.

dashed-outline.css
input:focus-visible {
  outline-style: dashed;
  outline-width: 2px;
  outline-color: #2563eb;
}
Try It Yourself

How It Works

Dashed outlines create visible focus without looking as heavy as a solid ring.

🔀 Style Variations

Compare dotted outlines and multiple styles side by side.

Example 3 — Dotted Focus Outline

A dotted outline works well for subtle keyboard focus on links.

dotted-outline.css
a:focus-visible {
  outline-style: dotted;
  outline-width: 3px;
  outline-color: #9333ea;
}
Try It Yourself

How It Works

Dotted styles use small dots instead of a continuous or dashed line.

Example 4 — Compare Outline Styles

See how solid, dashed, and dotted styles look on the same element type.

compare-styles.css
.solid { outline: 2px solid #2563eb; }
.dashed { outline: 2px dashed #2563eb; }
.dotted { outline: 2px dotted #2563eb; }
Try It Yourself

How It Works

The shorthand sets style, width, and color in one declaration for easy comparison.

Part of the outline property set

outline-style controls the line type only. Combine it with outline-width, outline-color, and optionally outline-offset, or use the outline shorthand.

outline-shorthand.css
button:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

♿ Accessibility

  • Prefer solid for focus — Solid outlines are easiest for keyboard users to see.
  • Do not use outline-style: none on :focus — unless you provide another visible focus indicator.
  • Keep enough width — Thin dotted outlines may be hard to notice on some screens.
  • Test contrast — Style alone is not enough; color and width matter too.

🧠 How outline-style Works

1

You choose a style keyword

Values like solid, dashed, or none define the line type.

Keyword
2

Width and color complete the outline

The outline becomes visible when style is not none and width is set.

Longhand
3

Browser draws outside the border

The styled outline appears without changing element layout.

Render
=

Styled focus or emphasis ring

Elements gain a clear visual outline in the chosen line style.

Browser Compatibility

The outline-style property is well supported across all modern browsers, including Chrome, Firefox, Safari, Edge, and Opera. It is a reliable property for creating consistent visual emphasis or focus indicators.

Baseline · Universal support

Excellent support everywhere

Common values like solid, dashed, and dotted work reliably across browsers.

99% Global browser support
Google Chrome 1+ · All versions
Full support
Mozilla Firefox 1.5+ · All versions
Full support
Apple Safari 1.2+ · macOS & iOS
Full support
Microsoft Edge 12+ · All versions
Full support
Opera 7+ · All versions
Full support
outline-style property 99% supported

Bottom line: outline-style is safe for focus and emphasis styling in modern projects.

Conclusion

The outline-style property is a useful tool for adding visual emphasis or focus indicators to elements on your webpage.

By customizing the style of the outline, you can enhance the user experience and improve the accessibility of your website. Experiment with different styles to see how they can complement your design and meet your needs.

💡 Best Practices

✅ Do

  • Use solid for keyboard focus rings
  • Pair style with width and color
  • Try dashed or dotted for softer emphasis
  • Use the outline shorthand when setting all parts
  • Test focus styles on buttons, links, and inputs

❌ Don’t

  • Set outline-style: none on focus without a replacement
  • Expect visible outlines with style set to none
  • Confuse outline-style with border-style layout effects
  • Rely on 3D styles for accessibility-critical focus
  • Forget to set outline-width greater than zero

Key Takeaways

Knowledge Unlocked

Five things to remember about outline-style

Use these points when choosing outline line types.

5
Core concepts
02

Default none

Hidden by default.

Default
📝 03

9 Keywords

Includes 3D styles.

Values
04

Focus Rings

Best with solid.

Use case
🔗 05

Outline Set

Needs width & color.

Companion

❓ Frequently Asked Questions

outline-style sets the line style of an element's outline, such as solid, dashed, or dotted.
The default value is none, which means no outline is drawn unless you set another style.
Usually yes. An outline becomes visible when style is not none and width is greater than zero.
solid is the most common choice because it is clear and easy to see for keyboard users.
They accept similar keywords, but outlines do not affect layout while borders do.

Practice in the Live Editor

Open the HTML editor and experiment with solid, dashed, and dotted outline-style values.

HTML Editor →

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.

5 people found this page helpful