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

              
                
<section> <!-- full-width 100% block element -->
  plain section (or otherwise 'box')<br>
  arbitrary height set just to seperate the sections.<br>
  in practice, the content would determine the height of the parent.
</section>


<section> <!-- full-width 100% block element -->
  <div>
    section showing max-width
  </div>
</section>


<section> 
  <div class='inner-column'>
    section showing <em>centered</em>
  </div>
</section>


<section class='with-background-color'> 
  <div class='inner-column'>
    section showing background color
  </div>
</section>


<section class='with-background-image'> 
  <div class='inner-column'>
    section showing background image
  </div>
</section>

              
            
!

CSS

              
                
* {
  box-sizing: border-box;
}

body * {
  padding: 10px;
}

html {
  border: 4px solid var(--pe-red);
}

div { /* a child element of the section */
  max-width: 400px;
  border: 4px solid var(--pe-green);
} /* to help constrain the content visually */

.inner-column {
  width: 80%; 
  /* ^ something you can also do */
  max-width: 600px;
  margin-right: auto;
  margin-left: auto;
  padding: 10px;
  border: 4px solid var(--pe-green);
}

.with-background-color {
  background-image: linear-gradient(to right, salmon, lightblue);
  /* note that if you put padding on the parent section
     vs. the inner-column - what would happen? */
}

.with-background-image {
  background-image: url('https://assets.codepen.io/4806767/cat.jpg');
  background-size: cover; /* try and cover it */
  background-position: center; /* keep it centered both ways */
}

.with-background-color, .with-background-image {
  color: var(--black);
}

.inner-column {
  margin-inline: auto; 
  /* new 'logical properties' in 2023 */

/*   
  replaces: 
  margin-right: auto;
  margin-left: auto; 
*/
}




































/* just for some presentation */
section + section {
  margin-top: 4px;
}

section {
  border: 4px solid var(--pe-blue);
  min-height: 26vh; /* arbitrary height */
}

html {
  background-color: var(--pe-gray-dark);
  color: var(--ghost);
}
              
            
!

JS

              
                
              
            
!
999px

Console