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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

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


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.


                <h1>Toggling Multiple Password Fields</h1>

    <label for="current-password">Current Password</label>
    <input id="current-password" type="password" name="current-password">

    <label for="new-password">New Password</label>
    <input id="new-password" type="password" name="new-password">

    <label for="show-passwords">
      <input id="show-passwords" type="checkbox" name="show-passwords">
      Show passwords

    <button type="submit">Change Passwords</button>


                * {
  box-sizing: border-box;

body {
  width: 88%;
  max-width: 30em;
  margin: 1em auto;
  line-height: 1.5;
  background-color: #fdfdfd;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';

label, input:not([type='checkbox']) {
  display: block;

input:not([type='checkbox']), button {
  border: .125em solid #999;
  border-radius: .25em;
  font: inherit;

input:not([type='checkbox']) {
  width: 100%;
  padding: .5em;
  background-color: #fff;

[type='checkbox'] {
  margin-left: 0;

button {
  padding: .5em 1em;
  background-color: #eee;
  transition: background-color 100ms;

button:hover {
  background-color: #999;


// Variables

// Get the password toggle
const toggle = document.querySelector('#show-passwords');

// Get the password fields
const passwords = Array.from(

// Functions

 * Toggle the visibility of a password field
 * based on a checkbox's current state
 * @param {HTMLInputElement} checkbox The checkbox
 * @param {HTMLInputElement} field The password field
function togglePassword (checkbox, field) {
  field.type = checkbox.checked ? 'text' : 'password';

 * Handle change events
function handleChange () {
  passwords.forEach(password => {
    togglePassword(this, password);

// Inits & Event Listeners

// Handle change events
toggle.addEventListener('change', handleChange);