Difference between the wordSpacing property and the letterSpacing property: - Javascript CSS Style Property

Javascript examples for CSS Style Property:wordSpacing

Description

Difference between the wordSpacing property and the letterSpacing property:

Demo Code

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

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

</body>
</html>

Related Tutorials