CSS Dimension Code Tutorials

CSS dimension properties allow you to control the height and width of an HTML element. It also allows you to control the spacing between 2 lines.

How to set the spacing between lines using a percent value

<!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">
p.small {line-height: 100%;}
p.big {line-height: 200%;}
</style>

</head>
<body>
<p>
The default line height in most browsers is about 110% to 120%. This is a paragraph with a standard line-height. This is a paragraph with a standard line-height. This is a paragraph with a standard line-height. This is a paragraph with a standard line-height. This is a paragraph with a standard line-height. This is a paragraph with a standard line-height.
</p>
<p class="small">
This paragraph has a line-height of 100%. This paragraph has a line-height of 100%. This paragraph has a line-height of 100%. This paragraph has a line-height of 100%. This paragraph has a line-height of 100%. This paragraph has a line-height of 100%.
</p>
<p class="big">
This paragraph has a line-height of 200%. This paragraph has a line-height of 200%. This paragraph has a line-height of 200%. This paragraph has a line-height of 200%. This paragraph has a line-height of 200%. This paragraph has a line-height of 200%.
</p>
</body>
</html>

The above XHTML and CSS code produces the images below:

The default line height in most browsers is about 110% to 120%. This is a paragraph with a standard line-height. This is a paragraph with a standard line-height. This is a paragraph with a standard line-height. This is a paragraph with a standard line-height. This is a paragraph with a standard line-height. This is a paragraph with a standard line-height.

This paragraph has a line-height of 100%. This paragraph has a line-height of 100%. This paragraph has a line-height of 100%. This paragraph has a line-height of 100%. This paragraph has a line-height of 100%. This paragraph has a line-height of 100%.

This paragraph has a line-height of 200%. This paragraph has a line-height of 200%. This paragraph has a line-height of 200%. This paragraph has a line-height of 200%. This paragraph has a line-height of 200%. This paragraph has a line-height of 200%.

Use the CSS and XHTML editor below to practice making paragraphs with different line-heights.