The CSS Outline is a line drawn around an element outside the border. It does not take up space in the box model, meaning it does not affect the element’s size or position. Outlines are mainly used for accessibility, highlighting focus, and styling effects.
Feature | Border | Outline |
---|---|---|
Takes space | Yes (part of the box model) | No (does not affect layout) |
Position | Inside the element's dimensions | Outside the element's border |
Can be rounded with border-radius |
Yes | No |
Can be offset | No | Yes, using outline-offset |
Property | Description | Example |
---|---|---|
outline |
Shorthand for setting width, style, and color. | outline: 2px solid red; |
outline-width |
Sets the thickness of the outline. | outline-width: 3px; |
outline-style |
Defines the style (solid, dashed, dotted, etc.). | outline-style: dashed; |
outline-color |
Specifies the outline color. | outline-color: blue; |
outline-offset |
Creates space between the outline and the border. | outline-offset: 5px; |