Computer >> Computer tutorials >  >> Programming >> CSS

Letter Spacing using CSS


To set space between letters i.e. characters, use the letter-spacing property. Following are the property values −

letter-spacing: normal|length|initial|inherit;

Example

<!DOCTYPE html>
<html>
<head>
<style>
p.demo1 {
   letter-spacing: 1px;
}
p.demo2 {
   letter-spacing: 10px;
}
</style>
</head>
<body>
<h1>Demo Heading</h1>
<h2>Heading2</h2>
<p class="demo1">This is demo text.</p>
<h2>Heading2</h2>
<p class="demo2">This is demo text.</p>
</body>
</html>

Output

Letter Spacing using CSS

Example

Let us now see another example −

<!DOCTYPE html>
<html>
<head>
<style>
p.demo1 {
   letter-spacing: 1cm;
}
p.demo2 {
   letter-spacing: -2px;
}
</style>
</head>
<body>
<h1>Demo Heading</h1>
<h2>Heading2</h2>
<p class="demo1">This is demo text.</p>
<h2>Heading2</h2>
<p class="demo2">This is demo text.</p>
</body>
</html>

Output

Letter Spacing using CSS