CSS outline
Property
Topic: CSS3 Properties ReferencePrev|Next
Description
The outline
property sets the width, style, and color for all four sides of an element's outline. It is a shorthand property for setting the individual outline properties i.e. outline-width
, outline-style
, and outline-color
in a single declaration.
The following table summarizes the usages context and the version history of this property.
Default value: | See individual properties |
---|---|
Applies to: | All elements |
Inherited: | No |
Animatable: | Yes, as some of the properties of the shorthand are animatable. See animatable properties. |
Version: | CSS 2, 3 |
Syntax
The syntax of the property is given with:
Note: If any property listed above is missing or omitted, the default value for that property will be inserted, if any. See individual properties for details.
The example below shows the outline
property in action.
Example
Try this code »p.one {
outline: 2px solid #ff0000;
}
p.two {
color: #00ff00;
outline-top: 5px solid;
}
Note: If outline-color
is missing or not specified (e.g. outline: 5px solid;
) the value of the element's color
property will be used instead. But, in the case of outline-style
, omitting the value will cause no outline to show at all, because the default value for outline-style
property is none
.
Property Values
The following table describes the values of this property.
Value | Description |
---|---|
outline-width |
Sets the width of the outline of an element. |
outline-style |
Sets the line style of the outline of an element. |
outline-color |
Sets the color of the outline of an element. |
initial |
Sets this property to its default value. |
inherit |
If specified, the associated element takes the computed value of its parent element outline property. |
Browser Compatibility
The outline
property is supported in all major modern browsers.
Basic Support—
|
Further Reading
See tutorial on: CSS Outline, CSS Border.
Related properties: outline-width
, outline-style
, outline-color