CSS OutlineCSS outline is just like CSS border property. It facilitates you to draw an extra border around an element to get visual attention. It is as easy as to apply as a border. See this example: Test it NowDifference between Border and OutlineAt first glance, border and outline look similar, but there are some very important differences between them:
The outline property is a shorthand property. It can be divided into outline-width, outline-style and outline-color properties. It facilitates you to use any of the property alone, if you need it. See this example: Test it NowIn the above example, you can see the three outline properties: Outline-width:It is similar to margin and padding. It can be either an absolute value or a relative value or one of the predefined outline width values i.e. thin, medium or thick. It is preferred to use either an absolute value or a relative value because different browsers interpret differently while using predefined outline width values like thin, medium or thick. Outline-color:It specifies the color that you use for the outline. It supports all the colors available in HTML and CSS. Outline-style:In the above example, we have used only solid outline style while there are a lot of outline style i.e. hidden, dotted, dashed, solid, double, groove, ridge, inset and outset. Let's take an example to demonstrate the usage of different outline-styles. See this example: Test it NowOutline offsetThe outline offset is used to create a distance between outline and border. It takes a CSS length unit and the empty space between the border and the outline will be transparent and then it takes the background color of the parent element. So you can see a visible difference between outline and border. Let's take an example to see the difference between outline and border. See this example: Test it Now
Next TopicCSS Visibility Property
|