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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


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


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.


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.


                <div id="x-small"><div>Extra Small<span>Resize the window</span></div></div>
<div id="small"><div>Small<span>Resize the window</span></div></div>
<div id="medium"><div>Medium<span>Resize the window</span></div></div>
<div id="large"><div>Large<span>Resize the window</span><button id="remove">Remove</button></div></div>
<div id="x-large"><div>Extra Large<span>Resize the window</span></div></div>



                html, body {
  height: 100%;
  margin: 0;
  font-family: sans-serif;

div[id] {
  height: 100%;
  color: white;
  font-size: 50px;
  text-align: center;  
  display: none;
  div {
    position: relative;
    top: 35%;
    span {
      display: block;
      font-size: 16px;
      margin: 10px;
    button {
      padding: 8px 14px;
      font-size: 16px;

#x-small {
  background-color: goldenrod;

#small {
  background-color: purple;

#medium {
  background-color: steelblue;

#large {
  background-color: firebrick;

#x-large {
  background-color: seagreen;


                var mediaQueries = {};

var xSmall = $("#x-small")
  , small  = $("#small")
  , medium = $("#medium")
  , large  = $("#large")
  , xLarge = $("#x-large");

// Create your media query list objects
addMediaQuery("x-small", "(max-width: 400px)");
addMediaQuery("small",   "(min-width: 400px)  and (max-width: 700px)");
addMediaQuery("medium",  "(min-width: 700px)  and (max-width: 1000px)");
addMediaQuery("large",   "(min-width: 1000px) and (max-width: 1300px)");
addMediaQuery("x-large", "(min-width: 1300px)");

// Remove the large media query
$("#remove").on("click", removeLargeMedia);

function addMediaQuery(name, query) {
  // MQL - media query list object
  var mql = window.matchMedia(query);
  // Bind the handler function and pass in the name of your mql
  var mediaChangeHandler = $.proxy(handleMediaChange, this, name);
  // Add handler function to mql
  // Add mql to the mediaQueries collection
  mediaQueries[name] = { listener: mediaChangeHandler, mql: mql };
  // Initial run of the query
  handleMediaChange(name, mql);

function handleMediaChange(name, mql) {
  console.log("MEDIA: %s %s => %s", name,, mql.matches);
  // Add your media change logic here 
  switch(name) {
      case "x-small" : mql.matches ? : xSmall.hide(); break;
      case "small"   : mql.matches ?  : small.hide();  break;
      case "medium"  : mql.matches ? : medium.hide(); break;
      case "large"   : mql.matches ?  : large.hide();  break;
      case "x-large" : mql.matches ? : xLarge.hide(); break;

function removeMediaQuery(name) {
  var media = mediaQueries[name];
  mediaQueries[name] = null;

function removeLargeMedia() {
  // Remove the large/x-large media queries
  // Create a new query for x-large media
  addMediaQuery("x-large", "(min-width: 1000px)");