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. 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


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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


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.


    <label for="email">Email</label>
    <input id="email" type="email" required placeholder="" />
    <label for="alpha">Alphanumeric Only</label>
    <input id="alpha" type="text" pattern="[a-zA-Z0-9]+" title="Only alphanumeric characters allowed" required/>
    <label for="select">Select</label>
    <select required>
      <option value="">Select option</option>
      <option value="1">Option one</option>
    <label for="password">Password</label>
    <input id="password" type="password" required/>
  <input type="submit" value="Log In" />

  <li>Only validate inputs on submit
  <li>Leverage browser-level feedback
  <li>Allow input styling off of <code>.error</code> class because <code>input:invalid</code> sorta sucks and triggers on page load.
  <li>Optional: Trigger validation on blur.
<p><code>// TODO:</code> Mess around with <code>pattern</code> validation and maybe <code>setCustomValidity(message)</code>.</p>
<p>Tested in Chrome, Firefox, Edge, and Mobile Safari</p>


                body {
  padding: 2em;
  line-height: 1.5;

div {
  margin-bottom: 1em;

label {
  margin-bottom: 0.25em;
  display: block;  

// Never Style input:invalid, it sucks. It triggers way too early. Uncomment to see.
// input:invalid {
//   border-color: red;
// }

// Applying an error class means we keep browser level feedback, error handling, and focus management.
textarea.error {
  outline: none;
  border-color: red;
  border-width: 1px;
  border-style: solid;
  // Use CSS to visually restore valid fields
  &:valid {
    border-style: auto;
    border-color: inherit;



                // Doing error handling on form submit won't work here because the validation blocks the submit event from firing.

//Get all the inputs...
const inputs = document.querySelectorAll('input, select, textarea');

// Loop through them...
for(let input of inputs) {
  // Just before submit, the invalid event will fire, let's apply our class there.
  input.addEventListener('invalid', (event) => {
  }, false);
  // Optional: Check validity onblur
  input.addEventListener('blur', (event) => {