Paragraph

Knowledge | HTML Tutorial


Definition and Usage

The <p> tag defines a paragraph.

Browsers automatically add some space (margin) before and after each <p> element. The margins can be modified with CSS (with the margin properties).

Optional Attributes
DTD indicates in which HTML 4.01/XHTML 1.0 DTD the attribute is allowed. S=Strict, T=Transitional, and F=Frameset.

align 	left              Deprecated. Use styles instead.
        right             Specifies the alignment of the text within a paragraph
        center
        justify 	
                        

Standard Attributes
The <p> tag supports the following standard attributes:

Attribute 	Value 	         Description 	                                                DTD
class 	        classname 	 Specifies a classname for an element 	                        STF
dir 	        rtl              Specifies the text direction for the content in an             STF
                ltr 	         element 	
id 	        id 	         Specifies a unique id for an element 	                        STF
lang 	        language_code 	 Specifies a language code for the content in an element 	STF
style 	        style_definition Specifies an inline style for an element 	                STF
title 	        text 	         Specifies extra information about an element 	                STF
xml:lang 	language_code 	 Specifies a language code for the content in an element,   	                 documents in XHTML                                             STF

Examples:
Code

<html>
<body>

<p>
This paragraph
contains a lot of lines
in the source code,
but the browser 
ignores it.
</p>

<p>
This paragraph
contains      a lot of spaces
in the source     code,
but the    browser 
ignores it.
</p>

<p>
The number of lines in a paragraph depends on the size of your browser window. If you resize the browser window, the number of lines in this paragraph will change.
</p>

</body>
</html>

Result:

This paragraph contains a lot of lines in the source code, but the browser ignores it.

This paragraph contains a lot of spaces in the source code, but the browser ignores it.

The number of lines in a paragraph depends on the size of your browser window. If you resize the browser window, the number of lines in this paragraph will change. 

Using align Attribute:

<p align="justify">
If you have invested your time and money to design a website
 you need dependable web hosting services to remain profitable.
You need it to be up, 24/7, unlike your company’s physical front
 door customers will come to your website at any hour, day or night
 and you’ve got to be ready for them. We help businesses to manage 
the infrastructure, security, support and maintenance of a mission
 critical website. Additionally, all our hosting packages are 
built-in with cross devices and platforms compatible technologies,
 what this means is that your professional site will be properly 
display on any device regardless whether is a desktop, a mac, a tablet, 
an iPad, a smart phone, and an iPhone, it will always be displayed
 with the same professionally look and feel no matter what you or your potentials will use.
</p>

Result:

If you have invested your time and money to design a website you need dependable web hosting services to remain profitable. You need it to be up, 24/7, unlike your company’s physical front door customers will come to your website at any hour, day or night and you’ve got to be ready for them. We help businesses to manage the infrastructure, security, support and maintenance of a mission critical website. Additionally, all our hosting packages are built-in with cross devices and platforms compatible technologies, what this means is that your professional site will be properly display on any device regardless whether is a desktop, a mac, a tablet, an iPad, a smart phone, and an iPhone, it will always be displayed with the same professionally look and feel no matter what you or your potentials will use.

Other ways to work with paragraph

The HTML Tag Should NOT be Used
The tag is deprecated in HTML 4, and removed from HTML5.
The World Wide Web Consortium (W3C) has removed the tag from its recommendations.
In HTML 4, style sheets (CSS) should be used to define the layout and display properties for many HTML elements.
The example below shows how the HTML could look by using the tag:

<html>
<body style="background-color:PowderBlue;">

<h1>Look! Styles and colors</h1>

<p style="font-family:verdana;color:red;">
This text is in Verdana and red</p>

<p style="font-family:times;color:green;">
This text is in Times and green</p>

<p style="font-size:30px;">This text is 30 pixels high</p>

</body>
</html>

Result:

<html>
<body style="background-color:yellow;">
<h2 style="background-color:red;">This is a heading</h2>
<p style="background-color:green;">This is a paragraph.</p>
</body>
</html>

Result:

<html>
<body>

<p>
<font size="5" face="arial" color="red">
This paragraph is in Arial, size 5, and in red text color.
</font>
</p>

<p>
<font size="3" face="verdana" color="blue">
This paragraph is in Verdana, size 3, and in blue text color.
</font>
</p>

<p>The font element is deprecated in HTML 4. Use CSS instead!</p>

</body>
</html>

Result:

Related Articles