Pin Me

Denoting Paragraphs in HTML

written by: Ada Stoy•edited by: Michele McDonough•updated: 3/9/2010

One of the first tags a HTML novice learns is

, the paragraph tag. The

tag is used to start a paragraph and if used correctly, your text won't look properly in the browser. Learn how to put a paragraph space in HTML code.

  • slide 1 of 2

    What is a Paragraph in HTML?

    For anyone who is new to HTML, the way paragraphs are recognized in HTML can seem a bit strange. If you have experience with text processing programs, most likely you expect that you press Enter and this is how you tell the program to put a paragraph.

    However, pressing the Enter key doesn't help in HTML. Unlike in word processing programs, in a code-based HTML editor, Enter is not the end of a paragraph. When you press Enter in the HTML code, you just start typing your code/text on a new line but you are still in the same paragraph.

    If you want to tell HTML to end a paragraph and start a new one, you need to use the <P> tag. The <P> tag is the way to make HTML recognize a paragraph. For instance,

    <P>This is a new paragraph.</P>

    displays the “This is a new paragraph." in the browser (without the quotes, of course).

    As most HTML tags, the <P> tag is used for opening a paragraph and the closing tag </P> is used to mark the end of a paragraph. Though you can omit the closing </P> tag, it is recommended not to do it because in some browsers this paragraph might not display properly. Also, since most other tags require a closing paragraph, it is more consistent if you close <P> tags as well.

    When your paragraphs are not properly put, this can cause a lot of issues. For instance, if you use a stylesheet to apply formatting on a paragraph-level and you don't use the <P> tag to mark the beginning of a paragraph but use other gimmicks instead, you will see that your text looks formatted in a way that you don't expect. When you apply paragraph-level formatting, it affects everything between the opening <P> tag and the closing </P> tag (or the next <P> tag, if you don't close the opening <P> tag).

  • slide 2 of 2

    Paragraphs and Line Breaks in HTML

    As in text processing programs, in HTML a paragraph starts on a new line but not every new line is necessarily a separate paragraph. Very often it is necessary to place some text on a new line but keep it with the previous paragraph. In both text processing with Microsoft Word or a similar program and in HTML you can do this with a line break.

    Unlike Microsoft Word, in HTML there is no use in pressing Shift+Enter while in code view. If you are using a visual HTML editor, it might be possible to use Enter to end a paragraph and Shift+Enter to put in a line break, but in HTML source these keys don't help. Instead, you can use the <BR> tag to split a line. The <BR> tag is an exception to all rules because it has no closing counterpart.

    Here is how to use the <BR> tag to put in a line break:

    <P>This is a new paragraph <BR> with a line break.</P>

    The above example will be displayed in the browser like this:

    This is a new paragraph

    with a line break.

    Paragraphs are fundamental to HTML and this is why it is really important to learn how to put paragraph space in HTML. On the other hand, paragraphs are among the easiest concepts in HTML, so it will hardly take you much effort to master them.