Pen Settings



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


Babel includes JSX processing.

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


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


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.


                <h1>Trying to polyfill lack of browser support for attr()'s 'url' type-or-unit</h1>

<p>According to (my understanding of) the spec, this CSS should change the content values from <code>attr(data-whatever, url)</code> to <code>url(data-whatever's-value)</code> but it doesn't. This is my attempt to polyfill a simple responsive image solution until browser support catches up with the spec.</p>

<img src="" data-medium="" data-large="">


                @import "compass/css3";

body {
  margin: 0;
  padding: 5%;

code {
  font-size: 0.8em;
  display: inline-block;
  background: #f4f4f4;
  border: 1px solid #ddd;
  padding: 0 2px;

@media (min-width: 31em) {
  img[data-medium] {
    content: attr(data-medium, url);
@media (min-width: 60em) {
  img[data-large] {
    content: attr(data-large, url);
@media (min-width: 75em) {
  img[data-x-large] {
    content: attr(data-x-large, url);



                (function(d, exp, undefined) {
  'use strict';
  function ResponsiveImages(selector) {
    var base = this,
        resize = exp.onresize;
    // bind resize method to 
    // window.onresize
    exp.onresize = function() {
      if (typeof resize === 'function') { 
    this.images = d.querySelectorAll('img');
    this.length = this.images.length;
  ResponsiveImages.prototype.resize = function() {
    if (!this.length || !exp.getComputedStyle) {
    for (var i = 0; i < this.length; i++) {
      var img = this.images[i],
          styles = exp.getComputedStyle(img);
      // always empty.... WHY?! :(
  exp.ResponsiveImages = ResponsiveImages;
}(document, this));

new ResponsiveImages();