One of the most significant new features of HTML5.1 is that it is supported by all common browsers. However, the central development of this version is the adaptation of multimedia content for responsive web design. Until now, different images were presented with varying resolution. Despite the fact that the <picture> container was not officially standardized for the introduction of HTML5, web developers were still able to use this element. With the new update, all common browsers now understand the <picture> element: the standardization with the new HTML now makes it official.
The <picture> element is a container that allows users to integrate image files via different source elements. Transfer time is saved and the mobile display of a website is improved as only image sources suitable for the screen size and resolution are loaded. In addition, broadband-friendly, high-resolution displays can also be used to provide alternative content. However, the new <srcset> attribute introduced with HTML 5.1 is also necessary for this: it pairs the images and the different sizes in relation to one another. The following example demonstrates how the finished integration including fallback with <img> can look in the end:
<picture>
<source media="(min-width: 1024px)" srcset="https://www.ionos.com/digitalguidefeuerwehr-1600.jpg">
<source media="(min-width: 480px)" srcset="https://www.ionos.com/digitalguidefeuerwehr-480.jpg">
<!---Fallback---> <img src="https://www.ionos.com/digitalguidefeuerwehr-480.jpg" srcset="https://www.ionos.com/digitalguidefeuerwehr-320.jpg" alt="Feuerwehrfest 2014">
</picture>
To a certain extent, the <picture> element and <srcset> go hand in hand. Even when the newest and most common browsers support both, the fallback element ensures that graphics are also displayed correctly for older browsers. The requirements for screen properties such as width and pixel density are definedwithin the source elements.