Outline-color

Outline-color is used to sets the outline color of an element. The color can be set by its name ie., rgb value or a hex value, etc. If absent then the default color will be the current color.

Syntax:

outline-color: <color> | invert | inherit;

Example: This example illustrates the Outline property where the color is set to the specific color value and outline style is solid.

HTML




<!DOCTYPE html>
<html>
<head>
    <style>
    p {
        border: solid orange 4px;
        outline-style: solid;
        outline-color: green;
        text-align: center;
    }
    </style>
</head>
  
<body>
    <h1>w3wiki</h1>
    <h3>Outline Property</h3>
    <p>A Computer Science portal for geeks.</p>
  
</body>
</html>


Output:

CSS Outline

CSS Outline allows drawing a line outside the border of elements. It is used to set all the properties of the outline in a single declaration.

 

 

 

Try It:

Solid Outline
Dotted Outline
Dashed Outline
No Outline
Double Outline
3D Grooved Outline
3D Ridged Outline
3D Outset Outline

Outline:
2px solid

Currently Active Property:

outline: 2px solid; 

Syntax:

selector{
outline: outline-width outline-type outline-color;
/*outline: 2px solid grey;*/
}

Example: This example uses the outline property to create a dashed blue outline.

HTML




<!DOCTYPE html>
<html>
    <head>
        <style>
            .dotted {
                outline: 2px dashed blue;
                color: green;
                text-align: center;
            }
        </style>
    </head>
  
    <body>
        <h1>w3wiki</h1>
        <h3>Outline Property</h3>
        <p class="dotted">
            A Computer Science portal for geeks.
        </p>
    </body>
</html>


Output:

CSS Outline Example output

CSS outline properties can be categorized into 4 types, namely, Outline-style, Outline-color, Outline-width & Outline-offset. We will discuss all the types of outline properties sequentially through the examples.

Similar Reads

CSS Outline Properties

...

Outline-style

...

Outline-color

There are lots of properties comes under the CSS outline collection all of them are well described with the example....

Outline-width

Outline-style It is used to set the appearance of the outline of an element ie., it tells us the style or type of outline. Any other outline property cannot be accessed without setting the outline-style. If absent then the default style will be set to none....

Outline-offset

Outline-color is used to sets the outline color of an element. The color can be set by its name ie., rgb value or a hex value, etc. If absent then the default color will be the current color....