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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

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

Packages

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.

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

              
                %h1 Accessible Responsive Background-Image Test
%h2 How can we communicate the role of images as css backgrounds?
%p Use cases:
%ul
  %li Responsive assets: preventing resources from loading on mobile using media queries
  %li Taking advantage of css background properties
  %li Scaling and cropping css background images
%ol
  %li
    %p Default: Img with alt attribute
    %h3 Beaker
  %img{'src'=>'http://img4.wikia.nocookie.net/__cb20101015151246/muppet/images/0/05/Beaker.jpg', 'alt'=>'Beaker'}
  %li
    %p div with scalable background, role='img' and alt attribute
    %h3 Animal
    %div.image
      %div{'id'=>'img1', 'role'=>'img', 'aria-label'=>"Animal's smiling face", 'style'=>'background-image: url(http://www.thelocalq.com/blogs/searchlights/wp-content/uploads/2011/12/animal-muppet1.jpg)'}
  %li
    %p div with scalable background, role='img' and offscreen span
    %h3 The Swedish Chef
    %div.image
      %div{'id'=>'img2', 'role'=>'img', 'aria-described-by'=>'swedishChefLbl', 'style'=>'background-image: url(http://www.thelocalq.com/blogs/searchlights/wp-content/uploads/2011/12/swedish-chef1.jpg)'}
        %span.offscreen{'id'=>'swedishChefLbl'} The Swedish Chef with a spoon
              
            
!

CSS

              
                *
  font-family: Menlo, Verdana, sans-serif
  text-align: left
    
.offscreen
  display: block
  left: -500000px
  position: absolute

h1
  font-size: 1.5em
  
h2, h3
  font-size: 1em
  
div.image 
  position: relative
  height: 0
  padding: 32% 0 0 0
  overflow: hidden
  max-width: 320px
  
  &> div
    background-repeat: no-repeat
    background-size: contain
    bottom: 0
    left: 0
    min-width: 100%
    max-width: 100%
    position: absolute
    right: 0
    top: 0
    
    &#img1
      
    &#img2
      padding-top: 64%
              
            
!

JS

              
                
              
            
!
999px

Console