Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <picture>
  
  <!-- widescreen image for wide viewports -->
  <!-- LQIP goes in the srcset; full quality images go in the data-srcset -->
  <source
    srcset="https://o.img.rodeo/c_crop,f_png,ar_16:9/w_16,q_auto/wikipedia-photos/016 16w"
    data-srcset="https://o.img.rodeo/c_crop,ar_16:9/w_500,f_auto,q_auto/wikipedia-photos/016 500w,
                 https://o.img.rodeo/c_crop,ar_16:9/w_1000,f_auto,q_auto/wikipedia-photos/016 1000w,
                 https://o.img.rodeo/c_crop,ar_16:9/w_1500,f_auto,q_auto/wikipedia-photos/016 1500w"
    media="(min-width: 600px)"
    sizes="50vw"
  />
  
  <!-- square-cropped image for narrow viewports -->
  <img
    srcset="https://o.img.rodeo/c_crop,ar_1/w_16,f_png,q_auto/wikipedia-photos/016 16w"
    data-srcset="https://o.img.rodeo/c_crop,ar_1/w_500,f_auto,q_auto/wikipedia-photos/016 500w,
                 https://o.img.rodeo/c_crop,ar_1/w_1000,f_auto,q_auto/wikipedia-photos/016 1000w,
                 https://o.img.rodeo/c_crop,ar_1/w_1500,f_auto,q_auto/wikipedia-photos/016 1500w"
    sizes="50vw"
  />
  
</picture>

              
            
!

CSS

              
                img {
  
  /* the one thing you'll probably want is an extrinsic size on the img, to make sure that the LQIP is always scaled up properly */
  width: 50vw;

/* none of the rest is necessary; just makes the demo a little nicer to look at */
  
  image-rendering: pixelated;
}

body {
  background: #110;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
              
            
!

JS

              
                // swap out the LQIP with the full-quality image in javascript
// there are a bunch of different ways that you could/would-want-to do this... here, I've super-delayed the image load, which you would never want to do in production, but it makes sure that you can *see* the LQIP, for demo purposes

const delay = 4000; // milliseconds
const imgsAndSources = [ ...document.querySelectorAll( 'img, source' ) ];
const timer = setTimeout( () => {
  imgsAndSources.forEach( ( el ) => {
    el.setAttribute( 'srcset', el.getAttribute( 'data-srcset' ) );
  } )
}, delay );
              
            
!
999px

Console