Skip to content
Related Articles

Related Articles

Which attribute is used to specify an alternate text for an image, if the image is not loaded properly in HTML ?

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 30 Jan, 2022

In this article, we will discuss the attribute that is used to specify an alternate text for an image, if an image is not loaded properly in HTML.

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.

Syntax:

<img alt="text">

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

Example: The following example demonstrates the <img> alt attribute.

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:

  • When the image source is available:

  • When the image source is not available:

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!