1. css
  2. /properties
  3. /outline-style

outline-style

Definition

The outline-style property in CSS is used to set the style of the outline around an element. Outlines are non-rectangular shapes that surround an element and are typically used to indicate focus, active states, or other types of user interactions.

Examples

Set the outline style to dotted:

.example {
  outline-style: dotted;
}

Set the outline style to solid:

.example {
  outline-style: solid;
}

Set the outline style to double:

.example {
  outline-style: double;
}

Values

ValueDescription
noneSpecifies that no outline should be drawn. This is the default value.
dottedSpecifies a dotted outline style.
dashedSpecifies a dashed outline style.
solidSpecifies a solid outline style.
doubleSpecifies a double outline style.
grooveSpecifies a 3D groove outline style, which creates a raised border that appears to be carved into the page.
ridgeSpecifies a 3D ridge outline style, which creates a border that appears to be extruded from the page.
insetSpecifies a 3D inset outline style, which creates a border that appears to be pressed into the page.
outsetSpecifies a 3D outset outline style, which creates a border that appears to be coming out of the page.
initialResets the property to its default value.
inheritInherits the property from its parent element.
hiddenSpecifies that the outline should be hidden, but still take up space. This can be useful for creating visual effects where an outline is only shown on hover or focus. This value is not supported in Internet Explorer.
dotted-2pxSpecifies a dotted outline style with a 2-pixel gap between dots. This value is not supported in Internet Explorer.
dashed-2pxSpecifies a dashed outline style with a 2-pixel gap between dashes. This value is not supported in Internet Explorer.
solid-2pxSpecifies a solid outline style with a 2-pixel width. This value is not supported in Internet Explorer.
double-2pxSpecifies a double outline style with a 2-pixel width. This value is not supported in Internet Explorer.
groove-2pxSpecifies a 3D groove outline style with a 2-pixel width. This value is not supported in Internet Explorer.
ridge-2pxSpecifies a 3D ridge outline style with a 2-pixel width. This value is not supported in Internet Explorer.
inset-2pxSpecifies a 3D inset outline style with a 2-pixel width. This value is not supported in Internet Explorer.
outset-2pxSpecifies a 3D outset outline style with a 2-pixel width. This value is not supported in Internet Explorer.
groove-ridgeSpecifies a 3D groove-ridge outline style with alternating ridges and grooves. This value is not supported in Internet Explorer.
ridge-grooveSpecifies a 3D ridge-groove outline style with alternating grooves and ridges. This value is not supported in Internet Explorer.

Best Practices

  • Only use outlines for interactive elements, such as links and form inputs. Outlines can be distracting and confusing for non-interactive elements, such as images and paragraphs.
  • Use a subtle outline style that doesn't overwhelm the content. A solid or dashed style is usually sufficient.
  • Avoid using outline styles that mimic 3D effects, such as groove, ridge, inset, and outset, as they can be confusing for users who rely on assistive technologies.
  • Ensure that the outline has sufficient contrast with the background color to be visible for users with low vision.
  • Use the hidden value to create visual effects where an outline is only shown on hover or focus, rather than relying on none and changing the border property, which can cause layout shifts.

Browser Compatibility

ChromeFirefoxSafariInternet ExplorerMicrosoft EdgeOpera
YesYesYesYesYesYes