Get the letter spacing of a <p> element: - Javascript CSS Style Property

Javascript examples for CSS Style Property:letterSpacing

Description

Get the letter spacing of a <p> element:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p id="myP" style="letter-spacing:10px;">This is an example paragraph.</p>

<button type="button" onclick="myFunction()">Return letter spacing of p</button>

<script>
function myFunction() {/*  ww  w.  j  a  v  a 2 s  .  c  om*/
    console.log(document.getElementById("myP").style.letterSpacing);
}
</script>

</body>
</html>

Related Tutorials