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="container">
  <h1>Drawing attention to internal focus</h1>
  <p>When using internal document links, it's important to manage keyboard focus for screen-reader users <i>and</i> draw sighted users' attention to the content you want them to focus on. In this demo, activating the internal links moves browser focus to their target headings; then, scripting applies a <code>highlight</code> class to the heading's parent and removes the class after the highlight animation ends.</p>
  <p><b>Note:</b> the <code>:focus-within</code> selector is not ideal here; it will match every time your user focuses on an element in a given region. We want to show our highlight <i>only</i> when the user clicks an intra-document link.</p>
  <div class="demo js-demo">
        <a href="#charismatic-introductions">Charismatic introductions</a><a href="#specialty-fans">Specialty fans</a>
      <h3 id="charismatic-introductions" tabindex="-1">Charismatic introductions</h3>
      <p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. <a href="#">Ipsam, culpa commodi</a>. Totam amet maxime quo pariatur.
        Ipsa ullam rem nam nesciunt! Dolores assumenda dolorum eveniet ullam dicta, facilis dignissimos reprehenderit!
        Lorem, ipsum dolor sit amet consectetur adipisicing elit. Numquam quasi perspiciatis ea impedit, unde, qui
        provident adipisci nesciunt aperiam laborum consequuntur. Atque nemo quisquam laborum numquam? Vitae, dolorem
      <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Nulla ea cupiditate, odit numquam, possimus aliquam
        quibusdam accusamus, enim doloremque laborum qui? Facilis veritatis numquam quaerat perspiciatis sint iste
        Lorem, ipsum dolor sit amet consectetur adipisicing elit. Quam facere quo culpa repudiandae porro, consequuntur
        sequi ad mollitia maiores quas exercitationem, delectus atque pariatur fugiat voluptates distinctio cupiditate
        animi! Lorem ipsum dolor sit amet consectetur adipisicing elit. Error facilis eaque officiis, voluptatem harum
        excepturi. Debitis veniam est itaque, perferendis omnis quidem nesciunt excepturi ducimus, quibusdam deserunt
        laudantium in qui. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illo, excepturi? Facilis,
        id eligendi illum cupiditate harum dolorum voluptatem at inventore optio, amet porro placeat. Quod et excepturi
        mollitia aspernatur.</p>
      <p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Pariatur eos dicta, suscipit facilis eligendi illo
        incidunt provident porro similique sint, harum sunt consequuntur? Minus cupiditate reiciendis enim cum
      <h3 id="specialty-fans" tabindex="-1">Specialty fans</h3>
      <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Odio, non pariatur sint eius ipsa omnis dicta quos
        deserunt magni facilis facere consequatur architecto asperiores quibusdam tempore iste excepturi impedit rerum!
        Lorem, ipsum dolor sit amet consectetur adipisicing elit. Vel, <a href="#">dolor unde</a>. Laudantium laboriosam aliquam non
        mollitia nesciunt quibusdam eligendi distinctio nobis, architecto unde quasi provident temporibus voluptas
        voluptatum voluptate. Lorem, ipsum dolor sit amet consectetur adipisicing elit. Id consequatur totam officiis
        repudiandae! Facilis deleniti quas vel molestias doloremque nisi aliquid inventore modi ullam. Enim id odio
        harum est.</p>
      <p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Amet, officiis deserunt. Vitae tempora accusamus ex
        nobis, ut sequi provident obcaecati quas, expedita quidem eveniet saepe labore nesciunt eligendi maiores.</p>
      <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Ipsa iusto est nemo quas deserunt, dolore itaque
        Assumenda incidunt voluptas quidem quo ratione, odio illo ducimus? Praesentium harum quibusdam quod. Lorem ipsum
        dolor sit amet consectetur adipisicing elit. Quaerat possimus quasi doloremque voluptatem, expedita esse ducimus
        cupiditate vitae adipisci voluptas excepturi ipsam culpa ullam ad animi accusamus quisquam. Dolore, molestias?


*:before {
  box-sizing: border-box;


:focus {
  outline: 3px dashed #0e4bff;

/*Don't show focus outline for negative-index elements */
[tabindex="-1"]:focus {
  outline: 0;

.highlight {
  animation: highlight 1.25s ease-in-out;

@keyframes highlight {
  0% {
    background: #f9f98b;
  100% {
    background: none;

*::after {
  box-sizing: border-box;

html {
  font: 10px / 1.15 sans-serif;
  font: calc(100% * 0.625) / 1.15 sans-serif;

body {
  font: 1.6rem/1.25 "HelveticaNeue-Light", "Helvetica Neue Light",
    "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
  color: #252525;
  margin-bottom: 1.5em;

@media screen and (min-width: 680px) {
  body {
    font-size: 1.92em;
    line-height: 1.4;

h1 {
  font-size: 2em;

h2:not(:first-child) {
  margin-bottom: 0;
h1 + * {
  margin-top: 1.25em;

h2:first-child {
  margin-top: 1.5em;
h2 + p,
p:first-child {
  margin-top: 1em;

p {
  max-width: 75ch;

code {
  background-color: #eee;
  padding: 0.1em 0.2em;
  color: #000;

.container {
  width: 95%;
  max-width: 100rem;
  margin: 0 auto;

.demo {
  max-width: 100rem;
  height: 30rem;
  overflow-y: scroll;
  padding: 1.5rem 1rem;
  margin: 0 auto;
  font-size: 0.9em;
  border: 3px solid black;

.demo nav {
  background: #000;

.demo nav a {
  display: inline-block;
  color: #fff;
  padding: 5px;
  padding: 1.2em 0.8em;

.demo nav a:hover,
.demo nav a:focus{
  color: #000;
  background-color: #fff;

.demo nav a:focus {
  outline-offset: -3px;

section {
  padding: 0 0.75rem;

section > h2 {
  margin-top: 0;



                if (!Element.prototype.matches) {
  Element.prototype.matches =
    Element.prototype.msMatchesSelector ||

function handleHashLinkClick(evt) {
  if (!'a[href^="#"]')) {
  const hash =;
  const targetHeading = document.querySelector(hash);
  const parent = targetHeading.parentElement;
  return parent.classList.add("highlight");

function handleFocusAnimationEnd(evt) {
  if (evt.animationName === "highlight") {
    return evt.srcElement.classList.remove("highlight");

function handleHashTargetMousedown(evt) {
  if ('[tabindex="-1"]')) {
    return evt.preventDefault();

document.addEventListener("DOMContentLoaded", function (e) {
  const demoContainer = document.querySelector(".js-demo");
  demoContainer.addEventListener("click", handleHashLinkClick, true);
  demoContainer.addEventListener("mousedown", handleHashTargetMousedown, true);
  demoContainer.addEventListener("animationend", handleFocusAnimationEnd, true);