Foundation - Accessibilité des boutons

La description

Lorsque votre bouton ne contient pas de texte lisible, vous pouvez ajouter du texte pour lecteur d'écran uniquement pour indiquer son objectif. Le symbole ou l'icône doit être placé dans un élément avec l' attribut aria-hidden- "true" , ce qui évite aux lecteurs d'écran de tenter de prononcer l'icône ou le symbole. Pour définir du texte uniquement pour les lecteurs d'écran, utilisez la classe .show-for-sr .

Exemple

L'exemple suivant illustre l'utilisation de l' accessibilité des boutons dans Foundation.

<html>
   <head>
      <title>Button Accessibility</title>

      <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/foundation.min.css" integrity="sha256-1mcRjtAxlSjp6XJBgrBeeCORfBp/ppyX4tsvpQVCcpA= sha384-b5S5X654rX3Wo6z5/hnQ4GBmKuIJKMPwrJXn52ypjztlnDK2w9+9hSMBz/asy9Gw sha512-M1VveR2JGzpgWHb0elGqPTltHK3xbvu3Brgjfg4cg5ZNtyyApxw/45yHYsZ/rCVbfoO5MSZxB241wWq642jLtA==" crossorigin="anonymous">
      <link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/foundicons/3.0.0/foundation-icons.css">

      <!-- Compressed JavaScript -->
      <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/foundation.min.js" integrity="sha256-WUKHnLrIrx8dew//IpSEmPN/NT3DGAEmIePQYIEJLLs= sha384-53StQWuVbn6figscdDC3xV00aYCPEz3srBdV/QGSXw3f19og3Tq2wTRe0vJqRTEO sha512-X9O+2f1ty1rzBJOC8AXBnuNUdyJg0m8xMKmbt9I3Vu/UOWmSg5zG+dtnje4wAZrKtkopz/PEDClHZ1LXx5IeOw==" crossorigin="anonymous"></script>


   </head>

   <body>
      <p>When he reached
         <button class = "button" type = "button">
            <span class = "show-for-sr">home</span>
            <!-- Screen readers will see "home" but Visual users will see the home icon, but not the "home" text -->
            <span aria-hidden = "true"><i class = "fi-home"></i></span>
         </button> the children were playing.
      </p>

      <p>Copy and paste the above sentence to see what it is.</p>
   </body>
</html>

Production

Exécutons les étapes suivantes pour voir comment fonctionne le code donné ci-dessus -

  • Enregistrez le code html ci-dessus button_accessibility.html fichier.

  • Ouvrez ce fichier HTML dans un navigateur, une sortie s'affiche comme indiqué ci-dessous.