The outline
property in CSS is used to set the style, color, and width of an outline around an element. It is often used to highlight elements without affecting their layout, providing a visible focus or emphasis.
Syntax:
/* Applying a red dotted outline to focused elements */
:focus {
outline: 2px dotted red;
}
Features
- Focus Indication: Commonly used to visually indicate focus on interactive elements, improving accessibility.
-
Style Options: The
outline
property supports various styles, includingdotted
,dashed
,solid
, and more. - Color: You can set the color of the outline using color values.
- Width: Specifies the width of the outline, controlling its thickness.