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

              
                <main>
  <article>
    <figure>
      <figcaption><code>text-wrap: auto</code></figcaption>
      <h1 class="auto">This is a long headline where each line takes up the full amount of space available, even if that means there’s a single word all alone by itself</h1>
    </figure>
    <figure>
      <figcaption><code>text-wrap: pretty</code></figcaption>
      <h1 class="pretty">This is a long headline where each line starts to take all the space available, but then it adjusts to never have a single word alone by itself</h1>
    </figure>
    <figure>
      <figcaption><code>text-wrap: balance</code></figcaption>
      <h1 class="balance">This is a long headline that wraps wherever it works to make all of the lines of text about the same length</h1>
    </figure>
  </article>
  
  <article>
    <figure>
      <figcaption><code>text-wrap: auto</code></figcaption>
      <h1 class="auto">Here’s a medium-length headline with enough content to make a word all alone by itself</h1>
    </figure>
    <figure>
      <figcaption><code>text-wrap: pretty</code></figcaption>
      <h1 class="pretty">Here’s a medium-length headline with enough content to make a word all alone by itself</h1>
    </figure>
    <figure>
      <figcaption><code>text-wrap: balance</code></figcaption>
      <h1 class="balance">Here’s a medium-length headline with enough content to make a word all alone by itself</h1>
    </figure>
  </article>
  
  <article>
    <figure>
      <figcaption><code>text-wrap: auto</code></figcaption>
      <h1 class="auto">It’s a shorter headline with a word alone by itself</h1>
    </figure>
    <figure>
      <figcaption><code>text-wrap: pretty</code></figcaption>
      <h1 class="pretty">It’s a shorter headline with a word alone by itself</h1>
    </figure>
    <figure>
      <figcaption><code>text-wrap: balance</code></figcaption>
      <h1 class="balance">It’s a shorter headline with a word alone by itself</h1>
    </figure>
  </article>
</main>

<footer class="error-message"><small>This is a demo of <code>text-wrap: pretty</code>. Your browser does not <a href="https://caniuse.com/mdn-css_properties_text-wrap_pretty" target="_blank">have support</a>. Try it in a browser that does, which curently (in March 2025) includes <a href="https://developer.apple.com/safari/resources/" target="_blank">Safari Technology Preview 216</a>.</small></footer>
              
            
!

CSS

              
                h1.balance { 
  text-wrap: balance;
}
h1.pretty { 
  text-wrap: pretty;
}
h1.auto {
  text-wrap: auto;  /* initial value */
}
h1 {
  font-family: 'Iowan Old Style', 'Palatino Linotype', 'URW Palladio L', P052, serif;
  font-weight: 300;
  font-size: 2.4rem;
  letter-spacing: -1px;
}

/* ---------------------------------- */

:root {
	color-scheme: light dark;
	background: light-dark(white, #222);
}
body {
  margin: 4rem;
}
main {
  display: grid;
  grid-template-columns: min-content min-content min-content;
}
h1 {
  inline-size: 35ch;
  block-size: fit-content;
  margin-block: 0 2em;
  border: 1px solid light-dark(color(display-p3 0.019 0.918 0.925), color(display-p3 0 0.985 1));
  resize: inline;
  overflow: auto;
}

/* --------------------------------------
   Error message for lack of support
-------------------------------------- */

.error-message { display: none; }
@supports not (text-wrap: pretty) {
  .error-message {
    color: white;
    padding: 2rem;
    margin-right: 3rem;
    background: darkred;
    display: block;
    text-align: center;
    font-size: 1.3rem;
    font-family: ui-system, sans-serif;
    a {
      color: #f1f170;
    }
    position: fixed;
    top: 10rem;
  }
}
              
            
!

JS

              
                
              
            
!
999px

Console