Filter (Advanced Search)
Downloads
0
Views
222
Video

Video is not available... Embedded is previous playlist.

Details

The HTML <picture> element allows you to define different images for different browser window sizes.

Resize the browser window to see how the image below changes depending on the width:

 

Show Different Images Depending on Browser Width

Resize the browser width and the image will change at 600px and 1500px.

Flowers

 


<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>

<h2>Show Different Images Depending on Browser Width</h2>
<p>Resize the browser width and the image will change at 600px and 1500px.</p>

<picture>
  <source srcset="/images/computer_lab.jpg" media="(max-width: 600px)">
  <source srcset="/images/cat.jpg" media="(max-width: 1500px)">
  <source srcset="/images/kitten.gif">
  <img src="/images/cat.jpg" alt="cat" style="width:auto;">
</picture>

</body>
</html>



Ad