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

              
                <!-- <html> (already included) -->
<!-- <body> (already included) -->


<header class='site-header'>
  <div class='inner-column'>
    <h1>Hi.</h1>
  </div>
</header>


<main class='page-content'>

  <section class='welcome'>
    <div class='inner-column'>
      <h2>OK. So, this "page-content" section has <code>grow: 1;</code> on it. That means "YES" try and grow. (well, it <em>really</em> means take up 1 fraction of the available space)</h2>
    </div>
  </section>
  
  <section class='other'>
    <div class='inner-column'>
      <h2>Other bit</h2>
    </div>
  </section>

</main>


<footer class='site-footer'>
  <div class='inner-column'>
    <h2>Footer</h2>
    
    <nav class='menu'>
      <a href="#">Menu link a</a>
      <a href="#">Menu link a</a>
      <a href="#">Menu link a</a>
    </nav>
  </div>
</footer>


<!-- </body> (already included) -->
<!-- </html> (already included) -->
              
            
!

CSS

              
                /* ^ reset included */
* {
  box-sizing: border-box;
}

.inner-column {
  width: 100%;
/*   width: 70vw;  */
  /* just for this example */

  max-width: 800px; /* especially small for CodePen example! */
  margin-right: auto;
  margin-left: auto;
  /* */
  margin-inline: auto; /* new! (handles both of the previous) */
}


/* SPECIFIC TO THE GROW  "sticky footer" (that isn't really sticky) */
body {
  min-height: 100vh; /* so there's something to stretch to */

  display: flex; /* so the childred can listen to flex rules */
  flex-direction: column;
}
.page-content {
  flex-grow: 1; 
  /* 1 === "true" grow to stretch  
    (you can think of it that way for now if you want)
    but it means it's taking up 1 fraction of what's left over (which is everything)
  */
  border: 4px solid red;
}
/* This is all dependent on the situation / child elements directly within the body */

main section:nth-of-type(2) {
  background-color: rgb(0 0 0 / 0.4);
} 
/* just to further show it's going all the way across */






































.welcome {
  .inner-column {
    max-width: 400px;
  }
}















































































/* this is NOT for you! */

html {
  --width: 4px;
  --space: 10px;
  
  border: 0;
  padding: 0;
}

body {
  color: rgba(255, 255, 255, .4);
}

nav a {
  display: inline-block;
  padding: 4px;
}

a {
  color: inherit;
}

main, body {
  display: flex;
  flex-direction: column;
  gap: 10px
}

html {
/*   border: var(--width) solid var(--pe-red); */
/*   padding: var(--space); */
  /* if you put this here... then it's taller than 100vh / and causes overflow */
  background-color: #4d4d4d;
}

body {
  border: var(--width) solid var(--pe-cyan);
  padding: var(--space);
}

header {
  border: var(--width) solid var(--pe-orange);
  padding: var(--space);
}

section {
  border: var(--width) solid var(--pe-green);
  padding: var(--space);
}

footer {
  border: var(--width) solid var(--pe-yellow);
  padding: var(--space);
}

div {
  border: var(--width) solid var(--pe-blue);
  padding: var(--space);
}

div > * {
  border: var(--width) solid #979797;
  padding: var(--space);
}

nav > * {
  border: var(--width) solid #979797;
  padding: var(--space);
}

div > * + * {
  margin-top: var(--space);
}

              
            
!

JS

              
                
              
            
!
999px

Console