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

Word Spacing using CSS


To set spacing between words, use the word-spacing property. The property values are as follows −

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

Example

Let us now see an example −

<!DOCTYPE html>
<html>
<head>
<style>
p.demo1 {
   word-spacing: normal;
}
p.demo2 {
   word-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

Word Spacing using CSS

Example

Let us now see another example −

<!DOCTYPE html>
<html>
<head>
<style>
p.demo1 {
   word-spacing: 3cm;
}
p.demo2 {
   word-spacing: 40px;
}
</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

Word Spacing using CSS