/

HTML / CSS / JavaScript Tutorial

CSS Property: letter-spacing

[this page | pdf | back links]

The CSS (CSS1) letter-spacing property identifies the amount of space between consecutive text characters.

 

Valid property values (other than inherit and initial) are:

 

Value

Description

length

Amount of extra space as a CSS length between characters. Can be negative

normal

(default value). No extra space between characters

 

Default Value:

normal

JavaScript syntax:

e.g. object.style.letterSpacing="4px"

Inherited:

Yes

Animatable:

Yes

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
div {width: 200px; border: 1px dotted black;}
.x1 {letter-spacing: 2px;}
</style>
</head>
<body>
Element with default property<br>
<div>abcdefgh</div><br>
Property set using in-file HTML style<br>
<div class="x1">abcdefgh</div><br>
Property set using JavaScript<br>
<div id="x2">abcdefgh</div>

<script>
document.getElementById("x2").style.letterSpacing = "2px";
</script>

</body>
</html>

FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedCSSPropertyLetterSpacing() {
  var x = document.createElement("DIV"); x.style.letterSpacing = "2px 3px"; return (window.getComputedStyle(x, null).letterSpacing == "2px 3px");
}


NAVIGATION LINKS
Contents | Prev | Next | CSS Properties


Desktop view | Switch to Mobile