Open In App

HTML <img> align Attribute

HTML <img> align attribute is used to set the alignment of an image. It is an inline element. It is used to specify the alignment of the image according to surrounding elements.

Note: The align attribute is not supported by HTML 5. It is now deprecated, HTML 5 uses CSS property instead of this attribute.

Syntax: 

<img align="left | right | center | top | middle | bottom ">

Attribute Values:

HTML img align attribute Examples

Example 1: In this example, we are aligning the image left and right.

<!DOCTYPE html>
<html>

<head>
    <title>
        HTML img align Attribute
    </title>
</head>

<body>
    <h1>
        GeeksforGeeks
    </h1>

    <h2>
        HTML img align Attribute
    </h2>

    <img src=
 "https://media.geeksforgeeks.org/wp-content/uploads/20190506164011/logo3.png" alt="GeeksforGeeks logo"
        align="right">
    <img src=
 "https://media.geeksforgeeks.org/wp-content/uploads/20190506164011/logo3.png" alt="GeeksforGeeks logo"
        align="left">
</body>

</html>

Output: 

Example 2: In this example, we are aligning the image in center.

<!DOCTYPE html>
<html>
    <head>
        <title>HTML img align Attribute</title>
    </head>

    <body>
        <h2>
            HTML img

            <img
                src=
"https://media.geeksforgeeks.org/wp-content/uploads/20190506164011/logo3.png"
                alt="GeeksforGeeks logo"
                align="center"
            />align Attribute
        </h2>
    </body>
</html>

Output:


html-img-align-attribute-example-output

HTML img align center


Supported Browsers:

The browser supported by HTML <img> align Attribute are listed below: 

HTML is the foundation of web pages, 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.

Article Tags :