Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

does the <picture> element in html5 make the "alt" attribute obsolete?

Working on a portfolio for a photographer / videographer and trying to find a good balance between fast load and good image quality on mobile devices. So far, I'm keen to bet on the picture element to load multiple versions of the images based on device max width like so:

<picture>    https://stackexchange.com/users/10606791?tab=reputation
  <source media="(max-width: 360px)" 
          srcset="picture_small.jpg">

  <source media="(max-width: 640px)"
          srcset="picture_medium.jpg">

  <source media="(max-width: 1366px)"
          srcset="picture_large.jpg">

  <img src="picture_original.jpg" width="6000" height="4000"
          alt="Really usefull description for each image">
</picture>

My concern is that the "alt" attribute will be ignored all together by user agents for the first 3 versions of the picture and hope of search engines to use it is also a long shot.

like image 650
Nelu Avatar asked Jan 11 '18 13:01

Nelu


People also ask

Why is the alt tag in the image element of HTML is necessary?

The required alt attribute specifies an alternate text for an image, if the image cannot be displayed. The alt attribute provides alternative information for an image if a user for some reason cannot view it (because of slow connection, an error in the src attribute, or if the user uses a screen reader).

What effect does the alt tag have on an image?

Alt tags provide context to what an image is displaying, informing search engine crawlers and allowing them to index an image correctly. However, not only do alt tags help search engine crawlers, not setting alt tags for your images can have a detrimental effect on the ranking of your web pages.

Why is it important to always include an alt attribute for an image?

Alt text provides better image context/descriptions to search engine crawlers, helping them to index and rank an image properly in image search. It also provides search engines with contextual information about the content on the page.

What happens if you do not include the alt attribute in an IMG element?

If no alt attribute is present, the screen reader will read the file name for the image instead, which can be a major distraction to those using screen-reading technology.


1 Answers

The <picture> element is a container only. The <img> element is the main part describing its contents. <source> only describes different sources. So the alt remains the same for all of them.

You cannot have a picture element without an img element. alt is a requirement in <img> and is part of its specification in the standard.

like image 114
Rob Avatar answered Sep 22 '22 08:09

Rob