The outline CSS shorthand property allows drawing a line around the element, outside the border. It is used to set all the properties of the outline in a single declaration. CSS outline properties can be categorized into 4 types, namely, Outline-style, Outline-color, Outline-width & Outline-offset. We will discuss all the types of outline properties sequentially through the examples.
Properties: There are lots of properties comes under the CSS outline collection all of them are well described with the example.
Outline-style: It is used to set the appearance of the outline of an element ie., it tells us the style or type of outline. Any other outline property cannot be accessed without setting the outline-style. If absent then the default style will be set to none.
Example: This example illustrates the Outline property where the style is set to the dotted lines.
Outline-color: It is used to sets the outline color of an element. The color can be set by its name ie., rgb value or a hex value, etc. If absent then the default color will be the current color.
outline-color: <color> | invert | inherit;
Example: This example illustrates the Outline property where the color is set to the specific color value.
Outline-width: It is used to specify the width of this outline for a specific element. The width of the outline can be set by specifying the size of the width in px, cm, pt, etc, or by using terms like a thin, thick, medium. If absent then the default width will be the medium.
Example: This example illustrates the Outline property where the width is set to the specific value.
Outline-offset: The CSS outline-offset Property sets the amount of space between an outline and the edge or border of an element. An outline is a line drawn around elements outside the border edge. The space between the element and its outline is transparent. Also, the outline may be non-rectangular. The default value is 0.
Example: This example illustrates the Outline property where the offset is defined with a specific value.
- Google Chrome 1.0
- Microsoft Edge 12.0
- Internet Explorer 8.0
- Firefox 1.5
- Opera 7.0
- Safari 1.2