Pen Settings



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


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.


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.


                <div class="layout">
  <header class="header item">
      <p>Nav element</p>

  <main class="item">
    <div class="content item">
      <p>This is the main content</p>
  <aside class="item aside">
    <p>Ads and side stuff</p>

  <footer class="item footer">
    <p>I'm the footer</p>


                .layout {
  --cols: 1fr;
  display: grid;
  grid-template-columns: var(--cols);
  align-items: start;
  gap: 1rem;
  max-width: 1800px;

  @media (min-width: 1020px) {
    --cols: minmax(min(160px, 10vw), min(200px, 15vw))
      minmax(min(1200px, 0px), min(1390px, 100%))
      minmax(min(200px, 10vw), min(300px, 15vw));

header {
  position: sticky;
  top: 0;
  grid-column: 1 / -1;

  @media (min-width: 1020px) {
    grid-column: 1 / 2;

footer {
  grid-column: 1 / -1;

  @media (min-width: 1020px) {
    grid-column: 2 / -1;

// main {
//   @media (max-width: 1019px) {
//     grid-column: 1 / -1;
//   }
// }

.aside {
  display: none;
  @media (min-width: 1020px) {
    display: block;

.item {
  padding: 2rem;
  font-size: 1rem;
  background-color: lightgrey;
  text-align: center;

.wrapper {
  max-width: 850px;
  margin: 1rem auto;
  padding-block: 1rem;

  > * + * {
    margin-top: 2rem;

/* other styles */

body {
  font-family: system-ui;
  line-height: 1.45;
  padding: 1rem;

* {
  box-sizing: border-box;

img {
  max-width: 100%;



                // Function to update the element with its width value
function updateElementWidth(elementClass) {
  const elements = document.getElementsByClassName(elementClass);
  for (let i = 0; i < elements.length; i++) {
    const element = elements[i];
    element.innerHTML = `${elementClass} width: ${element.offsetWidth}px`;

// Function to handle window resize event
function handleWindowResize() {

// Add event listener to handle window resize
window.addEventListener("resize", handleWindowResize);

// Initial call to update the element widths when the page loads