Pen Settings



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


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.


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.


                <div class="m-4">
  <p id="success" class="bg-green-300 p-4 hidden">🎉 Form submitted successfully!</p>
  <form class="my-4 flex flex-col gap-3 align-self-end max-w-sm rounded-lg p-4 bg-stone-200" novalidate>
      <label for="password">Password</label>
      <input id="password" type="password" required class="bg-slate-50">
      <p id="password-error" class="error text-red-800"></p>
      <label for="confirmPassword">Confirm Password</label>
      <input id="confirmPassword" type="password" required class="bg-slate-50">
      <p id="confirmPassword-error" class="error text-red-800"></p>
    <button class="self-end bg-cyan-800 text-white px-4 py-1">Submit</button>


                p:empty { 
  display: none;


                const form = document.querySelector('form');
const error = document.querySelector('.error');
const input = document.querySelector('input');
const success = document.querySelector('#success');

const inputs = {
  password: document.querySelector('#password'),
  confirmPassword: document.querySelector('#confirmPassword')

const errorMessages = {
  password: document.querySelector('#password-error'),
  confirmPassword: document.querySelector('#confirmPassword-error')

form.addEventListener('submit', event => {
  // Stop the form submission so we don't leave CodePen!
  errorMessages.password.textContent = '';
  errorMessages.confirmPassword.textContent = '';
  if (form.checkValidity()) {

function handleInvalid(event) {
  errorMessages[].textContent =;

function validatePasswordMatch() {
  if (inputs.password.value !== inputs.confirmPassword.value) {
    inputs.confirmPassword.setCustomValidity('Passwords do not match');
  } else {
    errorMessages.confirmPassword.textContent = '';

function handleInput(event) {
  errorMessages[].textContent = '';;
  // Revalidate the password match if there's been an error
  if (errorMessages.confirmPassword.textContent) {

inputs.password.addEventListener('invalid', handleInvalid);
inputs.confirmPassword.addEventListener('invalid', handleInvalid);

inputs.password.addEventListener('input', handleInput);
inputs.confirmPassword.addEventListener('input', handleInput);