css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <h3>Vertical-align of multiple elements by default not possible</h3>
<div class="block">
  <div class="inner inner1">Inline-Block</div>
  <div class="inner inner2">Inline-Block</div>

<h3>With an added pseudo element it's possible</h3>
<div class="block2">
  <div class="inner">Inline-Block</div>
  <div class="inner">Inline-Block</div>

<h3>It also works with just an added line-height and nothing else</h3>
<div class="block3">
  <div class="inner inner3">Inline-Block with some lengthy text to show that it also works with multiple lines.</div>
  <div class="inner inner3">Inline-Block.</div>

<h3>Button with vertically centered mult-line text</h3>
<div class="block4">
  <div class="inner inner4">Inline-Block with centered text.</div>
              /* By default vertical-align ist not possible, only different elements can be vertically aligned among eachother */
.block {
  background: red;
  height: 100px;

.inner {
  display: inline-block;
  vertical-align: middle;
  background: yellow;
  padding: 3px 5px;

.inner1 {
  height: 30px;

.inner2 {
  height: 20px;

/* With an added fake (pseudo) element it works. IMPORTANT: There must be no spaces between the elements in the source, else it doesn't work! */
.block2 {
  background: orange;
  height: 80px;

/* Fake (pseudo) element, that enables vertical-align */
.block2:before {
  content: "";
  display: inline-block;
  vertical-align: middle;
  height: 100%;

/* Also works if you set line-height instead of the height (or together with the same value as the height). No pseudo-element needed.  */
.block3 {
  background: green;
  /*height: 120px;*/
  line-height: 120px;

.inner3 {
  width: 30%;
  line-height: normal; /* Reset line-height for the child. IMPORTANT: Must be "normal", no integer value allowed! */

.block4 {
  background: magenta;
  line-height: 60px;

.inner4 {
  line-height: normal; /* Reset line-height for the child. */
  background: none;

/* Miscellaneous styling */
@import url(https://fonts.googleapis.com/css?family=PT+Sans:400,700);

h3, div {
  font-family: 'PT Sans', sans-serif;

.block, .block2, .block3 {
  border: 5px dotted rgba(0,0,0,.4); 
  background-clip: padding-box;
  width: 50%;

.block4 {
  text-align: center;
  width: 20%;
  box-shadow: 3px 3px 0 black;

h3 {
  margin: 40px 0 7px;
              /* By default it's not posible to vertically center inline-blocks with vertical-align (red box). But if you add a pseudo-element, it works (orange box). It also works if you just add line-height for the container with the same value as height (green box). */

/* Partially inspired by https://css-tricks.com/centering-in-the-unknown/ */
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................