Pen Settings

HTML

CSS

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

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

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.

HTML

              
                <p>Submit the form then check the console.</p>

<form>
  <p>
    <label for="name">Name</label>
    <input type="text" name="name" id="name" value="Mario">
  </p>
  <p>
    <label for="email">Email</label>
    <input type="email" name="email" id="email" value="mario@nintendo.com">
  </p>
  <p>
    <label for="message">Message</label>
    <textarea name="message" id="message">Mamma Mia!</textarea>
  </p>
  <p>
    <button type="submit">Submit</button>
  </p>
</form>
              
            
!

CSS

              
                * {
  box-sizing: border-box;
}

body {
  width: 88%;
  max-width: 30em;
  margin: 1em auto;
  line-height: 1.5;
  font-family: Arial, sans-serif;
}

label, input, textarea {
  display: block;
}

input, textarea, button {
  font: inherit;
}

input, textarea {
  width: 100%;
}

#output {
  font-family: monospace;
}
              
            
!

JS

              
                //
// Variables
//

// Get the form element
const form = document.querySelector('form');


//
// Functions
//

/**
 * Serialize all form data into an object
 * {@link https://gist.github.com/kieranbarker/245182a6e6af0b05be4233881c0aa60b}
 * @param {HTMLFormElement} form The form to serialize
 * @returns {Object} The serialized form data
 */
function serializeObject (form) {
  // Create a new FormData object
  const formData = new FormData(form);

  // Create an object to hold the name/value pairs
  const pairs = {};

  // Add each name/value pair to the object
  for (const [name, value] of formData) {
    pairs[name] = value;
  }

  // Return the object
  return pairs;
}

/**
 * Handle submit events
 * @param {Event} event The Event interface
 */
function handleSubmit (event) {
  // Prevent the default submission
  event.preventDefault();

  // Log the serialized data
  console.log(serializeObject(this));

  // Alert the user
  alert('Check the console.');
}


//
// Inits & Event Listeners
//

// Handle submit events
form.addEventListener('submit', handleSubmit);
              
            
!
999px

Console