Indents - HTML

Occasionally, you will want to indent the first line of paragraphs in your documents. To do so, you can use the text-indent property of the paragraph tag and an applicable style. For example, if you wanted the first line of all paragraphs to be indented by half an inch, you would use a style similar to the following:

Tip

If you want to have different styles of paragraphs in your document—some indented, some not indented—define your style using classes. For example, the following code defines an indent style of the paragraph tag:

You would then specify the class in any paragraph tag where you wanted the indent:

An example of indenting the first line of paragraphs is shown in the following code and its output in Figure:

Using styles, you can control the indentation of paragraphs.

Using styles, you can control the indentation of paragraphs.

If you want to indent an entire paragraph, use the padding-left and, optionally, the padding-right attribute. These attributes add additional space to the left and right of the block element. For example, to add a half-inch indent to the left of a paragraph, you could use this style definition:

Tip

You can use the <blockquote> tag to easily indent a paragraph (both left and right). However, this method doesn’t allow the type of control possible in defining a special style for elements you wish indented.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

HTML Topics