HTML DOM Image align Property
The HTML DOM Image align Property is used to set or return the value of the align attribute of the image element.
Note: This property is no longer supported in HTML5.
Syntax:
It returns the image align property.
Imageobject.align;
It sets the image to align property.
Imageobject.align="left|right|middle|top|bottom"
Property Values:
- left: It sets the Image to the left-align. It is a default value.
- right: It sets the Image to the right-align.
- middle: It sets the Image to the middle.
- top: It sets the Image to the top-align.
- bottom: It sets the Image to the bottom align.
Return Values: It returns a string value that represents the alignment of the Image element.
Example 1: This example returns the Image align property.
HTML
<!DOCTYPE html> < html > < body > < center > < h1 style = "color: green" > w3wiki </ h1 > < h2 >HTML DOM Image align Property</ h2 > < img id = "GFG" align = "middle" src = "https://media.w3wiki.net/wp-content/uploads/20190506164011/logo3.png" alt = "w3wiki logo" > < br > < button onclick = "Beginner()" > Click me! </ button > < p id = "sudo" ></ p > </ center > < script > function Beginner() { var g = document.getElementById("GFG").align; document.getElementById("sudo").innerHTML = g; } </ script > </ body > </ html > |
Output:
Example 2: Below code returns the Image align Property.
HTML
<!DOCTYPE html> < html > < body > < center > < h1 style = "color: green" > w3wiki </ h1 > < h2 >HTML DOM Image align Property</ h2 > < img id = "GFG" align = "middle" src = "https://media.w3wiki.net/wp-content/uploads/20190506164011/logo3.png" alt = "w3wiki logo" > < br > < button onclick = "Beginner()" >Click me!</ button > < p id = "sudo" ></ p > </ center > < script > function Beginner() { var g = document.getElementById("GFG").align = "left"; document.getElementById("sudo").innerHTML = g; } </ script > </ body > </ html > |
Output:
Supported Browsers:
- Google Chrome
- Internet Explorer
- Opera
- Firefox
- Apple Safari