HTML DOM Image align Property
Last Updated :
17 Feb, 2022
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" >
GeeksforGeeks
</ h1 >
< h2 >HTML DOM Image align Property</ h2 >
< img id = "GFG" align = "middle" src =
alt = "GeeksforGeeks logo" >
< br >
< button onclick = "Geeks()" >
Click me!
</ button >
< p id = "sudo" ></ p >
</ center >
< script >
function Geeks() {
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" >
GeeksforGeeks
</ h1 >
< h2 >HTML DOM Image align Property</ h2 >
< img id = "GFG" align = "middle" src =
alt = "GeeksforGeeks logo" >
< br >
< button onclick = "Geeks()" >Click me!</ button >
< p id = "sudo" ></ p >
</ center >
< script >
function Geeks() {
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
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...