Open In App

CSS outline-offset Property

The CSS outline-offset Property sets the amount of space between an outline and the edge or border of an element. An outline is a line drawn around elements outside the border edge. The space between the element and its outline is transparent. Also, the outline may be non-rectangular. The default value is 0. 

Syntax:



outline-offset: length|initial|inherit;

Property values:

Syntax:



outline-offset: 5px;

Example 1: 




<!DOCTYPE html>
<html>
<head>
    <title>
        outline-offset Property
    </title>
    <style>
        div {
            margin: 30px;
            border: 2px solid blue;
            background-color: yellow;
            outline: 4px dashed red;
            outline-offset: 15px;
        }
    </style>
</head>
 
<body>
    <div >GeeksForGeeks</div>
    <br>
</body>
</html>

Output:

  

Example 2: 




<!DOCTYPE html>
<html>
<head>
    <title>
        outline-offset Property
    </title>
    <style>
        div {
            margin: 10px;
            border: 2px solid red;
            background-color: blue;
            outline: 4px solid black;
            outline-offset: 5px;
        }
    </style>
</head>
 
<body>
    <div >GeeksForGeeks</div>
    <br>
</body>
</html>

syntax:

outline-offset: initial;

Example 3: 




<!DOCTYPE html>
<html>
 
<head>
    <title>
        outline-offset Property
    </title>
    <style>
        div {
            margin: 30px;
            border: 2px solid blue;
            background-color: yellow;
            outline: 4px dashed red;
            outline-offset: initial;
        }
    </style>
</head>
 
<body>
    <div>GeeksForGeeks</div>
    <br>
</body>
 
</html>

syntax:

outline-offset: inherit;

Supported Browsers: The browsers supported by outline-offset Property are listed below:


Article Tags :