CSS Outline properties and differences from border properties

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.