vergelijkingen

Om een ​​lijst of tabel met toegestane en niet-ondersteunde functies of technieken weer te geven, gebruikt u class="compare-yes" en class="compare-no" . Gebruik class="compare-better" en class="compare-worse" om een ​​vergelijking weer te geven tussen goedgekeurde en niet-aanbevolen benaderingen.

De volgende voorbeelden laten zien hoe deze klassen de juiste pictogrammen invoegen en de tekst opmaken.

Niet aanbevolen : laat inspringen met tabs

(bad sample code)
<p><span class="compare-worse">Not recommended</span> — indent with tabs</p>
<pre class="prettyprint">
(bad sample code)
</pre>

Aanbevolen : laat inspringen met spaties

(good sample code)
<p><span class="compare-better">Recommended</span> — indent with spaces</p>
<pre class="prettyprint">
(good sample code)
</pre>

In het volgende voorbeeld ziet u hoe u deze klassen in een vergelijkingstabel kunt gebruiken.

Op de volgende tabbladen wordt de broncode weergegeven voor de basis- en toegankelijkheidscompatibele versies van deze voorbeeldvergelijkingstabel.

De toegankelijkheidscompatibele versie is nodig om ondersteunende technologie zoals schermlezers te ondersteunen. In deze versie heeft elke cel in de tabel een leeg <span> -element met een aria-label dat wordt gebruikt om betekenisvolle helptekst te bieden. Omdat de helptekst de vergelijking documenteert, kunt u ook aria-hidden="true" toevoegen aan rij- en kolomkoppen.

Basis

<table>
  <tr>
    <th>Resource Type</th>
    <th><code>list</code></th>
    <th><code>insert</code></th>
    <th><code>update</code></th>
    <th><code>delete</code></th>
  </tr>
  <tr>
    <td><code>activity</code></td>
    <td><span class="compare-yes"></span></td>
    <td><span class="compare-yes"></span></td>
    <td><span class="compare-no"></span></td>
    <td><span class="compare-no"></span></td>
  </tr>
  <tr>
    <td><code>channel</code></td>
    <td><span class="compare-yes"></span></td>
    <td><span class="compare-no"></span></td>
    <td><span class="compare-no"></span></td>
    <td><span class="compare-no"></span></td>
  </tr>
  <tr>
    <td><code>channelBanner</code></td>
    <td><span class="compare-no"></span></td>
    <td><span class="compare-yes"></span></td>
    <td><span class="compare-no"></span></td>
    <td><span class="compare-no"></span></td>
  </tr>
</table>

A11y-compatibel

<table>
  <tr aria-hidden="true">
    <th>Resource Type</th>
    <th><code>list</code></th>
    <th><code>insert</code></th>
    <th><code>update</code></th>
    <th><code>delete</code></th>
  </tr>
  <tr>
    <td aria-hidden="true"><code>activity</code></td>
    <td><span aria-label="The activity resource type has a list method" class="compare-yes"></span></td>
    <td><span aria-label="The activity resource type has an insert method" class="compare-yes"></span></td>
    <td><span aria-label="The activity resource type does not have an update method" class="compare-no"></span></td>
    <td><span aria-label="The activity resource type does not have a delete method" class="compare-no"></span></td>
  </tr>
  <tr>
    <td aria-hidden="true"><code>channel</code></td>
    <td><span aria-label="The channel resource type has a list method" class="compare-yes"></span></td>
    <td><span aria-label="The channel resource type does not have an insert method" class="compare-no"></span></td>
    <td><span aria-label="The channel resource type does not have an update method" class="compare-no"></span></td>
    <td><span aria-label="The channel resource type does not have a delete method" class="compare-no"></span></td>
  </tr>
  <tr>
    <td aria-hidden="true"><code>channelBanner</code></td>
    <td><span aria-label="The channelBanner resource type does not have a list method" class="compare-no"></span></td>
    <td><span aria-label="The channelBanner resource type has an insert method" class="compare-yes"></span></td>
    <td><span aria-label="The channelBanner resource type does not have an update method" class="compare-no"></span></td>
    <td><span aria-label="The channelBanner resource type does not have a delete method" class="compare-no"></span></td>
  </tr>
</table>