Javascript DOM CSS Style wordSpacing Property compare to letterSpacing

Introduction

Difference between the letterSpacing property and the wordSpacing property:

View in separate window

<!DOCTYPE html>
<html>
<body>

<p id="myP1">This is an example paragraph.</p>
<p id="myP2">This is an example paragraph.</p>

<button type="button" onclick="changeLetters()">Set letter spacing</button>
<button type="button" onclick="changeWords()">Set word spacing</button>

<script>
function changeLetters() {//from   w w  w.  ja  v a2 s  . c o  m
  document.getElementById("myP1").style.letterSpacing = "15px";
}

function changeWords() {
  document.getElementById("myP2").style.wordSpacing = "15px";
}
</script>

</body>
</html>



PreviousNext

Related