How to specify an alternate text for an image in HTML ?

The alternative text for an image is useful when the image not displayed/loaded. If the image is not loaded the its alternative text is displayed on the web page. Alternative text is the alternative information for an image.

Example 1: In this example, the image path contains the image so it will display the image.

HTML

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html> 
<html
  
<head
    <title
        How to specify an alternate 
        text for an image? 
    </title
</head
  
<body
    <h1 style="color:green;">GeeksforGeeks</h1
  
    <h2>
        How to specify an alternate 
        text for an image?
    </h2
  
    <img src
        alt="GeeksforGeeks logo"
</body
  
</html>

chevron_right


Output:

Example 2: In this example, the image path is not correct so it will display alternative text information.



HTML

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html> 
<html
  
<head
    <title
        How to specify an alternate 
        text for an image? 
    </title
</head
  
<body
    <h1 style="color:green;">GeeksforGeeks</h1
  
    <h2>
        How to specify an alternate 
        text for an image?
    </h2
  
    <img src= "geeks.png"
        alt="GeeksforGeeks logo"
</body
  
</html>

chevron_right


Output:

full-stack-img




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.