letterSpacing Property - Javascript CSS Style Property

Javascript examples for CSS Style Property:letterSpacing

Description

The letterSpacing property sets or gets the space between characters.

Property Values

Value Description
normal Normal space between characters. This is default
length Defines the space in length units. Negative values are allowed
initial Sets this property to its default value.
inherit Inherits this property from its parent element.

Technical Details

Item Value
Default Value: normal?
Return Value: A String, representing the space between characters in the text
CSS VersionCSS1

Set the space between characters in a <p> element to 15 pixels:

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  av  a  2 s.c  o  m*/
    document.getElementById("myP").style.letterSpacing = '15px';
}
</script>

</body>
</html>

Related Tutorials