cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

            
              <form id="form">
  <input type="text">
  <button type="button" id="cancel-button">Cancel</button>
  <button type="submit" id="save-button">Save</button>
<form>
            
          
!
            
              /*
Change the type attribute of cancel-button to "submit" and see how the form submission behavior changes when the enter key is used. Unless the cancel button is type="button", the enter key submission will cancel the form, not submit it. This is because the first type="submit" (default) button's onClick handler is called before any form onSubmit handler.

React example: https://codepen.io/dzello/pen/wgLZYN
*/

var form = document.getElementById("form");
var saveButton = document.getElementById("save-button");
var cancelButton = document.getElementById("cancel-button");

cancelButton.addEventListener('click', function(event) {
  event.preventDefault();
  console.log('cancel handler called');
});

form.addEventListener('submit', function(event) {
  event.preventDefault();
  console.log('submit handler called');
});
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console