Interview Question

What is picture element?

`<picture>` lets the browser choose an image source while `<img>` provides the fallback and alternative text.

💡 Concept ✅ Quick Revision 🌐 HTML

Answer

The `<picture>` element is a container for responsive image sources and one required fallback `<img>`. • Each `<source>` can provide a media condition or image format. • The browser selects the first suitable source and otherwise uses the `<img>` resource. • The fallback `<img>` supplies the image alternative text used for accessibility.

💡 Simple Example

<picture><source media="(min-width: 800px)" srcset="/images/landscape-large.jpg"><img src="/images/landscape-small.jpg" alt="A green valley beneath snowy mountains" width="640" height="360"></picture>

⚡ Quick Revision

`<picture>` lets the browser choose an image source while `<img>` provides the fallback and alternative text.