HTML Paragraph

In addition to heading text, paragraphs are used to give an organized and segmented look to a web page. By default when a browser encounters special characters like space, line feed and carriage return in a web page it compresses each of these characters into single spaces. Because of this behavior of a browser even if you give a break in the content text it automatically appears as one single paragraph unless broken by a special tag called HTML paragraph tag.

To divide a web page into multiple paragraphs HTML paragraph tag is used to break the wall of text into smaller units. When the browser encounters a <P> tag in an HTML document a blank line is added before and after the text enclosed in <P></P> tag.

Features of HTML Paragraph Tag

  • HTML Paragraph Tag is a paired tag.
  • Ending </P> tag is optional. When browser encounters next <P> in the HTML document, it automatically assumes a </P> tag before it and starts a new paragraph.
  • Attributes can be used in the <P> tag to control look of individual paragraphs.
  • Text formatting tags can be included in between the HTML paragraph tags.

Attributes with <P></P>  

ALIGN

Align attributes is used to align the text of the paragraph. Paragraph text can be aligned to left, center or right. The values allowed for the ALIGN attribute are LEFT, RIGHT and CENTER. The paragraph text will appear LEFT aligned by default.

ID

This attribute is used to give identification to a paragraph element created with <P></P> tag. The ID must be an alphanumeric string. The ID value for each element of web page must be unique. This ID is used in a script to manipulate it on the basis of interaction of the user.

CLASS

This attribute is used to associate a paragraph with a class defined in a style sheet associated with the page or website. The style sheet element specifies the consistent style for multiple elements in a web page.

STYLE

Style attribute is used to add additional styling to a paragraph you can do with this attribute. You can set styles in a string form with CSS element and value pairs separated by semicolons.

TITLE

Title attribute is used to set tooltip text for a paragraph. When the user rests the mouse cursor on the paragraph text, a value assigned to TITLE attribute appears in a small outlined box.

DIR

DIR defines the direction of the non aligned text of a paragraph. Possible values are LTR for left to right or RTL for right to left.

Example HTML Paragraph Tag

<TITLE> Welcome to CSVeda.com </TITLE>
<HTML>
<P>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut 
labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
 nisi ut aliquip ex ea commodo consequat. </P>
<P ALIGN="RIGHT">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut 
labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
 nisi ut aliquip ex ea commodo consequat. </P>
<P ALIGN="CENTER">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut 
labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
 nisi ut aliquip ex ea commodo consequat. </P>
<P TITLE="Paragraph manipulated with title Attribute">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut 
labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
 nisi ut aliquip ex ea commodo consequat. 
</P>
<P DIR="LTR">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut 
labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
 nisi ut aliquip ex ea commodo consequat. </P>
<P DIR="RTL">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut 
labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
 nisi ut aliquip ex ea commodo consequat. </P>
<P STYLE="font-size:20px;font-family:Verdana; color:Purple; ">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut 
labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
 nisi ut aliquip ex ea commodo consequat. </P>
</HTML>
HTML Paragraph Tag