🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
Back to CSS Notes
Topic #38

Outline Offset


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

  p {
  margin: 30px;
  padding: 5px;
  border: 1px solid black;
  outline:
  3px solid red;

  outline-offset: 15px;
}

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

  p {
  margin: 30px;
  padding: 5px;
  background:
  yellow;
  border: 1px solid black;
  outline:
  3px solid red;

  outline-offset: 15px;
}

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

  p {
  margin: 30px;
  padding: 5px;
  background:
  yellow;
  border: 1px solid black;
  outline:
  3px solid red;

  outline-offset: -5px;
}

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

Want to go beyond the notes?

Join CodingNow 2.0's CSS course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Outline Offset – FAQs

Quick answers about learning Outline Offset in CSS.

This free note from CodingNow 2.0 explains Outline Offset in CSS — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every CSS topic on CodingNow 2.0, including Outline Offset, is 100% free with no signup required.
With focused practice, most students grasp Outline Offset in 1–3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now