Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

8.1. Indenting Paragraphs

You can indent any paragraph-level element in HTML. Such elements include regular paragraphs, list items, definitions, quotations, and headings. Indenting is the process of offsetting text from its usual position, either to the right or to the left. You can apply three types of indentation in HTML:

  • First-line indent This indents only the first line of a paragraph. Use the text-indent attribute. For in-line styling of a single paragraph, specify this style:

    <p style="text-indent: 20px">

    In a style sheet, specify a rule similar to this:

    p {text-indent: 20px}

  • Padding This adds a specified amount of space between the border of an element and its contents (inside of the element). It applies equally to all lines of text in the paragraph. Use the padding attribute to create this space. For in-line styling of a single paragraph, specify this style:

    <p style="padding: 20px">

    In a style sheet, specify a rule like this:

    p {padding: 20px}

  • Margin This adds a specified amount of white space around an element, on the outside of the element. It applies equally to all lines of text in the paragraph. Use the margin attribute to create this space. For a single paragraph, specify this style:

    <p style="margin: 20px">

    In a style sheet, specify the following rule:

    p {margin: 20px}


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint