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

              
                <body>
  <header>
  <nav><ul>
    <li><a href="#">Home</a></li>
    <li>Nesting demo</li>
    </ul>
  </nav>
  </header>
  <main>
    <h1>A <abbr title="Don't Repeat Yourself">DRY</abbr> method</h1>
    <p>Element including a <span class="small">mixin</span></p>    <button class="button-report">Report</button> 
    <button class="button-submit">Submit</button>
  </main>  
  <section>
    <div class="quote"></div>
    <ul>
      <li>First item</li>
      <li>Second item</li>
    </ul>
  </section>
  
</body>
              
            
!

CSS

              
                // Define variables
$myFont: Helvetica, sans-serif;

body {
  font-family: $myFont;
}

// Use Nesting
nav {
  ul {
    margin: 0;
    padding: 0;
    list-style: none;
  }
  li {
    display: inline-block;
  }
  a {
    display: block;
    padding: 6px 12px;
    text-decoration: none;
  }
}

/* Use @mixin */
@mixin important-text {
  color: red;
  font-size: 25px;
  font-weight: bold;
  border: 1px solid blue;  
}

// Note: a @mixin can contain another @mixin as well as accept arguments (separator: comma) with defaults values
@mixin add-padding($padding: 1em) {
  @include important-text;
  padding: $padding;
}

p {
  @include add-padding(0.2em);
  background-color: beige;
}

// Use @extend
button {
  border: none;
  padding: 15px 30px;
  text-align: center;
  font-size: 16px;
  cursor: pointer;
}

.button-report  {
  @extend button;
  background-color: red;
}

.button-submit  {
  @extend button;
  background-color: green;
  color: white;
}

// Use functions
.quote {
  margin: 2em;  
}

// String function
.quote:before {
  content: to-lower-case("Hello World!")
}

// Numeric function
.quote {
  $nbPx: random(15);
  border: $nbPx+px solid orange;
  padding: $nbPx/2+em;
}

// List Function
h1 {
  $border: append((5px dashed), (lightblue), space);
  border: $border;
}

// Map function
$font-sizes: ("small": 12px, "normal": 18px, "large": 24px);
  
.small {
  font-size: map-get($font-sizes, "small");
} 

// Selector Function
#{selector-append("ul, li")} {
  color: grey;
  margin: 1em;
};

// Introspection Function
.test {
  font-family: global-variable-exists(myFont); // returns true in compiled view
}

// Color Function
section {
  background-color: hsl(120, 100%, 75%, 0.3); // light green with opacity
}
              
            
!

JS

              
                
              
            
!
999px

Console