How to align text to the left, center or right with CSS
The below HTML and CSS code example shows you how to align text to the left, center or right 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="text-align: right;">
This text is aligned to the right.
</p>
<p style="text-align: center;">
This text is aligned to the center.
</p>
<p style="text-align: left;">
This text is aligned to the left.
</p>
</body>
</html>
The above HTML and CSS code makes the paragraphs below.
This text is aligned to the right.
This text is aligned to the center.
This text is aligned to the left.
Use the text editor below to practice controlling the line-height of a paragraph.