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

              
                
<div class="wrapper">
  
  <h2>
      Pre
    </h2>
  <h3>&lt;pre&gt;...&lt;&#47;pre&gt;</h3>
  <div class="example-container">
    <div class="example-wrapper">
      <figure class="figure">
        <pre>This is a short &lt;pre&gt; example.</pre>
      </figure>
</div>

<div class="example-wrapper">
  <figure class="figure">
    <pre>This is a very long &lt;pre&gt; example. It can be mutiple lines, by default it does not have multiple spaces, and has default wrapping. What if there's a long string? WellthisiswhathappenswhatdoyouthinkshouldIbreakorshouldInotLetmeknowpleaseIllbeaverylonglineandwillgetcutoff.</pre>
  </figure>
</div>
    
   <div class="example-wrapper example-wrapper--overflow">
     <figure class="figure">
      <pre>This is a very long &lt;pre&gt; example. It can be mutiple lines, by default it does not have multiple spaces, and has default wrapping. What if there's a long string? WellthisiswhathappenswhatdoyouthinkshouldIbreakorshouldInotLetmeknowpleaseIllbeaverylonglineandwillgetcutoff.</pre>
     </figure>
</div>
  </div>
  
    <h2>
      Code 
    </h2>
<h3>&lt;code&gt;...&lt;&#47;code&gt;</h3>
<div class="example-container">

<div class="example-wrapper">
  <figure class="figure">
    <code>
      This is a short &lt;code&gt; example.
    </code>
  </figure>
</div>

<div class="example-wrapper">
  <figure class="figure">
    <code>This is a very long &lt;code&gt; example. It can be mutiple lines, by default it does not have multiple spaces, and has default wrapping. What if there's a long string? WellthisiswhathappenswhatdoyouthinkshouldIbreakorshouldInotLetmeknowpleaseIllbeaverylonglineandwillgetcutoff.</code>
  </figure>
</div>
  
<div class="example-wrapper example-wrapper--overflow">
  <figure class="figure">
    <code>This is a very long &lt;code&gt; example. Let's add some overflow. It can be mutiple lines, by default it does not have multiple spaces, and has default wrapping. What if there's a long string? WellthisiswhathappenswhatdoyouthinkshouldIbreakorshouldInotLetmeknowpleaseIllbeaverylonglineandwillgetcutoff.</code>
  </figure>
</div>
  
</div>
  
 <!-- three -->
  
  <h2>Pre and Code</h2>
  <h3>&lt;pre&gt;&lt;code&gt;...&lt;&#47;pre&gt;&lt;&#47;code&gt;...</h3>
<div class="example-container">

<div class="example-wrapper">
  <figure class="figure">
    <pre><code>Example uses &lt;pre&gt; and &lt;code&gt;</code></pre>
  </figure>
</div>

<div class="example-wrapper">
  <figure class="figure">
      <pre><code>
Example uses &lt;pre&gt; and &lt;code&gt;.
Adjusted line breaks:
It can be mutiple lines, 
by default it does not have multiple spaces, 
and has default wrapping. What if there's a long string? WellthisiswhathappenswhatdoyouthinkshouldIbreakorshouldInotLetmeknowpleaseIllbeaverylonglineandwillgetcutoff.
      </pre></code>
    </figure>
</div>
  
</div>
  
  <!-- four -->
  
  <h2>Word-wrap and overflow-wrap</h2>

<div class="example-container">

<div class="example-wrapper">
  <figure class="figure">
    <figcaption>
      white-space: pre-wrap;  
      word-wrap: break-word;  
    </figcaption>
      <pre class="example-wrapper--word-wrap-break-all">
      
<code>Example uses &lt;pre&gt; and &lt;code&gt;. 
Without the white-space adjustment, the text would be very long and would not wrap. 
What if there's a long string WellthisiswhathappenswhatdoyouthinkshouldIbreakorshouldInotLetmeknowpleaseIllbeaverylonglineandwillgetcutoff.</code>
      </pre>
    </figure>
