HTML Paragraphs

The HTML p tag defines a paragraph.

A paragraph always starts on a new line and ends with a new line, and is usually a block of text.

Paragraph element is used to publish the text or content on the web pages.

Note: Browsers will automatically create some margin (white space) above and below the content of a paragraph.

Example

<p>I am a paragraph.</p>
<p>This is another paragraph.</p>

Output

I am a paragraph.

This is another paragraph.

It is also used for paragraph line spacing and paragraph style, design, bold, indent, paragraph tag attributes and paragraph tag font size, align, new line, paragraph tag without line break, paragraph width, paragraph center.

HTML Display

It's impossible to predict how contents (text or images) are displayed in HTML.

Large or small screens and resized windows will create different displays for the same HTML code.

You cannot change the display by adding extra white spaces or extra blank lines between the text in your HTML code.

Any unnecessary white spaces and blank lines between text are automatically removed by the browser by default.

Example

<p>
This paragraph
contains         a lot      of          white spaces
and                        blank lines

but the        browser
ignores it.
</p>

Output

This paragraph contains a lot of white spaces and blank lines but the browser ignores it.

It is also used for display online and inline block, display none, display image, display text in a box, and display multiline text.

HTML Horizontal Rules

The hr tag (horizontal rule) defines a thematic break between paragraph-level elements in an HTML document and is most often displayed as a horizontal line.

The hr element is used to separate content (or define a change in topic or a change of scene in a story) in an HTML page.

Example

<h1>This is heading 1</h1>
<p>This is some text.</p>
<hr />
<h2>This is heading 2</h2>
<p>This is some other text.</p>
<hr />

Output

This is heading 1

This is some text.


This is heading 2

This is some other text.



The hr tag is an empty tag, which means that it has no end tag /hr

It is also used for horizontal rule element with text, horizontal rule width and height, horizontal rule align left, horizontal rule in table, and horizontal rule html email.

HTML Line Breaks

The HTML br tag is used to insert a line break.

Use br if you want to add a new blank line without starting a new paragraph element.

There are many situations where you can use br tag. For example, you might want a series of fixed short lines such as writing a postal address, writing a poem, and so on.

Example

<p>This is<br />a paragraph<br />with line breaks.</p>
The <br />tag is an empty tag, which means that it has no end tag.

Output

This is
a paragraph
with line breaks.

The
tag is an empty tag, which means that it has no end tag.

It is also used for line breaks without br, line breaks not working, in paragraph, in table cell, in textarea, in title, line breaks not showing, code to line break, how to add multiple line breaks in html, remove line breaks in html.

The HTML <pre> Element

The HTML pre tag defines preformatted text.

The pre tag can be used to display space, tabs, indentation, line breaks, and other elements exactly as they wrote in the HTML file.

It's especially useful when presenting text that requires a lot of white space and line breaks, such as a poem or computer programming code.

Example

<pre>

  My Bonnie lies over the ocean.

  My Bonnie lies over the sea.

  My Bonnie lies over the ocean.

  Oh, bring back my Bonnie to me.

</pre>

Output

  My Bonnie lies over the ocean.

  My Bonnie lies over the sea.

  My Bonnie lies over the ocean.

  Oh, bring back my Bonnie to me.

It is also used for pre element, pre filled input field, pre written codes, pre checked checkbox, pre tag break word, pre tag alternative, pre tag font style, and pre tag not working.