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

              
                <div class="content-container">
  <header>
    <h1>Markup Must Communicate As Clearly As Design</h1>
    <h2>Live Notifications</h2>
  </header>
  <main>
    <p>When working from a design, it’s common to build what we see. However, the visual design is only one part of creating perceivable content.</p>
    <p>Because some people may not be able to see a notification circle, use screen-reader-specific markup to ensure it communicates the same as the UI.</p>

    <section class="content-section">
      <h3>Without perceivable markup</h3>

      <div class="notification no-aria">
        <svg xmlns="http://www.w3.org/2000/svg" fill="current-color" width="36px" height="36px" viewBox="0 -64 640 640">
          <path d="M192 256c61.9 0 112-50.1 112-112S253.9 32 192 32 80 82.1 80 144s50.1 112 112 112zm76.8 32h-8.3c-20.8 10-43.9 16-68.5 16s-47.6-6-68.5-16h-8.3C51.6 288 0 339.6 0 403.2V432c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48v-28.8c0-63.6-51.6-115.2-115.2-115.2zM480 256c53 0 96-43 96-96s-43-96-96-96-96 43-96 96 43 96 96 96zm48 32h-3.8c-13.9 4.8-28.6 8-44.2 8s-30.3-3.2-44.2-8H432c-20.4 0-39.2 5.9-55.7 15.4 24.4 26.3 39.7 61.2 39.7 99.8v38.4c0 2.2-.5 4.3-.6 6.4H592c26.5 0 48-21.5 48-48 0-61.9-50.1-112-112-112z" />
      </div>
    </section>

    <section class="content-section">
      <h3>With perceivable markup</h3>

      <div class="notification with-aria" aria-relevant="additions" aria-live="polite">
        <svg xmlns="http://www.w3.org/2000/svg" fill="current-color" width="36px" height="36px" viewBox="0 -64 640 640">
          <path d="M192 256c61.9 0 112-50.1 112-112S253.9 32 192 32 80 82.1 80 144s50.1 112 112 112zm76.8 32h-8.3c-20.8 10-43.9 16-68.5 16s-47.6-6-68.5-16h-8.3C51.6 288 0 339.6 0 403.2V432c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48v-28.8c0-63.6-51.6-115.2-115.2-115.2zM480 256c53 0 96-43 96-96s-43-96-96-96-96 43-96 96 43 96 96 96zm48 32h-3.8c-13.9 4.8-28.6 8-44.2 8s-30.3-3.2-44.2-8H432c-20.4 0-39.2 5.9-55.7 15.4 24.4 26.3 39.7 61.2 39.7 99.8v38.4c0 2.2-.5 4.3-.6 6.4H592c26.5 0 48-21.5 48-48 0-61.9-50.1-112-112-112z" />
      </div>
    </section>
  </main>
  <footer>
    <p>Keys To An Accessibility Mindset</p>
    <a href="https://twitter.com/DanielYuschick" aria-label="@Daniel Yuschick on Twitter">@DanielYuschick</a>
  </footer>
</div>
              
            
!

CSS

              
                .notification {
  position: relative;
  block-size: 36px;
  inline-size: 36px;
}

.notification-bubble {
  --bubble-size: 24px;

  content: "";
  background: var(--color-core-secondary);
  border-radius: 50%;
  position: absolute;
  inset-block-end: calc(var(--bubble-size) / 2 * -1);
  inset-inline-end: calc(var(--bubble-size) / 2 * -1);
  block-size: var(--bubble-size);
  inline-size: var(--bubble-size);
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 600;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  white-space: nowrap;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
}

