Pen Settings

HTML

CSS

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

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

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.

HTML

              
                <button id="test_button">
  Open Dialog 1
</button>

<button id="test_button2">
  Open Dialog 2
</button>

<!--
  Opening the modal dialog using iOS Safari + VO, Button 1 will open a dialog, but VO focus will not be moved to the dialog or it's child content, even though focus is being programmatically set to the dialog.

button 2 will open the dialog, and focus + VO focus will be moved to the dialog/first element within the dialog. the difference here is that the modal was set to visibility hidden, instead of display none, for its inactive state.
-->

<div tabindex="-1" id="test_dialog" role="dialog"  aria-labelledby="test">
  <h2 id="test">a test</h2>
  <p>a test paragraph</p>
  <button>close</button>
</div>

<div tabindex="-1" id="test_dialog2" role="dialog"  aria-labelledby="test2">
  <h2 id="test2">a test 2</h2>
  <p>a test paragraph</p>
  <button>close</button>
</div>
              
            
!

CSS

              
                #test_dialog {
  display: none;
}

#test_dialog2 {
  visibility: hidden;
}

#test_dialog.show {
  display: block;
  padding: 1em;
  box-shadow: 0 0 300px
}

#test_dialog2.show {
  visibility: visible;
  padding: 1em;
  box-shadow: 0 0 300px
}

button[aria-hidden] {
  opacity: .2;
}

*:focus {
  box-shadow: none;
  outline: 2px solid blue;
}
              
            
!

JS

              
                var btn = document.getElementById('test_button');
var btn2 = document.getElementById('test_button2');
var dialog = document.getElementById('test_dialog');
var dialog2 = document.getElementById('test_dialog2');
var btnClose = dialog.querySelector('button');
var btnClose2 = dialog2.querySelector('button');

btn.addEventListener('click', function () {
  dialog.classList.add('show');
  requestAnimationFrame(function() {
    dialog.focus();
  });
  this.setAttribute('aria-hidden', true);
  this.setAttribute('tabindex', '-1');
  btn2.setAttribute('aria-hidden', true);
  btn2.setAttribute('tabindex', '-1');
});

btn2.addEventListener('click', function () {
  dialog2.classList.add('show');
  dialog2.focus();
  this.setAttribute('aria-hidden', true);
  this.setAttribute('tabindex', '-1');
  btn.setAttribute('aria-hidden', true);
  btn.setAttribute('tabindex', '-1');
});

btnClose.addEventListener('click', function () {
  dialog.classList.remove('show');
  btn.removeAttribute('aria-hidden');
  btn.removeAttribute('tabindex');
  btn2.removeAttribute('aria-hidden');
  btn2.removeAttribute('tabindex');
  btn.focus();      
});

btnClose2.addEventListener('click', function () {
  dialog2.classList.remove('show');
  btn.removeAttribute('aria-hidden');
  btn.removeAttribute('tabindex');
  btn2.removeAttribute('aria-hidden');
  btn2.removeAttribute('tabindex');
  btn2.focus();      
});

              
            
!
999px

Console