The HTML <p> align Attribute is used to specify the alignment of paragraph text content. The align attribute in <p> aligns text horizontally.
CSS properties like ‘text-align’ offer precise alignment. It also determines paragraph alignment—left, right, center, or justified.
Note: This tag is Deprecated in HTML5.
Syntax:
<p align="left | right | center | justify">
Attribute Values:
left
|
It sets the text left-align. It is a default value.
|
right
|
It sets the text right-align.
|
center
|
It sets the text center-align.
|
justify
|
It stretch the text of paragraph to set the width of all lines equal.
|
Example:
In this example, we will see the implementation of the <p> align Attribute with an example.
html
<!DOCTYPE html>
< html >
< head >
< title >
HTML p align Attribute
</ title >
</ head >
< style >
body {
font-size: 25px;
}
</ style >
< body >
< h1 style = "color: green;" >
GeeksforGeeks
</ h1 >
< h2 style = "color: crimson;" >
HTML p align Attribute
</ h2 >
< p align = "left" >
Left align content
</ p >
< p align = "center" >
center align content
</ p >
< p align = "right" >
Right align content
</ p >
</ body >
</ html >
|
Output:
Output
Example:
In this example, we will see the implementation of <p> align tag justify with an example.
HTML
<!DOCTYPE html>
< html >
< head >
< title >
HTML p align Attribute
</ title >
</ head >
< style >
body {
font-size: 25px;
}
</ style >
< body >
< h1 >
< p align = "justify" style = "color: green;" >
GeeksforGeeks
</ p >
</ h1 >
< h2 style = "color: crimson;" >
HTML p align Attribute
</ h2 >
< p align = "left" >
Left align content
</ p >
< p align = "center" >
center align content
</ p >
< p align = "right" >
Right align content
</ p >
</ body >
</ html >
|
Output:
Output
Supported Browsers:
- Google Chrome 1 and above
- Microsoft Edge 12 and above
- Firefox 1 and above
- Opera 15 and above
- Safari 1 and above
HTML is the foundation of webpages, is used for webpage development by structuring websites and web apps.You can learn HTML from the ground up by following this HTML Tutorial and HTML Examples.
Last Updated :
22 Dec, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...