HTML <img> alt属性

❮HTML<img>タグ

代替テキストが指定された画像:

<img src="img_girl.jpg" alt="Girl in a jacket" width="500" height="600">

定義と使用法

必須alt属性は、画像を表示できない場合に、画像の代替テキストを指定します。

この属性は、ユーザーが何らかの理由で画像を表示できない場合(接続が遅い、属性にエラーがあるため、またはユーザーがスクリーンリーダーを使用している場合)altに、画像の代替情報を提供します。src

ヒント:画像のツールチップを作成するには、title属性を使用します。


ブラウザのサポート

Attribute
alt Yes Yes Yes Yes Yes

構文

<img alt="text">

属性値

Value Description
text Specifies an alternate text for an image.

Guidelines for the alt text:

  • The text should describe the image if the image contains information
  • The text should explain where the link goes if the image is inside an <a> element
  • Use alt="" if the image is only for decoration

❮HTML<img>タグ