HTML | Paragraph

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.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>

chevron_right


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.

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output :

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

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>

chevron_right


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 –>.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>

chevron_right


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.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>

chevron_right


Output :



My Personal Notes arrow_drop_up

I am a technology enthusiast who has a keen interest in programming I am pursuing Engineering in Computer Science from GEU, Dehradun I like to unwind by watching movies and English sitcomsI have a keen interest in music

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.