CSS outline-width Property

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

What You’ll Learn

The outline-width property controls how thick an element’s outline is. It is key for visible focus rings and emphasis without changing layout.

01

Thickness

Control outline size.

02

Keywords

thin, medium, thick.

03

Length Values

px, em, rem.

04

Default medium

Browser standard.

05

Focus Rings

Keyboard highlight.

06

No Layout Shift

Unlike borders.

Introduction

The outline-width property in CSS is used to define the thickness of the outline of an element. Unlike borders, outlines do not take up space in the layout and are drawn outside the element’s border edge.

This property is useful for highlighting elements, creating focus states, or adding visual emphasis to specific parts of a webpage.

Definition and Usage

Use keyword values like thin or thick for quick sizing, or precise lengths like 2px and 3px for consistent focus rings across your design system.

Pair outline-width with outline-style and outline-color for a complete outline effect.

💡
Beginner Tip

For accessible focus rings, try outline: 2px solid #2563eb; or set outline-width: 3px; with your preferred style and color.

📝 Syntax

The syntax for the outline-width property is simple and can be used with various values to control the thickness of the outline.

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

Here, width specifies the thickness of the outline and can be a keyword or a length value.

Basic Example

outline-width.css
button {
  outline: solid black;
  outline-width: thick;
}

Syntax Rules

  • Keywords: thin, medium, and thick.
  • Lengths: any valid CSS length such as px, em, or rem.
  • An outline needs a visible outline-style to show the width.
  • The outline shorthand can set width, style, and color together.

🎯 Default Value

The default value of the outline-width property is medium, which is a browser-defined width that varies between browsers but is generally considered a standard medium thickness.

Use explicit pixel values when you need the same thickness everywhere.

⚡ Quick Reference

QuestionAnswer
Initial valuemedium
Applies toAll elements
InheritedNo
AnimatableNo
Common useFocus ring thickness and visual emphasis

💎 Property Values

ValueExampleDescription
thinoutline-width: thin;A thin outline; exact width is defined by the browser
mediumoutline-width: medium;A medium outline; default browser thickness
thickoutline-width: thick;A thick outline; exact width is defined by the browser
Lengthoutline-width: 3px;A specific width using units such as px, em, or rem
thin — light ring medium — default thick — bold ring 2px–4px — precise focus

👀 Live Preview

Same solid blue outline with different outline-width values:

thin medium thick 4px

Examples Gallery

Use keyword widths and precise pixel lengths for buttons, inputs, and focus rings.

📐 Basic Widths

Set keyword and length values on outlines.

Example 1 — Button with thick Outline Width

In this example, we set the outline width of a button to thick.

thick-outline.html
<style>
  button {
    outline: solid black;
    outline-width: thick;
  }
</style>

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

How It Works

The thick keyword makes the outline noticeably bolder than the default medium width.

Example 2 — Input with 3px Outline Width

In this example, we set the outline width of an input field to 3px.

px-outline.html
<style>
  input[type="text"] {
    outline: dashed blue;
    outline-width: 3px;
  }
</style>

<input type="text" placeholder="Type something...">
Try It Yourself

How It Works

Pixel lengths give exact control over outline thickness regardless of browser defaults.

♿ Focus & Comparison

Choose accessible focus widths and compare sizes side by side.

Example 3 — Accessible 2px Focus Ring

A 2px solid outline is a common choice for keyboard focus indicators.

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

How It Works

Two pixels is thick enough to see clearly without overpowering the element.

Example 4 — Compare thin, medium, and thick

See how keyword widths change the same outline style and color.

compare-width.css
.thin { outline: solid #2563eb; outline-width: thin; }
.medium { outline: solid #2563eb; outline-width: medium; }
.thick { outline: solid #2563eb; outline-width: thick; }
Try It Yourself

How It Works

Keyword widths are convenient, but exact pixel values are more consistent across browsers.

Part of the outline property set

outline-width sets thickness only. Combine it with outline-style, outline-color, and outline-offset, or use the outline shorthand.

outline-shorthand.css
/* width + style + color in one line */
button:focus-visible {
  outline: 3px solid #2563eb;
}

♿ Accessibility

  • Use visible width — Focus outlines should be thick enough to notice, often 2px or more.
  • Do not set width to 0 — on focus states unless you provide another clear indicator.
  • Pair with contrast — Width alone is not enough; color contrast matters too.
  • Test keyboard focus — Verify the ring is visible on all interactive elements.

🧠 How outline-width Works

1

An outline style is set

The outline must not be none before width is visible.

Style
2

Width controls thickness

outline-width sets how bold the ring appears.

Thickness
3

Outline draws outside the border

The thicker ring does not change layout or box dimensions.

No shift
=

Clear emphasis or focus ring

Elements stand out with the thickness you choose.

Browser Compatibility

The outline-width property is well supported in all modern browsers, including Chrome, Firefox, Safari, Edge, and Opera. This makes it a reliable choice for styling outlines consistently across platforms.

Baseline · Universal support

Excellent support everywhere

Keyword and length values for outline-width work reliably in all major 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-width property 99% supported

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

Conclusion

The outline-width property provides a simple and effective way to control the thickness of outlines on elements.

By using this property, you can enhance the visual emphasis of your webpage elements, making them more noticeable or helping to create a cohesive design. Experiment with different values to find the perfect thickness for your design needs.

💡 Best Practices

✅ Do

  • Use 2px to 4px for keyboard focus rings
  • Prefer pixel values for consistent cross-browser thickness
  • Pair width with style, color, and optional offset
  • Test focus visibility on buttons, links, and inputs
  • Use thick for quick emphasis in demos

❌ Don’t

  • Set outline width without a visible outline style
  • Use extremely thin rings for critical focus states
  • Assume keyword widths are identical in every browser
  • Confuse outline-width with border-width layout effects
  • Remove focus width without a replacement indicator

Key Takeaways

Knowledge Unlocked

Five things to remember about outline-width

Use these points when controlling outline thickness.

5
Core concepts
02

Default medium

Browser standard.

Default
📝 03

Keywords & px

thin to 4px.

Values
04

Focus Rings

Common use case.

Use case
🔲 05

Outline Set

Needs style & color.

Companion

❓ Frequently Asked Questions

outline-width sets how thick an element's outline is, using keywords like thin, medium, thick, or a specific length such as 2px.
The default value is medium, which is a browser-defined standard thickness.
Yes. An outline is visible only when outline-style is not none and outline-width is greater than zero.
Yes. Length values such as 2px, 3px, and 0.25em give you precise control over thickness.
No. Outlines are drawn outside the border box and do not change element size or surrounding layout.

Practice in the Live Editor

Open the HTML editor and experiment with keyword and pixel outline-width 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