XML technologies / CSS / Advanced websites with CSS / CSS property reference / outline

(Excerpt from “CSS − Advanced websites with Cascading Stylesheets” by Rachel Andrew & Dan Shafer)

An element’s outline (outline) is similar to its border (border). However, it takes up no space in the CSS box model and therefore does not affect the positioning of other elements. Also, outline does not create a rectangular box around the element but follows the irregular edge of a text paragraph. Unlike its border, the outline of an inline element spanning multiple lines always extends from the start to the end of each line.

The shorthand property outline lets you declare the properties outline-color, outline-style and outline-width in one declaration. All three properties can also be declared separately.

Inherited: no

See also: border, outline-color, outline-style, outline-width

Values

The syntax for the property outline is as follows. Values are separated by spaces:

outline: [color] [style] [width]

color represents a valid value for outline-color, style represents a valid value for outline-style, width represents a valid value for outline-width.

All three values are optional, but at least one must be declared. Values can appear in any order. Any undeclared value automatically takes its default.

Default value: none

Compatibility

CSS version: 2

Works only in Internet Explorer 5 for Macintosh and Opera 7, but, contrary to the CSS2 specification, only as a rectangular outline (like border).

Example

The following style rule uses the pseudo-class :focus to create a dashed, red, medium-width outline around the input field element:

input:focus, select:focus, textarea:focus {
 outline: medium dashed red;
}

  

 

 

 

back to top