CSS Outline Properties
Definition and Usage
A outline (contour) is a line that is drawn around an element, at the periphery of the edge of the bounding rectangle, that acts as an element of prominence.
Note: Footprints do not occupy space or are not necessarily rectangles.
The outline shorthand property sets all the outline properties in a declaration.
The following properties can be set sequentially: Outline-color Outline-style outline-width
If you do not set one of these values, there will be no problems, such as Outline:solid #ff0000; is also allowed.
Possible values
value |
Description |
Outline-color |
Specifies the color of the border. See: Possible values in Outline-color. |
Outline-style |
Specifies the style of the border. See: Possible values in Outline-style. |
Outline-width |
Specifies the width of the border. See: Possible values in Outline-width. |
Inherit |
Specifies that the settings for the outline property should be inherited from the parent element. |
ExampleSet the style for 4 borders:
p {border:red solid thin; outline: #00ff00 dotted thick;}
</style>
In the browser, when the mouse clicks or uses the TAB key to get a link or a radio to the focus, the element will be surrounded by a dashed outline box. This contour dashed box is outline.
Outline can tell the user that an HTML element that can excite an event gets the focus, which is especially meaningful for users who love keyboard operations. A clearly pleasing outline design improves the user experience of using forms. On the other hand, outline also have some annoying places, such as the use of CSS Design tab (tab), when you select a tab, the outline of the tab line will always be displayed, some of the effect is beautiful.
the difference between outline and border
Border can be applied to almost all tangible HTML elements, while outline is designed for elements such as links, form controls, and ImageMap. Thus another difference can be inferred, that is: the effect of outline will automatically appear with the focus of the element, corresponding to the blur and automatically disappear. These are the default behavior of the browser, without the need for JavaScript to be controlled with CSS.
In addition outline does not affect the size or position of the element as border does, outline does not occupy space.
Go from w3school,http://my.oschina.net/guomingliang/blog/337169