HTML PARAGRAPHS

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

Paragraphs are defined with the <p> tag. Paragraph tag is a very basic and typically the first tag you will need to publish your text on the web pages. Here’s an example:

<p>This is a paragraph</p>
<p>This is a second paragraph</p>

[su_label type=”info”]RESULT[/su_label]

Closing a Paragraph Element

In HTML 4 and earlier versions, it was enough to initiate a new paragraph using the opening tag. Most browsers will display HTML correctly even if you forget the end tag. For example:

<p>This is an open paragraph.
<p>This is another open paragraph
creating line breaks

[su_label type=”info”]RESULT[/su_label]

The <br> tag is used to insert a line break on the web page.

Since the <br> is an empty element, so there is no need of corresponding </br> tag.

<p>contains some text <br> with line break</p>
<p>Another paragraph <br>this one here <br> with a line break</p>

[su_label type=”info”]RESULT[/su_label]

Creating Horizontal Rules

You can use the <hr> tag to create horizontal rules or lines to visually separate content sections on a web page. Like <br>, the <hr> tag is also an empty element. Here’s an example:

<p>Just a text paragraph</p>
<hr>
<p>Another test paragraph</p>

[su_label type=”info”]RESULT[/su_label]

Managing White Spaces

Normally the browser will display the multiple spaces created inside the HTML code by pressing the space-bar key or tab key on the keyboard as a single space. Multiple line breaks created inside the HTML code through pressing the enter key is also displayed as a single space.

The following paragraphs will be displayed in a single line without any extra space:

<p>There are   multiple     spaces    in this      paragraph</p>
<p>
    There are
    three lines on this
    particular paragraph.
</p>

[su_label type=”info”]RESULT[/su_label]

Insert   for creating extra consecutive spaces, while insert <br> tag for creating line breaks on your web pages, as demonstrated in the following example:

<p>This is an example of multiple&NBSP;&NBSP;&NBSP;spaces.</p>
<p>An example of multiple<br><br>line<br><br><br>breaks.</p>

Defining Pre formatted Text

Sometimes, using &nbsp;<br>, etc. for managing spaces isn’t very convenient. Alternatively, you can use the <pre> tag to display spaces, tabs, line breaks, etc. exactly as written in the HTML file. It is very helpful in presenting text where spaces and line breaks are important like poem or code.

The following example will display the text in the browser as it is in the source code:

<pre>
    TWINKLE, TWINKLE, LITTLE STAR, 
    HOW I WONDER WHAT YOU ARE! 
    UP ABOVE THE WORLD SO HIGH, 
    LIKE A DIAMOND IN THE SKY.
</pre>

[su_label type=”info”]RESULT[/su_label]