How to set the spacing between words in a text in JavaScript?

JavascriptObject Oriented ProgrammingFront End Technology

Use the wordSpacing property in JavaScript to set the spacing between words.

Example

You can try to run the following code to learn how to implement wordSpacing property −

<!DOCTYPE html>
   <html>
      <body>
         <p id = "pid">This is an example paragraph.</p>
         <button type = "button" id="btn" onclick = "display()">Set Space</button>
         <script>
            function display() {
               document.getElementById("pid").style.wordSpacing = "25px";
            }
         </script>
      </body>
</html>
raja
Published on 27-Feb-2018 10:29:09
Advertisements