Pen Settings

HTML

CSS

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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

HTML

              
                <h1>Testing aria-roledescription</h1>

<p>
  Experimenting with <code>aria-roledescription</code> for my blog post <cite><a href="https://adrianroselli.com/2020/04/avoid-aria-roledescription.html" aria-roledescription="Jumplink">Avoid <code>aria-roledescription</code></a></cite>.
</p>

<form>

  <div>

    <h2>Overriding a Field Type</h2>

    <label for="Fancywig">Phone Number</label>
    <input type="text" id="Fancywig" aria-roledescription="Only numbers are allowed">

  </div>
  <div>

    <h2>'Standardizing' a Field Type</h2>

    <label for="Choice">Choose</label>
    <select id="Choice" aria-roledescription="dropdown">
      <option>Hammer</option>
      <option>Sandwich</option>
      <option>Wrench</option>
      <option>Burrito</option>
      <option>Pliers</option>
      <option>Wrap</option>
    </select>

  </div>
  <div>

    <h2>Adding Context to a Single Control</h2>

    <div>
      <button aria-roledescription="attachment button">
        family_reunion.jpg
      </button>
    </div>

  </div>
  <div>

    <h2>Localized Control</h2>

    <div>
      <button lang="pt" aria-roledescription="meu berimbau botão">
        Jogar
      </button>
    </div>

  </div>
  <div>

    <h2>Adding Context to a Set of Controls</h2>

    <div>
      <button aria-pressed="false" aria-roledescription="toggle">Wifi</button>
    </div>
    <div>
      <button aria-pressed="false" aria-roledescription="switch">Bluetooth</button>
    </div>

  </div>
  <div>

    <h2>Adding Context to a Widget</h2>

    <section role="region" aria-roledescription="accordion" aria-label="Widget">
      <div>
        <button type="button" id="btnDisc01" aria-expanded="false" onclick="toggleDisclosure(this.id);" aria-controls="Disclosed01">
          <span>
            <svg xmlns="\http://www.w3.org/2000/svg&quot;" viewBox="0 0 80 80" focusable="false">
              <path d="M70.3 13.8L40 66.3 9.7 13.8z"></path>
            </svg>
          </span>
          Item 1
        </button>
        <div id="Disclosed01" class="disclosee">
          <p>
            Here is some disclosed content.
          </p>
        </div>
      </div>
      <div>
        <button type="button" id="btnDisc02" aria-expanded="false" onclick="toggleDisclosure(this.id);" aria-controls="Disclosed02">
          <span>
            <svg xmlns="\http://www.w3.org/2000/svg&quot;" viewBox="0 0 80 80" focusable="false">
              <path d="M70.3 13.8L40 66.3 9.7 13.8z"></path>
            </svg>
          </span>
          Item 2
        </button>
        <div id="Disclosed02" class="disclosee">
          <p>
            Here is some disclosed content.
          </p>
        </div>
        <div>
          <button type="button" id="btnDisc03" aria-expanded="false" onclick="toggleDisclosure(this.id);" aria-controls="Disclosed03">
            <span>
              <svg xmlns="\http://www.w3.org/2000/svg&quot;" viewBox="0 0 80 80" focusable="false">
                <path d="M70.3 13.8L40 66.3 9.7 13.8z"></path>
              </svg>
            </span>
            Item 3
          </button>
          <div id="Disclosed03" class="disclosee">
            <p>
              Here is some disclosed content.
            </p>
          </div>
        </div>

    </section>

  </div>

</form>
              
            
!

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; */
}

label {
  display: block;
}

div div, label {
  margin-top: 1.5em;
}

form {
    display: grid;
  grid-template-columns: repeat(auto-fit, minmax(20em, 1fr));
}

form > div {
/*   outline: 1px dotted #f00; */
  margin: 2em 1em;
}

:focus {
  outline: .5em solid rgba(0,0,255,.25);
}

/* All the CSS needed to make disclosures work */

/* button[aria-expanded="true"] ~ .disclosee {
  display: block;
} */

button[aria-expanded="false"] + div {
  display: none;
}

/* END All the CSS needed to make disclosures work */


button[aria-expanded] span {
  display: inline-block;
  font-size: 60%;
  color: #000;
  background-color: #00f;
  padding: 0.3em 0.2em 0 0.2em;
  border: 0.2em solid #00f;
  border-radius: 50%;
  line-height: 1;
  text-align: center;
  text-indent: 0;
  transform: rotate(270deg);
}

button[aria-expanded] svg {
  width: 1.25em;
  height: 1.25em;
  fill: #fff;
  transition: transform 0.25s ease-in;
  transform-origin: center 45%;
}

button[aria-expanded]:hover,
button[aria-expanded]:focus {
  background-color: #666;
  color: #fff;
  outline: none;
  border-color: #666;
}

button[aria-expanded]:hover span,
button[aria-expanded]:focus span {
  background-color: #fff;
  outline: none;
}

button[aria-expanded]:hover svg,
button[aria-expanded]:focus svg {
  fill: #00f;
}

/* Lean on programmatic state for styling */
button[aria-expanded="true"] svg {
  transform: rotate(90deg);
}

section[role=region] {
  padding: 0;
  border: .05em solid #ccc;
}

section[role=region] div {
  margin: 0;
}

section[role=region] button {
  display: block;
  width: 100%;
  text-align: left;
  font-size: 110%;
  font-weight: bold;
  background: #efefef;
  border: .01em solid #ccc;
  padding: .5em .75em;
}

.disclosee {
  padding: .25em .75em;
}
              
            
!

JS

              
                function closeAllDisclosures() {
  var openDs = document.querySelectorAll("button[aria-expanded]");
  for (var i = 0; i < openDs.length; i++) {
    if (openDs[i].getAttribute("aria-expanded") == "true") {
      openDs[i].setAttribute("aria-expanded", "false");
    }
  }
}

function toggleDisclosure(btnID) {
  closeAllDisclosures();
  // Get the button that triggered this
  var theButton = document.getElementById(btnID);
  // If the button is not expanded...
  if (theButton.getAttribute("aria-expanded") == "false") {
    // Now set the button to expanded
    theButton.setAttribute("aria-expanded", "true");
  // Otherwise button is not expanded...
  } else {
    // Now set the button to collapsed
    theButton.setAttribute("aria-expanded", "false");
  }
}
              
            
!
999px

Console