</div>
  
  <div class="example-wrapper">
 <figure class="figure">
    <figcaption>
      overflow-wrap: break-word; 
    </figcaption>
      <code class="overflow-wrap-break-word">This is a very long &lt;code&gt; example.       WellthisiswhathappenswhatdoyouthinkshouldIbreakorshouldInotLetmeknowpleaseIllbeaverylonglineandwillgetcutoff.
      </code>
    </figure>
</div>
  
</div>
  
  <!-- five -->
  
  <h2>Word-break</h2>

<div class="example-container">
  
   <div class="example-wrapper">
 <figure class="figure">
   <figcaption>
     word-break: keep-all; 
   </figcaption>
      <code class="word-break-keep-all">This is a very long &lt;code&gt; example.
WellthisiswhathappenswhatdoyouthinkshouldIbreakorshouldInotLetmeknowpleaseIllbeaverylonglineandwillgetcutoff.
      </code>
    </figure>
</div>
  
  <div class="example-wrapper">
 <figure class="figure">
   <figcaption>
     overflow-wrap: break-word;<br />
     word-break: keep-all;  
   </figcaption>
      <code class="overflow-wrap-break-word word-break-keep-all">This is a very long &lt;code&gt; example.
WellthisiswhathappenswhatdoyouthinkshouldIbreakorshouldInotLetmeknowpleaseIllbeaverylonglineandwillgetcutoff.
      </code>
    </figure>
</div>
  
</div>
  
  <!-- six -->
  
  <h2>White-space</h2>

<div class="example-container">
  
  
  
  <div class="example-wrapper">
 <figure class="figure">
   <figcaption>
     white-space: normal;<br />
     word-wrap: break-word; 
   </figcaption>
      <code class="overflow-wrap-break-word word-break-keep-all">  
 
White space is not preserved when normal. Multiple spaces    like this will look like a single space.
      </code>
    </figure>
</div>
  
   <div class="example-wrapper">
 <figure class="figure">
   <figcaption>
     white-space: pre-wrap; <br />
     word-wrap: break-word; 
   </figcaption>
      <pre class="example-wrapper--word-wrap-break-all">
White space is preserved. There can be multiple spaces    like this.
      </pre>
    </figure>
</div>
  
</div>
  
  </div>
              
            
!

CSS

              
                @import url('//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css');

@import url('https://fonts.googleapis.com/css?family=Montserrat:400,500,600,700');

:root {
  --light-gray: #eeeeee;
  --text-black: #434344;
}

body {
  background-color: var(--light-gray);
  color: var(--text-black);
  font-family: "Montserrat", sans-serif;
  font-weight: 400;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

h2 {
  margin: 1rem 0;
}

.wrapper {
  max-width: 50rem;
  margin: 1rem auto;
  padding: 3rem;
}

.example-container {
  background-color: #fff;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  padding: 3rem;
  margin-bottom: 3rem;
}

.code-wrapper {
  background-color: purple;
  padding: 1rem;
}

.code-wrapper code {
  color: #fff;
}

.example-wrapper {
  background-color: #8fe8f8;
  width: calc(50% -  1em);
  margin: 1rem 0;
  padding: 1rem;
}

caption {
  flex-direction: row;
}

.example-wrapper--overflow {
  overflow-x: scroll;
}

.word-wrap-break-word {
  word-wrap: break-word;
}

.overflow-wrap-break-word {
  overflow-wrap: break-word;
}

pre.example-wrapper--word-wrap-break-all {
white-space: pre-wrap;  
 word-wrap: break-word;  
}

.word-break-keep-all {
  word-break: keep-all;
}

figcaption {
  color: white;
  background: purple;
  padding: 1rem;
  margin: .5rem;
}


              
            
!

JS

              
                
              
            
!
999px

Console