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

              
                <div class="margin-2">
  <a href="#example-modal-1" class="usa-button" aria-controls="example-modal-1" data-open-modal>Open default modal</a>
  <div class="usa-modal" id="example-modal-1" aria-labelledby="modal-1-heading" aria-describedby="modal-1-description">
    <div class="usa-modal__content">
      <div class="usa-modal__main">
        <h2 class="usa-modal__heading" id="modal-1-heading">
          Form with client side validation
        </h2>
        <div class="usa-prose">
          <form id="formid" >
              <div class="usa-form-group usa-form-group--year">
            <label class="usa-label" for="date_of_birth_year">Year</label>
            <input class="usa-input" aria-describedby="mdHint" id="date_of_birth_year" name="date_of_birth_year" minlength="4" maxlength="4" pattern="[0-9]*" inputmode="numeric" value="" />
          </div>
          </form>
          <script>
              // prevent the form from submitting 
              const form = document.querySelector('#formid')
              form.addEventListener('submit', e => e.preventDefault())
              
//               // temp work around
//               const modal_toggle_button = document.querySelector('a[href="#example-modal-1"]')
//               modal_toggle_button.addEventListener('click',() => {
//                 const submit_button = document.querySelector('button[form="formid"]')
//                 submit_button.removeAttribute('data-close-modal')
                
//                 submit_button.addEventListener('click', () => {
//                     if(form.checkValidity()) submit_button.setAttribute('data-close-modal', true) 
//                 })
//               })
          </script>
        </div>
        <div class="usa-modal__footer">
          <ul class="usa-button-group">
            <li class="usa-button-group__item">
              <button type="submit" form="formid" class="usa-button" data-close-modal>
                Submit (and close)
              </button>
            </li>
            <li class="usa-button-group__item">
              <button type="button" class="usa-button usa-button--unstyled padding-105 text-center" data-close-modal>
                Close
              </button>
            </li>
          </ul>
        </div>
      </div>
      <button type="button" class="usa-button usa-modal__close" aria-label="Close this window" data-close-modal>
        <svg class="usa-icon" aria-hidden="true" focusable="false" role="img">
          <use xlink:href="/assets/img/sprite.svg#close"></use>
        </svg>
      </button>
    </div>
  </div>
</div>
              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console