Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

Save Automatically?

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

              
                <h1>Comparison of CSS layout code brevity.</h1>
<hr>

<h2>display: inline-block</h2>
<p class="graph" style="background-image: linear-gradient(to right, #ddd 234px, transparent 234px);">Minified CSS: 234 bytes</p>
<div class="container container--1">
  <div class="item item--a">.item--a</div>
  <div class="item item--b">.item--b</div>
</div>
<hr>

<h2>float: left</h2>
<p class="graph" style="background-image: linear-gradient(to right, #ddd 171px, transparent 171px);">Minified CSS: 171 bytes</p>
<div class="container container--2">
  <div class="item item--a">.item--a</div>
  <div class="item item--b">.item--b</div>
</div>
<hr>

<h2>display: flex</h2>
<p class="graph" style="background-image: linear-gradient(to right, #ddd 95px, transparent 95px);">Minified CSS: 95 bytes</p>
<div class="container container--3">
  <div class="item item--a">.item--a</div>
  <div class="item item--b">.item--b</div>
</div>
<hr>

<h2>display: grid</h2>
<p class="graph" style="background-image: linear-gradient(to right, #ddd 47px, transparent 47px);">Minified CSS: 47 bytes</p>
<div class="container container--4">
  <div class="item item--a">.item--a</div>
  <div class="item item--b">.item--b</div>
</div>
<hr>

<h2>The shortest code is the grid.(Minified CSS: 47 bytes)</h2>
<pre><code>.container--4 { 
  display: grid; 
  grid: auto / 120px 1fr;
}</code></pre>
              
            
!

CSS

              
                /* ---------- Skip this base code ---------- */
* { box-sizing: border-box; } h1 { font-size: 24px; } h2 { margin-bottom: 0; font-size: 20px; } pre { padding: 8px; background: black; color: #fff; } .graph { padding: 4px; margin-top: 0; margin-bottom: 4px; } .container { border: 16px solid silver; } .item { padding: 8px; color: #fff; } .item--a { background: coral; } .item--b { background: royalblue; }

/* ---------- display: inline-block (Minified CSS: 234 bytes) ---------- */
.container--1 {
  white-space: nowrap;
  font-size: 0;
  line-height: 0;
}
.container--1 .item {
  display: inline-block;
  vertical-align: top;
  line-height: 1.25;
  font-size: 16px;
}
.container--1 .item--a { width: 120px; }
.container--1 .item--b { width: calc(100% - 120px); }

/* ---------- float: left (Minified CSS: 171 bytes) ---------- */
.container--2::after {
  content: '';
  display: block;
  clear: both;
}
.container--2 .item { float: left; }
.container--2 .item--a { width: 120px; }
.container--2 .item--b { width: calc(100% - 120px); }

/* ---------- display: flex (Minified CSS: 95 bytes) ---------- */
.container--3 { display: flex; }
.container--3 .item--a { flex: 0 0 120px; }
.container--3 .item--b { flex: 1; }

/* ---------- display: grid (Minified CSS: 47 bytes) ---------- */
.container--4 { 
  display: grid; 
  grid: auto / 120px 1fr;
}
              
            
!

JS

              
                
              
            
!
999px

Console