HTML | DOM Paragraph align Property
The HTML DOM Paragraph align property is used to set or return the value of the align attribute of a <p> element.
Note: This property is not supported by HTML5
Syntax:
- It returns the paragraph align property.
Pobject.align;
- It sets the paragraph align property.
Pobject.align="left | right | center"
Property Values:
- left: It sets the left-align to horizontal line.
- center: It sets the center-align to horizontal line. It is the default value.
- right: It sets the right-align to horizontal line.
Return Values: It returns a string value which represents the alignment of the paragraph element.
Example 1: This example returns the paragraph align property.
HTML
<!DOCTYPE html> < html > < head > < title > HTML DOM paragraph align property </ title > </ head > < body style = "text-align:center;" > < h1 style = "color:green;" > w3wiki </ h1 > < h2 >DOM paragraph align Property </ h2 > < button onclick = "Beginner()" > Click Here </ button > < p id = "s" align = "left" > A computer science portal for Beginner. </ p > < p id = "Beginner" ></ p > < script > function Beginner() { var txt = document.getElementById("s").align; document.getElementById( "Beginner").innerHTML=txt; } </ script > </ body > </ html > |
Output: Before Clicking on Button:
After Clicking on Button:
Example 2: This example sets the paragraph align property.
HTML
<!DOCTYPE html> < html > < head > < title > HTML DOM paragraph align property </ title > </ head > < body style = "text-align:center;" > < h1 style = "color:green;" > w3wiki </ h1 > < h2 >DOM paragraph align Property</ h2 > < button onclick = "Beginner()" > Click Here </ button > < p id = "s" align = "left" > A computer science portal for Beginner. </ p > < p id = "Beginner" ></ p > < script > function Beginner() { var txt = document.getElementById( "s").align = "right"; document.getElementById( "Beginner").innerHTML = txt; } </ script > </ body > </ html > |
Output: Before Clicking on Button:
After Clicking on Button:
Supported Browsers: The browsers supported by DOM Paragraph align Property are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Apple Safari
- Opera