Course Content
HTML Introduction
0/1
HTML Editors
0/1
HTML Basic Tags
0/1
HTML Elements
0/1
HTML Attributes
0/1
HTML Headings
0/1
HTML Paragraph
0/1
HTML Text Formatting
0/1
HTML Meta Tags
0/1
HTML Quotations
0/1
HTML Comments
0/1
HTML Images
0/1
HTML Background
0/1
HTML Colors
0/1
HTML Lists
0/1
HTML Tables
0/1
HTML Forms
0/1
HTML Spell Check
0/1
HTML Media
0/1
HTML Marquees
0/1
HTML CSS
0/1
HTML Links
0/1
HTML Block & Inline
0/1
HTML Classes
0/1
HTML Id
0/1
HTML I frames
0/1
HTML Java script
0/1
HTML File paths
0/1
HTML Layout
0/1
HTML Responsive
0/1
HTML Computer Code
0/1
HTML Tutorial
About Lesson

HTML Paragraphs

In this tutorial, we will learn about paragraph, horizontal rule, line break rule and pre element in HTML with the help of examples.


Paragraphs

In HTML <p> tag defines the paragraph. HTML paragraphs have both opening and closing tags. So, anything wrap between <p> and </p> element is consider as a paragraph. A paragraph always starts on a new line and is usually a block of text.

  • Almost all browsers read a line as a paragraph even if we don’t use the end tag (</p> tag), but this may occur unexpectedly error. So, we must use the closing tag.
  • Browsers automatically add some space before and after a paragraph which is the margin.
  • If the user adds multiple spaces, the browser reduces them and convert into one single space.
  • If the user adds multiple lines, the browser reduces them and convert it into a single line.

Example :

<!DOCTYPE html>
<html>
  <head>
    <title>HTML Paragraph</title>
  </head>
  <body>
    <p>This is the first paragraph.</p>
    <p>This is the second paragraph.</p>
  </body>
</html>

Output

This is the first paragraph.

This is the second paragraph.


Horizontal Rules

  • The horizontal lines are used to separate the content of a document.
  • The <hr> tag defines a break in an HTML page and is most often displayed as a horizontal line.
  • The <hr> tag is an empty tag and doesn’t have any closing tag.

Example :

<!DOCTYPE html>
<html>
  <head>
    <title>HTML Horizontal Rule</title>
  </head>
  <body>
    <p>This is the first paragraph.</p>
    <hr>
    <p>This is the second paragraph.</p>
  </body>
</html>

Output

This is the first paragraph.


This is the second paragraph.


Line Break Rules

  • The line break rule used to defines a line break in a section of the HTML document.
  • The <br> tag used if you want a line break without starting a new line/paragraph.
  • The <br> tag is an empty tag and doesn’t have any closing tag.

Example :

<!DOCTYPE html>
<html>
  <head>
    <title>HTML Line Break Rule</title>
  </head>
  <body>
    <p>This is the first paragraph.</p>
    <br>
    <p>This is the second paragraph.</p>
  </body>
</html>

Output

This is the first paragraph.

 

This is the second paragraph.


<pre> element

  • HTML <pre> tag defines preformatted text.
  • The <pre> tag display text as written in HTML document.
  • The <pre> tag break all the limitations (like-spaces, line break, etc) of the paragraph tag.
  • It also contains an opening and a closing tag. It displays text within a fixed width-height and preserves the extra lines and whitespaces.

Example :

<!DOCTYPE html>
<html>
  <head>
    <title>HTML Preformatted Tag</title>
  </head>
  <body>
    <pre>This is
            the first
          paragraph.</pre>
    <br>
    <pre>This is the     second <h2>paragraph</h2></pre>
  </body>
</html>

Output

This is
    the first
   paragraph.

 

This is the     second

paragraph

error: Content is protected !!