Open In App

What is the purpose of the outline Property in CSS ?

Last Updated : 01 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

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, including dotted, 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.

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads