Skip to content
Related Articles

Related Articles

HTML | Paragraph
  • Last Updated : 14 Dec, 2017

There are many reasons why we should publish text in paragraphs such as short paragraphs attract more readers, it filters the information and help in driving a point.

So due to the following benefits of publishing text in paragraphs, HTML also has a tag for the same purpose. The <p> tag is used to define paragraphs. It is one of the most basic tags that a person requires to publish a text on a webpage. The text to be published in a paragraph is written between the opening <p> and closing </p> tag.




<!DOCTYPE html>
<html>
<body>
  
<p>This is the first paragraph.</p>
<p>This is the second paragraph.</p>
<p>This is the third paragraph.</p>
  
</body>
</html>


Output :

Closing the Paragraph Element :
In HTML 4 and earlier versions, closing the paragraph tag wasn’t compulsory. A paragraph could be initiated by just using a new paragraph opening tag.




<!DOCTYPE html>
<html>
<body>
  
<p>This is the first paragraph.
<p>This is the second paragraph.
<p>This is the third paragraph.
  
</body>
</html>


Output :



Line Breaks in Paragraph :
The <br> tag which stands for a break is used to insert a line break without changing the paragraph.




<!DOCTYPE html>
<html>
<body>
  
<p>This is the first<br> paragraph<br>
                 with two line breaks.</p>
<p>This is the second <br> paragraph<br>
             with three<br>line breaks.</p
  
</body>
</html>


Output :

Comments in HTML :
Comments are added to provide extra information which helps in understanding the source code. It usually helps the developer in the future when he thinks of modifying the source code. Comments are not displayed in the output screen.
An HTML comment begins with <!– and ends with –>.




<!DOCTYPE html>
<html>
<body>
 <!-- this is an HTML comment -->
 <p>This is the first<br> paragraph<br>
                   with two line breaks.</p>
    <!-- Beginning of second paragraph -->
<p>This is the second <br> paragraph<br>
               with three<br>line breaks.</p
  
</body>
</html>


Output :

The PRE Element in HTML :
The <pre> tag defines preformatted text. The pre tag preserves both spaces and line breaks which are present in the text enclosed between the pre tags.




<!DOCTYPE html>
<html>
<body>
  
<h3>Twinkle Twinkle Little Star</h3>
  
<pre>
Twinkle, twinkle, little star
  
How I wonder what you are
  
Up above the world so high
  
Like a diamond in the sky
</pre>
  
</body>
</html>


Output :

full-stack-img

My Personal Notes arrow_drop_up
Recommended Articles
Page :