</> Code Corner

CSS · CSS Tutorial · Lesson 13

CSS Outline

A line drawn outside the border.

An outline is a line drawn outside the element's border, to make it "stand out". Unlike borders, outlines do not take up space and may overlap other content.

Example

<style>
p { border: 2px solid black; padding: 8px; }
.o1 { outline: 3px dashed tomato; }
.o2 { outline: 4px solid dodgerblue; outline-offset: 6px; }
</style>
<p class="o1">Dashed outline</p>
<p class="o2">Outline with offset</p>
Tip: Browsers show an outline on focused links and inputs. Do not remove it without providing another visible focus style — keyboard users depend on it.

Keep reading “CSS Outline”

Sign up to read the full lesson, try every example in the live editor, and take the 5-question quiz.

Chat with us 👋