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

              
                <h2>The <strong>Cascade</strong></h2>

<div id="track-labels">
  <strong class="label">Normal Track</strong>
  <strong class="label">Important Track</strong>
</div>
<div class='cascade-list'>
  <details style='--i: 0' data-cat='origin' class='has-import'>
    <summary>Origin & Importance</summary>
    <div class="cat-content">
      <ol layer-list='combined'>
        <li>↔️ CSS Transitions</li>

        <li data-side='important'>🖥 User Agent (Browser)</li>
        <li data-side='important'>👥 User (Preferences)</li>
        <li data-side='important'>🎨 Author (Site)</li>

        <li>🔁 CSS Animations</li>

        <li data-side='normal'>🎨 Author (Site)</li>
        <li data-side='normal'>👥 User (Preferences)</li>
        <li data-side='normal'>🖥 User Agent (Browser)</li>
      </ol>
    </div>
  </details>

  <details style='--i: 1' data-cat='context' class='has-import'>
    <summary>(Shadow) Context</summary>
    <div class="cat-content">
      <strong class='label' data-side='important'>important</strong>
      <ol layer-list='important'>
        <li>🫥 Shadow DOM</li>
        <li>☀️ Host (Light) DOM</li>
      </ol>
      <strong class='label' data-side='normal'>normal</strong>
      <ol layer-list='normal'>
        <li>☀️ Host (Light) DOM</li>
        <li>🫥 Shadow DOM</li>
      </ol>
    </div>
  </details>

  <details style='--i: 2' data-cat='style' class='has-import'>
    <summary>Element-Attached (Inline) Styles</summary>
    <div class="cat-content">
      <strong class='label' data-side='important'>important</strong>
      <ol layer-list='important'>
        <li>Inline Styles</li>
        <li>Selectors</li>
      </ol>
      <strong class='label' data-side='normal'>normal</strong>
      <ol layer-list='normal'>
        <li>Inline Styles</li>
        <li>Selectors</li>
      </ol>
    </div>
  </details>

  <details style='--i: 3' data-cat='layers' class='has-import'>
    <summary>Cascade Layers (2022)</summary>
    <div class="cat-content">
      <strong class='label' data-side='important'>important</strong>
      <ol layer-list='important'>
        <li><i>» first-layer</i></li>
        <li><i>» …</i></li>
        <li><i>» last-layer</i></li>
        <li><i>un-layered styles</i></li>
      </ol>
      <strong class='label' data-side='normal'>normal</strong>
      <ol layer-list='normal'>
        <li><i>un-layered styles</i></li>
        <li><i>» last-layer</i></li>
        <li><i>» …</i></li>
        <li><i>» first-layer</i></li>
      </ol>
    </div>
  </details>

  <details style='--i: 4' data-cat='specificity'>
    <summary>Selector Specificity</summary>
    <div class="cat-content">
      <ol layer-list='combined'>
        <li><code>#id</code></li>
        <li>
          <code>.class</code>,
          <code>:pseudo-class</code>,
          <code>[attribute]</code>
        </li>
        <li>
          <code>element</code>,
          <code>::pseudo-element</code>
        </li>
        <li>
          <code>*</code>,
          <code>:where()</code>
        </li>
      </ol>
    </div>
  </details>

  <details style='--i: 5' data-cat='scope'>
    <summary>Scope Proximity <em>(new!)</em></summary>
    <div class="cat-content">
      <p>Nearest scope root (in the DOM) wins</p>
    </div>
  </details>

  <details style='--i: 6' data-cat='order'>
    <summary>Order of Appearance</summary>
    <div class="cat-content">
      <p>Last style wins!</p>
    </div>
  </details>
</div>

              
            
!

CSS

              
                #track-labels {
  display: flex;
  justify-content: space-between;
}

.cascade-list {
  display: grid;
  grid-gap: 0.125em;
  grid-template-columns:
    repeat(6, 1fr)
    auto
    repeat(6, 1fr)
  ;
  justify-content: center;
}

[data-cat] {
  --h: calc(180deg + 36deg * var(--i, 0));
  --col-abs: calc(var(--i, 0) + 1);
  --col-neg: calc(var(--col-abs, 1) * -1);
  --pad: min(5vmin, 4em);
  --bg: hsl(var(--h, 0deg) 50% 75%);
  --import-bg: hsl(var(--h, 0deg) 50% 25% / var(--bgi-a, 0.5));
  background: var(--bg);
  color: hsl(var(--h, 0deg) 15% 5%);
  clip-path: polygon(0 0, 100% 0, calc(100% - var(--pad)) 100%, var(--pad) 100%);
  grid-column: var(--col-abs, 1) / var(--col-neg, -1);
  padding: 0.25em calc(var(--pad) + 0.5em);
}

