CSS Outline Offset
The CSS outline-offset property is used to set the offset distance between the external border edge and internal outline edge.
CSS Outline Offset
The outline-offset property adds space between an outline and the edge/border of an element. The space between an element and its outline is straightforward.
The accompanying example specifies an outline 15px external the border edge:
Example
<!DOCTYPE html> <html> <head> <style> p { margin: 30px; border: 1px solid black; outline: 1px solid red; outline-offset: 15px; } </style> </head> <body> <h2>The outline-offset Property</h2> <p>This paragraph has an outline 15px outside the border edge.</p> </body> </html>
The accompanying example shows that the space between an element and its outline is straightforward:
Example
<!DOCTYPE html> <html> <head> <style> p { margin: 30px; background:yellow; border: 1px solid black; outline: 1px solid red; outline-offset: 15px; } </style> </head> <body> <h2>The outline-offset Property</h2> <p>This paragraph has an outline of 15px outside the border edge.</p> </body> </html>
All CSS Outline Properties
Property | Description |
outline | A shorthand property for setting outline-width, outline-style, and outline-color in one declaration |
outline-color | Sets the color of an outline |
outline-offset | Specifies the space between an outline and the edge or border of an element |
outline-style | Sets the style of an outline |
outline-width | Sets the width of an outline |
Thanks for reading! We hope you found this tutorial helpful and we would love to hear your feedback in the Comments section below. And show us what you’ve learned by sharing your projects with us.