CSS Outline


Previous


Next

An outline is a line drawn outside the element’s border.

Example

<!DOCTYPE html>
<html>
<head>
<style>
p {
border: 2px solid black;
outline: #4CAF50 solid 10px;
margin: auto;
padding: 20px;
text-align: center;
}
</style>
</head>
<body>

<h2>CSS Outline</h2>
<p>This element has a 2px black border and a green outline with a width of 10px.</p>

</body>
</html>

CSS Outline

An outline is a line that is drawn around elements, OUTSIDE the borders, to make the element “stand out”.

CSS has the following outline properties:

  • outline-style
  • outline-color
  • outline-width
  • outline-offset
  • outline

CSS Outline Style

The outline-style property specifies the style of the outline, and can have one of the following values:

  • dotted – Defines a dotted outline
  • dashed – Defines a dashed outline
  • solid – Defines a solid outline
  • double – Defines a double outline
  • groove – Defines a 3D grooved outline
  • ridge – Defines a 3D ridged outline
  • inset – Defines a 3D inset outline
  • outset – Defines a 3D outset outline
  • none – Defines no outline
  • hidden – Defines a hidden outline

The following example shows the different outline-style values:

Example

Demonstration of the different outline styles:

<!DOCTYPE html>
<html>
<head>
<style>
p {outline-color:red;}

p.dotted {outline-style: dotted;}
p.dashed {outline-style: dashed;}
p.solid {outline-style: solid;}
p.double {outline-style: double;}
p.groove {outline-style: groove;}
p.ridge {outline-style: ridge;}
p.inset {outline-style: inset;}
p.outset {outline-style: outset;}
</style>
</head>
<body>

<h2>The outline-style Property</h2>

<p>A dotted outline</p>
<p>A dashed outline</p>
<p>A solid outline</p>
<p>A double outline</p>
<p>A groove outline. The effect depends on the outline-color value.</p>
<p>A ridge outline. The effect depends on the outline-color value.</p>
<p>An inset outline. The effect depends on the outline-color value.</p>
<p>An outset outline. The effect depends on the outline-color value.</p>

</body>
</html>


Previous


Next

Scroll to Top