HTML Paragraphs

HTML Paragraph

In HTML, a paragraph is defined by the <p> element. By default, it is a block-level element, which means it usually starts on a new line in the browser.

Example

Run Code
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>

HTML Display

There is a difference in how your text appears on your code editor and on the browser.

The browser will remove all whitespace before displaying it on the screen.

Example

Run Code
<p>
This paragraph
contains a lot of lines
in the source code,
but the browser
ignores it.
</p>

<p>
This paragraph
contains         a lot of spaces
in the source         code,
but the        browser
ignores it.
</p>

HTML Horizontal Rules

In HTML, Horizontal Rules are defined using the <hr> tag.

The <hr> element in html is a void element. So it has no end tag.

The <hr> tag is used to create a horizontal line to separate content.

Example

Run Code
<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>

HTML Line Breaks

In HTML, Line Breaks are defined using the <br> tag.

The <br> element in html is a void element. So it has no end tag.

The <br> tag is used to insert a line break in text.

Example

Run Code
<p>This is<br>a paragraph<br>with line breaks.</p>