Javascript DOM CSS Style letterSpacing Property compare to wordSpacing property

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  ww w.  j  a v  a 2s.c  om*/
  document.getElementById("myP1").style.letterSpacing = "15px";
}

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

</body>
</html>



PreviousNext

Related