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="wrapper">
	<h1>Native Dialog - Test 5: initial focus on dialog - with <code>role="dialog"</code></h1>
	<p><a href="" target="_blank">Debug version</a></p>
	<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quibusdam voluptatibus, animi ratione et voluptate assumenda harum, ipsa dignissimos aliquam perspiciatis suscipit ipsam, similique labore voluptates itaque temporibus provident qui laboriosam.</p>
	<button id="open-btn" class="button">Open Dialog</button>
	<p><a href="" target="_blank">Debug version</a></p>

<dialog role="dialog" tabindex="-1">
	<h2 id="dialog-heading">Wombats</h2>
	<p id="dialog-description">Short-legged, Australian marsupials.</p>
	<p>Wombats are <a href="" target="_blank">marsupials</a> with brown, tan or grey fur and from head to tail. They are expert diggers with short, muscular legs and sharp claws.</p>
	<button id="close-btn" class="button">Close</button>


                dialog:focus {
	outline: 0;
	box-shadow: 0 0 0 1px #fff, 0 0 0 4px #000;

dialog h2 { 
	margin-top: 0; 

dialog::backdrop {
  background: rgba(0,0,0,.75);

	dialog {
		width: 50%;

/* Inert */
[inert] {
  pointer-events: none;
  cursor: default;

[inert], [inert] * {
  user-select: none;


                let openBtn = document.getElementById('open-btn'),
		closeBtn = document.getElementById('close-btn'),
		wrapper = document.querySelectorAll('.wrapper')[0],
		dialog = document.querySelector('dialog');

		// event listeners for open/close buttons
		openBtn.addEventListener('click', openDialog);
		closeBtn.addEventListener('click', closeDialog);

		// open dialog
		function openDialog() {

		// close dialog
		function closeDialog() {

		// handle escape key close
		document.addEventListener('keydown', (e) => {
			if ((e.keyCode || e.which) === 27){

		// listen for click outside dialog to close 
		dialog.addEventListener("click", (e) => {
			var rect =;
			var minX = rect.left +;
			var minY = +;
			if ((e.clientX < minX || e.clientX >= minX + ||
					(e.clientY < minY || e.clientY >= minY + {