The code below shows you how to specify the line-height of a paragraph using a pixel value 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>Web Development Tutorials.com</title>
<style type="text/css">
p.one
{
line-height: 10px;
}
p.two
{
line-height: 40px;
}
</style>
</head>
<body>
<p>
The default line-height in most web browsers is 20 px. The line-height of this paragraph is 20px.
The default line-height in most web browsers is 20 px. The line-height of this paragraph is 20px.
The default line-height in most web browsers is 20 px. The line-height of this paragraph is 20px.
</p>
<p>
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>
This paragraph has a line-height of 40px. This paragraph has a line-height of 40px.
This paragraph has a line-height of 40px. This paragraph has a line-height of 40px.
This paragraph has a line-height of 40px. This paragraph has a line-height of 40px.
</p>
</body>
</html>
The code above creates the images below.
The default line-height in most web browsers is 20 px. The line-height of this paragraph is 20px. The default line-height in most web browsers is 20 px. The line-height of this paragraph is 20px. The default line-height in most web browsers is 20 px. The line-height of this paragraph is 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 40px. This paragraph has a line-height of 40px. This paragraph has a line-height of 40px. This paragraph has a line-height of 40px. This paragraph has a line-height of 40px. This paragraph has a line-height of 40px.
Use the text editor below to practice what you have learned.