Another option: You can use the <picture>
element, but it is not yet supported by all browsers.
An example for a border of 1024 pixels of display area width:
css: hide div
with image
@media only screen and (max-width: 1024px) { #n2 { display: none; } }
html: in the source
media query shows a large image with a display area width of 1025 pixels or more, otherwise a small image (preview) is shown from the img
, which is not visible due to the css
rule.
<div id="n1"> <img src="http://jpegshare.net/thumbs/fc/39/fc390b2cebab53f54a4d41e5145a7322.jpg"> </div> <div id="n2"> <picture> <source media="(min-width: 1025px)" srcset="http://jpegshare.net/images/fc/39/fc390b2cebab53f54a4d41e5145a7322.png"> <img src="http://jpegshare.net/thumbs/fc/39/fc390b2cebab53f54a4d41e5145a7322.jpg"> </picture> </div>
PS In browsers that do not support <picture>
, only previews will be shown.