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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

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

              
                <div class="center">
  <h1 id="title">Multiple Labels on a Single Input</h1>
  <div class="test-cases"><a href="https://codepen.io/straker/pen/OYVmzQ">View test cases</a></div>
  <div class="legend">
    <h2>Legend</h2>
    <dl class="clear">
      <dt class="supported">✓</dt>
      <dd>Supported</dd>
      <dt class="unsupported">×</dt>
      <dd>Unsupported</dd>
    </dl>
  </div>
</div>

<table aria-labelledby="title">
  <tr>
    <th scope="col" width="18%">Code</code></th>
    <th scope="col" width="14%">VoiceOver and Safari 12.0.3 on OS X Mojave 10.14.3</th>
    <th scope="col" width="14%">VoiceOver and Safari on iOS 12.2.0</th>
    <th scope="col" width="14%">JAWS 2019.1903.47 and IE on Windows</th>
    <th scope="col" width="14%">NVDA 2019.1 and Firefox 66.0.4 on Windows</th>
    <th scope="col" width="14%">Talkback and Chrome 73.0.3683.90 on Android 7.0</th>
  </tr>
  <tr>
    <th scope="row"><pre><code>&lt;input type="checkbox" id="A"&gt;
&lt;label for="A"&gt;Please&lt;/label&gt;
&lt;label for="A"&gt;Excuse&lt;/label&gt;
&lt;label for="A"&gt;My&lt;/label&gt;
&lt;label for="A"&gt;Dear&lt;/label&gt;
&lt;label for="A"&gt;Aunt&lt;/label&gt;
&lt;label for="A"&gt;Sally&lt;/label&gt;</code></pre></th>
    <td class="unsupported"><span>×</span></td>
    <td class="unsupported"><span>×</span></td>
    <td class="unsupported"><span>×</span></td>
    <td class="supported"><span>✓</span></td>
    <td class="supported"><span>✓</span></td>
  </tr>
  <tr>
    <th scope="row"><pre><code>&lt;input type="checkbox" id="B"/&gt;
&lt;label for="B"&gt;Please&lt;/label&gt;
&lt;label for="B" aria-hidden="true"&gt;Excuse&lt;/label&gt;
&lt;label for="B" aria-hidden="true"&gt;My&lt;/label&gt;
&lt;label for="B" aria-hidden="true"&gt;Dear&lt;/label&gt;
&lt;label for="B" aria-hidden="true"&gt;Aunt&lt;/label&gt;
&lt;label for="B" aria-hidden="true"&gt;Sally&lt;/label&gt;</code></pre></th>
    <td class="supported"><span>✓</span></td>
    <td class="supported"><span>✓</span></td>
    <td class="supported"><span>✓</span></td>
    <td class="supported"><span>✓</span></td>
    <td class="unsupported"><span>×</span></td>
  </tr>
  <tr>
    <th scope="row"><pre><code>&lt;input type="checkbox" id="C"/&gt;
&lt;label for="C" aria-hidden="true"&gt;Please&lt;/label&gt;
&lt;label for="C" &gt;Excuse&lt;/label&gt;</code></pre></th>
    <td class="supported"><span>✓</span></td>
    <td class="supported"><span>✓</span></td>
    <td class="supported"><span>✓</span></td>
    <td class="supported"><span>✓</span></td>
    <td class="unsupported"><span>×</span></td>
  </tr>
  <tr>
    <th scope="row"><pre><code>&lt;input type="checkbox" id="D" aria-labelledby="E"/&gt;
&lt;label for="D" aria-hidden="true"&gt;Please&lt;/label&gt;
&lt;label for="D" id="E"&gt;Excuse&lt;/label&gt;</code></pre></th>
    <td class="supported"><span>✓</span></td>
    <td class="supported"><span>✓</span></td>
    <td class="supported"><span>✓</span></td>
    <td class="supported"><span>✓</span></td>
    <td class="supported"><span>✓</span></td>
  </tr>
  <tr>
    <th scope="row"><pre><code>&lt;input type="checkbox" id="F" aria-labelledby="G H"/&gt;
&lt;label for="F" id="G" aria-hidden="true"&gt;Please&lt;/label&gt;
&lt;label for="F" id="H"&gt;Excuse&lt;/label&gt;</code></pre></th>
    <td class="supported"><span>✓</span></td>
    <td class="supported"><span>✓</span></td>
    <td class="supported"><span>✓</span></td>
    <td class="supported"><span>✓</span></td>
    <td class="supported"><span>✓</span></td>
  </tr>
  <tr>
    <th scope="row"><pre><code>&lt;input type="checkbox" id="I"/&gt;
&lt;label for="I" style="display:none"&gt;Please&lt;/label&gt;
&lt;label for="I" &gt;Excuse&lt;/label&gt;</code></pre></th>
    <td class="supported"><span>✓</span></td>
    <td class="supported"><span>✓</span></td>
    <td class="supported"><span>✓</span></td>
    <td class="supported"><span>✓</span></td>
    <td class="supported"><span>✓</span></td>
  </tr>
  <tr>
    <th scope="row"><pre><code>&lt;input type="checkbox" id="J" aria-labelledby="K L M N O P"/&gt;
