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.


                <h1>The <code>FocusEvent.relatedTarget</code> property</h1>

<p>Tab through the page and check the console.</p>

  <a href="#">Link</a>

  <button type="button">Button</button>


                * {
  box-sizing: border-box;

body {
  width: 90%;
  max-width: 40em;
  margin: 1em auto;
  line-height: 1.5;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;

h1 {
  overflow-wrap: break-word;

code {
  font-family: SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  font-size: 90%;
  color: #b22222;

button {
  font: inherit;

/* */
@media (prefers-color-scheme: dark) {
  html {
    background: #000;

  body {
    filter: invert(100%) hue-rotate(180deg);


 * Handle focusin and focusout events.
 * @param {FocusEvent} event - The FocusEvent interface.
function handleFocus(event) {
  // Log the event type

  // Log the target and relatedTarget
  console.log('relatedTarget:', event.relatedTarget);

  // Log a newline character

// Handle focusin and focusout events
document.body.addEventListener('focusin', handleFocus);
document.body.addEventListener('focusout', handleFocus);