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

              
                <header>
  <h1>Demo of <code>text-box</code></h1> 
  <div class="toggle">
    <label for="guides">Show guides: </label>
    <input type="checkbox" switch id="guides">
  </div>
</header>
<main>
  <article>
    <figure>
      <img src='https://images.unsplash.com/photo-1733108906414-fde4a7596456?crop=entropy&cs=srgb&fm=jpg&ixid=M3wzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE3MzMzMzk0NDN8&ixlib=rb-4.0.3&q=85' alt=''>
      <h2 class="name">Holiday Decorations</h2>
      <p>Lorem ipsum odor amet, consectetuer adipiscing elit. Consectetur sed laoreet ad gravida egestas; potenti posuere dignissim. Turpis nostra taciti ornare imperdiet felis ante fusce ridiculus. Fringilla praesent felis blandit amet morbi rhoncus odio torquent torquent?</p>
      <figcaption><code>text-box: normal</code></figcaption>
    </figure>
    <figure class="trimmed">
      <img src='https://images.unsplash.com/photo-1733108906414-fde4a7596456?crop=entropy&cs=srgb&fm=jpg&ixid=M3wzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE3MzMzMzk0NDN8&ixlib=rb-4.0.3&q=85' alt=''>
      <h2 class="name">Holiday Decorations</h2>
      <p>Lorem ipsum odor amet, consectetuer adipiscing elit. Consectetur sed laoreet ad gravida egestas; potenti posuere dignissim. Turpis nostra taciti ornare imperdiet felis ante fusce ridiculus. Fringilla praesent felis blandit amet morbi rhoncus odio torquent torquent?</p>
      <figcaption><code>text-box: trim-start cap</code></figcaption>
    </figure>
  </article>
 </main>



<aside class="no-support">This is a demo of <code>text-box</code>. If you are reading this message, your browser does not have support. Please try this in Safari 18.2 or another <a href="https://caniuse.com/css-text-box-trim">browser with support</a>.</aside>
              
            
!

CSS

              
                
article .trimmed h2 {
  text-box: trim-start cap;
}

article {
  display: grid;
  grid-template-columns: repeat(auto-fit, 78ch);
  gap: 4rem;
  figure {
    margin-block-end: 2rem;
    min-width: 600px;
    margin: 0;
  }
  figcaption {
    font-size: 200%;
    text-align: center;
    margin-block-start: 2rem;
    color: light-dark(rebeccapurple, hotpink); 
  }
  img { 
    width: 320px;
    float: left;
    margin-inline-end: 1.5em;
    margin-block-end: 0.45em; 
  }
  h2 {
    font-family: "Ewert";
    font-size: 2.8rem;
    margin-block: 0;
    line-height: 1.1;
  }
  p {
    font-size: 0.9rem;
    font-family: Merriweather, georgia, serif;
    line-height: 1.6;
    margin: 0.95em 0 0;
  }
  .trimmed figcaption {
    margin-top: calc( 2rem + 9px);
  }
}

/*---  Guide  -------------------------------*/
figure {
  border-top: 3px solid canvas;
}
body:has(input[id="guides"]:checked) {
  figure {
    border-top: 3px dotted #00e8e8;
  }
}

/*-------------------------------------------*/
/*   Overall page and UI                     */
/*-------------------------------------------*/

:root {
  color-scheme: light dark;
}
body, button {
  font-family: system-ui, sans-serif;
}
body {
  margin: 4rem;
}
header {
  display: flex;
  justify-content: space-between;
  align-items: start;
}
header h1 code {
  font-size-adjust: 0.64;
  padding-inline: 4px;
  color: light-dark(rebeccapurple, hotpink);
}
.toggle {
  margin-block: 1lh;
  padding: 0.25lh 0.75lh;
  border: 1px solid #00e8e8;
  min-width: max-content;
  border-radius: 1lh;
  font-size: 1.1rem;
  font-weight: 300;
  accent-color: #00e8e8;
  display: flex;
  align-items: center;
  label {
    margin-inline-end: 0.5em;
  }
}
main {
  display: grid;
  gap: 6rem;
  margin-block-start: 2rem;
/*   width: 1700px; */
}

/*-------------------------------------------*/
/*   Browser support message                 */
/*-------------------------------------------*/

@supports (text-box: trim-start cap) {
  .no-support {
    display: none;
  }
}
.no-support {
  padding: 1rlh;
  background: darkred;
  color: white;
  font-family: system-ui, sans-serif;
  a {
    color: white;
    text-decoration: underline;
  }
} 

              
            
!

JS

              
                
              
            
!
999px

Console