/**********
*** SETUP
**********/
/***** Properties *****/
:root {
  --color-aux-50: rgb(10, 10, 11);
  --color-aux-100: rgb(29, 29, 32);
  --color-aux-200: rgb(48, 48, 54);
  --color-aux-300: rgb(77, 77, 86);
  --color-aux-400: rgb(96, 96, 108);
  --color-aux-500: rgb(115, 115, 130);
  --color-aux-600: rgb(147, 147, 159);
  --color-aux-700: rgb(169, 169, 178);
  --color-aux-800: rgb(190, 190, 197);
  --color-aux-900: rgb(223, 223, 226);
  --color-aux-950: rgb(242, 239, 233);

  --color-core-primary: #bc3908;
  --color-core-secondary: #f6aa1c;
  --color-core-tertiary: #621708;

  --font-family-body: "Inter", sans-serif;
  --font-family-heading: "Sofia Sans", sans-serif;

  --space-base: 4px;
  --space-base-half: calc(var(--space-base) / 2);
  --space-base-1x: var(--space-base);
  --space-base-2x: calc(var(--space-base) * 2);
  --space-base-3x: calc(var(--space-base) * 3);
  --space-base-4x: calc(var(--space-base) * 4);
  --space-base-6x: calc(var(--space-base) * 6);
  --space-base-8x: calc(var(--space-base) * 8);
  --space-base-12x: calc(var(--space-base) * 12);
  --space-base-16x: calc(var(--space-base) * 16);
  --space-base-24x: calc(var(--space-base) * 24);
}

/***** Landmarks *****/
body {
  /* background by SVGBackgrounds.com */
  background-color: var(--color-aux-950);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2000 1500'%3E%3Cdefs%3E%3Crect fill='none' stroke-width='1' id='a' x='-400' y='-300' width='800' height='600'/%3E%3C/defs%3E%3Cg style='transform-origin:center'%3E%3Cg transform='rotate(77.4 0 0)' style='transform-origin:center'%3E%3Cg transform='rotate(-160 0 0)' style='transform-origin:center'%3E%3Cg transform='translate(1000 750)'%3E%3Cuse stroke='%23F2F4F3' href='%23a' transform='rotate(10 0 0) scale(2.1)'/%3E%3Cuse stroke='%23eee8e3' href='%23a' transform='rotate(20 0 0) scale(2.2)'/%3E%3Cuse stroke='%23ebdbd4' href='%23a' transform='rotate(30 0 0) scale(2.3)'/%3E%3Cuse stroke='%23e7cfc4' href='%23a' transform='rotate(40 0 0) scale(2.4)'/%3E%3Cuse stroke='%23e4c2b4' href='%23a' transform='rotate(50 0 0) scale(2.5)'/%3E%3Cuse stroke='%23e0b6a5' href='%23a' transform='rotate(60 0 0) scale(2.6)'/%3E%3Cuse stroke='%23dca995' href='%23a' transform='rotate(70 0 0) scale(2.7)'/%3E%3Cuse stroke='%23d99d85' href='%23a' transform='rotate(80 0 0) scale(2.8)'/%3E%3Cuse stroke='%23d59076' href='%23a' transform='rotate(90 0 0) scale(2.9)'/%3E%3Cuse stroke='%23d28466' href='%23a' transform='rotate(100 0 0) scale(3)'/%3E%3Cuse stroke='%23ce7756' href='%23a' transform='rotate(110 0 0) scale(3.1)'/%3E%3Cuse stroke='%23ca6b47' href='%23a' transform='rotate(120 0 0) scale(3.2)'/%3E%3Cuse stroke='%23c75e37' href='%23a' transform='rotate(130 0 0) scale(3.3)'/%3E%3Cuse stroke='%23c35227' href='%23a' transform='rotate(140 0 0) scale(3.4)'/%3E%3Cuse stroke='%23c04518' href='%23a' transform='rotate(150 0 0) scale(3.5)'/%3E%3Cuse stroke='%23BC3908' href='%23a' transform='rotate(160 0 0) scale(3.6)'/%3E%3C/g%3E%3C/g%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  background-attachment: fixed;
  background-size: cover;
  background-position: center center;
  display: grid;
  align-content: center;
}

footer {
  --padding-offset: var(--space-base-4x);

  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  border-block-start: 1px solid #000;
  padding-block: var(--padding-offset);
  margin-block-start: var(--padding-offset);
}

/***** Textual *****/
a,
a:visited,
a:active,
a:link {
  color: var(--color-aux-50);

  &:not([aria-current="page"], .active):hover {
    background: var(--color-aux-800);
  }
}

span,
p {
  font-family: var(--font-family-body);
}