&lt;label for="J" id="K"&gt;Please&lt;/label&gt;
&lt;label for="J" id="L"&gt;Excuse&lt;/label&gt;
&lt;label for="J" id="M"&gt;My&lt;/label&gt;
&lt;label for="J" id="N"&gt;Dear&lt;/label&gt;
&lt;label for="J" id="O"&gt;Aunt&lt;/label&gt;
&lt;label for="J" id="P"&gt;Sally&lt;/label&gt;</code></pre></th>
    <td class="supported"><span>✓</span></td>
    <td class="unsupported"><span>×</span></td>
    <td class="supported"><span>✓</span></td>
    <td class="supported"><span>✓</span></td>
    <td class="supported"><span>✓</span></td>
  </tr>
  <tr>
    <th scope="row"><pre><code>&lt;input type="checkbox" id="C"/&gt;
&lt;label for="C" aria-hidden="true"&gt;&lt;/label&gt;
&lt;label for="C" &gt;Excuse&lt;/label&gt;</code></pre></th>
    <td class="supported"><span>✓</span></td>
    <td class="unsupported"><span>×</span></td>
    <td class="supported"><span>✓</span></td>
    <td class="unsupported"><span>×</span></td>
    <td class="unsupported"><span>×</span></td>
  </tr>
</table>

<table>
  <caption>Announced as</caption>
  <tr>
    <th scope="col" width="18%">Code</code></th>
    <th scope="col" width="14%">VoiceOver and Safari 12.0.3 on OS X Mojave 10.14.3</th>
    <th scope="col" width="14%">VoiceOver and Safari on iOS 12.2.0</th>
    <th scope="col" width="14%">JAWS 2019.1903.47 and IE on Windows</th>
    <th scope="col" width="14%">NVDA 2019.1 and Firefox 66.0.4 on Windows</th>
    <th scope="col" width="14%">Talkback and Chrome 73.0.3683.90 on Android 7.0</th>
  </tr>
  <tr>
    <th scope="row"><pre><code>&lt;input type="checkbox" id="A"&gt;
&lt;label for="A"&gt;Please&lt;/label&gt;
&lt;label for="A"&gt;Excuse&lt;/label&gt;
&lt;label for="A"&gt;My&lt;/label&gt;
&lt;label for="A"&gt;Dear&lt;/label&gt;
&lt;label for="A"&gt;Aunt&lt;/label&gt;
&lt;label for="A"&gt;Sally&lt;/label&gt;</code></pre></th>
    <td>Please, Please, unchecked, checkbox</td>
    <td>Please, checkbox, unchecked</td>
    <td>Sally, checkbox, not checked</td>
    <td>Not checked, Please Excuse My Dear Aunt Sally, checkbox</td>
    <td>Not checked, Please Excuse My Dear Aunt Sally, checkbox</td>
  </tr>
  <tr>
    <th scope="row"><pre><code>&lt;input type="checkbox" id="B"/&gt;
&lt;label for="B"&gt;Please&lt;/label&gt;
&lt;label for="B" aria-hidden="true"&gt;Excuse&lt;/label&gt;
&lt;label for="B" aria-hidden="true"&gt;My&lt;/label&gt;
&lt;label for="B" aria-hidden="true"&gt;Dear&lt;/label&gt;
&lt;label for="B" aria-hidden="true"&gt;Aunt&lt;/label&gt;
&lt;label for="B" aria-hidden="true"&gt;Sally&lt;/label&gt;</code></pre></th>
    <td>Please, Please, unchecked, checkbox</td>
    <td>Please, checkbox, unchecked</td>
    <td>Please, checkbox, not checked</td>
    <td>Please, checkbox, not checked</td>
    <td>Not checked, Please Excuse My Dear Aunt Sally, checkbox</td>
  </tr>
  <tr>
    <th scope="row"><pre><code>&lt;input type="checkbox" id="C"/&gt;
&lt;label for="C" aria-hidden="true"&gt;Please&lt;/label&gt;
&lt;label for="C" &gt;Excuse&lt;/label&gt;</code></pre></th>
    <td>Excuse, unchecked, checkbox</td>
    <td>Excuse, checkbox, unchecked</td>
    <td>Excuse, checkbox, not checked</td>
    <td>Excuse, checkbox, not checked</td>
    <td>Not checked, Please Excuse, checkbox</td>
  </tr>
  <tr>
    <th scope="row"><pre><code>&lt;input type="checkbox" id="D" aria-labelledby="E"/&gt;
&lt;label for="D" aria-hidden="true"&gt;Please&lt;/label&gt;
&lt;label for="D" id="E"&gt;Excuse&lt;/label&gt;</code></pre></th>
    <td>Excuse, unchecked, checkbox</td>
    <td>Excuse, checkbox, unchecked</td>
    <td>Excuse, checkbox, not checked</td>
    <td>Excuse, checkbox, not checked</td>
    <td>Not checked, Excuse, checkbox</td>
  </tr>
  <tr>
    <th scope="row"><pre><code>&lt;input type="checkbox" id="F" aria-labelledby="G H"/&gt;
