CSS Outline
In CSS (Cascading Style Sheets), the outline
property is used to create a visible outline around an element. It is similar to the border
property, but it does not take up any space or affect the layout of the element.
The outline
property accepts several values:
outline-width
: Specifies the thickness of the outline. It can be set to a specific value (in pixels, ems, or other units) or one of the predefined values:thin
,medium
, orthick
.outline-style
: Defines the style of the outline. It can be set tosolid
,dashed
,dotted
,double
,groove
,ridge
,inset
, oroutset
. These values are similar to the ones used for theborder-style
property.outline-color
: Sets the color of the outline. It can be specified using a color name, a hex code, an RGB value, or any other valid CSS color format.outline-offset
: Specifies the distance between the outline and the element’s border or edge. It creates space between the outline and the content, allowing it to be visually separated from the element.
Here’s an example of how to use the outline
property:
css
/* Applying outline to an element */
.example {
outline: 2px solid blue;
}
/* Using individual outline properties */
.example {
outline-width: 2px;
outline-style: solid;
outline-color: blue;
outline-offset: 5px;
}
It’s important to note that the outline
property is not supported in some older versions of Internet Explorer (up to IE8). However, it is widely supported in modern browsers.