Bootstrap 5 Picture is used to add more than one source to an image component in a webpage. This tag works the same as in normal HTML but we can use the BootStrap utilities and components with it. This is really useful to make responsive designs without using traditional techniques.
To use this, we have to add a default image tag and we can add no or multiple sources of different or even the same image. The <picture> element is used to specify multiple <source> elements for a specific <img>. Add the .img-* classes to the <img> and not to the <picture> tag.
Bootstrap5 Images Picture Class: There is no predefined class for this but you should use the .img-* class to obtain responsiveness, we can use Bootstrap 5 Responsive images to the source element tags.
Syntax:
<picture> <source srcset="https://www.geeksforgeeks.org/bootstrap-5-images-picture/..." type="image/svg+xml"> <img src="https://www.geeksforgeeks.org/bootstrap-5-images-picture/..." class="img-fluid" alt="https://www.geeksforgeeks.org/bootstrap-5-images-picture/..."> </picture>
There are no certain used classes as such in this implementation.
Example 1: The code below demonstrates how we can add multiple images of different resolutions to make it responsive as per the viewport size using the source and img tag inside the picture tag.
Output:
Example 2: The code below demonstrates how we can add multiple different images as per the viewport size using the source and img tag inside the picture tag.
Output:
Reference: https://getbootstrap.com/docs/5.0/content/images/#picture
Stay connected with us on social media platform for instant update click here to join our Twitter, & Facebook We are now on Telegram. Click here to join our channel (@TechiUpdate) and stay updated with the latest Technology headlines. For all the latest Technology News Click Here