Skip to main content
D
CSS
CSS Outline

CSS Outline

CSS outlines draw a line outside the border.

Read Time
5 min read
Difficulty
Beginner
Last Updated
Jun 15, 2026
Version
v1.0.0

Introduction

CSS draws outlines outside an element's border to make it stand out. Unlike borders, outlines do not take up space or affect the layout of surrounding elements. Browsers use outlines to highlight focused inputs.

Syntax

Syntax
1/* outline syntax */
2input:focus {
3  outline: 2px solid blue;
4}

Example

Example
1/* this draws an outline */
2p {
3  border: 1px solid black;
4  outline: 3px dashed red;
5  outline-offset: 5px;
6}

Key Points

  • Outlines sit completely outside the border.
  • Outlines do not affect the element's physical size.
  • Outlines can overlap other elements.
  • The `outline-offset` property adds space before the outline.

Up Next

Continue your journey with the next topic.

Go to CSS Text