Skip to content
Related Articles

Related Articles

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

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 02 Feb, 2022

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:

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:

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!