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.


                <article class="module photo">
  <h2>CodePen Hat</h2>
  <img src="" width="640" height="640" />
  <div class="content">
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Optio reiciendis vero enim modi id itaque ea odio excepturi sapiente dolores fugit recusandae iure quos laudantium mollitia ut numquam laboriosam aspernatur!</p>
  <button data-text-original="View Larger" data-text-swap="View Smaller" class="bigger">View Larger</button>



                .module {
  width: 250px;
  border: 1px solid black;
  position: relative;
  img {
    width: 100%;
    height: auto;
  h2 {
    background: black;
    color: white;
    margin: 0;
    padding: 10px;
  .content {
    padding: 10px;
  .bigger {
    position: absolute;
    top: 260px;
    right: 10px;

.module[data-state="expanded"] {
  img {
    width: 200%;

body {
  padding: 20px;
  font-size: small;
p {
  margin: 0;


                $(".bigger").on("click", function() {
  var el = $(this);
  var module = el.parent();
  // Swap expanded state
  module.attr("data-state") == "expanded" 
    ? module.attr("data-state", "")
    : module.attr("data-state", "expanded");
  // Swap button text.
  el.text() =="text-swap") 
    ? el.text("text-original")) 
    : el.text("text-swap"));