outline-offset

Draft

Definition

The outline-offset CSS property is used to set the amount of space between an outline and the edge of an element. It allows you to create a gap or offset between the outline and the element’s border or content.

The outline-offset property accepts length values, such as pixels (px) or other CSS units. Negative values are also allowed.

Here’s an example:

button {
  outline: 2px solid blue;
  outline-offset: 4px;
}

In this example, the button element is styled with a blue outline that is 2 pixels wide. The outline-offset: 4px rule creates a 4-pixel gap between the outline and the button’s border or content, making the outline appear slightly outside the button.

You can adjust the outline-offset value to create different spacing effects between the outline and the element. A positive value will increase the gap, while a negative value will cause the outline to overlap with the element’s content.

It’s important to note that the outline-offset property only applies if an outline is set using the outline property. If no outline is set, the outline-offset property has no effect.

The outline-offset property can be useful for fine-tuning the appearance of outlines, adding visual separation between the outline and the element’s content or border. It allows for greater control over the styling of outlines in CSS.