.has-import {
  background-image: linear-gradient(
    to right,
    transparent calc(50% - 2px),
    white calc(50% - 2px) calc(50% + 2px),
    var(--import-bg) calc(50% + 2px)
  );
}

[open] {
  --bgi-a: 1;
}

summary {
  background: var(--bg);
  border: thin solid;
  border-radius: 3px;
  cursor: pointer;
  font-weight: bold;
  text-shadow: 0 1px 0 var(--bg);
  margin-bottom: 0.5em;
  padding-inline: 1ch;
}

.label {
  font-size: var(--text-small);
}

/* category content */
.cat-content {
  display: grid;
  grid-auto-flow: dense;
  grid-template-columns: repeat(2, 1fr);
  grid-gap: 0.25em 1em;
}

.cat-content > * {
  grid-column: span 2;
}

/* layers */
[layer-list] {
  display: grid;
  font-family: 'Dank Mono', 'Courier New', Courier, monospace;
  font-size: 0.8em;
  grid-gap: inherit;
}

[layer-list='normal'] {
  grid-column: 1;
}

[layer-list='important'] {
  grid-column: 2;
}

[layer-list='combined'] {
  display: grid;
  grid: inherit;
  grid-auto-flow: row;
}

[layer-list='combined'] li {
  grid-column: var(--side, 1 / -1);
}

[data-side] {
  grid-column: var(--side, 1);
}

[data-side='normal'] {
  --side: 1;
}

[data-side='important'] {
  --side: 2;
  color: white;
}

[layer-list='important'],
[data-side='important'] {
  --pre: '❗️';
  --bl: 15%;
  --cl: 95%;
}

/* items */
[layer-list] li {
  --li-a: calc(1 - var(--li, 0) * 0.12);
  align-items: center;
  background: hsl(var(--h, 0deg) 50% var(--bl, 95%) / var(--li-a, 0.5));
  border-inline-start: thick solid currentColor;
  color: hsl(var(--h, 0deg) 5% var(--cl, 15%));
  display: flex;
  flex-wrap: wrap;
  padding: 0.25em;
}

[layer-list] li:nth-child(2) { --li: 1; }
[layer-list] li:nth-child(3) { --li: 2; }
[layer-list] li:nth-child(4) { --li: 3; }
[layer-list] li:nth-child(5) { --li: 4; }
[layer-list] li:nth-child(6) { --li: 5; }
[layer-list] li:nth-child(7) { --li: 6; }
[layer-list] li:nth-child(8) { --li: 7; }

[layer-list] li::before {
  content: var(--pre);
  display: inline-block;
}

[layer-list] code {
  display: inline-block;
  white-space: nowrap;
}


@layer reset, base;

@layer base {
  body {    
    --text-small: clamp(0.938rem, 0.824rem + 0.568cqi, 1.25rem);
    --text-normal: clamp(1.25rem, 1.023rem + 1.136cqi, 1.875rem);
    --text-large: clamp(1.35rem, 0.818rem + 2.659cqi, 2.813rem);
    --text-xlarge: clamp(1.7rem, 0.784rem + 4.58cqi, 4.219rem);
    --gap: clamp(12px, 0rem + 3.75cqi, 24px);
    display: grid;
    font-family: avenir, roboto, helvetica, sans-serif;
    font-size: var(--text-normal);
    grid-template-rows: auto auto 1fr;
    margin: var(--gap);
  }
  
  .sr-only {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    -webkit-clip-path: inset(50%);
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    margin: -1px;
    padding: 0;
    position: absolute;
    width: 1px;
    white-space: nowrap;
  }

  ol, h2 {
    margin: 0;
    padding: 0;
  }

  li {
    list-style: none;
  }
}

@layer reset {
  * { box-sizing: border-box; }
  html { block-size: 100%; }
  
  body {
    margin: unset;
    min-block-size: 100%;
  }  
  
  picture { display: contents; }
  img { display: block; }

  img,
  svg {
    max-inline-size: 100%;
  }
    
  input,
  button,
  textarea,
  select {
    font: inherit;
  }
}

              
            
!

JS

              
                
              
            
!
999px

Console