How to set all outline properties in a single declaration with JavaScript?


To set all outline properties in one declaration, use the outline property. It sets the following properties: outline-width, outline-style, and outline-color.

Example

You can try to run the following code to learn how to work with outline properties −

Live Demo

<!DOCTYPE html>
<html>
   <head>
      <style>
         #box {
            border: 2px dashed blue;
         }
      </style>
   </head>
   <body>
      <div id="box">This is a div.</div>
      <br>
      <button type="button" onclick="display()">Click to set Outline</button>
      <script>
         function display() {
            document.getElementById("box").style.outline = "5px solid red";
         }
      </script>
   </body>
</html>

Updated on: 23-Jun-2020

72 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements