bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/CSS/CSS Foundations
CSS•CSS Foundations

CSS Outline Offset

Flash cards

Review the key moves

1/4
Core idea

What is the main idea behind CSS Outline Offset?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

2Fill blank

Complete the missing token from the example code.

___: 30px;
3Order

Put the learning moves in the order that makes the concept easiest to apply.

All CSS Outline Properties
CSS Outline Offset with Negative Value
CSS Outline Offset

The outline-offset property adds a space between an outline and the edge/border of an element. The space between an element and its outline is transparent.

The following example specifies an outline 15px outside the border edge:

This paragraph has a black border and a red outline 15px outside the border edge.

Example

Formatted code
p {
  margin: 30px;
  padding: 5px;
  border: 1px solid black;
  outline: 3px solid red;
  outline-offset: 15px;
}

Live preview

The following example shows that the space between an element's border and its outline is transparent:

This paragraph has an outline of 15px outside the border edge.

Example

Formatted code
p {
  margin: 30px;
  padding: 5px;
  background: yellow;
  border: 1px solid black;
  outline: 3px solid red;
  outline-offset: 15px;
}

Live preview

CSS Outline Offset with Negative Value

The following example shows the use of an outline-offset with a negative value, now the outline will be placed inside the border edge:

This paragraph has a black border and a red outline -5px inside the border edge.

Example

Formatted code
p {
  margin: 30px;
  padding: 5px;
  background: yellow;
  border: 1px solid black;
  outline: 3px solid red;
  outline-offset: -5px;
}

Live preview

All CSS Outline Properties

PropertyDescription
outlineA shorthand property for setting outline-width, outline-style, and outline-color in one declaration
outline-colorSets the color of an outline
outline-offsetSpecifies the space between an outline and the edge or border of an element
outline-styleSets the style of an outline
outline-widthSets the width of an outline

Previous

CSS Outline Shorthand

Next

CSS Text Color