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

              
                <h1>Live Regions</h1>

<div>
  <div>
    <h2>Polite</h2>

    <button type="button" onclick="popRegion('[aria-live=\'polite\']','I am a polite region. ');">Polite message</button>

    <p>
      This is content you can move into while waiting for the live region to fire. It is delayed three quarters of a second to give you a chance to move in here.
    </p>

    <div id="PoliteRegion" aria-live="polite"></div>

  </div>
  <div>

    <h2>Assertive</h2>

    <button type="button" onclick="popRegion('[aria-live=\'assertive\']','I am more assertive. ');">Assertive message</button>

    <p>
      This is content you can move into while waiting for the live region to fire. It is delayed three quarters of a second to give you a chance to move in here.
    </p>

    <div id="AssertiveRegion" aria-live="assertive"></div>

  </div>
  <div>

    <h2>Alert Role</h2>

    <button type="button" onclick="popRegion('[role=\'alert\']','Interrupting cow! ');">Knock knock</button>

    <p>
      This is content you can move into while waiting for the live region to fire. It is delayed three quarters of a second to give you a chance to move in here.
    </p>

    <div id="AlertRegion" role="alert"></div>

  </div>
</div>
              
            
!

CSS

              
                body {
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto,
    Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  line-height: 1.4;
  /*   line-height: 1.5; */
  /*   letter-spacing: 0.12em; */
  /*   word-spacing: 0.16em; */
}

[aria-live], [role="alert"] {
  margin: 1em 0;
  box-sizing: border-box;
  min-width: 10em;
  min-height: 3em;
  padding: .5em 1em;
  border: .1em dotted #00f;
}

[role="alert"] {
  border-color: #c00;
}

h1 + div {
  display: flex;
  gap: 5vw;
  flex-wrap: wrap;
}

h1 + div > div {
  flex: 1 1 10em;
}

h2 {
  margin-top: 0;
}

button {
  font: inherit;
}
              
            
!

JS

              
                function popRegion(selector,msg) {
  var liveRegion = document.querySelector(selector);
//   Delay the live region update so
//   the user can get into some other
//   content to test how it announces
  setTimeout(function () {
    liveRegion.innerHTML = liveRegion.innerHTML + msg;
  //   Clear the live region
    setTimeout(function () {
      liveRegion.innerHTML = "";
    }, 2000);
  }, 750);
}

              
            
!
999px

Console