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


  <h2>The <code>defaultChecked</code> Property on Checkboxes</h2>

  <p>The first button on this page uses the <code>checked</code> property to find out which checkboxes are currently selected. The second button uses the <code>defaultChecked</code> property to find out which items were originally checked by default. Try selecting
    different options, then use the buttons again.</p>

  <form id="form">
      <input type="checkbox" value="one" name="setOne"> One<br />
      <input type="checkbox" value="two" name="setOne" checked> Two<br />
      <input type="checkbox" value="three" name="setOne"> Three<br />
      <input type="checkbox" value="four" name="setOne" checked> Four

  <div class="btns">
    <button>Get Current Checked</button> <button>Get Default Checked</button>




                body {
  font-family: Arial, sans-serif;
  font-size: 20px;
  padding: 0 20px;

main {
  text-align: center;
  margin: 0 auto;
  max-width: 800px;

p {
  text-align: left;
  padding: 0 20px;

code {
  color: firebrick;

form {
  max-width: 500px;
  margin: auto;

.btns {
  padding-bottom: 20px;

output {
  display: block;
  font-weight: bold;
  margin-bottom: 20px;


                let myForm = document.getElementById('form'),
    btn = document.querySelector('button'),
    btn2 = document.querySelectorAll('button')[1],
    op = document.querySelector('output'),
    op2 = document.querySelectorAll('output')[1],

btn.addEventListener('click', function () {
  op.innerHTML = 'Current selected option(s): ';
  for (i of myForm.setOne) {
    if (i.checked === true) {
      op.innerHTML += `${i.value} `;
}, false);

btn2.addEventListener('click', function () {
  op2.innerHTML = 'Default selected option(s): ';
  for (i of myForm.setOne) {
    if (i.defaultChecked === true) {
       op2.innerHTML += `${i.value} `;
}, false);