How to set the column rule properties with JavaScript?


The columnRule property is used in JavaScript to set the column rule. It allows you to set the style, color, and width between column rule.

Example

You can try to run the following code to set the column rule properties with JavaScript −

Live Demo

<!DOCTYPE html>
<html>
   <body>
      <p>Click below to create 4 columns</p>
      <button onclick="display()">Columns</button>
      <div id="myID">
         This is demo text. This is demo text. This is demo text. This is demo text.
         This is demo text. This is demo text. This is demo text. This is demo text.
         This is demo text. This is demo text. This is demo text. This is demo text.
         This is demo text. This is demo text. This is demo text. This is demo text.
         This is demo text. This is demo text. This is demo text. This is demo text.
         This is demo text. This is demo text. This is demo text. This is demo text.
         This is demo text. This is demo text. This is demo text. This is demo text.
      </div>
      <script>
         function display() {
            document.getElementById("myID").style.columnCount = "4";
            document.getElementById("myID").style.columnRule = "2px outset red";
         }
      </script>
   </body>
</html>

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 23-Jun-2020

107 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements