CSS outline Property
Shorthand for outline-width, outline-style, and outline-color drawn outside the border
Syntax
outline: <outline-width> <outline-style> <outline-color>;Values
| Value | Description |
|---|---|
| none | No outline |
| 1px solid blue | Thin solid blue outline |
| 2px dashed red | Dashed red outline |
| auto | Browser-defined focus outline |
Example
.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
outline-widthSets the width of the outline around an element
outline-styleSets the style of the outline drawn around an element
outline-colorSets the color of the outline drawn around an element
outline-offsetSets the space between an outline and the edge of the border
borderShorthand for border-width, border-style, and border-color
Explore More CSS Properties
Browse our complete reference of 251 CSS properties with syntax, examples, and tips.