Back to CSS Notes
Topic #36

Outline Color

Outline colour lets focus indicators contrast against any background. Choosing visible colours helps keyboard users navigate.


CSS Outline Color

The outline-color property is used to set the color of the outline.

The color can be set by:

  • name - specify a color name, like "red"
  • HEX - specify a hex value, like "#ff0000"
  • RGB - specify a RGB value, like "rgb(255,0,0)"
  • HSL - specify a HSL value, like "hsl(0, 100%, 50%)"
  • invert - performs a color inversion (which ensures that the outline is visible, regardless of color background)

CSS Outline Color Examples

Here are some different outlines with different colors. Also notice that these elements also have a thin black border inside the outline:

A solid red outline.

A dotted blue outline.

An outset green outline.

A solid invert outline.

Example

  p {
  border: 1px solid black;
  padding: 5px;
}

  p.ex1 {
  outline-style: solid;
  outline-color: red;
}

p.ex2 {
  outline-style: dotted;
  outline-color: blue;

  }

p.ex3 {
  outline-style: outset;
  outline-color:
  green;
}

p.ex4 {
  outline-style: solid;

  outline-color: invert;
}

HEX Values

The outline color can also be specified using a hexadecimal value (HEX):

Example

  p.ex1 {
  outline-style: solid;
  outline-color: #ff0000;
  /* red */
}

RGB Values

Or by using RGB values:

Example

  p.ex1 {
  outline-style: solid;
  outline-color: rgb(255, 0, 0); /*
  red */
}

HSL Values

You can also use HSL values:

Example

  p.ex1 {
  outline-style: solid;
  outline-color: hsl(0, 100%, 50%);
  /* red */
}

Note: You can learn more about HEX, RGB and HSL values in our CSS Colors chapters.

Want to go beyond the notes?

Join Coding Now Tech Institute's CSS course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Outline Color – FAQs

Quick answers about learning Outline Color in CSS.

This free note from Coding Now Tech Institute explains Outline Color in CSS — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every CSS topic on Coding Now Tech Institute, including Outline Color, is 100% free with no signup required.
With focused practice, most students grasp Outline Color in 1–3 days from these notes; pairing it with Coding Now Tech Institute'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 Coding Now Tech Institute Community (/community) — expert instructors answer within 24 hours.
Call NowEnroll Now