CodePen

HTML

            
              <article>
<img
     src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/small.png"
     srcset="https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/large.png 1280w,
             https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/medium.png 640w,
             https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/small.png 320w"
     sizes="(min-width: 500px) 50%, 100%"  
     alt="A woman reading">
</article>
            
          
!

CSS

            
              * {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  padding-top: 20px;
}

article {
  margin: 0 auto;
  max-width: 1000px;
}

article img {
  max-width: 100%;
}

.vw-line {
  text-align: center;
}
            
          
!
? ?
? ?
Must be a valid URL.
+ add another resource
via CSS Lint

JS

            
              $("<div />", {
  class: 'vw-line',
  html: "Viewport Width: <span id='vw'></span>"
}).prependTo("body");

var vwDisplay = $("#vw");
$(window).on("resize", function() {
  vwDisplay.text($(this).width());
}).resize();
            
          
!
Must be a valid URL.
+ add another resource
via JS Hint
Loading ..................