Open In App

Describe the purpose of using alt attribute in <img> tag in HTML

Last Updated : 07 Jun, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

The <img> alt attribute is used to specify the alternate text for an image. It is useful when the image is not displayed. It is used to give alternative information for an image. It is also very much helpful in the Google ranking of your page.

In this article, we will discuss the alt attribute in the <img> tag.

Syntax:

<img alt="text">

Attribute Values: It contains single value text which specifies the alternative text for an image.

Example: In this example, we will use the alt attribute of the img tag.

HTML




<!DOCTYPE html>
<html>
<head>
    <title>
        HTML img alt Attribute
    </title>
</head>
<body>
    <h1>GeeksforGeeks</h1>
    <h2>HTML img alt Attribute</h2>
    <img src=
         alt="GeeksforGeeks logo">
</body>
</html>


Output:


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads