Paragraphs in HTML are used to display text elements on a web page. In HTML paragraphs are defined using
Paragraphs in HTML
HTML paragraphs are defined using
<p> tag. The text enclosed in between
</p> acts as a paragraph.
Most browsers recognize a line as a paragraph even if we forget using the closing
</p> tag as the earlier versions of the HTML used to support it.
This is a paragraph.
This is another paragraph.
From the above example you could notice that by default a line space is added before and after a paragraph. This is achieved by the browser by setting up the top and bottom margins automatically for every paragraph.
Properties of Paragraphs
HTML Line Break using <br>
As discussed earlier in the properties of paragraphs in HTML, line breaks can be achieved by using the
with line breaks.
Note that the
<br> tag is an empty tag which means, it doesn’t an end tag.
HTML Preformatted Text using <pre>
Preformatted text in HTML is defined by the
<pre> tag. The text enclosed between a
<pre> and the closing
</pre> tag is usually displayed in a fixed-width/ monospaced font such as Courier New or Consolas and also maintains/ preserves both spaces and line breaks.
Hence, whatever you write inside the
</pre> tags will remain the same with spaces, line breaks and everything.
This is line 1 This is line 2 This is line 3
Text alignment is achieved in HTML using the
align attribute. It allows us to adjust text horizontally left, right or center.
This line is aligned left
This line is aligned right
This line is aligned center