Atrybut HTML <img> alt

❮ Znacznik HTML <img>

Przykład

Obraz z podanym tekstem alternatywnym:

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

Definicja i użycie

Wymagany altatrybut określa tekst alternatywny dla obrazu, jeśli obrazu nie można wyświetlić.

Atrybut zapewnia alternatywne informacje dla obrazu, jeśli użytkownik z altjakiegoś powodu nie może go wyświetlić (z powodu wolnego połączenia, błędu w srcatrybucie lub jeśli użytkownik korzysta z czytnika ekranu).

Wskazówka: Aby utworzyć podpowiedź dla obrazu, użyj titleatrybutu!


Obsługa przeglądarki

Attribute
alt Yes Yes Yes Yes Yes

Składnia

<img alt="text">

Wartości atrybutów

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

❮ Znacznik HTML <img>