&lt;label for="F" id="G" aria-hidden="true"&gt;Please&lt;/label&gt;
&lt;label for="F" id="H"&gt;Excuse&lt;/label&gt;</code></pre></th>
    <td>Please Excuse, unchecked, checkbox</td>
    <td>Please Excuse, checkbox, unchecked</td>
    <td>Please Excuse, checkbox, not checked</td>
    <td>Please Excuse, checkbox, not checked</td>
    <td>Not checked, Please Excuse, checkbox</td>
  </tr>
  <tr>
    <th scope="row"><pre><code>&lt;input type="checkbox" id="I"/&gt;
&lt;label for="I" style="display:none"&gt;Please&lt;/label&gt;
&lt;label for="I" &gt;Excuse&lt;/label&gt;</code></pre></th>
    <td>Excuse, unchecked, checkbox</td>
    <td>Excuse, checkbox, unchecked</td>
    <td>Excuse, checkbox, unchecked</td>
    <td>Excuse, checkbox, not checked</td>
    <td>Not checked, Excuse, checkbox</td>
  </tr>
  <tr>
    <th scope="row"><pre><code>&lt;input type="checkbox" id="J" aria-labelledby="K L M N O P"/&gt;
&lt;label for="J" id="K"&gt;Please&lt;/label&gt;
&lt;label for="J" id="L"&gt;Excuse&lt;/label&gt;
&lt;label for="J" id="M"&gt;My&lt;/label&gt;
&lt;label for="J" id="N"&gt;Dear&lt;/label&gt;
&lt;label for="J" id="O"&gt;Aunt&lt;/label&gt;
&lt;label for="J" id="P"&gt;Sally&lt;/label&gt;</code></pre></th>
    <td>Please Excuse My Dear Aunt Sally, unchecked, checkbox</td>
    <td>Please, unchecked, checkbox</td>
    <td>Please Excuse My Dear Aunt Sally, checkbox, unchecked</td>
    <td>Please Excuse My Dear Aunt Sally, checkbox, not checked</td>
    <td>Not checked, Please Excuse My Dear Aunt Sally, checkbox</td>
  </tr>
  <tr>
    <th scope="row"><pre><code>&lt;input type="checkbox" id="C"/&gt;
&lt;label for="C" aria-hidden="true"&gt;&lt;/label&gt;
&lt;label for="C" &gt;Excuse&lt;/label&gt;</code></pre></th>
    <td>Excuse, unchecked, checkbox</td>
    <td>Checkbox, unchecked</td>
    <td>Excuse, checkbox, unchecked</td>
    <td>Checkbox, not checked</td>
    <td>Not checked, checkbox</td>
  </tr>
</table>

<footer>
  <p><em>Thanks to Paul Grenier for testing iOS VoiceOver and Safari<em></p> 
</footer>
              
            
!

CSS

              
                body, h1, h2, h3, h4, h5, h6 {
  font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
}

.center {
  text-align: center;
}

h1 {
  margin-bottom: 0.5rem;
}

.test-cases a {
  display: block;
}

.legend {
  display: inline-block;
  border: 1px solid;
  padding: 1.5rem 1rem 1rem;
  position: relative;
  margin: 2rem 0;
}

.legend h2 {
  position: absolute;
  background: white;
  top: 0;
  margin: 0;
  transform: translate(-50%, -50%);
  padding: 0.5rem;
  left: 50%;
}

dl {
  margin: 0;
}

.clear:before,
.clear:after {
  content: '';
  display: table;
}

.clear:after {
  clear: both;
}

dt, dd {
  float: left;
}

dt {
  width: 4.5rem;
  clear: both;
  margin: 0 0.5rem 0.5rem;;
}

dd {
  margin-left: 1rem;
}

.supported,
.unsupported {
  line-height: 1.25;
}

table {
  border: 1px solid black;
}

th[scope="col"] {
  background: #333;
  color: white;
  padding: 0.5rem;
  -webkit-font-smoothing: antialiased;
  -moz-font-smoothing: antialiased;
  -o-font-smoothing: antialiased;
}

th[scope="row"] {
  background: #ccc;
  color: inherit;
  text-align: left;
  padding: 0 0.5rem 0.25rem;
}

tr:nth-child(even) {
  background: #e9e9e9;
}

td {
  text-align: center;
  padding: 0.5rem;
}

.supported {
  background: #03A678;
}

.unsupported {
  background: #b94a48;
  color: white;
}

.mixed {
  background: #e9c906;
}

tr:nth-child(odd) .supported {
  background: rgba(3, 166, 120, 0.7);
}

tr:nth-child(odd) .unsupported {
  background: rgba(185, 74, 72, 0.7);
  color: black;
}

tr:nth-child(odd) .mixed {
  background: rgba(233, 201, 6, 0.7);
}

td span {
  display: flex;
  align-items: center;
  justify-content: center;
}

table + table {
  margin-top: 3rem;
}

table caption {
  font-size: 2rem;
}

pre {
  font-size: 0.9rem;
}
              
            
!

JS

              
                
              
            
!
999px

Console