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

Setting Spaces between Letters with CSS letter-spacing Property


Using the CSS letter-spacing property, we can specify the amount of space between letters of text.

Example

The following examples illustrate CSS letter-spacing property.

<!DOCTYPE html>
<html>
<head>
<style>
p:first-of-type {
   margin: 3%;
   padding: 3%;
   background-color: seagreen;
   color: white;
   letter-spacing: 2em;
   font-size: 2em;
   text-align: center;
}
</style>
</head>
<body>
<p>BOOM</p>
<p>BOOM</p>
</body>
</html>

Output

This will produce the following result −

Setting Spaces between Letters with CSS letter-spacing Property

Example

<!DOCTYPE html>
<html>
<head>
<style>
div {
   display: flex;
   margin: 3%;
   padding: 3%;
   border: 23px ridge navy;
}
p {
   margin: 3%;
   background-color: navajowhite;
   letter-spacing: 12px;
   font-size: 1.2em;
   text-align: center;
}
</style>
</head>
<body>
<div>
<p>BOOM</p>
<p>abcdefghijklmnop-qrstuvwxyz</p>
</div>
</body>
</html>

Output

This will produce the following result −

Setting Spaces between Letters with CSS letter-spacing Property