Centered Heading

The first line of this paragraph is indented 10 pixels. This is accomplished by setting the text-indent of the paragraph to 10px. Note that this only affects the first line in the paragraph - subsequent lines are not indented. For paragraphs consisting of more than one line, the default left-justification is the easiets to read.


Right-Justified Heading

Right-justifying a line of text is sometimes effective, but multi-line paragraphs that are right justified tend to look odd.


Centered Heading

A common use of DIV elements is to group together multiple elements, such as a heading and paragraph, and format them together.


Most books, magazines and newspapers justify the text, meaning that spacing is adjusted so that lines align on the right side as well as the left. This can sometimes add a more formal feel to text, but studies suggest that justification can slow people's reading speed.

This entire paragraph is indented 10 pixels. This is accomplished by setting the margin-left of the paragraph to 10px. Note that margin-right is not reset, so the text extends all the way to the right edge of the page.

This entire paragraph is indented 20 pixels on both the left and the right sides. This is accomplished by setting both margin-left and margin-right to 20px. This is a common way of formatting a quotation or excerpt from a book.

This entire paragraph is centered in the page, using only the middle half of the page. This is accomplished by setting both margin-left and margin-right of the paragraph to 25% of the page width. It also uses text-align to justify the text so that both edges are aligned.