The home where you level up

Save my spot

outline-style

Term side of the Card.
Topic: Borders, Outlines & Shadows
Unit title: outline-style
Categories: Property
Explanation side of the Card

Explanation: The property that defines the style of an element's outline. It can be set to values like 'solid', 'dashed', 'dotted' or 'none', specifying how the outline line should appear, which helps in highlighting or decorating elements.

Browser compatibility:
  • The chrome browser supports this feature starting from version 1.
  • The edge browser supports this feature starting from version 12.
  • The firefox browser supports this feature starting from version 1.5.
  • The safari browser supports this feature starting from version 1.2.
Availability: 

Example

Wrongcss
a:focus-visible {
  outline-width: 2px;
  outline-color: blue;
}
Rightcss
a:focus-visible {
  outline-width: 2px;
  outline-style: solid;
  outline-color: blue;
}

The default outline-style is 'none', so width and color alone draw nothing.

Common mistakes

  • The outline doesn't appear because outline-style defaults to 'none'.
  • Using 'hidden', which outline-style doesn't accept.

Key points

  • Outlines set with longhands also set outline-style.
  • Focus styles use 'solid' or 'auto', not 'none'.

Interview questions

What does outline-style: auto do?

It lets the browser draw its own native focus ring, often in the platform's accent color.

What is the default outline-style?

'none', so no outline is drawn until a style is set, except the browser's own focus ring on focus.

Can outline-style be different on each side?

No. Unlike border-style, an outline uses one style all around.

The home where you level up

Daily 3-minute lessons to understand your AI's code.

No spam — just launch news.
Unsubscribe anytime. · Privacy Policy

Analytics cookiesWe'd like to use analytics cookies to see which pages are useful. They're set only if you accept. Privacy Policy