📜  如何为 HTML 中的图像指定替代文本?

📅  最后修改于: 2021-11-08 02:19:38             🧑  作者: Mango

当图像未显示/加载时,图像的替代文本很有用。如果图像未加载,则其替代文本将显示在网页上。替代文本是图像的替代信息。

示例 1:在此示例中,图像路径包含图像,因此它将显示图像。

HTML
 
 
  
 
     
        How to specify an alternate 
        text for an image? 
     
 
  
 
    

GeeksforGeeks

         

        How to specify an alternate          text for an image?     

               


HTML
 
 
  
 
     
        How to specify an alternate 
        text for an image? 
     
 
  
 
    

GeeksforGeeks

         

        How to specify an alternate          text for an image?     

               


输出:

示例 2:在此示例中,图像路径不正确,因此将显示替代文本信息。

HTML

 
 
  
 
     
        How to specify an alternate 
        text for an image? 
     
 
  
 
    

GeeksforGeeks

         

        How to specify an alternate          text for an image?     

               

输出: