Sponsored Ads
The Html <p> tag is used to create paragraph in Html. <p> tag is the most simple and easily understood tag in Html.
Sponsored Ads
Example
<p>This is a paragraph</p>
<p>Hear is another paragraph</p>
Html Display
You cannot always make sure how browsers display html. Each browsers may display html in different way. Similarly large and small screen devices and resized window will create different results displaying the same document.
Similarly html is not a word processing software. So html don’t have much options for formatting texts. The browsers will strip away continuous spaces and only display a single space.
Also line breaks are ignored browsers. So Creating multi line texts by pressing the enter button won’t work in html.
Example
<p>
This paragraph
contains a lot of lines and spaces
in the source code,
but the browser
ignores it all and display the entire
text only in one line
</p>
Output
Sponsored Ads
Html Line breaks
Line breaks are ignored by browsers. But you can create Line breaks in html using <br> tag. The html <br> tag is a void tag so you don’t need a closing tag. So use the <br> tag if you want to start a new line without creating a paragraph.
Example
<p>This paragraph contains a line break and hence <br>will be printed in multiple lines</p>
Output
This paragraph contains a line break and hence
will be printed in multiple lines
The HTML <pre> Element
Even though Html ignores white space and line breaks there is a method to display line breaks and white spaces in Html. Html <pre> tag is used for this.
The HTML <pre> element defines preformatted text.
The text inside a <pre> element is displayed in a fixed-width font (usually Courier), and it preserves both white spaces and line breaks:
Example:
<pre>
This is a preformatted text
With lots of white spaces and
line breaks. And browsers
preserve the space and
line breaks while displaying
</pre>
Sponsored Ads
The above code will be displayed like this.
This is a preformatted text With lots of white spaces and line breaks. And browsers preserve the space and line breaks while displaying
Sponsored Ads