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

JavascriptWeb DevelopmentFront End Scripts

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>
raja
Published on 27-Feb-2018 15:30:10
Advertisements