p + p {
  margin-block-start: 1rem;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-family-heading);
}

code {
  background: var(--color-aux-100);
  color: var(--color-aux-950);
  display: block;
  padding: 0.25rem 0.5rem;

  &.inline {
    display: inline-block;
  }
}

/***** Other *****/
.content-container {
  inline-size: 75%;
  margin-inline: auto;
}

/**********
*** RESET
**********/
* {
  margin: 0;
  padding: 0;
}

*,
::before,
::after {
  box-sizing: border-box;
}

*:where(:not(fieldset, progress, meter)) {
  background-origin: border-box;
  background-repeat: no-repeat;
  border-style: solid;
  border-width: 0;
}

html {
  -webkit-text-size-adjust: none;
  block-size: 100%;
}

@media (prefers-reduced-motion: no-preference) {
  html:focus-within {
    scroll-behavior: smooth;
  }
}

body {
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  min-block-size: 100%;
  text-rendering: optimizeSpeed;
}

:where(img, svg, video, canvas, audio, iframe, embed, object) {
  display: block;
}
:where(img, svg, video) {
  block-size: auto;
  max-inline-size: 100%;
}

:where(svg) {
  fill: currentColor;
  stroke: none;
}

:where(svg):where(:not([fill])) {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke: currentColor;
}

:where(svg):where(:not([width])) {
  inline-size: 5rem;
}

:where(input, button, textarea, select),
:where(input[type="file"])::-webkit-file-upload-button {
  color: inherit;
  font-size: inherit;
  font: inherit;
  letter-spacing: inherit;
  word-spacing: inherit;
}

:where(textarea) {
  resize: block;
}

:where(p, h1, h2, h3, h4, h5, h6) {
  overflow-wrap: break-word;
}

:where(ul, ol) {
  list-style-position: inside;
}

:where(ul, ol, [role="list"]) {
  list-style: none;
}

:where(ul, ol, [role="list"]) li::before {
  border: 0px;
  clip: rect(0px, 0px, 0px, 0px);
  content: "\\200B";
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0px;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

a:not([class]) {
  text-decoration-skip-ink: auto;
}

:where(a[href], area, button, input, label[for], select, summary, textarea, [tabindex]:not([tabindex*="-"])) {
  cursor: pointer;
  touch-action: manipulation;
}
:where(input[type="file"]) {
  cursor: auto;
}
:where(input[type="file"])::-webkit-file-upload-button,
:where(input[type="file"])::file-selector-button {
  cursor: pointer;
}

@media (prefers-reduced-motion: no-preference) {
  :focus-visible {
    transition: outline-offset 145ms cubic-bezier(0.25, 0, 0.4, 1);
  }
  :where(:not(:active)):focus-visible {
    transition-duration: 0.25s;
  }
}
:where(:not(:active)):focus-visible {
  outline-offset: 5px;
}

:where(button, button[type], input[type="button"], input[type="submit"], input[type="reset"]),
:where(input[type="file"])::-webkit-file-upload-button,
:where(input[type="file"])::file-selector-button {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  text-align: center;
  user-select: none;
}

:where(button, button[type], input[type="button"], input[type="submit"], input[type="reset"])[disabled] {
  cursor: not-allowed;
}

/**********
*** UTILITIES
**********/
.active-nav {
  background: var(--color-core-primary);
  color: var(--color-aux-950);
  text-decoration: underline;
}

.content-section {
  padding-block: var(--space-base-8x);
}

              
            
!

JS

              
                const noAriaContainer = document.querySelector(".notification.no-aria");
const ariaContainer = document.querySelector(".notification.with-aria");

setTimeout(() => {
  const notification = document.createElement("div");
  notification.className = "notification-bubble";
  notification.innerHTML = "<span>1</span>";
  noAriaContainer.append(notification);
}, 10000);

setTimeout(() => {
  const notification = document.createElement("div");
  notification.className = "notification-bubble";
  notification.innerHTML =
    "<span>" +
    "1" +
    '<span class="visually-hidden"> unread notification</span>' +
    "</span>";
  ariaContainer.append(notification);
}, 13000);

              
            
!
999px

Console