Accessibility Guidelines for HTML, CSS and Javascript
Total Page:16
File Type:pdf, Size:1020Kb
Accessibility guidelines for HTML, CSS and JavaScript Date Version Author Status / comments Nov 3rd, 2018 3.0 Atalan Jan 21, 2019 3.1 Atalan Minor changes in text of the 6.2 guideline. In partnership with: Air Liquide – Atos – BNP Paribas – Capgemini – EDF – Generali – SFR – SNCF – Société Générale – SPIE Observers: AbilityNet (UK) – Agence Entreprises & Handicap – AnySurfer (Belgium) – Association des Paralysés de France (APF) – Association Valentin Haüy (AVH) – CIGREF – Design For All Foundation (Spain) – ESSEC – Handirect – Hanploi – Sciences Po – Télécom ParisTech Acknowledgments Special thanks to our AcceDe Web partners for their input and commitment: Thanks to their support, participation in the working groups, proofreading of documents, and testing of manuals, the partner companies have provided valuable input to the Accede Web project. This has made it possible to create manuals that successfully meet the needs of the different stakeholders of a web project. These companies are also contributing to making the web more accessible by authorizing the free distribution of this content. We would also like to thank the following observers of the AcceDe Web project whose actions raise awareness of the AcceDe Web manuals and aid their distribution: AbilityNet (UK), Agence Entreprises & Handicap, AnySurfer (Belgium), Association des Paralysés de France, Association Valentin Haüys, CIGREF, Design for All foundation (Spain), ESSEC, Handirect, Hanploi, Sciences Po and Télécom ParisTech. We thank all the members of the review committees for the quality and relevance of their comments: • English version: Robin Christopherson (UK - AbilityNet), Ramon Corominas (Spain - Technosite), Deborah Edwards-Onoro (USA - Lireo Design), Thomas Frandzen (Denmark - Agency for Digitisation, Ministry of Finance), Char James-Tanny, (USA - a11yBos), Matt May (USA – Adobe), Sophie Schuermans (Belgium – Anysurfer), Jared Smith (USA - WebAIM), Christophe Strobbe (Germany), Gijs Veyfeyken (Belgium – Anysurfer) • French version: Benjamin Ach (accessibility expert), Vincent Aniort (APF), Jean-Baptiste Audras (University of Grenoble), Claire Bizingre (accessibility consultant), Victor Brito (accessibility consultant), Anna Castilla (Provaltis), Ève Demazière (Sciences Po), Nicolas Fortin (French Ministry of Media and Culture), Marc-Étienne Vargenau (Alcatel-Lucent) and Éric Vidal (Fédération des aveugles de France), as well as all the teams of our partner companies. Finally, we would like to thank Laurent Bracquart and Johan Ramon, Christophe Pineau and Marion Santelli of Atalan for their dedication and commitment to this initiative. Sébastien Delorme, Sylvie Goldfain, Atalan Table of contents Introduction ................................................................................................................................................ 6 Context and objectives ............................................................................................................................. 6 Who should read this document, and how to use it? ............................................................................... 6 Contact ..................................................................................................................................................... 6 License agreement .................................................................................................................................. 7 1 General structure ............................................................................................................................... 8 Add structure to the header area using <header role="banner"> ........................................ 8 Mark up the search field with role="search" .......................................................................... 8 Structure the main content area with <main role="main"> ................................................... 8 Structure information about the website and its author with <footer role="contentinfo"> 9 Structure primary and secondary navigation menus with <nav role="navigation"> .......... 9 Structure navigation menus with lists .......................................................................................... 10 Identify the current position in navigation systems with aria-current ................................... 10 Create a logical and thorough hierarchy for headings, using <h1> to <h6> tags ................. 12 Write the HTML code in a logical reading order ......................................................................... 15 Ensure that the HTML flow is consistent from one page to another ....................................... 16 2 Page Title........................................................................................................................................... 17 Provide a descriptive <title> element on each page ........................................................... 17 3 Language........................................................................................................................................... 18 Provide the primary language of the page with the lang attribute on the <html> tag ......... 18 Use the lang attribute to indicate a change of language ........................................................... 18 Make sure that hidden content is translated ............................................................................... 19 4 HTML Grammar and Semantics ...................................................................................................... 20 Write HTML code that follows the formal grammar rules of the DOCTYPE used ...................... 20 Use HTML elements for their right semantic purpose ................................................................ 20 5 Links and Buttons ............................................................................................................................ 21 Distinguish buttons from links ..................................................................................................... 21 Make link and button labels explicit with aria-label or the title attribute ..................... 21 Don't use the title or aria-label attributes on links and buttons that are already explicit ...... 22 Add the size and format of files to "Download" links. .................................................................. 23 Give advance warning before opening a new window ................................................................ 24 Combine successive elements being links (or buttons) with the same destination as one single link (or one button) ................................................................................................................................. 24 6 Images and Icons ............................................................................................................................. 27 Icon Fonts.................................................................................................................................... 27 SVG (Scalable Vector Graphics) ................................................................................................ 29 <img /> and <input type="image" /> tags ..................................................................... 31 Tag images that have captions with <figure role="group"> and <figcaption> ........ 33 Don't use CSS to display images that carry information ............................................................. 35 7 Forms ................................................................................................................................................. 36 Use the <label> tag with the for and id attributes to label form fields with a visible name 36 Use the aria-label or title attribute to label form fields that don't have a visible label 36 Add help text directly into the <label> tag ............................................................................. 37 Add required or aria-required="true" to mandatory fields....................................... 38 Add error messages and correction suggestions directly into the <label> tag...................... 39 Update the <title> element when the page reloads to display an error or confirmation message ................................................................................................................................................. 40 Group related fields with <fieldset> and <legend> .......................................................... 41 Organize the items of dropdown lists logically ............................................................................ 42 In forms with multiple steps, identify the current step using aria-current="step" ............. 43 8 Lists ................................................................................................................................................... 44 Tag unordered lists with <ul> and <li> ................................................................................ 44 Tag ordered lists with <ol> and <li> .................................................................................... 44 Mark up definition lists with <dl>, <dt> and <dd> ............................................................... 44 9 Tables ................................................................................................................................................ 46 Provide a <caption> for every data table .............................................................................. 46 Mark