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

              
                <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 a query string
 * {@link https://gist.github.com/kieranbarker/bb7c54bd12156c069419f64a22e61552}
 * @param {HTMLFormElement} form The form
 * @returns {String} The query string
 */
function serialize (form) {
  // Create a new FormData object
  const formData = new FormData(form);

  // Create a new URLSearchParams object
  const params = new URLSearchParams(formData);

  // Return the query string
  return params.toString();
}

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

  // Log the query string
  console.log(serialize(this));

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


//
// Inits & Event Listeners
//

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

Console