Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <div class="container">
<h1>Responsive Image</h1>
  <div class="flexContainer">
    <div><p>The image to the right is inside a flex item inside a flex container <code>.flexContainer</code></p>
      <p>As the flex container is resized the image resizes.  This is due to the <code>width</code> of 100% set by <code>.respImg</code> class.</p>
      <p>The 100% is relative, ie it is 100% of its parent's width.</p>
      <p>In this case the parent of the &lt;img&gt; is the flex-item, that itself is given 50% of the flex container via the flex property of <code>flex:0 0 50%</code>.</p>
    </div>
  <img src="https://picsum.photos/400/300" alt="Placeholder 400x100" class="respImg">
    </div>
</div>
</div>

              
            
!

CSS

              
                /* Utility class for responsive images */
.respImg{
  width:100%;
  height:auto;
}
/* Default mobile-first styles */
body {
    font-family: 'Arial', sans-serif;
    font-size: 1rem;
    color: #333;
}
.container{
  width:100%;
/*   exaggerated borders to illustrate demo */
  border-left:5px solid #000;
  border-right:5px solid #000;
  padding:5px;
}
.flexContainer{
  display:flex;
  gap:10px;
}
/* Give both flex items 50% of the flex space */
.flexContainer > div{
  flex:0 0 50%;
}
/* Tablet styles */
@media (min-width: 600px) {
    body {
        font-size: 1.1rem;
    }
    .container{
        width:100%;
    }
}

/* Desktop styles */
@media (min-width: 1024px) {
    body {
        font-size: 1.2rem;

    }
    .container{
        max-width: 960px;
        margin: auto;
    }
}
code{
color: #ed143d;
    background-color: #fff;
    padding-left: 5px;
    padding-right: 5px;
    font-family: Consolas, "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", Monaco, "Courier New", "monospace";
}
              
            
!

JS

              
                
              
            
!
999px

Console