Box Model

CSS outline Property

Shorthand for outline-width, outline-style, and outline-color drawn outside the border

Syntax

CSS
outline: <outline-width> <outline-style> <outline-color>;

Values

ValueDescription
noneNo outline
1px solid blueThin solid blue outline
2px dashed redDashed red outline
autoBrowser-defined focus outline

Example

CSS
.button:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

Understanding CSS outline

The CSS outline property shorthand for outline-width, outline-style, and outline-color drawn outside the border. As part of the Box Model module in CSS, it is one of the most commonly used properties for controlling the visual presentation of web pages.

You can set outline to values such as none, 1px solid blue, 2px dashed red, auto, among others. Each value changes how the browser renders the affected element, giving you fine-grained control over your page layout and design. Choosing the right value depends on the specific design requirements of your project.

Common use cases for the outline property include responsive web design, component-based layouts, and creating visually consistent interfaces across devices. It works closely with related properties like outline-width, outline-style, outline-color to achieve complex styling effects. Understanding how these properties interact helps you write cleaner, more maintainable stylesheets.

Browser support for outline is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. For older browsers, consider using fallback values or progressive enhancement strategies. The property can also be set dynamically via JavaScript using element.style.outline or the CSS custom properties (variables) approach for theming.

Related Properties

Explore More CSS Properties

Browse our complete reference of 251 CSS properties with syntax, examples, and tips.