HTML paragraph HTML
<p> tag is used to define a paragraph in a webpage. It is a Paired Tag, i.e. it comes with an opening
<p> and a closing
<p> tag is very important tag, as all the content written on a website needs to get formatted in the form of paragraphs. Browsers automatically add blank lines above and below a paragraph to seaprate it from other content or othe paragraphs on the page.
HTML Paragraphs are block level elements, i.e., a new paragraph will always start from a new line. Also, Paragraph tags gets automatically closed if another block-element gets parsed before the
Look at the example below, to know how to use
This is First Paragraph
This is Second Paragraph
This is Third Paragraph
If you put a lot of spaces inside the HTML
<p> tag, browser removes extra spaces and extra line while displaying the page. The browser counts number of spaces and lines as a single one.
You can add spaces and new lines on a paragraph by using
<pre> tag but don't practice it immaturely. The spaces will look poor on the website. In the example below, as you can see in the results, all the space is ignored by the browser.
This is First Paragraph.
This is Second Paragraph.
This is Third Paragraph.
<pre> element defines preformatted text. The text inside a
<pre> tag is displayed in a fixed-width font, and it preserves both spaces and line breaks.
<pre> tag is also a paired tag. It can be used when you want to display a certain amount of text with preformatted spaces and line breaks. For example, to display a block of code of a programming language or to display a poem with proper line breaks.
In the example below, you can see that the text is displayed as it is, in the browser, as it was written inside the
This is a Paragraph Tag. This is a Paragraph Tag. This is a Paragraph Tag. This is a Paragraph Tag.