Latest web development tutorials

HTML DOM Image align property

Image Object Reference Image Object

Definition and Usage

align property sets or returns align attribute values ​​of the image.

align attribute specifies the alignment of inline content.

grammar

imageObject.align=value

align attribute can have the following values:

描述
left 图像左对齐
right 图像右对齐
middle 图像居中对齐
top 图像顶部对齐
bottom 图像底部对齐


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support align attribute


Examples

Examples

The following example of the image according to the surrounding text will be right-aligned:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function alignImg(){
    document.getElementById("compman").align="right";
}
</script>
</head>
<body>

<img id="compman" src="compman.gif" alt="Computerman" width="107" height="98">
<p>一些文本。一些文本。一些文本。一些文本。一些文本。</p>
<input type="button" onclick="alignImg()" value="图像对齐">

</body>
</html>

try it"


Image Object Reference Image Object