Open In App

HTML img alt Attribute

Last Updated : 14 Oct, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

The <img> alt attribute is used to specify alternative text for an image. This attribute is particularly useful when the image cannot be displayed, either due to a broken link or when users rely on screen readers.

Syntax

<img src="image.jpg" alt="text">

Attribute Values

  • The alt attribute contains a single value, which is a text description of the image. This description should succinctly convey the content or function of the image.

Example of img alt Attribute

HTML img alt attribute works only when the image link is broken or the image cannot be displayed, so in this example, we are showing the broken image to so the output of the 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="https://media.geeksforgeeks.org/wp-content/uploads/20190506164011/logo3.png" alt="GeeksforGeeks logo">

</body>

</html>

Output:

 

Supported Browsers:

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

  • Google Chrome
  • Edge 12 and above
  • Internet Explorer
  • Firefox
  • Safari
  • Opera

Next Article

Similar Reads