How to specify the space between lines using pixel values with the line-height attribute with CSS
The below HTML and CSS code example shows you how to specify the space between lines using pixel values with the line-height attribute with CSS.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>this is the title of the web page</title>
<style type="text/css">
</style>
</head>
<body>
<p style="line-height: 20px;">
This paragraph has a line-height of 20px. The default line-height in most web browsers is about 20px.
This paragraph has a line-height of 20px. The default line-height in most web browsers is about 20px.
</p>
<p style="line-height: 10px;">
This paragraph has a line-height of 10px. This paragraph has a line-height of 10px.
This paragraph has a line-height of 10px. This paragraph has a line-height of 10px.
This paragraph has a line-height of 10px. This paragraph has a line-height of 10px.
</p>
<p style="line-height: 60px;">
This paragraph has a line-height of 60px. This paragraph has a line-height of 60px.
This paragraph has a line-height of 60px. This paragraph has a line-height of 60px.
This paragraph has a line-height of 60px. This paragraph has a line-height of 60px.
</p>
</body>
</html>
The XHTML and CSS code above makes the paragraphs below:
This paragraph has a line-height of 20px. The default line-height in most web browsers is about 20px. This paragraph has a line-height of 20px. The default line-height in most web browsers is about 20px.
This paragraph has a line-height of 10px. This paragraph has a line-height of 10px. This paragraph has a line-height of 10px. This paragraph has a line-height of 10px. This paragraph has a line-height of 10px. This paragraph has a line-height of 10px.
This paragraph has a line-height of 60px. This paragraph has a line-height of 60px. This paragraph has a line-height of 60px. This paragraph has a line-height of 60px. This paragraph has a line-height of 60px. This paragraph has a line-height of 60px.
You can use the practice CSS and XHTML editor below to practice setting the line-height of a line with CSS.