WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

HTML Paragraphs


HTML can divide a document into paragraphs.


HTML Paragraphs

<p>Tags define paragraphs.

<p>The element automatically creates some white space before and after it. The browser adds these spaces automatically, or you can specify in the style sheet.

Example

<p>This is a paragraph</p>
<p>This is basic paragraph</p>
<p>This is another paragraph</p>
Try it yourself »

HTML output-usage reminder

We cannot determine the exact effect of the HTML being displayed. The size of the screen and the adjustments to the window can all lead to different results.

For HTML, you cannot change the effect of the output by adding extra spaces or line breaks in the HTML code.

When a page is displayed, the browser removes extra spaces and blank lines in the source code. All consecutive spaces or blank lines are counted as one space. Note that all consecutive blank lines (line breaks) in the HTML code are also displayed as a single space.

Example

<p>
This paragraph
contains a ton of lines
in the source code,
but the program
ignores it.
</p>

<p>
This paragraph
contains         a ton of spaces
in the source         code,
but the        program
ignores it.
</p>
Try it Yourself »

You ought not Forget the End Tag

Even if you forget to use the closing tag, most browsers display the HTML correctly:

Example

<p>This is a paragraph
<p>This is a basic paragraph
<p>This is another passage
Try it yourself »

The above example is fine in most browsers, but don't rely on this approach. Forgetting to use end tags can produce unexpected results and errors. Note: Omitting end tags is not allowed in future versions of HTML.


HTML Line Breaks

<br> The label inserts a simple newline character.

<br> The tag is an empty tag, meaning it has no end tag.


Example

<p>This is<br>a para<br>graph with line breaks</p>
Try it yourself »

The <br> component is a vacant HTML component. It has no closure tag.


The Poem Problem

This lyric will show as one line:

Example

<p>
  Dream enormous, and let your energy shine.

  Dream huge, and let your enthusiasm good.

  Dream huge, and let your energy time.

  Dream huge, and let your enthusiasm money.
</p>
Try it Yourself »

The HTML <pre> Element

The HTML <pre> component characterizes preformatted text.

The message inside a <pre> component is shown in a fixed-width text style (more often than not tag), and it jam the two spaces and line breaks:

Example

<pre>
  Dream enormous, and let your enthusiasm shine.

  ream huge, and let your energy good.

  Dream huge, and let your enthusiasm time

  et your energy money.
</pre>
Try it Yourself »