Open In App

HTML | DOM Style outline Property

The Style outline property in HTML DOM is used to set or return all outline properties in one declaration. This property draws a line around an element. It sets or returns the one or more border property in short form. The outline can be set the following properties:

Syntax:



object.style.outline
object.style.outline = "width|style|color|initial|inherit"

Return Values: It returns a string value that represents the outline width, style and/or color of an element

Property Values:



Example 1: Add a thick solid blue outline around the div container. 




<!DOCTYPE html>
<html>
     
<head>
    <title>
        HTML DOM Style outline Property
    </title>
</head>
 
<body>
    <div id = "container">
        <h1>GeeksforGeeks</h1>
         
        <h2>DOM Style outline Property</h2>
    </div>
 
    <script>
        function myGeeks() {
            document.getElementById("container").style.outline
                    = "thick solid blue";
        }
        myGeeks();
    </script>
</body>
 
</html>                   

Output:

  

Example 2: Add a length dashed green outline around the div container. 




<!DOCTYPE html>
<html>
     
<head>
    <title>
        HTML DOM Style outline Property
    </title>
    <style>
    #container {
        border: 3px solid black;
        outline: 3px solid blue;
    }
    </style>
</head>
 
<body>
    <div id = "GFG">
        <h1>GeeksforGeeks</h1>
         
        <h2>DOM Style outline Property</h2>
    </div>
     
    <button onclick = "myGeeks()">
        Click Here!
    </button>
     
    <!-- script to set outline style -->
    <script>
        function myGeeks() {
            document.getElementById("GFG").style.outline
                    = "7px dashed green";
        }
    </script>
</body>
 
</html>                   

Output:

 

 

Supported Browsers: The browser supported by DOM Style outline property are listed below:


Article Tags :