<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <id>https://web.dev/</id>
  <title>Meggin Kearney on web.dev</title>
  <updated>2026-04-15T23:21:06Z</updated>
  <author>
    <name>Meggin Kearney</name>
  </author>
  <link href="https://web.dev/authors/megginkearney/feed.xml" rel="self"/>
  <link href="https://web.dev/"/>
  <icon>https://web-dev.imgix.net/image/admin/1sJM27b1jwZmcKa6yJEf.jpg?auto=format</icon>
  <logo>https://web.dev/images/shared/rss-banner.png</logo>
  <subtitle>Meggin is a Tech Writer</subtitle>
  
  
  <entry>
    <title>Save Credentials from Forms</title>
    <link href="https://web.dev/security-credential-management-save-forms/"/>
    <updated>2022-02-24T00:00:00Z</updated>
    <id>https://web.dev/security-credential-management-save-forms/</id>
    <content type="html" mode="escaped">&lt;figure&gt;
&lt;video&gt;      &lt;source src=&quot;https://storage.googleapis.com/web-dev-uploads/video/C47gYyWYVMMhDmtYSLOWazuyePF2/hglb1gObe5c9zqoF2VuX.mov&quot; type=&quot;video/mp4&quot; /&gt;    &lt;/video&gt;
&lt;figcaption&gt;Save Credentials from sign-in forms&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;Keep your registration and sign-in forms as simple as possible.&lt;/p&gt;
&lt;p&gt;Save credentials from sign-in forms
so users won&#39;t have to sign in again when they return.&lt;/p&gt;
&lt;p&gt;To store user credentials from forms:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Include &lt;code&gt;autocomplete&lt;/code&gt; in the form.&lt;/li&gt;
&lt;li&gt;Prevent the form from submitting.&lt;/li&gt;
&lt;li&gt;Authenticate by sending a request.&lt;/li&gt;
&lt;li&gt;Store the credential.&lt;/li&gt;
&lt;li&gt;Update the UI or proceed to the personalized page.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;include-autocomplete-in-the-form&quot;&gt;Include &lt;code&gt;autocomplete&lt;/code&gt; in the form &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/security-credential-management-save-forms/#include-autocomplete-in-the-form&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Before moving forward,
check if your form includes &lt;code&gt;autocomplete&lt;/code&gt; attributes.
This helps the Credential Management API find the &lt;code&gt;id&lt;/code&gt; and &lt;code&gt;password&lt;/code&gt;
from the form and construct a credential object.&lt;/p&gt;
&lt;p&gt;This also helps browsers not supporting the Credential Management API
to understand its semantics.
Learn more about autofill in
&lt;a href=&quot;https://cloudfour.com/thinks/autofill-what-web-devs-should-know-but-dont/&quot; rel=&quot;noopener&quot;&gt;this article&lt;/a&gt; by
&lt;a href=&quot;https://medium.com/@grigs&quot; rel=&quot;noopener&quot;&gt;Jason Grigsby&lt;/a&gt;.&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;form&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;signup&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;method&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;post&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;email&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;text&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;autocomplete&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;username email&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;display-name&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;text&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;autocomplete&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;password&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;password&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;autocomplete&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;new-password&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;submit&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Sign Up!&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;form&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;h2 id=&quot;prevent-the-form-from-submitting&quot;&gt;Prevent the form from submitting &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/security-credential-management-save-forms/#prevent-the-form-from-submitting&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;When the user presses the submit button, prevent the form from submitting, which would otherwise
result in a page transition:&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;    &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; f &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;#signup&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    f&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;submit&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token parameter&quot;&gt;e&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      e&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;preventDefault&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;By preventing a page transition,
you can retain the credential information while verifying its authenticity.&lt;/p&gt;
&lt;h2 id=&quot;authenticate-by-sending-a-request&quot;&gt;Authenticate by sending a request &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/security-credential-management-save-forms/#authenticate-by-sending-a-request&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;To authenticate the user, deliver credential information to your server using AJAX.&lt;/p&gt;
&lt;p&gt;On the server side, create an endpoint (or simply alter an existing endpoint)
that responds with HTTP code 200 or 401, so that it’s clear to the browser
whether the sign-up/sign-in/change password is successful or not.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Try sign-in with AJAX&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token function&quot;&gt;fetch&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;/signin&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token literal-property property&quot;&gt;method&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;POST&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token literal-property property&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;FormData&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;target&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token literal-property property&quot;&gt;credentials&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;include&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;h2 id=&quot;store-the-credential&quot;&gt;Store the credential &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/security-credential-management-save-forms/#store-the-credential&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;To store a credential, first check if the API is available,
then instantiate a
&lt;a href=&quot;https://developer.mozilla.org/docs/Web/API/PasswordCredential&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;PasswordCredential&lt;/code&gt;&lt;/a&gt;
with the form element as an argument
either synchronously or asynchronously.
Call
&lt;a href=&quot;https://developer.mozilla.org/docs/Web/API/CredentialsContainer/store&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;navigator.credentials.store()&lt;/code&gt;&lt;/a&gt;.
If the API is not available,
you can simply forward the profile information to the next step.&lt;/p&gt;
&lt;p&gt;Synchronous example:&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;window&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;PasswordCredential&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; c &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;PasswordCredential&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;target&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; navigator&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;credentials&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;store&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;c&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; Promise&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;resolve&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;profile&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;Asynchronous example:&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;window&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;PasswordCredential&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; c &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; navigator&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;credentials&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token literal-property property&quot;&gt;password&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; e&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;target&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; navigator&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;credentials&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;store&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;c&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; Promise&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;resolve&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;profile&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;Once the request succeeds, store the credential information.
(Don&#39;t store the credentials information if the request failed
as doing so confuses returning users.)&lt;/p&gt;
&lt;p&gt;When the Chrome browser obtains credential information,
a notification pops up asking to store a credential
(or federation provider).&lt;/p&gt;
&lt;figure&gt;
  &lt;img alt=&quot;store credential&quot; decoding=&quot;async&quot; height=&quot;202&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 385px) 385px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/gbo4Q6zSt7ryUzb8d3KB.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/gbo4Q6zSt7ryUzb8d3KB.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/gbo4Q6zSt7ryUzb8d3KB.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/gbo4Q6zSt7ryUzb8d3KB.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/gbo4Q6zSt7ryUzb8d3KB.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/gbo4Q6zSt7ryUzb8d3KB.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/gbo4Q6zSt7ryUzb8d3KB.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/gbo4Q6zSt7ryUzb8d3KB.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/gbo4Q6zSt7ryUzb8d3KB.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/gbo4Q6zSt7ryUzb8d3KB.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/gbo4Q6zSt7ryUzb8d3KB.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/gbo4Q6zSt7ryUzb8d3KB.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/gbo4Q6zSt7ryUzb8d3KB.png?auto=format&amp;w=770 770w&quot; width=&quot;385&quot; /&gt;
  &lt;figcaption&gt;Notification for an auto signed-in user&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;h2 id=&quot;update-the-ui&quot;&gt;Update the UI &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/security-credential-management-save-forms/#update-the-ui&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;If everything went well, update the UI using the profile information,
or proceed to the personalized page.&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;     &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;profile&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;       &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;profile&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;         &lt;span class=&quot;token function&quot;&gt;updateUI&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;profile&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;       &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;     &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;catch&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;error&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;       &lt;span class=&quot;token function&quot;&gt;showError&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Sign-in Failed&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;     &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;h2 id=&quot;full-code-example&quot;&gt;Full code example &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/security-credential-management-save-forms/#full-code-example&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;div&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Get form&#39;s DOM object&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; f &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;#signup&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;f&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;submit&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token comment&quot;&gt;// Stop submitting form by itself&lt;/span&gt;&lt;br /&gt;  e&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;preventDefault&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;token comment&quot;&gt;// Try sign-in with AJAX&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token function&quot;&gt;fetch&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;/signin&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token literal-property property&quot;&gt;method&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;POST&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token literal-property property&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;FormData&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;target&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token literal-property property&quot;&gt;credentials&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;include&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;res&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;status &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; Promise&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;resolve&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; Promise&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;reject&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Sign-in failed&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;profile&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token comment&quot;&gt;// Instantiate PasswordCredential with the form&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;window&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;PasswordCredential&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; c &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;PasswordCredential&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;target&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; navigator&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;credentials&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;store&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;c&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; Promise&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;resolve&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;profile&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;profile&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token comment&quot;&gt;// Successful sign-in&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;profile&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token function&quot;&gt;updateUI&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;profile&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;catch&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token comment&quot;&gt;// Sign-in failed&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token function&quot;&gt;showError&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Sign-in Failed&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;h2 id=&quot;browser-compatibility&quot;&gt;Browser compatibility &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/security-credential-management-save-forms/#browser-compatibility&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id=&quot;passwordcredential&quot;&gt;&lt;code&gt;PasswordCredential&lt;/code&gt; &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/security-credential-management-save-forms/#passwordcredential&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;div class=&quot;wdi-browser-compat&quot;&gt;
  &lt;span class=&quot;wdi-browser-compat__label&quot;&gt;Browser support&lt;/span&gt;
  &lt;ul class=&quot;wdi-browser-compat__items&quot;&gt;
    &lt;li class=&quot;wdi-browser-compat__item&quot;&gt;
    &lt;span class=&quot;wdi-browser-compat__icon&quot; data-browser=&quot;chrome&quot;&gt;
      &lt;span class=&quot;visually-hidden&quot;&gt;Chrome 51, Supported&lt;/span&gt;
    &lt;/span&gt;
    &lt;span class=&quot;wdi-browser-compat__version&quot; data-compat=&quot;yes&quot; title=&quot;Supported&quot; aria-label=&quot;Supported&quot;&gt;
      51
    &lt;/span&gt;
    &lt;/li&gt;&lt;li class=&quot;wdi-browser-compat__item&quot;&gt;
    &lt;span class=&quot;wdi-browser-compat__icon&quot; data-browser=&quot;firefox&quot;&gt;
      &lt;span class=&quot;visually-hidden&quot;&gt;Firefox, Not supported&lt;/span&gt;
    &lt;/span&gt;
    &lt;span class=&quot;wdi-browser-compat__version&quot; data-compat=&quot;no&quot; title=&quot;Not supported&quot; aria-label=&quot;Not supported&quot;&gt;
&lt;p&gt;&lt;/p&gt;&lt;/span&gt;
&lt;/li&gt;&lt;li class=&quot;wdi-browser-compat__item&quot;&gt;
&lt;span class=&quot;wdi-browser-compat__icon&quot; data-browser=&quot;edge&quot;&gt;
&lt;span class=&quot;visually-hidden&quot;&gt;Edge 79, Supported&lt;/span&gt;
&lt;/span&gt;
&lt;span class=&quot;wdi-browser-compat__version&quot; data-compat=&quot;yes&quot; title=&quot;Supported&quot; aria-label=&quot;Supported&quot;&gt;
79
&lt;/span&gt;
&lt;/li&gt;&lt;li class=&quot;wdi-browser-compat__item&quot;&gt;
&lt;span class=&quot;wdi-browser-compat__icon&quot; data-browser=&quot;safari&quot;&gt;
&lt;span class=&quot;visually-hidden&quot;&gt;Safari, Not supported&lt;/span&gt;
&lt;/span&gt;
&lt;span class=&quot;wdi-browser-compat__version&quot; data-compat=&quot;no&quot; title=&quot;Not supported&quot; aria-label=&quot;Not supported&quot;&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;/span&gt;
&lt;/li&gt;&lt;p&gt;&lt;/p&gt;
  &lt;/ul&gt;
  &lt;a class=&quot;wdi-browser-compat__link&quot; href=&quot;https://developer.mozilla.org/docs/Web/API/PasswordCredential#browser_compatibility&quot; target=&quot;_blank&quot;&gt;Source&lt;/a&gt;
&lt;/div&gt;
&lt;h3 id=&quot;navigatorcredentialsstore&quot;&gt;&lt;code&gt;navigator.credentials.store()&lt;/code&gt; &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/security-credential-management-save-forms/#navigatorcredentialsstore&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;div class=&quot;wdi-browser-compat&quot;&gt;
  &lt;span class=&quot;wdi-browser-compat__label&quot;&gt;Browser support&lt;/span&gt;
  &lt;ul class=&quot;wdi-browser-compat__items&quot;&gt;
    &lt;li class=&quot;wdi-browser-compat__item&quot;&gt;
    &lt;span class=&quot;wdi-browser-compat__icon&quot; data-browser=&quot;chrome&quot;&gt;
      &lt;span class=&quot;visually-hidden&quot;&gt;Chrome 51, Supported&lt;/span&gt;
    &lt;/span&gt;
    &lt;span class=&quot;wdi-browser-compat__version&quot; data-compat=&quot;yes&quot; title=&quot;Supported&quot; aria-label=&quot;Supported&quot;&gt;
      51
    &lt;/span&gt;
    &lt;/li&gt;&lt;li class=&quot;wdi-browser-compat__item&quot;&gt;
    &lt;span class=&quot;wdi-browser-compat__icon&quot; data-browser=&quot;firefox&quot;&gt;
      &lt;span class=&quot;visually-hidden&quot;&gt;Firefox 60, Supported&lt;/span&gt;
    &lt;/span&gt;
    &lt;span class=&quot;wdi-browser-compat__version&quot; data-compat=&quot;yes&quot; title=&quot;Supported&quot; aria-label=&quot;Supported&quot;&gt;
      60
    &lt;/span&gt;
    &lt;/li&gt;&lt;li class=&quot;wdi-browser-compat__item&quot;&gt;
    &lt;span class=&quot;wdi-browser-compat__icon&quot; data-browser=&quot;edge&quot;&gt;
      &lt;span class=&quot;visually-hidden&quot;&gt;Edge 79, Supported&lt;/span&gt;
    &lt;/span&gt;
    &lt;span class=&quot;wdi-browser-compat__version&quot; data-compat=&quot;yes&quot; title=&quot;Supported&quot; aria-label=&quot;Supported&quot;&gt;
      79
    &lt;/span&gt;
    &lt;/li&gt;&lt;li class=&quot;wdi-browser-compat__item&quot;&gt;
    &lt;span class=&quot;wdi-browser-compat__icon&quot; data-browser=&quot;safari&quot;&gt;
      &lt;span class=&quot;visually-hidden&quot;&gt;Safari 13, Supported&lt;/span&gt;
    &lt;/span&gt;
    &lt;span class=&quot;wdi-browser-compat__version&quot; data-compat=&quot;yes&quot; title=&quot;Supported&quot; aria-label=&quot;Supported&quot;&gt;
      13
    &lt;/span&gt;
    &lt;/li&gt;
  &lt;/ul&gt;
  &lt;a class=&quot;wdi-browser-compat__link&quot; href=&quot;https://developer.mozilla.org/docs/Web/API/CredentialsContainer/store#browser_compatibility&quot; target=&quot;_blank&quot;&gt;Source&lt;/a&gt;
&lt;/div&gt;
&lt;h2 id=&quot;feedback&quot;&gt;Feedback &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/security-credential-management-save-forms/#feedback&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
</content>
    <author>
      <name>Eiji Kitamura</name>
    </author><author>
      <name>Meggin Kearney</name>
    </author>
  </entry>
  
  <entry>
    <title>Accessible tap targets</title>
    <link href="https://web.dev/accessible-tap-targets/"/>
    <updated>2020-03-31T00:00:00Z</updated>
    <id>https://web.dev/accessible-tap-targets/</id>
    <content type="html" mode="escaped">&lt;p&gt;When your design is displayed on a mobile device,
you should ensure that interactive elements like buttons or links are large enough,
and have enough space around them,
to make them easy to press without accidentally overlapping onto other elements.
This benefits all users,
but is especially helpful for anyone with a motor impairment.&lt;/p&gt;
&lt;p&gt;A minimum recommended touch target size is around 48 device independent pixels
on a site with a properly set mobile viewport.
For example, while an icon may only have a width and height of 24px,
you can use additional padding to bring the tap target size up to 48px.
The 48x48 pixel area corresponds to around 9mm,
which is about the size of a person&#39;s finger pad area.&lt;/p&gt;
&lt;p&gt;In the demo, I have added padding to all of the links in order to make sure they meet the minimum size.&lt;/p&gt;
&lt;div class=&quot;glitch-embed-wrap&quot; style=&quot;height: 420px; width: 100%;&quot;&gt;
  &lt;iframe allow=&quot;camera; clipboard-read; clipboard-write; encrypted-media; geolocation; microphone; midi&quot; loading=&quot;lazy&quot; src=&quot;https://glitch.com/embed/#!/embed/tap-targets?attributionHidden=true&amp;sidebarCollapsed=true&amp;path=index.html&amp;previewSize=100&quot; style=&quot;height: 100%; width: 100%; border: 0;&quot; title=&quot;tap-targets on Glitch&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;
&lt;p&gt;Touch targets should also be spaced about 8 pixels apart,
both horizontally and vertically,
so that a user&#39;s finger pressing on one tap target does not inadvertently touch another tap target.&lt;/p&gt;
&lt;h2 id=&quot;testing-your-touch-targets&quot;&gt;Testing your touch targets &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/accessible-tap-targets/#testing-your-touch-targets&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;If your target is text and you have used relative values such as &lt;code&gt;em&lt;/code&gt; or &lt;code&gt;rem&lt;/code&gt; to size the text and any padding,
you can use DevTools to check that the computed value of that area is large enough.
In the example below I am using &lt;code&gt;em&lt;/code&gt; for my text and padding.&lt;/p&gt;
&lt;div class=&quot;glitch-embed-wrap&quot; style=&quot;height: 420px; width: 100%;&quot;&gt;
  &lt;iframe allow=&quot;camera; clipboard-read; clipboard-write; encrypted-media; geolocation; microphone; midi&quot; loading=&quot;lazy&quot; src=&quot;https://glitch.com/embed/#!/embed/tap-targets-2?attributionHidden=true&amp;sidebarCollapsed=true&amp;path=style.css&amp;previewSize=100&quot; style=&quot;height: 100%; width: 100%; border: 0;&quot; title=&quot;tap-targets-2 on Glitch&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;
&lt;p&gt;Inspect the &lt;code&gt;a&lt;/code&gt; of the link,
and in Chrome DevTools switch to the &lt;a href=&quot;https://developer.chrome.com/docs/devtools/css/overrides/#computed&quot; rel=&quot;noopener&quot;&gt;Computed pane&lt;/a&gt;  where you can inspect the various parts of the box
and see what pixel size they resolve to.
In Firefox DevTools there is a Layout Panel.
In that Panel you get the actual size of the inspected element.&lt;/p&gt;
&lt;figure style=&quot;max-width: 500px&quot;&gt;
  &lt;img alt=&quot;The Layout Panel in Firefox DevTools showing the size of the a element&quot; decoding=&quot;async&quot; height=&quot;565&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 800px) 800px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/admin/vmFzREveRttHVDfLqqCx.jpg?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/admin/vmFzREveRttHVDfLqqCx.jpg?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/admin/vmFzREveRttHVDfLqqCx.jpg?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/admin/vmFzREveRttHVDfLqqCx.jpg?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/admin/vmFzREveRttHVDfLqqCx.jpg?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/admin/vmFzREveRttHVDfLqqCx.jpg?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/admin/vmFzREveRttHVDfLqqCx.jpg?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/admin/vmFzREveRttHVDfLqqCx.jpg?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/admin/vmFzREveRttHVDfLqqCx.jpg?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/admin/vmFzREveRttHVDfLqqCx.jpg?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/admin/vmFzREveRttHVDfLqqCx.jpg?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/admin/vmFzREveRttHVDfLqqCx.jpg?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/admin/vmFzREveRttHVDfLqqCx.jpg?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/admin/vmFzREveRttHVDfLqqCx.jpg?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/admin/vmFzREveRttHVDfLqqCx.jpg?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/admin/vmFzREveRttHVDfLqqCx.jpg?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/admin/vmFzREveRttHVDfLqqCx.jpg?auto=format&amp;w=1428 1428w, https://web-dev.imgix.net/image/admin/vmFzREveRttHVDfLqqCx.jpg?auto=format&amp;w=1600 1600w&quot; width=&quot;800&quot; /&gt;
&lt;/figure&gt;
&lt;h2 id=&quot;using-media-queries-to-detect-touchscreen-use&quot;&gt;Using media queries to detect touchscreen use &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/accessible-tap-targets/#using-media-queries-to-detect-touchscreen-use&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Instead of simply testing for viewport dimensions, and then guessing
that small dimensions are likely to be phones or tablets, which in turn
use a touchscreen, there are now more robust ways to adapt
your design based on actual device capabilities.&lt;/p&gt;
&lt;p&gt;One of the media features we can now test for with media queries
is whether the user&#39;s &lt;em&gt;primary input&lt;/em&gt; is a touchscreen (&lt;code&gt;pointer&lt;/code&gt;) and
whether &lt;em&gt;any&lt;/em&gt; of the currently detected inputs is a touchscreen (&lt;code&gt;any-pointer&lt;/code&gt;).
The &lt;code&gt;pointer&lt;/code&gt; and &lt;code&gt;any-pointer&lt;/code&gt; features will return &lt;code&gt;fine&lt;/code&gt; or &lt;code&gt;coarse&lt;/code&gt;.
A fine pointer will be someone using a mouse or trackpad,
even if that mouse is connected via Bluetooth to a phone.
A &lt;code&gt;coarse&lt;/code&gt; pointer indicates a touchscreen,
which could be a mobile device but may also be a laptop screen or large tablet.&lt;/p&gt;
&lt;p&gt;If you are adjusting your CSS within a media query to increase the touch target,
testing for a coarse pointer allows you to increase the tap targets for all touchscreen users.
This gives the larger tap area whether the device is a phone or larger device.&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.container a&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; .2em&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token atrule&quot;&gt;&lt;span class=&quot;token rule&quot;&gt;@media&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;any-pointer&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; coarse&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token selector&quot;&gt;.container a&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; .8em&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;You can find out more about interaction media features such as pointer
in the &lt;a href=&quot;https://web.dev/responsive-web-design-basics/&quot;&gt;Responsive web design basics&lt;/a&gt; article.&lt;/p&gt;
</content>
    <author>
      <name>Dave Gash</name>
    </author><author>
      <name>Meggin Kearney</name>
    </author><author>
      <name>Rachel Andrew</name>
    </author><author>
      <name>Rob Dodson</name>
    </author><author>
      <name>Patrick H. Lauke</name>
    </author>
  </entry>
  
  <entry>
    <title>Accessible responsive design</title>
    <link href="https://web.dev/accessible-responsive-design/"/>
    <updated>2020-03-31T00:00:00Z</updated>
    <id>https://web.dev/accessible-responsive-design/</id>
    <content type="html" mode="escaped">&lt;p&gt;We know that it&#39;s a good idea to design responsively to provide the best multi-device experience,
but responsive design also yields a win for accessibility.&lt;/p&gt;
&lt;p&gt;Consider a site like &lt;a href=&quot;https://udacity.com/&quot; rel=&quot;noopener&quot;&gt;Udacity&lt;/a&gt;:&lt;/p&gt;
&lt;figure&gt;
  &lt;img alt=&quot;The Udacity site&quot; decoding=&quot;async&quot; height=&quot;393&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 800px) 800px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/admin/5q9dDtEubSM23SzokQNu.jpg?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/admin/5q9dDtEubSM23SzokQNu.jpg?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/admin/5q9dDtEubSM23SzokQNu.jpg?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/admin/5q9dDtEubSM23SzokQNu.jpg?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/admin/5q9dDtEubSM23SzokQNu.jpg?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/admin/5q9dDtEubSM23SzokQNu.jpg?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/admin/5q9dDtEubSM23SzokQNu.jpg?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/admin/5q9dDtEubSM23SzokQNu.jpg?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/admin/5q9dDtEubSM23SzokQNu.jpg?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/admin/5q9dDtEubSM23SzokQNu.jpg?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/admin/5q9dDtEubSM23SzokQNu.jpg?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/admin/5q9dDtEubSM23SzokQNu.jpg?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/admin/5q9dDtEubSM23SzokQNu.jpg?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/admin/5q9dDtEubSM23SzokQNu.jpg?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/admin/5q9dDtEubSM23SzokQNu.jpg?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/admin/5q9dDtEubSM23SzokQNu.jpg?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/admin/5q9dDtEubSM23SzokQNu.jpg?auto=format&amp;w=1428 1428w, https://web-dev.imgix.net/image/admin/5q9dDtEubSM23SzokQNu.jpg?auto=format&amp;w=1600 1600w&quot; width=&quot;800&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;A low-vision user who has difficulty reading small print might zoom in the page,
perhaps as much as 400%.
Because the site is designed responsively,
the UI will rearrange itself for the &amp;quot;smaller viewport&amp;quot; (actually for the larger page),
which is great for desktop users who require screen magnification
and for mobile screen reader users as well. It&#39;s a win-win.
Here&#39;s the same page magnified to 400%:&lt;/p&gt;
&lt;figure&gt;
  &lt;img alt=&quot;The Udacity site zoomed to 400%&quot; decoding=&quot;async&quot; height=&quot;393&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 800px) 800px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/admin/WKHO21uWQz5lJ7Aqej1E.jpg?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/admin/WKHO21uWQz5lJ7Aqej1E.jpg?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/admin/WKHO21uWQz5lJ7Aqej1E.jpg?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/admin/WKHO21uWQz5lJ7Aqej1E.jpg?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/admin/WKHO21uWQz5lJ7Aqej1E.jpg?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/admin/WKHO21uWQz5lJ7Aqej1E.jpg?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/admin/WKHO21uWQz5lJ7Aqej1E.jpg?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/admin/WKHO21uWQz5lJ7Aqej1E.jpg?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/admin/WKHO21uWQz5lJ7Aqej1E.jpg?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/admin/WKHO21uWQz5lJ7Aqej1E.jpg?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/admin/WKHO21uWQz5lJ7Aqej1E.jpg?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/admin/WKHO21uWQz5lJ7Aqej1E.jpg?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/admin/WKHO21uWQz5lJ7Aqej1E.jpg?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/admin/WKHO21uWQz5lJ7Aqej1E.jpg?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/admin/WKHO21uWQz5lJ7Aqej1E.jpg?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/admin/WKHO21uWQz5lJ7Aqej1E.jpg?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/admin/WKHO21uWQz5lJ7Aqej1E.jpg?auto=format&amp;w=1428 1428w, https://web-dev.imgix.net/image/admin/WKHO21uWQz5lJ7Aqej1E.jpg?auto=format&amp;w=1600 1600w&quot; width=&quot;800&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;In fact, just by designing responsively,
we&#39;re meeting rule &lt;a href=&quot;https://webaim.org/standards/wcag/checklist#sc1.4.4&quot; rel=&quot;noopener&quot;&gt;1.4.4 of the WebAIM checklist&lt;/a&gt;,
which states that a page &amp;quot;… should be readable and functional when the text size is doubled.&amp;quot;&lt;/p&gt;
&lt;p&gt;Going over all of responsive design is outside the scope of this guide,
but here are a few important takeaways that will benefit your responsive experience
and give your users better access to your content.&lt;/p&gt;
&lt;h2 id=&quot;use-the-viewport-meta-tag&quot;&gt;Use the viewport meta tag &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/accessible-responsive-design/#use-the-viewport-meta-tag&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;div&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;meta&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;viewport&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;width=device-width, initial-scale=1.0&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;Setting &lt;code&gt;width=device-width&lt;/code&gt; will match the screen&#39;s width in device-independent pixels,
and setting &lt;code&gt;initial-scale=1&lt;/code&gt; establishes a 1:1 relationship between CSS pixels and device-independent pixels.
Doing this instructs the browser to fit your content to the screen size,
so users don&#39;t just see a bunch of scrunched-up text.&lt;/p&gt;
&lt;p&gt;See &lt;a href=&quot;https://web.dev/responsive-web-design-basics/#viewport&quot;&gt;Size content to viewport&lt;/a&gt; to learn more.&lt;/p&gt;
&lt;h2 id=&quot;allow-users-to-zoom&quot;&gt;Allow users to zoom &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/accessible-responsive-design/#allow-users-to-zoom&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;It is possible to use the viewport meta tag to prevent zooming,
by setting &lt;code&gt;maximum-scale=1&lt;/code&gt; or &lt;code&gt;user-scaleable=no&lt;/code&gt;.
Avoid doing this, and let your users zoom in if they need to.&lt;/p&gt;
&lt;h2 id=&quot;design-with-flexibility&quot;&gt;Design with flexibility &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/accessible-responsive-design/#design-with-flexibility&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Avoid targetting specific screen sizes and instead use a flexible grid,
making changes to the layout when the content dictates.
As we saw with the Udacity example above, this approach ensures that the design responds
whether the reduced space is due to a smaller screen or a higher zoom level.&lt;/p&gt;
&lt;p&gt;You can read more about these techniques in the &lt;a href=&quot;https://web.dev/responsive-web-design-basics/&quot;&gt;Responsive web design basics&lt;/a&gt; article.&lt;/p&gt;
&lt;h2 id=&quot;use-relative-units-for-text&quot;&gt;Use relative units for text &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/accessible-responsive-design/#use-relative-units-for-text&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;To get the best out of your flexible grid
use relative units like em or rem for things like text size, instead of pixel values.
Some browsers support resizing text only in user preferences,
and if you&#39;re using a pixel value for text, this setting will not affect your copy.
If, however, you&#39;ve used relative units throughout,
then the site copy will update to reflect the user&#39;s preference.&lt;/p&gt;
&lt;p&gt;This will enable the whole site to reflow as the user zooms,
creating the reading experience they need to use your site.&lt;/p&gt;
&lt;h2 id=&quot;avoid-disconnecting-the-visual-view-from-the-source-order&quot;&gt;Avoid disconnecting the visual view from the source order &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/accessible-responsive-design/#avoid-disconnecting-the-visual-view-from-the-source-order&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A visitor who is tabbing through your site with the keyboard
will be following the order of the content in the HTML document.
When using modern layout methods such as &lt;a href=&quot;https://web.dev/responsive-web-design-basics/#flexbox&quot;&gt;Flexbox&lt;/a&gt; and &lt;a href=&quot;https://web.dev/responsive-web-design-basics/#grid&quot;&gt;Grid&lt;/a&gt;,
it is easy to make the visual rendering not match the source order.
This can lead to disconcerting jumps around the page for someone using the keyboard to move around.&lt;/p&gt;
&lt;p&gt;Make sure to test your design at each breakpoint by tabbing through the content,
does the flow through the page still make sense?&lt;/p&gt;
&lt;p&gt;Read more about &lt;a href=&quot;https://web.dev/content-reordering/&quot;&gt;the source and visual display disconnect&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;take-care-with-spatial-clues&quot;&gt;Take care with spatial clues &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/accessible-responsive-design/#take-care-with-spatial-clues&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;When writing microcopy avoid using language which indicates the location of an element on the page.
For example, referring to navigation &amp;quot;on your left&amp;quot; makes no sense in a mobile version
when the navigation is at the top of the screen.&lt;/p&gt;
&lt;h2 id=&quot;ensure-tap-targets-are-large-enough-on-touchscreen-devices&quot;&gt;Ensure tap targets are large enough on touchscreen devices &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/accessible-responsive-design/#ensure-tap-targets-are-large-enough-on-touchscreen-devices&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;On touchscreen devices make sure your tap targets are large enough
to make them easy to activate without hitting other links.
A good size for any tappable element is 48px,
read more guidance on &lt;a href=&quot;https://web.dev/accessible-tap-targets/&quot;&gt;tap targets&lt;/a&gt;.&lt;/p&gt;
</content>
    <author>
      <name>Dave Gash</name>
    </author><author>
      <name>Meggin Kearney</name>
    </author><author>
      <name>Rachel Andrew</name>
    </author><author>
      <name>Rob Dodson</name>
    </author>
  </entry>
  
  <entry>
    <title>Color and contrast accessibility</title>
    <link href="https://web.dev/color-and-contrast-accessibility/"/>
    <updated>2020-03-31T00:00:00Z</updated>
    <id>https://web.dev/color-and-contrast-accessibility/</id>
    <content type="html" mode="escaped">&lt;p&gt;If you have good vision, it&#39;s easy to assume that everyone perceives colors,
or text legibility, the same way you do—but of course that&#39;s not the case.&lt;/p&gt;
&lt;p&gt;As you might imagine,
some color combinations that are easy for some people to read are difficult or impossible for others.
This usually comes down to color contrast,
the relationship between the foreground and background colors&#39; luminance.
When the colors are similar, the contrast ratio is low;
when they are different, the contrast ratio is high.&lt;/p&gt;
&lt;p&gt;The &lt;a href=&quot;https://webaim.org/standards/wcag/&quot; rel=&quot;noopener&quot;&gt;WebAIM guidelines&lt;/a&gt; recommend an AA (minimum) contrast ratio of 4.5:1 for all text.
An exception is made for very large text (120-150% larger than the default body text),
for which the ratio can go down to 3:1. Notice the difference in the contrast ratios shown below.&lt;/p&gt;
&lt;figure&gt;
  &lt;img alt=&quot;An image showing the different contrast ratios&quot; decoding=&quot;async&quot; height=&quot;328&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 800px) 800px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/admin/DcYclKelVqhQ2CWlIG97.jpg?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/admin/DcYclKelVqhQ2CWlIG97.jpg?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/admin/DcYclKelVqhQ2CWlIG97.jpg?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/admin/DcYclKelVqhQ2CWlIG97.jpg?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/admin/DcYclKelVqhQ2CWlIG97.jpg?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/admin/DcYclKelVqhQ2CWlIG97.jpg?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/admin/DcYclKelVqhQ2CWlIG97.jpg?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/admin/DcYclKelVqhQ2CWlIG97.jpg?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/admin/DcYclKelVqhQ2CWlIG97.jpg?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/admin/DcYclKelVqhQ2CWlIG97.jpg?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/admin/DcYclKelVqhQ2CWlIG97.jpg?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/admin/DcYclKelVqhQ2CWlIG97.jpg?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/admin/DcYclKelVqhQ2CWlIG97.jpg?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/admin/DcYclKelVqhQ2CWlIG97.jpg?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/admin/DcYclKelVqhQ2CWlIG97.jpg?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/admin/DcYclKelVqhQ2CWlIG97.jpg?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/admin/DcYclKelVqhQ2CWlIG97.jpg?auto=format&amp;w=1428 1428w, https://web-dev.imgix.net/image/admin/DcYclKelVqhQ2CWlIG97.jpg?auto=format&amp;w=1600 1600w&quot; width=&quot;800&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;The contrast ratio of 4.5:1 was chosen for level AA
because it compensates for the loss in contrast sensitivity
usually experienced by users with vision loss equivalent to approximately 20/40 vision.
20/40 is commonly reported as typical visual acuity of people at about age 80.
For users with low vision impairments or color deficiencies,
we can increase the contrast up to 7:1 for body text.&lt;/p&gt;
&lt;p&gt;You can use the Accessibility Audit in Lighthouse to check your color contrast.
Open DevTools, click Audits, and select Accessibility to run the report.&lt;/p&gt;
&lt;figure&gt;
  &lt;img alt=&quot;A screenshot of the output of an audit for color contrast.&quot; decoding=&quot;async&quot; height=&quot;218&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 800px) 800px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/admin/vSFzNOurQO6z2xV6qWuW.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/admin/vSFzNOurQO6z2xV6qWuW.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/admin/vSFzNOurQO6z2xV6qWuW.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/admin/vSFzNOurQO6z2xV6qWuW.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/admin/vSFzNOurQO6z2xV6qWuW.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/admin/vSFzNOurQO6z2xV6qWuW.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/admin/vSFzNOurQO6z2xV6qWuW.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/admin/vSFzNOurQO6z2xV6qWuW.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/admin/vSFzNOurQO6z2xV6qWuW.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/admin/vSFzNOurQO6z2xV6qWuW.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/admin/vSFzNOurQO6z2xV6qWuW.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/admin/vSFzNOurQO6z2xV6qWuW.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/admin/vSFzNOurQO6z2xV6qWuW.png?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/admin/vSFzNOurQO6z2xV6qWuW.png?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/admin/vSFzNOurQO6z2xV6qWuW.png?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/admin/vSFzNOurQO6z2xV6qWuW.png?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/admin/vSFzNOurQO6z2xV6qWuW.png?auto=format&amp;w=1428 1428w, https://web-dev.imgix.net/image/admin/vSFzNOurQO6z2xV6qWuW.png?auto=format&amp;w=1600 1600w&quot; width=&quot;800&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;Chrome also includes an experimental feature to help you &lt;a href=&quot;https://developer.chrome.com/blog/new-in-devtools-87/#css-overview&quot; rel=&quot;noopener&quot;&gt;detect all the low contrast texts of your page&lt;/a&gt;. You can also use the &lt;a href=&quot;https://developer.chrome.com/blog/new-in-devtools-86/#accessible-color&quot; rel=&quot;noopener&quot;&gt;accessible color suggestion&lt;/a&gt; to fix the low contrast text.&lt;/p&gt;
&lt;figure&gt;
  &lt;img alt=&quot;A screenshot of the output of the Chrome low contrast text experimental feature.&quot; decoding=&quot;async&quot; height=&quot;521&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 800px) 800px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/admin/VYZeK2l2vs6pIoWhH2hO.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/admin/VYZeK2l2vs6pIoWhH2hO.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/admin/VYZeK2l2vs6pIoWhH2hO.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/admin/VYZeK2l2vs6pIoWhH2hO.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/admin/VYZeK2l2vs6pIoWhH2hO.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/admin/VYZeK2l2vs6pIoWhH2hO.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/admin/VYZeK2l2vs6pIoWhH2hO.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/admin/VYZeK2l2vs6pIoWhH2hO.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/admin/VYZeK2l2vs6pIoWhH2hO.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/admin/VYZeK2l2vs6pIoWhH2hO.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/admin/VYZeK2l2vs6pIoWhH2hO.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/admin/VYZeK2l2vs6pIoWhH2hO.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/admin/VYZeK2l2vs6pIoWhH2hO.png?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/admin/VYZeK2l2vs6pIoWhH2hO.png?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/admin/VYZeK2l2vs6pIoWhH2hO.png?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/admin/VYZeK2l2vs6pIoWhH2hO.png?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/admin/VYZeK2l2vs6pIoWhH2hO.png?auto=format&amp;w=1428 1428w, https://web-dev.imgix.net/image/admin/VYZeK2l2vs6pIoWhH2hO.png?auto=format&amp;w=1600 1600w&quot; width=&quot;800&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;For a more complete report, install the &lt;a href=&quot;https://accessibilityinsights.io/&quot; rel=&quot;noopener&quot;&gt;Accessibility Insights Extension&lt;/a&gt;.
One of the checks in the Fastpass report, is color contrast.
You will get a detailed report of any failing elements.&lt;/p&gt;
&lt;figure&gt;
  &lt;img alt=&quot;The report in Accessibility Insights&quot; decoding=&quot;async&quot; height=&quot;473&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 800px) 800px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/admin/CR21TFMZw8gWsSTWOGIF.jpg?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/admin/CR21TFMZw8gWsSTWOGIF.jpg?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/admin/CR21TFMZw8gWsSTWOGIF.jpg?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/admin/CR21TFMZw8gWsSTWOGIF.jpg?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/admin/CR21TFMZw8gWsSTWOGIF.jpg?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/admin/CR21TFMZw8gWsSTWOGIF.jpg?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/admin/CR21TFMZw8gWsSTWOGIF.jpg?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/admin/CR21TFMZw8gWsSTWOGIF.jpg?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/admin/CR21TFMZw8gWsSTWOGIF.jpg?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/admin/CR21TFMZw8gWsSTWOGIF.jpg?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/admin/CR21TFMZw8gWsSTWOGIF.jpg?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/admin/CR21TFMZw8gWsSTWOGIF.jpg?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/admin/CR21TFMZw8gWsSTWOGIF.jpg?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/admin/CR21TFMZw8gWsSTWOGIF.jpg?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/admin/CR21TFMZw8gWsSTWOGIF.jpg?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/admin/CR21TFMZw8gWsSTWOGIF.jpg?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/admin/CR21TFMZw8gWsSTWOGIF.jpg?auto=format&amp;w=1428 1428w, https://web-dev.imgix.net/image/admin/CR21TFMZw8gWsSTWOGIF.jpg?auto=format&amp;w=1600 1600w&quot; width=&quot;800&quot; /&gt;
&lt;/figure&gt;
&lt;h2 id=&quot;advanced-perceptual-contrast-algorithm-apca&quot;&gt;Advanced Perceptual Contrast Algorithm (APCA) &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/color-and-contrast-accessibility/#advanced-perceptual-contrast-algorithm-apca&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The &lt;a href=&quot;https://git.apcacontrast.com/documentation/WhyAPCA&quot; rel=&quot;noopener&quot;&gt;Advanced Perceptual Contrast Algorithm (APCA)&lt;/a&gt; is a new way to compute contrast based on modern research on color perception.&lt;/p&gt;
&lt;p&gt;Compared to &lt;a href=&quot;https://www.w3.org/WAI/WCAG21/quickref/#contrast-minimum&quot; rel=&quot;noopener&quot;&gt;AA&lt;/a&gt;/&lt;a href=&quot;https://www.w3.org/WAI/WCAG21/quickref/#contrast-enhanced&quot; rel=&quot;noopener&quot;&gt;AAA&lt;/a&gt; guidelines, APCA is more context-dependent.&lt;/p&gt;
&lt;p&gt;The contrast is calculated based on the following features:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Spatial properties (font weight and text size)&lt;/li&gt;
&lt;li&gt;Text color (perceived lightness difference between text and background)&lt;/li&gt;
&lt;li&gt;Context (ambient light, surroundings, and intended purpose of the text)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Chrome includes an &lt;a href=&quot;https://developer.chrome.com/blog/new-in-devtools-89/#apca&quot; rel=&quot;noopener&quot;&gt;experimental feature to replace the AA/AAA contrast ratio guidelines with APCA&lt;/a&gt;.&lt;/p&gt;
&lt;figure&gt;
  &lt;img alt=&quot;A screenshot of the output of the APCA feature in Chrome.&quot; decoding=&quot;async&quot; height=&quot;543&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 800px) 800px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/admin/YhGKRLYvt37j3ldlwiXE.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/admin/YhGKRLYvt37j3ldlwiXE.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/admin/YhGKRLYvt37j3ldlwiXE.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/admin/YhGKRLYvt37j3ldlwiXE.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/admin/YhGKRLYvt37j3ldlwiXE.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/admin/YhGKRLYvt37j3ldlwiXE.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/admin/YhGKRLYvt37j3ldlwiXE.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/admin/YhGKRLYvt37j3ldlwiXE.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/admin/YhGKRLYvt37j3ldlwiXE.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/admin/YhGKRLYvt37j3ldlwiXE.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/admin/YhGKRLYvt37j3ldlwiXE.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/admin/YhGKRLYvt37j3ldlwiXE.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/admin/YhGKRLYvt37j3ldlwiXE.png?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/admin/YhGKRLYvt37j3ldlwiXE.png?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/admin/YhGKRLYvt37j3ldlwiXE.png?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/admin/YhGKRLYvt37j3ldlwiXE.png?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/admin/YhGKRLYvt37j3ldlwiXE.png?auto=format&amp;w=1428 1428w, https://web-dev.imgix.net/image/admin/YhGKRLYvt37j3ldlwiXE.png?auto=format&amp;w=1600 1600w&quot; width=&quot;800&quot; /&gt;
&lt;/figure&gt;
&lt;h2 id=&quot;dont-convey-information-with-color-alone&quot;&gt;Don&#39;t convey information with color alone &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/color-and-contrast-accessibility/#dont-convey-information-with-color-alone&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;There are roughly 320 million people worldwide with color vision deficiency.
About 1 in 12 men and 1 in 200 women have some form of &amp;quot;color blindness&amp;quot;;
that means about 1/20th, or 5%, of your users will not experience your site the way you intended.
When we rely on color to convey information, we push that number to unacceptable levels.&lt;/p&gt;
&lt;aside class=&quot;aside flow bg-state-info-bg color-state-info-text&quot;&gt;&lt;div class=&quot; flow&quot;&gt; Note: The term &amp;quot;color blindness&amp;quot; is often used to describe a visual condition where a person has trouble distinguishing colors, but in fact very few people are truly color blind. Most people with color deficiencies can see some or most colors, but have difficulty differentiating between certain colors such as reds and greens (most common), browns and oranges, and blues and purples. &lt;/div&gt;&lt;/aside&gt;
&lt;p&gt;For example, in an input form,
a telephone number might be underlined in red to show that it is invalid.
But to a color deficient or screen reader user, that information is not conveyed well, if at all.
Thus, you should always try to provide multiple avenues for the user to access critical information.&lt;/p&gt;
&lt;figure style=&quot;width: 200px&quot;&gt;
  &lt;img alt=&quot;A image of an input form with an incorrect phone number highlighted only with a red color.&quot; decoding=&quot;async&quot; height=&quot;323&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 293px) 293px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/admin/MKmlhejyjNpk7XE9R2KV.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/admin/MKmlhejyjNpk7XE9R2KV.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/admin/MKmlhejyjNpk7XE9R2KV.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/admin/MKmlhejyjNpk7XE9R2KV.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/admin/MKmlhejyjNpk7XE9R2KV.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/admin/MKmlhejyjNpk7XE9R2KV.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/admin/MKmlhejyjNpk7XE9R2KV.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/admin/MKmlhejyjNpk7XE9R2KV.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/admin/MKmlhejyjNpk7XE9R2KV.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/admin/MKmlhejyjNpk7XE9R2KV.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/admin/MKmlhejyjNpk7XE9R2KV.png?auto=format&amp;w=586 586w&quot; width=&quot;293&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;The &lt;a href=&quot;https://webaim.org/standards/wcag/checklist#sc1.4.1&quot; rel=&quot;noopener&quot;&gt;WebAIM checklist states in section 1.4.1&lt;/a&gt; that
&amp;quot;color should not be used as the sole method of conveying content or distinguishing visual elements.&amp;quot;
It also notes that &amp;quot;color alone should not be used to distinguish links from surrounding text&amp;quot;
unless they meet certain contrast requirements.
Instead, the checklist recommends adding an additional indicator such as an underscore
(using the CSS &lt;code&gt;text-decoration&lt;/code&gt; property) to indicate when the link is active.&lt;/p&gt;
&lt;p&gt;An easy way to fix the previous example is to add an additional message to the field,
announcing that it is invalid and why.&lt;/p&gt;
&lt;figure style=&quot;width: 200px&quot;&gt;
  &lt;img alt=&quot;The same input form as in the last example, this time with a text label indicating the problem with the field.&quot; decoding=&quot;async&quot; height=&quot;343&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 292px) 292px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/admin/FLQPcG16akNRoElx3pnz.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/admin/FLQPcG16akNRoElx3pnz.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/admin/FLQPcG16akNRoElx3pnz.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/admin/FLQPcG16akNRoElx3pnz.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/admin/FLQPcG16akNRoElx3pnz.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/admin/FLQPcG16akNRoElx3pnz.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/admin/FLQPcG16akNRoElx3pnz.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/admin/FLQPcG16akNRoElx3pnz.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/admin/FLQPcG16akNRoElx3pnz.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/admin/FLQPcG16akNRoElx3pnz.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/admin/FLQPcG16akNRoElx3pnz.png?auto=format&amp;w=584 584w&quot; width=&quot;292&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;When you&#39;re building an app, keep these sorts of things in mind
and watch out for areas where you may be relying too heavily on color to convey important information.&lt;/p&gt;
&lt;p&gt;If you&#39;re curious about how your site looks to different people,
or if you rely heavily on the use of color in your UI,
you can use DevTools to simulate various forms of visual impairment,
including different types of color blindness.
Chrome includes an &lt;a href=&quot;https://developer.chrome.com/blog/new-in-devtools-83/#vision-deficiencies&quot; rel=&quot;noopener&quot;&gt;Emulate Vision Deficiencies feature&lt;/a&gt;.
To access it open DevTools and then open the &lt;strong&gt;Rendering&lt;/strong&gt; tab in the Drawer,
you can then emulate the following color deficiencies.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Protanopia: the inability to perceive any red light.&lt;/li&gt;
&lt;li&gt;Deuteranopia: the inability to perceive any green light.&lt;/li&gt;
&lt;li&gt;Tritanopia: the inability to perceive any blue light.&lt;/li&gt;
&lt;li&gt;Achromatopsia: the inability to perceive any color except for shades of grey (extremely rare).&lt;/li&gt;
&lt;/ul&gt;
&lt;figure&gt;
  &lt;img alt=&quot;Emulating the vision of a person with Achromatopsia shows our page in greyscale.&quot; decoding=&quot;async&quot; height=&quot;393&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 800px) 800px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/admin/VAnFxYhzFcpovdTCToPl.jpg?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/admin/VAnFxYhzFcpovdTCToPl.jpg?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/admin/VAnFxYhzFcpovdTCToPl.jpg?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/admin/VAnFxYhzFcpovdTCToPl.jpg?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/admin/VAnFxYhzFcpovdTCToPl.jpg?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/admin/VAnFxYhzFcpovdTCToPl.jpg?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/admin/VAnFxYhzFcpovdTCToPl.jpg?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/admin/VAnFxYhzFcpovdTCToPl.jpg?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/admin/VAnFxYhzFcpovdTCToPl.jpg?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/admin/VAnFxYhzFcpovdTCToPl.jpg?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/admin/VAnFxYhzFcpovdTCToPl.jpg?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/admin/VAnFxYhzFcpovdTCToPl.jpg?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/admin/VAnFxYhzFcpovdTCToPl.jpg?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/admin/VAnFxYhzFcpovdTCToPl.jpg?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/admin/VAnFxYhzFcpovdTCToPl.jpg?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/admin/VAnFxYhzFcpovdTCToPl.jpg?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/admin/VAnFxYhzFcpovdTCToPl.jpg?auto=format&amp;w=1428 1428w, https://web-dev.imgix.net/image/admin/VAnFxYhzFcpovdTCToPl.jpg?auto=format&amp;w=1600 1600w&quot; width=&quot;800&quot; /&gt;
&lt;/figure&gt;
&lt;h2 id=&quot;high-contrast-mode&quot;&gt;High contrast mode &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/color-and-contrast-accessibility/#high-contrast-mode&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;High-contrast mode allows a user to invert foreground and background colors,
which often helps text stand out better.
For someone with a low vision impairment,
high-contrast mode can make it much easier to navigate the content on the page.
There are a few ways to get a high-contrast setup on your machine.&lt;/p&gt;
&lt;p&gt;Operating systems like Mac OSX and Windows offer high-contrast modes
that can be enabled for everything at the system level.&lt;/p&gt;
&lt;p&gt;A useful exercise is to turn on high-contrast settings
and verify that all of the UI in your application is still visible and usable.&lt;/p&gt;
&lt;p&gt;For example, a navigation bar might use a subtle background color
to indicate which page is currently selected.
If you view it in a high-contrast extension, that subtlety completely disappears,
and with it goes the reader&#39;s understanding of which page is active.&lt;/p&gt;
&lt;figure style=&quot;width: 500px&quot;&gt;
  &lt;img alt=&quot;Screenshot of a navigation bar in high contrast mode where the acvtive tab is hard to read&quot; decoding=&quot;async&quot; height=&quot;57&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 640px) 640px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/admin/dgmA4W1Qu8JmcgsH80HD.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/admin/dgmA4W1Qu8JmcgsH80HD.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/admin/dgmA4W1Qu8JmcgsH80HD.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/admin/dgmA4W1Qu8JmcgsH80HD.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/admin/dgmA4W1Qu8JmcgsH80HD.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/admin/dgmA4W1Qu8JmcgsH80HD.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/admin/dgmA4W1Qu8JmcgsH80HD.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/admin/dgmA4W1Qu8JmcgsH80HD.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/admin/dgmA4W1Qu8JmcgsH80HD.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/admin/dgmA4W1Qu8JmcgsH80HD.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/admin/dgmA4W1Qu8JmcgsH80HD.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/admin/dgmA4W1Qu8JmcgsH80HD.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/admin/dgmA4W1Qu8JmcgsH80HD.png?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/admin/dgmA4W1Qu8JmcgsH80HD.png?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/admin/dgmA4W1Qu8JmcgsH80HD.png?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/admin/dgmA4W1Qu8JmcgsH80HD.png?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/admin/dgmA4W1Qu8JmcgsH80HD.png?auto=format&amp;w=1280 1280w&quot; width=&quot;640&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;Similarly, if you consider the example from the previous lesson,
the red underline on the invalid phone number field might be
displayed in a hard-to-distinguish blue-green color.&lt;/p&gt;
&lt;figure&gt;
  &lt;img alt=&quot;Screenshot of the address form used earlier, this time in high contrast mode. The color change of the invalid element is hard to read.&quot; decoding=&quot;async&quot; height=&quot;328&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 700px) 700px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/admin/HtlXwmHQHBcAO4LYSfAA.jpg?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/admin/HtlXwmHQHBcAO4LYSfAA.jpg?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/admin/HtlXwmHQHBcAO4LYSfAA.jpg?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/admin/HtlXwmHQHBcAO4LYSfAA.jpg?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/admin/HtlXwmHQHBcAO4LYSfAA.jpg?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/admin/HtlXwmHQHBcAO4LYSfAA.jpg?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/admin/HtlXwmHQHBcAO4LYSfAA.jpg?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/admin/HtlXwmHQHBcAO4LYSfAA.jpg?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/admin/HtlXwmHQHBcAO4LYSfAA.jpg?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/admin/HtlXwmHQHBcAO4LYSfAA.jpg?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/admin/HtlXwmHQHBcAO4LYSfAA.jpg?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/admin/HtlXwmHQHBcAO4LYSfAA.jpg?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/admin/HtlXwmHQHBcAO4LYSfAA.jpg?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/admin/HtlXwmHQHBcAO4LYSfAA.jpg?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/admin/HtlXwmHQHBcAO4LYSfAA.jpg?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/admin/HtlXwmHQHBcAO4LYSfAA.jpg?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/admin/HtlXwmHQHBcAO4LYSfAA.jpg?auto=format&amp;w=1400 1400w&quot; width=&quot;700&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;If you are meeting the contrast ratios covered earlier
you should be fine when it comes to supporting high-contrast mode.
But for added peace of mind, consider installing the
&lt;a href=&quot;https://chrome.google.com/webstore/detail/high-contrast/djcfdncoelnlbldjfhinnjlhdjlikmph&quot; rel=&quot;noopener&quot;&gt;High Contrast Chrome Extension&lt;/a&gt;
and giving your page a once-over just to check that everything works, and looks, as expected.&lt;/p&gt;
</content>
    <author>
      <name>Dave Gash</name>
    </author><author>
      <name>Meggin Kearney</name>
    </author><author>
      <name>Rachel Andrew</name>
    </author><author>
      <name>Rob Dodson</name>
    </author>
  </entry>
  
  <entry>
    <title>Sign in Users</title>
    <link href="https://web.dev/security-credential-management-retrieve-credentials/"/>
    <updated>2016-11-08T00:00:00Z</updated>
    <id>https://web.dev/security-credential-management-retrieve-credentials/</id>
    <content type="html" mode="escaped">&lt;p&gt;To sign in users, retrieve the credentials from the browser&#39;s password
manager and use those to automatically log in users.
For users with multiple accounts,
let them select the account with just one tap using the account chooser.&lt;/p&gt;
&lt;h2 id=&quot;auto-sign-in&quot;&gt;Auto Sign-in &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/security-credential-management-retrieve-credentials/#auto-sign-in&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Auto sign-in can happen anywhere on your website;
not only the top page but other leaf pages too.
This is useful when users reach various pages in your website,
via a search engine.&lt;/p&gt;
&lt;p&gt;To enable auto sign-in:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Get credential information.&lt;/li&gt;
&lt;li&gt;Authenticate the user.&lt;/li&gt;
&lt;li&gt;Update the UI or proceed to the personalized page.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&quot;get-credential-information&quot;&gt;Get credential information &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/security-credential-management-retrieve-credentials/#get-credential-information&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;div class=&quot;wdi-browser-compat&quot;&gt;
  &lt;span class=&quot;wdi-browser-compat__label&quot;&gt;Browser support&lt;/span&gt;
  &lt;ul class=&quot;wdi-browser-compat__items&quot;&gt;
    &lt;li class=&quot;wdi-browser-compat__item&quot;&gt;
    &lt;span class=&quot;wdi-browser-compat__icon&quot; data-browser=&quot;chrome&quot;&gt;
      &lt;span class=&quot;visually-hidden&quot;&gt;Chrome 51, Supported&lt;/span&gt;
    &lt;/span&gt;
    &lt;span class=&quot;wdi-browser-compat__version&quot; data-compat=&quot;yes&quot; title=&quot;Supported&quot; aria-label=&quot;Supported&quot;&gt;
      51
    &lt;/span&gt;
    &lt;/li&gt;&lt;li class=&quot;wdi-browser-compat__item&quot;&gt;
    &lt;span class=&quot;wdi-browser-compat__icon&quot; data-browser=&quot;firefox&quot;&gt;
      &lt;span class=&quot;visually-hidden&quot;&gt;Firefox 60, Supported&lt;/span&gt;
    &lt;/span&gt;
    &lt;span class=&quot;wdi-browser-compat__version&quot; data-compat=&quot;yes&quot; title=&quot;Supported&quot; aria-label=&quot;Supported&quot;&gt;
      60
    &lt;/span&gt;
    &lt;/li&gt;&lt;li class=&quot;wdi-browser-compat__item&quot;&gt;
    &lt;span class=&quot;wdi-browser-compat__icon&quot; data-browser=&quot;edge&quot;&gt;
      &lt;span class=&quot;visually-hidden&quot;&gt;Edge 18, Supported&lt;/span&gt;
    &lt;/span&gt;
    &lt;span class=&quot;wdi-browser-compat__version&quot; data-compat=&quot;yes&quot; title=&quot;Supported&quot; aria-label=&quot;Supported&quot;&gt;
      18
    &lt;/span&gt;
    &lt;/li&gt;&lt;li class=&quot;wdi-browser-compat__item&quot;&gt;
    &lt;span class=&quot;wdi-browser-compat__icon&quot; data-browser=&quot;safari&quot;&gt;
      &lt;span class=&quot;visually-hidden&quot;&gt;Safari 13, Supported&lt;/span&gt;
    &lt;/span&gt;
    &lt;span class=&quot;wdi-browser-compat__version&quot; data-compat=&quot;yes&quot; title=&quot;Supported&quot; aria-label=&quot;Supported&quot;&gt;
      13
    &lt;/span&gt;
    &lt;/li&gt;
  &lt;/ul&gt;
  &lt;a class=&quot;wdi-browser-compat__link&quot; href=&quot;https://developer.mozilla.org/docs/Web/API/CredentialsContainer/get#browser_compatibility&quot; target=&quot;_blank&quot;&gt;Source&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;To get credential information, invoke
&lt;a href=&quot;https://developer.mozilla.org/docs/Web/API/CredentialsContainer/get&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;navigator.credentials.get()&lt;/code&gt;&lt;/a&gt;.
Specify the type of credentials to request
by giving it a &lt;code&gt;password&lt;/code&gt; or &lt;code&gt;federated&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Always use &lt;code&gt;mediation: &#39;silent&#39;&lt;/code&gt; for auto sign-ins,
so you can easily dismiss the process if the user:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Has no credentials stored.&lt;/li&gt;
&lt;li&gt;Has multiple credentials stored.&lt;/li&gt;
&lt;li&gt;Is signed out.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Before getting a credential,
don’t forget to check if the user is already signed in:&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;window&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;PasswordCredential &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; window&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;FederatedCredential&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;user&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;isSignedIn&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    navigator&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;credentials&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token literal-property property&quot;&gt;password&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token literal-property property&quot;&gt;federated&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token literal-property property&quot;&gt;providers&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;https://accounts.google.com&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token literal-property property&quot;&gt;mediation&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;silent&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token comment&quot;&gt;// ...&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;The promise returned by &lt;code&gt;navigator.credentials.get()&lt;/code&gt; resolves
with either a credential object or &lt;code&gt;null&lt;/code&gt;.
To determine whether it is a &lt;code&gt;PasswordCredential&lt;/code&gt; or a &lt;code&gt;FederatedCredential&lt;/code&gt;,
simply look at the &lt;code&gt;.type&lt;/code&gt; property of the object,
which will be either &lt;code&gt;password&lt;/code&gt; or &lt;code&gt;federated&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If the &lt;code&gt;.type&lt;/code&gt; is &lt;code&gt;federated&lt;/code&gt;,
the &lt;code&gt;.provider&lt;/code&gt; property is a string that represents the identity provider.&lt;/p&gt;
&lt;h3 id=&quot;authenticate-user&quot;&gt;Authenticate user &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/security-credential-management-retrieve-credentials/#authenticate-user&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Once you have the credential,
run an authentication flow depending on the type of credential,
&lt;code&gt;password&lt;/code&gt; or &lt;code&gt;federated&lt;/code&gt;:&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;     &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;c&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;       &lt;span class=&quot;token keyword&quot;&gt;switch&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;c&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;type&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;         &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;password&#39;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;br /&gt;           &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;sendRequest&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;c&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;           &lt;span class=&quot;token keyword&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;         &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;federated&#39;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;br /&gt;           &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;gSignIn&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;c&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;           &lt;span class=&quot;token keyword&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;       &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;     &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;       &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; Promise&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;resolve&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;     &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;When the promise resolves,
check if you&#39;ve received a credential object.
If not, it means auto sign-in couldn’t happen.
Silently dismiss the auto sign-in process.&lt;/p&gt;
&lt;h3 id=&quot;update-ui&quot;&gt;Update UI &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/security-credential-management-retrieve-credentials/#update-ui&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;If the authentication is successful,
update the UI or forward the user to the personalized page:&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;profile&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;     &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;profile&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;       &lt;span class=&quot;token function&quot;&gt;updateUI&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;profile&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;     &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;h3 id=&quot;dont-forget-to-show-authentication-error-message&quot;&gt;Don’t forget to show authentication error message &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/security-credential-management-retrieve-credentials/#dont-forget-to-show-authentication-error-message&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;To avoid user confusion,
users should see a blue toast saying “Signing in”
at the time of getting the credential object:&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;Blue toast showing user is signing in.&quot; decoding=&quot;async&quot; height=&quot;123&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 386px) 386px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/4nT0MfpnEaOvFAmZxkLM.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/4nT0MfpnEaOvFAmZxkLM.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/4nT0MfpnEaOvFAmZxkLM.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/4nT0MfpnEaOvFAmZxkLM.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/4nT0MfpnEaOvFAmZxkLM.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/4nT0MfpnEaOvFAmZxkLM.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/4nT0MfpnEaOvFAmZxkLM.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/4nT0MfpnEaOvFAmZxkLM.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/4nT0MfpnEaOvFAmZxkLM.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/4nT0MfpnEaOvFAmZxkLM.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/4nT0MfpnEaOvFAmZxkLM.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/4nT0MfpnEaOvFAmZxkLM.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/4nT0MfpnEaOvFAmZxkLM.png?auto=format&amp;w=772 772w&quot; width=&quot;386&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;One important tip: if you succeed in obtaining a credential object
but fail to authenticate the user, you should show an error message:&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;catch&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;error&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;token function&quot;&gt;showError&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Sign-in Failed&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;h3 id=&quot;full-code-example&quot;&gt;Full code example &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/security-credential-management-retrieve-credentials/#full-code-example&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;div&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;window&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;PasswordCredential &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; window&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;FederatedCredential&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;user&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;isSignedIn&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    navigator&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;credentials&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token literal-property property&quot;&gt;password&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token literal-property property&quot;&gt;federated&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;token literal-property property&quot;&gt;providers&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;https://accounts.google.com&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token literal-property property&quot;&gt;mediation&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;silent&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;c&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;token keyword&quot;&gt;switch&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;c&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;type&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;password&#39;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;br /&gt;              &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;sendRequest&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;c&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;              &lt;span class=&quot;token keyword&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;federated&#39;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;br /&gt;              &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;gSignIn&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;c&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;              &lt;span class=&quot;token keyword&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; Promise&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;resolve&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;profile&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;profile&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;token function&quot;&gt;updateUI&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;profile&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;catch&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token function&quot;&gt;showError&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Sign-in Failed&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;h2 id=&quot;sign-in-via-account-chooser&quot;&gt;Sign-in via account chooser &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/security-credential-management-retrieve-credentials/#sign-in-via-account-chooser&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;If a user requires mediation, or has multiple accounts,
use the account chooser to let the user sign-in,
skipping the ordinary sign-in form, for example:&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;Google account chooser showing multiple accounts.&quot; decoding=&quot;async&quot; height=&quot;346&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 390px) 390px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/drlYzW650dtEob0LyzRl.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/drlYzW650dtEob0LyzRl.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/drlYzW650dtEob0LyzRl.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/drlYzW650dtEob0LyzRl.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/drlYzW650dtEob0LyzRl.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/drlYzW650dtEob0LyzRl.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/drlYzW650dtEob0LyzRl.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/drlYzW650dtEob0LyzRl.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/drlYzW650dtEob0LyzRl.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/drlYzW650dtEob0LyzRl.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/drlYzW650dtEob0LyzRl.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/drlYzW650dtEob0LyzRl.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/C47gYyWYVMMhDmtYSLOWazuyePF2/drlYzW650dtEob0LyzRl.png?auto=format&amp;w=780 780w&quot; width=&quot;390&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;The steps to sign in via the account chooser are the same as in
&lt;a href=&quot;https://web.dev/security-credential-management-retrieve-credentials/#auto-sign-in&quot;&gt;auto sign-in&lt;/a&gt;,
with an additional call to show the account chooser
as part of getting credential information:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Get the credential information and show the account chooser.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://web.dev/security-credential-management-retrieve-credentials/#authenticate-user&quot;&gt;Authenticate the user&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://web.dev/security-credential-management-retrieve-credentials/#update-ui&quot;&gt;Update the UI or proceed to a personalized page&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&quot;get-credential-information-and-show-account-chooser&quot;&gt;Get credential information and show account chooser &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/security-credential-management-retrieve-credentials/#get-credential-information-and-show-account-chooser&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Show an account chooser in response to a defined user action,
for example, when the user taps the &amp;quot;Sign-In&amp;quot; button. Call
&lt;a href=&quot;https://developer.mozilla.org/docs/Web/API/CredentialsContainer/get&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;navigator.credentials.get()&lt;/code&gt;&lt;/a&gt;,
and add &lt;code&gt;mediation: &#39;optional&#39;&lt;/code&gt; or &lt;code&gt;mediation: &#39;required&#39;&lt;/code&gt; to show the account chooser.&lt;/p&gt;
&lt;p&gt;When &lt;code&gt;mediation&lt;/code&gt; is &lt;code&gt;required&lt;/code&gt;, the user is always shown an account chooser to sign in.
This option allows users with multiple accounts to easily switch between them.
When &lt;code&gt;mediation&lt;/code&gt; is &lt;code&gt;optional&lt;/code&gt;,
the user is explicitly shown an account chooser to sign in after a
&lt;a href=&quot;https://web.dev/web/fundamentals/security/credential-management/retrieve-credentials#turn_off_auto_sign-in_for_future_visits&quot;&gt;&lt;code&gt;navigator.credentials.preventSilentAccess()&lt;/code&gt;&lt;/a&gt;
call.
This is normally to ensure automatic sign-in doesn&#39;t happen
after the user chooses to sign-out or unregister.&lt;/p&gt;
&lt;p&gt;Example showing &lt;code&gt;mediation: &#39;optional&#39;&lt;/code&gt;:&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;    &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; signin &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;#signin&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    signin&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;click&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token parameter&quot;&gt;e&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;     &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;window&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;PasswordCredential &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; window&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;FederatedCredential&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;       navigator&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;credentials&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;         &lt;span class=&quot;token literal-property property&quot;&gt;password&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;         &lt;span class=&quot;token literal-property property&quot;&gt;federated&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;           &lt;span class=&quot;token literal-property property&quot;&gt;providers&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;br /&gt;             &lt;span class=&quot;token string&quot;&gt;&#39;https://accounts.google.com&#39;&lt;/span&gt;&lt;br /&gt;           &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;br /&gt;         &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;         &lt;span class=&quot;token literal-property property&quot;&gt;mediation&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;optional&#39;&lt;/span&gt;&lt;br /&gt;       &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;Once the user selects an account,
the promise resolves with the credential.
If the users cancels the account chooser,
or there are no credentials stored,
the promise resolves with &lt;code&gt;null&lt;/code&gt;.
In that case, fall back to the sign in form experience.&lt;/p&gt;
&lt;h3 id=&quot;dont-forget-to-fall-back-to-sign-in-form&quot;&gt;Don&#39;t forget to fall back to sign-in form &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/security-credential-management-retrieve-credentials/#dont-forget-to-fall-back-to-sign-in-form&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;You should fall back to a sign-in form for any of these reasons:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;No credentials are stored.&lt;/li&gt;
&lt;li&gt;The user dismissed the account chooser without selecting an account.&lt;/li&gt;
&lt;li&gt;The API is not available.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;profile&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;profile&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;token function&quot;&gt;updateUI&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;profile&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;          location&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;href &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;/signin&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;catch&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;error&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        location&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;href &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;/signin&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;h3 id=&quot;full-code-example-2&quot;&gt;Full code example &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/security-credential-management-retrieve-credentials/#full-code-example-2&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;div&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; signin &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;#signin&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;signin&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;click&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;window&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;PasswordCredential &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; window&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;FederatedCredential&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    navigator&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;credentials&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token literal-property property&quot;&gt;password&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token literal-property property&quot;&gt;federated&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;token literal-property property&quot;&gt;providers&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;https://accounts.google.com&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token literal-property property&quot;&gt;mediation&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;optional&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;c&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;token keyword&quot;&gt;switch&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;c&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;type&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;password&#39;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;br /&gt;              &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;sendRequest&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;c&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;              &lt;span class=&quot;token keyword&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;federated&#39;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;br /&gt;              &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;gSignIn&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;c&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;              &lt;span class=&quot;token keyword&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; Promise&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;resolve&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;profile&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;profile&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;token function&quot;&gt;updateUI&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;profile&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;          location&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;href &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;/signin&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;catch&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        location&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;href &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;/signin&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;h2 id=&quot;federated-login&quot;&gt;Federated Login &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/security-credential-management-retrieve-credentials/#federated-login&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Federated login lets users sign in with one tap and
without having to remember additional login details for your website.&lt;/p&gt;
&lt;p&gt;To implement federated login:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Authenticate the user with a third-party identity.&lt;/li&gt;
&lt;li&gt;Store the identity information.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://web.dev/security-credential-management-retrieve-credentials/#update-ui&quot;&gt;Update the UI or proceed to a personalized page&lt;/a&gt; (same as in auto sign-in).&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&quot;authenticate-user-with-third-party-identity&quot;&gt;Authenticate user with third-party identity &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/security-credential-management-retrieve-credentials/#authenticate-user-with-third-party-identity&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;When a user taps on a federated login button,
run the specific identity provider authentication flow with the
&lt;a href=&quot;https://developer.mozilla.org/docs/Web/API/FederatedCredential&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;FederatedCredential&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&quot;wdi-browser-compat&quot;&gt;
  &lt;span class=&quot;wdi-browser-compat__label&quot;&gt;Browser support&lt;/span&gt;
  &lt;ul class=&quot;wdi-browser-compat__items&quot;&gt;
    &lt;li class=&quot;wdi-browser-compat__item&quot;&gt;
    &lt;span class=&quot;wdi-browser-compat__icon&quot; data-browser=&quot;chrome&quot;&gt;
      &lt;span class=&quot;visually-hidden&quot;&gt;Chrome 51, Supported&lt;/span&gt;
    &lt;/span&gt;
    &lt;span class=&quot;wdi-browser-compat__version&quot; data-compat=&quot;yes&quot; title=&quot;Supported&quot; aria-label=&quot;Supported&quot;&gt;
      51
    &lt;/span&gt;
    &lt;/li&gt;&lt;li class=&quot;wdi-browser-compat__item&quot;&gt;
    &lt;span class=&quot;wdi-browser-compat__icon&quot; data-browser=&quot;firefox&quot;&gt;
      &lt;span class=&quot;visually-hidden&quot;&gt;Firefox, Not supported&lt;/span&gt;
    &lt;/span&gt;
    &lt;span class=&quot;wdi-browser-compat__version&quot; data-compat=&quot;no&quot; title=&quot;Not supported&quot; aria-label=&quot;Not supported&quot;&gt;
&lt;p&gt;&lt;/p&gt;&lt;/span&gt;
&lt;/li&gt;&lt;li class=&quot;wdi-browser-compat__item&quot;&gt;
&lt;span class=&quot;wdi-browser-compat__icon&quot; data-browser=&quot;edge&quot;&gt;
&lt;span class=&quot;visually-hidden&quot;&gt;Edge 79, Supported&lt;/span&gt;
&lt;/span&gt;
&lt;span class=&quot;wdi-browser-compat__version&quot; data-compat=&quot;yes&quot; title=&quot;Supported&quot; aria-label=&quot;Supported&quot;&gt;
79
&lt;/span&gt;
&lt;/li&gt;&lt;li class=&quot;wdi-browser-compat__item&quot;&gt;
&lt;span class=&quot;wdi-browser-compat__icon&quot; data-browser=&quot;safari&quot;&gt;
&lt;span class=&quot;visually-hidden&quot;&gt;Safari, Not supported&lt;/span&gt;
&lt;/span&gt;
&lt;span class=&quot;wdi-browser-compat__version&quot; data-compat=&quot;no&quot; title=&quot;Not supported&quot; aria-label=&quot;Not supported&quot;&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;/span&gt;
&lt;/li&gt;&lt;p&gt;&lt;/p&gt;
  &lt;/ul&gt;
  &lt;a class=&quot;wdi-browser-compat__link&quot; href=&quot;https://developer.mozilla.org/docs/Web/API/FederatedCredential#browser_compatibility&quot; target=&quot;_blank&quot;&gt;Source&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;For example, if the provider is Google, use the
&lt;a href=&quot;https://web.dev/identity/sign-in/web/&quot;&gt;Google Sign-In JavaScript library&lt;/a&gt;:&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;navigator&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;credentials&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token literal-property property&quot;&gt;password&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token literal-property property&quot;&gt;mediation&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;optional&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token literal-property property&quot;&gt;federated&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token literal-property property&quot;&gt;providers&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;https://account.google.com&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;cred&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;cred&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token comment&quot;&gt;// Instantiate an auth object&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; auth2 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; gapi&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;auth2&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getAuthInstance&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;      &lt;span class=&quot;token comment&quot;&gt;// Is this user already signed in?&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;auth2&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;isSignedIn&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; googleUser &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; auth2&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;currentUser&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span class=&quot;token comment&quot;&gt;// Same user as in the credential object?&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;googleUser&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getBasicProfile&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getEmail&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; cred&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;token comment&quot;&gt;// Continue with the signed-in user.&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; Promise&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;resolve&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;googleUser&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;      &lt;span class=&quot;token comment&quot;&gt;// Otherwise, run a new authentication flow.&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; auth2&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;signIn&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token literal-property property&quot;&gt;login_hint&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; id &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;Google Sign-In results in an ID token as a proof of authentication.&lt;/p&gt;
&lt;p&gt;In general, federated logins are built on top of standard protocols such as
&lt;a href=&quot;http://openid.net/connect/&quot; rel=&quot;noopener&quot;&gt;OpenID Connect&lt;/a&gt; or
&lt;a href=&quot;https://oauth.net/2/&quot; rel=&quot;noopener&quot;&gt;OAuth&lt;/a&gt;.
To learn how to authenticate with federated accounts,
refer to respective federated identity providers&#39; docs.
Popular examples include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://web.dev/identity/sign-in/web/&quot;&gt;Google Sign-In&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://developers.facebook.com/docs/facebook-login&quot; rel=&quot;noopener&quot;&gt;Facebook Login&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://dev.twitter.com/web/sign-in/implementing&quot; rel=&quot;noopener&quot;&gt;Twitter Sign-in&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://developer.github.com/v3/oauth/&quot; rel=&quot;noopener&quot;&gt;GitHub OAuth&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;store-identity-information&quot;&gt;Store identity information &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/security-credential-management-retrieve-credentials/#store-identity-information&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Once authentication is done, you can store the identity information.
The information you’ll store here is the &lt;code&gt;id&lt;/code&gt; from the identity provider
and a provider string that represents the identity provider
(&lt;code&gt;name&lt;/code&gt; and &lt;code&gt;iconURL&lt;/code&gt; are optional).
Learn more about this information in the
&lt;a href=&quot;https://w3c.github.io/webappsec-credential-management/#credential&quot; rel=&quot;noopener&quot;&gt;Credential Management specification&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To store federated account details, instantiate a new
&lt;a href=&quot;https://developer.mozilla.org/docs/Web/API/FederatedCredential&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;FederatedCredential&lt;/code&gt;&lt;/a&gt;
object with the user&#39;s identifier and the provider&#39;s identifier.
Then invoke
&lt;a href=&quot;https://developer.mozilla.org/docs/Web/API/CredentialsContainer/store&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;navigator.credentials.store()&lt;/code&gt;&lt;/a&gt;
to store the identity information.&lt;/p&gt;
&lt;p&gt;After successful federation,
instantiate a &lt;code&gt;FederatedCredential&lt;/code&gt; synchronously, or asynchronously:&lt;/p&gt;
&lt;p&gt;Example of synchronous approach:&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Create credential object synchronously.&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; cred &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;FederatedCredential&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token literal-property property&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; id&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// id in IdP&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token literal-property property&quot;&gt;provider&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;https://account.google.com&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// A string representing IdP&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; name&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// name in IdP&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token literal-property property&quot;&gt;iconURL&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; iconUrl&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Profile image url&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;Example of asynchronous approach:&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Create credential object asynchronously.&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; cred &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; navigator&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;credentials&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token literal-property property&quot;&gt;federated&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token literal-property property&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; id&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token literal-property property&quot;&gt;provider&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;https://accounts.google.com&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; name&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token literal-property property&quot;&gt;iconURL&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; iconUrl&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;Then store the credential object:&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Store it&lt;/span&gt;&lt;br /&gt;navigator&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;credentials&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;store&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;cred&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token comment&quot;&gt;// continuation&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;h2 id=&quot;sign-out&quot;&gt;Sign out &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/security-credential-management-retrieve-credentials/#sign-out&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Sign out your users when the sign-out button is tapped.
First terminate the session,
then turn off auto sign-in for future visits.
(How you terminate your sessions is totally up to you.)&lt;/p&gt;
&lt;h3 id=&quot;turn-off-auto-sign-in-for-future-visits&quot;&gt;Turn off auto sign-in for future visits &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/security-credential-management-retrieve-credentials/#turn-off-auto-sign-in-for-future-visits&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Call
&lt;code&gt;navigator.credentials.preventSilentAccess()&lt;/code&gt;:&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token function&quot;&gt;signoutUser&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;navigator&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;credentials &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; navigator&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;credentials&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;preventSilentAccess&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  navigator&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;credentials&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;preventSilentAccess&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;This will ensure the auto sign-in won’t happen until next time the user enables auto sign-in.
To resume auto sign-in, a user can choose to intentionally sign in
by choosing the account they wish to sign in with from the account chooser.
Then the user is always signed back in until they explicitly sign out.&lt;/p&gt;
&lt;h2 id=&quot;feedback&quot;&gt;Feedback &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/security-credential-management-retrieve-credentials/#feedback&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
</content>
    <author>
      <name>Eiji Kitamura</name>
    </author><author>
      <name>Meggin Kearney</name>
    </author>
  </entry>
  
  <entry>
    <title>The Credential Management API</title>
    <link href="https://web.dev/security-credential-management/"/>
    <updated>2016-11-08T00:00:00Z</updated>
    <id>https://web.dev/security-credential-management/</id>
    <content type="html" mode="escaped">&lt;p&gt;The &lt;a href=&quot;https://www.w3.org/TR/credential-management/&quot; rel=&quot;noopener&quot;&gt;Credential Management API&lt;/a&gt;
is a standards-based browser API that provides a programmatic interface
between the site and the browser for seamless sign-in across devices.&lt;/p&gt;
&lt;p&gt;The Credential Management API:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Removes friction from sign-in flows&lt;/strong&gt; - Users can be automatically signed back into a site even if their session has expired or they saved credentials on another device.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Allows one tap sign in with account chooser&lt;/strong&gt; - Users can choose an account in a native account chooser.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Stores credentials&lt;/strong&gt; - Your application can store either a username and password combination or even federated account details. These credentials can be synced across devices by the browser.&lt;/li&gt;
&lt;/ul&gt;
&lt;aside class=&quot;aside flow bg-tertiary-box-bg color-tertiary-box-text&quot;&gt;&lt;p class=&quot;cluster &quot;&gt;&lt;span class=&quot;aside__icon box-block &quot;&gt;&lt;svg width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; role=&quot;img&quot; aria-label=&quot;Lightbulb&quot; fill=&quot;currentColor&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;   &lt;path d=&quot;M9 21c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-1H9v1zm3-19C8.14 2 5 5.14 5 9c0 2.38 1.19 4.47 3 5.74V17c0 .55.45 1 1 1h6c.55 0 1-.45 1-1v-2.26c1.81-1.27 3-3.36 3-5.74 0-3.86-3.14-7-7-7zm2.85 11.1l-.85.6V16h-4v-2.3l-.85-.6A4.997 4.997 0 017 9c0-2.76 2.24-5 5-5s5 2.24 5 5c0 1.63-.8 3.16-2.15 4.1z&quot;&gt;&lt;/path&gt; &lt;/svg&gt;&lt;/span&gt;&lt;strong&gt;Important&lt;/strong&gt;&lt;/p&gt;&lt;div class=&quot; flow&quot;&gt; Using the Credential Management API requires the page be served from a secure origin. &lt;/div&gt;&lt;/aside&gt;
&lt;p&gt;Want to see it in action? Try the
&lt;a href=&quot;https://credential-management-sample.appspot.com/&quot; rel=&quot;noopener&quot;&gt;Credential Management API Demo&lt;/a&gt;
and take a look at the
&lt;a href=&quot;https://github.com/GoogleChrome/credential-management-sample&quot; rel=&quot;noopener&quot;&gt;code&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&quot;check-credential-management-api-browser-support&quot;&gt;Check Credential Management API browser support &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/security-credential-management/#check-credential-management-api-browser-support&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;div class=&quot;wdi-browser-compat&quot;&gt;
  &lt;span class=&quot;wdi-browser-compat__label&quot;&gt;Browser support&lt;/span&gt;
  &lt;ul class=&quot;wdi-browser-compat__items&quot;&gt;
    &lt;li class=&quot;wdi-browser-compat__item&quot;&gt;
    &lt;span class=&quot;wdi-browser-compat__icon&quot; data-browser=&quot;chrome&quot;&gt;
      &lt;span class=&quot;visually-hidden&quot;&gt;Chrome 51, Supported&lt;/span&gt;
    &lt;/span&gt;
    &lt;span class=&quot;wdi-browser-compat__version&quot; data-compat=&quot;yes&quot; title=&quot;Supported&quot; aria-label=&quot;Supported&quot;&gt;
      51
    &lt;/span&gt;
    &lt;/li&gt;&lt;li class=&quot;wdi-browser-compat__item&quot;&gt;
    &lt;span class=&quot;wdi-browser-compat__icon&quot; data-browser=&quot;firefox&quot;&gt;
      &lt;span class=&quot;visually-hidden&quot;&gt;Firefox 60, Supported&lt;/span&gt;
    &lt;/span&gt;
    &lt;span class=&quot;wdi-browser-compat__version&quot; data-compat=&quot;yes&quot; title=&quot;Supported&quot; aria-label=&quot;Supported&quot;&gt;
      60
    &lt;/span&gt;
    &lt;/li&gt;&lt;li class=&quot;wdi-browser-compat__item&quot;&gt;
    &lt;span class=&quot;wdi-browser-compat__icon&quot; data-browser=&quot;edge&quot;&gt;
      &lt;span class=&quot;visually-hidden&quot;&gt;Edge 18, Supported&lt;/span&gt;
    &lt;/span&gt;
    &lt;span class=&quot;wdi-browser-compat__version&quot; data-compat=&quot;yes&quot; title=&quot;Supported&quot; aria-label=&quot;Supported&quot;&gt;
      18
    &lt;/span&gt;
    &lt;/li&gt;&lt;li class=&quot;wdi-browser-compat__item&quot;&gt;
    &lt;span class=&quot;wdi-browser-compat__icon&quot; data-browser=&quot;safari&quot;&gt;
      &lt;span class=&quot;visually-hidden&quot;&gt;Safari 13, Supported&lt;/span&gt;
    &lt;/span&gt;
    &lt;span class=&quot;wdi-browser-compat__version&quot; data-compat=&quot;yes&quot; title=&quot;Supported&quot; aria-label=&quot;Supported&quot;&gt;
      13
    &lt;/span&gt;
    &lt;/li&gt;
  &lt;/ul&gt;
  &lt;a class=&quot;wdi-browser-compat__link&quot; href=&quot;https://developer.mozilla.org/docs/Web/API/Credential#browser_compatibility&quot; target=&quot;_blank&quot;&gt;Source&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;Before using the Credential Management API, first check if &lt;code&gt;PasswordCredential&lt;/code&gt;
or &lt;code&gt;FederatedCredential&lt;/code&gt; is supported.&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;window&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;PasswordCredential &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; window&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;FederatedCredential&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token comment&quot;&gt;// Call navigator.credentials.get() to retrieve stored&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token comment&quot;&gt;// PasswordCredentials or FederatedCredentials.&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;aside class=&quot;aside flow bg-state-warn-bg color-state-warn-text&quot;&gt;&lt;p class=&quot;cluster &quot;&gt;&lt;span class=&quot;aside__icon box-block color-state-warn-text&quot;&gt;&lt;svg width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;currentColor&quot; role=&quot;img&quot; aria-label=&quot;Warning sign&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;   &lt;path fill-rule=&quot;evenodd&quot; clip-rule=&quot;evenodd&quot; d=&quot;M23 21L12 2 1 21h22zm-12-3v-2h2v2h-2zm0-4h2v-4h-2v4z&quot;&gt;&lt;/path&gt; &lt;/svg&gt;&lt;/span&gt;&lt;strong&gt;Warning&lt;/strong&gt;&lt;/p&gt;&lt;div class=&quot; flow&quot;&gt; Feature detection by checking &lt;code&gt;navigator.credentials&lt;/code&gt; may break your website on browsers supporting &lt;a href=&quot;https://www.w3.org/TR/webauthn/&quot;&gt;WebAuthn&lt;/a&gt;(PublicKeyCredential) but not all credential types (&lt;code&gt;PasswordCredential&lt;/code&gt; and &lt;code&gt;FederatedCredential&lt;/code&gt;) defined by the Credential Management API. &lt;a href=&quot;https://web.dev/web/updates/2018/03/webauthn-credential-management&quot;&gt;Learn more&lt;/a&gt;. &lt;/div&gt;&lt;/aside&gt;
&lt;h3 id=&quot;sign-in-user&quot;&gt;Sign in user &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/security-credential-management/#sign-in-user&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;To sign in the user, retrieve the credentials from the browser&#39;s password
manager and use them to log in the user.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;When a user lands on your site and they are not signed in,
call &lt;a href=&quot;https://developer.mozilla.org/docs/Web/API/CredentialsContainer/get&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;navigator.credentials.get()&lt;/code&gt;&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Use the retrieved credentials to sign in the user.&lt;/li&gt;
&lt;li&gt;Update the UI to indicate the user has been signed in.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Learn more in
&lt;a href=&quot;https://web.dev/security-credential-management-retrieve-credentials#auto-sign-in&quot;&gt;Sign In Users&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&quot;save-or-update-user-credentials&quot;&gt;Save or update user credentials &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/security-credential-management/#save-or-update-user-credentials&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;If the user signed in with a federated identity provider such as Google
Sign-In, Facebook, GitHub:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;After the user successfully signs in or creates an account, create the &lt;a href=&quot;https://developer.mozilla.org/docs/Web/API/FederatedCredential&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;FederatedCredential&lt;/code&gt;&lt;/a&gt; with the user&#39;s email address as
the ID and specify the identity provider with &lt;code&gt;FederatedCredentials.provider&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Save the credential object using &lt;a href=&quot;https://developer.mozilla.org/docs/Web/API/CredentialsContainer/store&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;navigator.credentials.store()&lt;/code&gt;&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Learn more in
&lt;a href=&quot;https://web.dev/security-credential-management-retrieve-credentials#federated-login&quot;&gt;Sign In Users&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If the user signed in with a username and password:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;After the user successfully signs in or creates an account, create the &lt;a href=&quot;https://developer.mozilla.org/docs/Web/API/PasswordCredential&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;PasswordCredential&lt;/code&gt;&lt;/a&gt; with the user ID and
the password.&lt;/li&gt;
&lt;li&gt;Save the credential object using &lt;a href=&quot;https://developer.mozilla.org/docs/Web/API/CredentialsContainer/store&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;navigator.credentials.store()&lt;/code&gt;&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Learn more in
&lt;a href=&quot;https://web.dev/security-credential-management-save-forms&quot;&gt;Save Credentials from Forms&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&quot;sign-out&quot;&gt;Sign out &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/security-credential-management/#sign-out&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;When the user signs out, call &lt;a href=&quot;https://web.dev/web/fundamentals/security/credential-management/retrieve-credentials#turn_off_auto_sign-in_for_future_visits&quot;&gt;&lt;code&gt;navigator.credentials.preventSilentAccess()&lt;/code&gt;&lt;/a&gt;
to prevent the user from being automatically signed back in.&lt;/p&gt;
&lt;p&gt;Disabling auto-sign-in also enables users to switch between accounts easily,
for example, between work and personal accounts, or between accounts on
shared devices, without having to re-enter their sign-in information.&lt;/p&gt;
&lt;p&gt;Learn more in
&lt;a href=&quot;https://web.dev/security-credential-management-retrieve-credentials#sign-out&quot;&gt;Sign out&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;feedback&quot;&gt;Feedback &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/security-credential-management/#feedback&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
</content>
    <author>
      <name>Eiji Kitamura</name>
    </author><author>
      <name>Meggin Kearney</name>
    </author>
  </entry>
  
  <entry>
    <title>Introduction to ARIA</title>
    <link href="https://web.dev/semantics-aria/"/>
    <updated>2016-10-04T00:00:00Z</updated>
    <id>https://web.dev/semantics-aria/</id>
    <content type="html" mode="escaped">&lt;p&gt;So far, we&#39;ve encouraged using native HTML elements because they give you focus,
keyboard support, and built-in semantics, but there are times when a simple
layout and native HTML won&#39;t do the job. For example, currently there&#39;s no
standardized HTML element for a very common UI construct, the pop-up menu. Nor
is there an HTML element that provides a semantic characteristic such as &amp;quot;the
user needs to know about this as soon as possible&amp;quot;.&lt;/p&gt;
&lt;p&gt;In this lesson, then, we&#39;ll explore how to express semantics that HTML can&#39;t
express on its own.&lt;/p&gt;
&lt;p&gt;The &lt;a href=&quot;https://www.w3.org/TR/wai-aria/&quot; class=&quot;external&quot; rel=&quot;noopener&quot;&gt;Web Accessibility Initiative&#39;s Accessible Rich Internet Applications
specification&lt;/a&gt; (WAI-ARIA, or just
ARIA) is good for bridging areas with accessibility issues that can&#39;t be managed
with native HTML. It works by allowing you to specify attributes that modify the
way an element is translated into the accessibility tree. Let&#39;s look at an
example.&lt;/p&gt;
&lt;p&gt;In the following snippet, we use a list item as a kind of custom checkbox. The
CSS &amp;quot;checkbox&amp;quot; class gives the element the required visual characteristics.&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;tabindex&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;0&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;checkbox&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;checked&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    Receive promotional offers&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;While this works fine for sighted users, a screen reader will give no indication
that the element is meant to be a checkbox, so low-vision users may miss the
element entirely.&lt;/p&gt;
&lt;p&gt;Using ARIA attributes, however, we can give the element the missing information
so the screen reader can properly interpret it. Here, we&#39;ve added the &lt;code&gt;role&lt;/code&gt; and
&lt;code&gt;aria-checked&lt;/code&gt; attributes to explicitly identify the element as a checkbox and
to specify that it is checked by default. The list item will now be added to the
accessibility tree and a screen reader will correctly report it as a checkbox.&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;tabindex&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;0&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;checkbox&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;checkbox&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;checked&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;aria-checked&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;true&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    Receive promotional offers&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;aside class=&quot;aside flow bg-state-info-bg color-state-info-text&quot;&gt;&lt;div class=&quot; flow&quot;&gt; We&#39;ll cover the list of ARIA attributes and when to use them &lt;a href=&quot;https://web.dev/semantics-aria/#what-can-aria-do&quot;&gt;later&lt;/a&gt;. &lt;/div&gt;&lt;/aside&gt;
&lt;p&gt;ARIA works by changing and augmenting the standard DOM accessibility tree.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;The standard DOM accessibility tree.&quot; class=&quot;float-right&quot; decoding=&quot;async&quot; height=&quot;383&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 575px) 575px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fB932LjGfGgJRELivys8.jpg?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fB932LjGfGgJRELivys8.jpg?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fB932LjGfGgJRELivys8.jpg?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fB932LjGfGgJRELivys8.jpg?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fB932LjGfGgJRELivys8.jpg?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fB932LjGfGgJRELivys8.jpg?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fB932LjGfGgJRELivys8.jpg?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fB932LjGfGgJRELivys8.jpg?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fB932LjGfGgJRELivys8.jpg?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fB932LjGfGgJRELivys8.jpg?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fB932LjGfGgJRELivys8.jpg?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fB932LjGfGgJRELivys8.jpg?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fB932LjGfGgJRELivys8.jpg?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fB932LjGfGgJRELivys8.jpg?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fB932LjGfGgJRELivys8.jpg?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fB932LjGfGgJRELivys8.jpg?auto=format&amp;w=1150 1150w&quot; width=&quot;575&quot; /&gt;
&lt;/figure&gt;
&lt;figure&gt;
&lt;img alt=&quot;The ARIA augmented accessibility tree.&quot; class=&quot;float-right&quot; decoding=&quot;async&quot; height=&quot;383&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 575px) 575px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/G1IWcJBT9tfZq4xCKTqq.jpg?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/G1IWcJBT9tfZq4xCKTqq.jpg?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/G1IWcJBT9tfZq4xCKTqq.jpg?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/G1IWcJBT9tfZq4xCKTqq.jpg?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/G1IWcJBT9tfZq4xCKTqq.jpg?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/G1IWcJBT9tfZq4xCKTqq.jpg?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/G1IWcJBT9tfZq4xCKTqq.jpg?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/G1IWcJBT9tfZq4xCKTqq.jpg?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/G1IWcJBT9tfZq4xCKTqq.jpg?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/G1IWcJBT9tfZq4xCKTqq.jpg?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/G1IWcJBT9tfZq4xCKTqq.jpg?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/G1IWcJBT9tfZq4xCKTqq.jpg?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/G1IWcJBT9tfZq4xCKTqq.jpg?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/G1IWcJBT9tfZq4xCKTqq.jpg?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/G1IWcJBT9tfZq4xCKTqq.jpg?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/G1IWcJBT9tfZq4xCKTqq.jpg?auto=format&amp;w=1150 1150w&quot; width=&quot;575&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;Although ARIA allows us to subtly (or even radically) modify the accessibility
tree for any element on the page, that is the only thing it changes. &lt;strong&gt;ARIA
doesn&#39;t augment any of the element&#39;s inherent behavior&lt;/strong&gt;; it won&#39;t make the
element focusable or give it keyboard event listeners. That is still part of our
development task.&lt;/p&gt;
&lt;p&gt;It&#39;s important to understand that there is no need to redefine default
semantics. Regardless of its use, a standard HTML &lt;code&gt;&amp;lt;input type=&amp;quot;checkbox&amp;quot;&amp;gt;&lt;/code&gt;
element doesn&#39;t need an additional &lt;code&gt;role=&amp;quot;checkbox&amp;quot;&lt;/code&gt; ARIA attribute to be
correctly announced.&lt;/p&gt;
&lt;p&gt;It&#39;s also worth noting that certain HTML elements have restrictions on what ARIA
roles and attributes can be used on them. For example, a standard &lt;code&gt;&amp;lt;input type=&amp;quot;text&amp;quot;&amp;gt;&lt;/code&gt; element may not have any additional role/attribute applied to it.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;See the &lt;a href=&quot;https://www.w3.org/TR/html-aria/#sec-strong-native-semantics&quot; rel=&quot;noopener&quot;&gt;ARIA in HTML spec&lt;/a&gt;
for more information.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Let&#39;s see what other capabilities ARIA has to offer.&lt;/p&gt;
&lt;h2 id=&quot;what-can-aria-do&quot;&gt;What can ARIA do? &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/semantics-aria/#what-can-aria-do&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;As you saw with the checkbox example, ARIA can modify existing element semantics
or add semantics to elements where no native semantics exist. It can also
express semantic patterns that don&#39;t exist at all in HTML, like a menu or a tab
panel. Often, ARIA lets us create widget-type elements that wouldn&#39;t be possible
with plain HTML.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;For example, ARIA can add extra label and description text that is only
exposed to assistive technology APIs.&lt;br /&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;aria-label&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;screen reader only label&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;ARIA can express semantic relationships between elements that extend the
standard parent/child connection, such as a custom scrollbar that controls a
specific region.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;scrollbar&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;aria-controls&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;main&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;main&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    . . .&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;And ARIA can make parts of the page &amp;quot;live,&amp;quot; so they immediately inform
assistive technology when they change.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;aria-live&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;polite&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;GOOG: $400&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;One of the core aspects of the ARIA system is its collection of &lt;em&gt;roles&lt;/em&gt;. A role
in accessibility terms amounts to a shorthand indicator for a particular UI
pattern. ARIA provides a vocabulary of patterns we can use via the &lt;code&gt;role&lt;/code&gt;
attribute on any HTML element.&lt;/p&gt;
&lt;p&gt;When we applied &lt;code&gt;role=&amp;quot;checkbox&amp;quot;&lt;/code&gt; in the previous example, we were telling
assistive technology that the element should follow the &amp;quot;checkbox&amp;quot; pattern. That
is, we&#39;re guaranteeing that it will have a checked state (either checked or not
checked), and that the state may be toggled using the mouse or the spacebar,
just like a standard HTML checkbox element.&lt;/p&gt;
&lt;p&gt;In fact, because keyboard interactions feature so prominently in screen reader
usage, it&#39;s very important to make sure that, when creating a custom widget, the
&lt;code&gt;role&lt;/code&gt; attribute is always applied in the same place as the &lt;code&gt;tabindex&lt;/code&gt;
attribute; this ensures that keyboard events go to the right place and that when
focus lands on an element its role is conveyed accurately.&lt;/p&gt;
&lt;p&gt;The &lt;a href=&quot;https://www.w3.org/TR/wai-aria/&quot; rel=&quot;noopener&quot;&gt;ARIA spec&lt;/a&gt; describes a
taxonomy of possible values for the &lt;code&gt;role&lt;/code&gt; attribute and associated ARIA
attributes that may be used in conjunction with those roles. This is the best
source of definitive information about how the ARIA roles and attributes work
together and how they can be used in a way that is supported by browsers and
assistive technologies.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;A list of all the available ARIA roles.&quot; decoding=&quot;async&quot; height=&quot;361&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 800px) 800px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HSW9NAR73Hd7gDYiWhQh.jpg?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HSW9NAR73Hd7gDYiWhQh.jpg?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HSW9NAR73Hd7gDYiWhQh.jpg?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HSW9NAR73Hd7gDYiWhQh.jpg?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HSW9NAR73Hd7gDYiWhQh.jpg?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HSW9NAR73Hd7gDYiWhQh.jpg?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HSW9NAR73Hd7gDYiWhQh.jpg?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HSW9NAR73Hd7gDYiWhQh.jpg?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HSW9NAR73Hd7gDYiWhQh.jpg?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HSW9NAR73Hd7gDYiWhQh.jpg?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HSW9NAR73Hd7gDYiWhQh.jpg?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HSW9NAR73Hd7gDYiWhQh.jpg?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HSW9NAR73Hd7gDYiWhQh.jpg?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HSW9NAR73Hd7gDYiWhQh.jpg?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HSW9NAR73Hd7gDYiWhQh.jpg?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HSW9NAR73Hd7gDYiWhQh.jpg?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HSW9NAR73Hd7gDYiWhQh.jpg?auto=format&amp;w=1428 1428w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HSW9NAR73Hd7gDYiWhQh.jpg?auto=format&amp;w=1600 1600w&quot; width=&quot;800&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;However, the spec is very dense; a more approachable place to start is the &lt;a href=&quot;https://www.w3.org/TR/wai-aria-practices-1.1/&quot; rel=&quot;noopener&quot;&gt;ARIA
Authoring Practices document&lt;/a&gt;
, which explores best practices for using the available ARIA roles and
properties.&lt;/p&gt;
&lt;p&gt;ARIA also offers landmark roles that extend the options available in HTML5. See
the &lt;a href=&quot;https://www.w3.org/TR/wai-aria-practices-1.1#kbd_layout_landmark_XHTML&quot; rel=&quot;noopener&quot;&gt;Landmark Roles Design
Patterns&lt;/a&gt;
spec for more information.&lt;/p&gt;
</content>
    <author>
      <name>Meggin Kearney</name>
    </author><author>
      <name>Dave Gash</name>
    </author><author>
      <name>Alice Boxhall</name>
    </author>
  </entry>
  
  <entry>
    <title>Hiding and updating content</title>
    <link href="https://web.dev/hiding-and-updating-content/"/>
    <updated>2016-10-04T00:00:00Z</updated>
    <id>https://web.dev/hiding-and-updating-content/</id>
    <content type="html" mode="escaped">&lt;h2 id=&quot;aria-hidden&quot;&gt;aria-hidden &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/hiding-and-updating-content/#aria-hidden&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Another important technique in fine-tuning the experience for assistive
technology users involves ensuring that only relevant parts of the page are
exposed to assistive technology. There are several ways to ensure that a section
of the DOM does not get exposed to accessibility APIs.&lt;/p&gt;
&lt;p&gt;First, anything that is explicitly hidden from the DOM will also not be included
in the accessibility tree. So anything that has a CSS style of &lt;code&gt;visibility: hidden&lt;/code&gt; or &lt;code&gt;display: none&lt;/code&gt; or uses the HTML5 &lt;code&gt;hidden&lt;/code&gt; attribute will also be
hidden from assistive technology users.&lt;/p&gt;
&lt;p&gt;However, an element that is not visually rendered but not explicitly hidden is
still included in the accessibility tree. One common technique is to include
&amp;quot;screen reader only text&amp;quot; in an element that is absolute positioned offscreen.&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.sr-only&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; absolute&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;left&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; -10000px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;overflow&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; hidden&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;Also, as we have seen, it&#39;s possible to provide screen reader only text via an
&lt;code&gt;aria-label&lt;/code&gt;, &lt;code&gt;aria-labelledby&lt;/code&gt;, or &lt;code&gt;aria-describedby&lt;/code&gt; attribute referencing an
element that is otherwise hidden.&lt;/p&gt;
&lt;p&gt;See this WebAIM article on &lt;a href=&quot;https://webaim.org/techniques/css/invisiblecontent/#techniques&quot; rel=&quot;noopener&quot;&gt;Techniques for hiding
text&lt;/a&gt;
for more information on creating &amp;quot;screen reader only&amp;quot; text.&lt;/p&gt;
&lt;p&gt;Finally, ARIA provides a mechanism for excluding content from assistive
technology that is not visually hidden, using the &lt;code&gt;aria-hidden&lt;/code&gt; attribute.
Applying this attribute to an element effectively removes it &lt;em&gt;and all of its
descendants&lt;/em&gt; from the accessibility tree. The only exceptions are elements
referred to by an &lt;code&gt;aria-labelledby&lt;/code&gt; or &lt;code&gt;aria-describedby&lt;/code&gt; attribute.&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;deck&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;slide&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;aria-hidden&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;true&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    Sales Targets&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;slide&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    Quarterly Sales&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;slide&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;aria-hidden&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;true&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    Action Items&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;For example, you might use &lt;code&gt;aria-hidden&lt;/code&gt; if you&#39;re creating some modal UI that
blocks access to the main page. In this case, a sighted user might see some kind
of semi-transparent overlay indicating that most of the page can&#39;t currently be
used, but a screen reader user may still be able to explore to the other parts
of the page. In this case, as well as creating the keyboard trap &lt;a href=&quot;https://web.dev/using-tabindex/#modals-and-keyboard-traps/&quot;&gt;explained
earlier&lt;/a&gt;,
you need to make sure that the parts of the page that are currently out of scope
are &lt;code&gt;aria-hidden&lt;/code&gt; as well.&lt;/p&gt;
&lt;p&gt;Now that you understand the basics of ARIA, how it plays with native HTML
semantics, and how it can be used to perform fairly major surgery on the
accessibility tree as well as changing the semantics of a single element, let&#39;s
look at how we can use it to convey time-sensitive information.&lt;/p&gt;
&lt;h2 id=&quot;aria-live&quot;&gt;aria-live &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/hiding-and-updating-content/#aria-live&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;aria-live&lt;/code&gt; lets developers mark a part of the page as &amp;quot;live&amp;quot; in the sense that
updates should be communicated to users immediately regardless of the page
position, rather than if they just happen to explore that part of the page. When
an element has an &lt;code&gt;aria-live&lt;/code&gt; attribute, the part of the page containing it and
its descendants is called a &lt;em&gt;live region&lt;/em&gt;.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;ARIA live establishes a live region.&quot; decoding=&quot;async&quot; height=&quot;354&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 800px) 800px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hhZJxeHAdDC9JxNi6wxh.jpg?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hhZJxeHAdDC9JxNi6wxh.jpg?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hhZJxeHAdDC9JxNi6wxh.jpg?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hhZJxeHAdDC9JxNi6wxh.jpg?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hhZJxeHAdDC9JxNi6wxh.jpg?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hhZJxeHAdDC9JxNi6wxh.jpg?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hhZJxeHAdDC9JxNi6wxh.jpg?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hhZJxeHAdDC9JxNi6wxh.jpg?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hhZJxeHAdDC9JxNi6wxh.jpg?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hhZJxeHAdDC9JxNi6wxh.jpg?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hhZJxeHAdDC9JxNi6wxh.jpg?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hhZJxeHAdDC9JxNi6wxh.jpg?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hhZJxeHAdDC9JxNi6wxh.jpg?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hhZJxeHAdDC9JxNi6wxh.jpg?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hhZJxeHAdDC9JxNi6wxh.jpg?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hhZJxeHAdDC9JxNi6wxh.jpg?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hhZJxeHAdDC9JxNi6wxh.jpg?auto=format&amp;w=1428 1428w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hhZJxeHAdDC9JxNi6wxh.jpg?auto=format&amp;w=1600 1600w&quot; width=&quot;800&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;For example, a live region might be a status message that appears as a result of
a user action. If the message is important enough to grab a sighted user&#39;s
attention, it is important enough to direct an assistive technology user&#39;s
attention to it by setting its &lt;code&gt;aria-live&lt;/code&gt; attribute. Compare this plain &lt;code&gt;div&lt;/code&gt;&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;status&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Your message has been sent.&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;with its &amp;quot;live&amp;quot; counterpart.&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;status&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;aria-live&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;polite&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Your message has been sent.&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;&lt;code&gt;aria-live&lt;/code&gt; has three allowable values: &lt;code&gt;polite&lt;/code&gt;, &lt;code&gt;assertive&lt;/code&gt;, and &lt;code&gt;off&lt;/code&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;aria-live=&amp;quot;polite&amp;quot;&lt;/code&gt; tells assistive technology to alert the user to this
change when it has finished whatever it is currently doing. It&#39;s great to use
if something is important but not urgent, and accounts for the majority of
&lt;code&gt;aria-live&lt;/code&gt; use.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;aria-live=&amp;quot;assertive&amp;quot;&lt;/code&gt; tells assistive technology to interrupt whatever it&#39;s
doing and alert the user to this change immediately. This is only for
important and urgent updates, such as a status message like &amp;quot;There has been a
server error and your changes are not saved; please refresh the page&amp;quot;, or
updates to an input field as a direct result of a user action, such as
buttons on a stepper widget.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;aria-live=&amp;quot;off&amp;quot;&lt;/code&gt; tells assistive technology to temporarily suspend
&lt;code&gt;aria-live&lt;/code&gt; interruptions.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There are some tricks to making sure your live regions work correctly.&lt;/p&gt;
&lt;p&gt;First, your &lt;code&gt;aria-live&lt;/code&gt; region should probably be set in the initial page load.
This is not a hard-and-fast rule, but if you&#39;re having difficulty with an
&lt;code&gt;aria-live&lt;/code&gt; region, this might be the issue.&lt;/p&gt;
&lt;p&gt;Second, different screen readers react differently to different types of
changes. For example, it&#39;s possible to trigger an alert on some screen readers
by toggling a descendant element&#39;s &lt;code&gt;hidden&lt;/code&gt; style from true to false.&lt;/p&gt;
&lt;p&gt;Other attributes that work with &lt;code&gt;aria-live&lt;/code&gt; help you fine-tune what is
communicated to the user when the live region changes.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;aria-atomic&lt;/code&gt; indicates whether the entire region should be considered as a
whole when communicating updates. For example, if a date widget consisting of a
day, month, and year has &lt;code&gt;aria-live=true&lt;/code&gt; and &lt;code&gt;aria-atomic=true&lt;/code&gt;, and the user
uses a stepper control to change the value of just the month, the full contents
of the date widget would be read out again. &lt;code&gt;aria-atomic&lt;/code&gt;&#39;s value may be &lt;code&gt;true&lt;/code&gt;
or &lt;code&gt;false&lt;/code&gt; (the default).&lt;/p&gt;
&lt;p&gt;&lt;code&gt;aria-relevant&lt;/code&gt; indicates what types of changes should be presented to the user.
There are some options that may be used separately or as a token list.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;additions&lt;/em&gt;, meaning that any element being added to the live region is
significant. For example, appending a span to an existing log of status
messages would mean that the span would be announced to the user (assuming
that &lt;code&gt;aria-atomic&lt;/code&gt; was &lt;code&gt;false&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;&lt;em&gt;text&lt;/em&gt;, meaning that text content being added to any descendant node is
relevant. For example, modifying a custom text field&#39;s &lt;code&gt;textContent&lt;/code&gt; property
would read the modified text to the user.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;removals&lt;/em&gt;, meaning that the removal of any text or descendant nodes should
be conveyed to the user.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;all&lt;/em&gt;, meaning that all changes are relevant. However, the default value for
&lt;code&gt;aria-relevant&lt;/code&gt; is &lt;code&gt;additions text&lt;/code&gt;, meaning that if you don&#39;t specify
&lt;code&gt;aria-relevant&lt;/code&gt; it will update the user for any addition to the element,
which is what you are most likely to want.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Finally, &lt;code&gt;aria-busy&lt;/code&gt; lets you notify assistive technology that it should
temporarily ignore changes to an element, such as when things are loading. Once
everything is in place, &lt;code&gt;aria-busy&lt;/code&gt; should be set to false to normalize the
reader&#39;s operation.&lt;/p&gt;
</content>
    <author>
      <name>Meggin Kearney</name>
    </author><author>
      <name>Dave Gash</name>
    </author><author>
      <name>Alice Boxhall</name>
    </author>
  </entry>
  
  <entry>
    <title>DOM Order Matters</title>
    <link href="https://web.dev/dom-order-matters/"/>
    <updated>2016-10-04T00:00:00Z</updated>
    <id>https://web.dev/dom-order-matters/</id>
    <content type="html" mode="escaped">&lt;p&gt;Working with native elements is a great way to learn about focus behavior
because they are automatically inserted into the tab order based on their
position in the DOM.&lt;/p&gt;
&lt;p&gt;For example, you might have three button elements, one after the other in the
DOM. Pressing &lt;code&gt;Tab&lt;/code&gt; focuses each button in order. Try clicking the code block
below to move the focus navigation start point, then press &lt;code&gt;Tab&lt;/code&gt; to move focus
through the buttons.&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;I Should&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Be Focused&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Last!&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;&lt;button&gt;I Should&lt;/button&gt;
&lt;button&gt;Be Focused&lt;/button&gt;
&lt;button&gt;Last!&lt;/button&gt;&lt;/p&gt;
&lt;p&gt;However, it&#39;s important to note that, using CSS, it&#39;s possible to have things
exist in one order in the DOM but appear in a different order on screen. For
example, if you use a CSS property like &lt;code&gt;float&lt;/code&gt; to move one button to the right,
the buttons appear in a different order on screen. But, because their order in
the DOM remains the same, so does their tab order. When the user tabs through
the page, the buttons gain focus in a non-intuitive order. Try clicking on the
code block below to move the focus navigation start point, then press &lt;code&gt;Tab&lt;/code&gt; to
move focus through the buttons.&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token special-attr&quot;&gt;&lt;span class=&quot;token attr-name&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token value css language-css&quot;&gt;&lt;span class=&quot;token property&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; right&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;I Should&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Be Focused&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Last!&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;&lt;button style=&quot;float: right;&quot;&gt;I Should&lt;/button&gt;
&lt;button&gt;Be Focused&lt;/button&gt;
&lt;button&gt;Last!&lt;/button&gt;&lt;/p&gt;
&lt;p&gt;Be careful when changing the visual position of elements on screen using CSS.
This can cause the tab order to jump around, seemingly at random, confusing
users who rely on the keyboard. For this reason, the Web AIM checklist states
&lt;a href=&quot;https://webaim.org/standards/wcag/checklist#sc1.3.2&quot; rel=&quot;noopener&quot;&gt;in section 1.3.2&lt;/a&gt;
that the reading and navigation order, as determined by code order, should be
logical and intuitive.&lt;/p&gt;
&lt;p&gt;As a rule, try tabbing through your pages every so often just to make sure you
haven&#39;t accidentally messed up the tab order. It&#39;s a good habit to adopt, and
one that doesn&#39;t require much effort.&lt;/p&gt;
&lt;h2 id=&quot;offscreen-content&quot;&gt;Offscreen content &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/dom-order-matters/#offscreen-content&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;What if you have content that isn&#39;t currently displayed, yet still needs to be
in the DOM, such as a responsive side-nav? When you have elements like this that
receive focus when they&#39;re off screen, it can seem as if the focus is
disappearing and reappearing as the user tabs through the page — clearly
an undesirable effect. Ideally, we should prevent the panel from gaining focus
when it&#39;s off screen, and only allow it to be focused when the user can interact
with it.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;An offscreen slide-in panel can steal focus.&quot; decoding=&quot;async&quot; height=&quot;358&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 640px) 640px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/rFoyZjpWlErRqMfCuDed.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/rFoyZjpWlErRqMfCuDed.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/rFoyZjpWlErRqMfCuDed.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/rFoyZjpWlErRqMfCuDed.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/rFoyZjpWlErRqMfCuDed.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/rFoyZjpWlErRqMfCuDed.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/rFoyZjpWlErRqMfCuDed.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/rFoyZjpWlErRqMfCuDed.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/rFoyZjpWlErRqMfCuDed.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/rFoyZjpWlErRqMfCuDed.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/rFoyZjpWlErRqMfCuDed.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/rFoyZjpWlErRqMfCuDed.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/rFoyZjpWlErRqMfCuDed.png?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/rFoyZjpWlErRqMfCuDed.png?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/rFoyZjpWlErRqMfCuDed.png?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/rFoyZjpWlErRqMfCuDed.png?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/rFoyZjpWlErRqMfCuDed.png?auto=format&amp;w=1280 1280w&quot; width=&quot;640&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;Sometimes you need to do a bit of detective work to figure out where focus has
gone. You can use &lt;code&gt;document.activeElement&lt;/code&gt; from the console to figure out which
element is currently focused.&lt;/p&gt;
&lt;p&gt;Once you know which off screen element is being focused, you can set it to
&lt;code&gt;display: none&lt;/code&gt; or &lt;code&gt;visibility: hidden&lt;/code&gt;, and then set it back to &lt;code&gt;display: block&lt;/code&gt; or &lt;code&gt;visibility: visible&lt;/code&gt; before showing it to the user.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;A slide-in panel set to display none.&quot; decoding=&quot;async&quot; height=&quot;358&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 640px) 640px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/TN3xE2fdhhhGReCgKeoD.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/TN3xE2fdhhhGReCgKeoD.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/TN3xE2fdhhhGReCgKeoD.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/TN3xE2fdhhhGReCgKeoD.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/TN3xE2fdhhhGReCgKeoD.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/TN3xE2fdhhhGReCgKeoD.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/TN3xE2fdhhhGReCgKeoD.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/TN3xE2fdhhhGReCgKeoD.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/TN3xE2fdhhhGReCgKeoD.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/TN3xE2fdhhhGReCgKeoD.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/TN3xE2fdhhhGReCgKeoD.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/TN3xE2fdhhhGReCgKeoD.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/TN3xE2fdhhhGReCgKeoD.png?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/TN3xE2fdhhhGReCgKeoD.png?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/TN3xE2fdhhhGReCgKeoD.png?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/TN3xE2fdhhhGReCgKeoD.png?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/TN3xE2fdhhhGReCgKeoD.png?auto=format&amp;w=1280 1280w&quot; width=&quot;640&quot; /&gt;
&lt;/figure&gt;
&lt;figure&gt;
&lt;img alt=&quot;A slide-in panel set to display block.&quot; decoding=&quot;async&quot; height=&quot;359&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 640px) 640px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hckTc1M9mB618hduv4yy.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hckTc1M9mB618hduv4yy.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hckTc1M9mB618hduv4yy.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hckTc1M9mB618hduv4yy.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hckTc1M9mB618hduv4yy.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hckTc1M9mB618hduv4yy.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hckTc1M9mB618hduv4yy.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hckTc1M9mB618hduv4yy.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hckTc1M9mB618hduv4yy.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hckTc1M9mB618hduv4yy.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hckTc1M9mB618hduv4yy.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hckTc1M9mB618hduv4yy.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hckTc1M9mB618hduv4yy.png?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hckTc1M9mB618hduv4yy.png?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hckTc1M9mB618hduv4yy.png?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hckTc1M9mB618hduv4yy.png?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hckTc1M9mB618hduv4yy.png?auto=format&amp;w=1280 1280w&quot; width=&quot;640&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;In general, we encourage developers to tab through their sites before each
publish to see that the tab order doesn&#39;t disappear or jump out of a logical
sequence. If it does, you should make sure you are appropriately hiding
offscreen content with &lt;code&gt;display: none&lt;/code&gt; or &lt;code&gt;visibility: hidden&lt;/code&gt;, or that you
rearrange elements&#39; physical positions in the DOM so they are in a logical
order.&lt;/p&gt;
</content>
    <author>
      <name>Meggin Kearney</name>
    </author><author>
      <name>Dave Gash</name>
    </author><author>
      <name>Rob Dodson</name>
    </author>
  </entry>
  
  <entry>
    <title>Introduction to Focus</title>
    <link href="https://web.dev/focus/"/>
    <updated>2016-10-04T00:00:00Z</updated>
    <id>https://web.dev/focus/</id>
    <content type="html" mode="escaped">&lt;p&gt;In this lesson we&#39;ll talk about &lt;em&gt;focus&lt;/em&gt; and how you can manage it in your
application. Focus refers to which control on the screen (an input item such as
a field, checkbox, button, or link) currently receives input from the keyboard,
and from the clipboard when you paste content.&lt;/p&gt;
&lt;p&gt;This is a great place to start learning about accessibility because we all know
how to use a keyboard, it&#39;s easy to relate to and test, and it benefits
virtually all users.&lt;/p&gt;
&lt;p&gt;Users with motor impairments, which could be anything from permanent paralysis
to a sprained wrist, may rely on a keyboard or switch device to navigate your
page, so a good focus strategy is critical to providing a good experience for
them.&lt;/p&gt;
&lt;p&gt;And for the power users who know every keyboard shortcut on their machine, being
able to quickly navigate your site with the keyboard alone will certainly make
them more productive.&lt;/p&gt;
&lt;p&gt;Thus, a well implemented focus strategy ensures that everyone using your
application has a better experience. We&#39;ll see in the upcoming lessons that the
effort you put into focus is an important basis for supporting assistive
technology users and, indeed, all users.&lt;/p&gt;
&lt;h2 id=&quot;what-is-focus&quot;&gt;What is focus? &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/focus/#what-is-focus&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Focus determines where keyboard events go in the page at any given moment. For
instance, if you focus a text input field and begin typing, the input field
receives the keyboard events and displays the characters you type. While it has
focus, it will also receive pasted input from the clipboard.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;Keyboard focus in a text field.&quot; decoding=&quot;async&quot; height=&quot;68&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 238px) 238px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/CSqLPOjucmboi2mskmLR.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/CSqLPOjucmboi2mskmLR.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/CSqLPOjucmboi2mskmLR.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/CSqLPOjucmboi2mskmLR.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/CSqLPOjucmboi2mskmLR.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/CSqLPOjucmboi2mskmLR.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/CSqLPOjucmboi2mskmLR.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/CSqLPOjucmboi2mskmLR.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/CSqLPOjucmboi2mskmLR.png?auto=format&amp;w=476 476w&quot; width=&quot;238&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;The currently focused item is often indicated by a &lt;em&gt;focus ring&lt;/em&gt;, the style of
which depends on both the browser and on any styling the page author has
applied. Chrome, for instance, typically highlights focused elements with a blue
border, whereas Firefox uses a dashed border.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;Sign up button.&quot; decoding=&quot;async&quot; height=&quot;94&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 198px) 198px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/6AGj7kGYsWlSjCGCK5je.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/6AGj7kGYsWlSjCGCK5je.png?auto=format&amp;w=198 198w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/6AGj7kGYsWlSjCGCK5je.png?auto=format&amp;w=226 226w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/6AGj7kGYsWlSjCGCK5je.png?auto=format&amp;w=257 257w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/6AGj7kGYsWlSjCGCK5je.png?auto=format&amp;w=293 293w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/6AGj7kGYsWlSjCGCK5je.png?auto=format&amp;w=334 334w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/6AGj7kGYsWlSjCGCK5je.png?auto=format&amp;w=381 381w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/6AGj7kGYsWlSjCGCK5je.png?auto=format&amp;w=396 396w&quot; width=&quot;198&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;Some users operate their computer almost entirely with the keyboard or other
input device. For those users, focus is critical; it&#39;s their primary means of
reaching everything on the screen. For that reason, the Web AIM checklist states
in section 2.1.1 that &lt;a href=&quot;https://webaim.org/standards/wcag/checklist#sc2.1.1&quot; class=&quot;external&quot; rel=&quot;noopener&quot;&gt;all page functionality should be available using the
keyboard&lt;/a&gt;,
unless it&#39;s something you cannot do with a keyboard, such as freehand drawing.&lt;/p&gt;
&lt;p&gt;As a user, you can control which element is currently focused using &lt;code&gt;Tab&lt;/code&gt;,
&lt;code&gt;Shift+Tab&lt;/code&gt;, or the arrow keys. On Mac OSX this works a little differently:
while Chrome always lets you navigate with &lt;code&gt;Tab&lt;/code&gt;, you need to press &lt;code&gt;Option+Tab&lt;/code&gt;
to change focus in other browsers like Safari. (You can change this setting in
the Keyboard section of System Preferences.)&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;Keyboard preferences dialog.&quot; decoding=&quot;async&quot; height=&quot;426&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 547px) 547px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/EJuYSrFk9YK1sP2Mx0ap.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/EJuYSrFk9YK1sP2Mx0ap.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/EJuYSrFk9YK1sP2Mx0ap.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/EJuYSrFk9YK1sP2Mx0ap.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/EJuYSrFk9YK1sP2Mx0ap.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/EJuYSrFk9YK1sP2Mx0ap.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/EJuYSrFk9YK1sP2Mx0ap.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/EJuYSrFk9YK1sP2Mx0ap.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/EJuYSrFk9YK1sP2Mx0ap.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/EJuYSrFk9YK1sP2Mx0ap.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/EJuYSrFk9YK1sP2Mx0ap.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/EJuYSrFk9YK1sP2Mx0ap.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/EJuYSrFk9YK1sP2Mx0ap.png?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/EJuYSrFk9YK1sP2Mx0ap.png?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/EJuYSrFk9YK1sP2Mx0ap.png?auto=format&amp;w=1094 1094w&quot; width=&quot;547&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;The order in which focus proceeds forward and backward through interactive
elements via &lt;code&gt;Tab&lt;/code&gt; is called, not surprisingly, the &lt;em&gt;tab order&lt;/em&gt;. Ensuring that
you design your page with a logical tab order is an important step that we&#39;ll
cover later.&lt;/p&gt;
&lt;h2 id=&quot;what-is-focusable&quot;&gt;What is focusable? &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/focus/#what-is-focusable&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Built-in interactive HTML elements like text fields, buttons, and select lists
are &lt;em&gt;implicitly focusable&lt;/em&gt;, meaning they are automatically inserted into the tab
order and have built-in keyboard event handling without developer intervention.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;Implicitly focusable fields.&quot; decoding=&quot;async&quot; height=&quot;190&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 526px) 526px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/QrwBWUKleKcvVtbzKlhh.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/QrwBWUKleKcvVtbzKlhh.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/QrwBWUKleKcvVtbzKlhh.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/QrwBWUKleKcvVtbzKlhh.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/QrwBWUKleKcvVtbzKlhh.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/QrwBWUKleKcvVtbzKlhh.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/QrwBWUKleKcvVtbzKlhh.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/QrwBWUKleKcvVtbzKlhh.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/QrwBWUKleKcvVtbzKlhh.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/QrwBWUKleKcvVtbzKlhh.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/QrwBWUKleKcvVtbzKlhh.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/QrwBWUKleKcvVtbzKlhh.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/QrwBWUKleKcvVtbzKlhh.png?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/QrwBWUKleKcvVtbzKlhh.png?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/QrwBWUKleKcvVtbzKlhh.png?auto=format&amp;w=1052 1052w&quot; width=&quot;526&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;But not all elements are focusable; paragraphs, divs, and various other page
elements are not focused as you tab through the page, and that&#39;s by design.
There&#39;s generally no need to focus something if the user can&#39;t interact with it.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;Not all elements are focusable,&quot; decoding=&quot;async&quot; height=&quot;253&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 609px) 609px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/flJvC3AboT9pMnS8fJAc.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/flJvC3AboT9pMnS8fJAc.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/flJvC3AboT9pMnS8fJAc.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/flJvC3AboT9pMnS8fJAc.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/flJvC3AboT9pMnS8fJAc.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/flJvC3AboT9pMnS8fJAc.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/flJvC3AboT9pMnS8fJAc.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/flJvC3AboT9pMnS8fJAc.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/flJvC3AboT9pMnS8fJAc.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/flJvC3AboT9pMnS8fJAc.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/flJvC3AboT9pMnS8fJAc.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/flJvC3AboT9pMnS8fJAc.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/flJvC3AboT9pMnS8fJAc.png?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/flJvC3AboT9pMnS8fJAc.png?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/flJvC3AboT9pMnS8fJAc.png?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/flJvC3AboT9pMnS8fJAc.png?auto=format&amp;w=1218 1218w&quot; width=&quot;609&quot; /&gt;
&lt;/figure&gt;
&lt;h2 id=&quot;experiencing-focus&quot;&gt;Experiencing focus &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/focus/#experiencing-focus&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Let&#39;s try some of the focus techniques we just discussed. Using Chrome, go to
this &lt;a href=&quot;http://udacity.github.io/ud891/lesson2-focus/01-basic-form/&quot; rel=&quot;noopener&quot;&gt;airline site mockup
page&lt;/a&gt;
and search for a specific ticket &lt;strong&gt;using only keyboard input&lt;/strong&gt;. The page doesn&#39;t
accept mouse input, so you can&#39;t fudge the exercise (not that we don&#39;t trust you
;-).&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;Airline site mockup.&quot; decoding=&quot;async&quot; height=&quot;544&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 679px) 679px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/KB2dPuBGEeORUQwi6dM6.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/KB2dPuBGEeORUQwi6dM6.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/KB2dPuBGEeORUQwi6dM6.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/KB2dPuBGEeORUQwi6dM6.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/KB2dPuBGEeORUQwi6dM6.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/KB2dPuBGEeORUQwi6dM6.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/KB2dPuBGEeORUQwi6dM6.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/KB2dPuBGEeORUQwi6dM6.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/KB2dPuBGEeORUQwi6dM6.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/KB2dPuBGEeORUQwi6dM6.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/KB2dPuBGEeORUQwi6dM6.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/KB2dPuBGEeORUQwi6dM6.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/KB2dPuBGEeORUQwi6dM6.png?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/KB2dPuBGEeORUQwi6dM6.png?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/KB2dPuBGEeORUQwi6dM6.png?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/KB2dPuBGEeORUQwi6dM6.png?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/KB2dPuBGEeORUQwi6dM6.png?auto=format&amp;w=1358 1358w&quot; width=&quot;679&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;The ticket parameters you should specify are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;one way&lt;/li&gt;
&lt;li&gt;to Melbourne&lt;/li&gt;
&lt;li&gt;leaving on 12 October 2017 (10/12/2017)&lt;/li&gt;
&lt;li&gt;returning on 23 October 2017 (10/23/2017)&lt;/li&gt;
&lt;li&gt;window seat&lt;/li&gt;
&lt;li&gt;do not want to receive promotional offers&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;When you successfully complete the form with no input errors and activate the
Search button, the form will simply clear and reset. Go ahead and complete the
form, then come back.&lt;/p&gt;
&lt;p&gt;Let&#39;s examine how the form uses your keyboard input. Starting with your first
few &lt;code&gt;Tab&lt;/code&gt; presses, the browser highlights the navigation items for Flights,
Hotels, and Rental Cars. As you continue to press &lt;code&gt;Tab&lt;/code&gt; you proceed to the
radiobutton group where you can choose from Round Trip, One Way, or Multi City
using the arrow keys.&lt;/p&gt;
&lt;p&gt;Continue through the name and address fields, filling in the required
information. When you arrive at the destination select element, you can use the
arrow keys to choose a city, or you can start typing to autocomplete the field.
Similarly, in the date fields, you can use the arrow keys or just type a date.&lt;/p&gt;
&lt;p&gt;Selecting a seat type also relies on the arrow keys, or you can type &amp;quot;w&amp;quot;, &amp;quot;a&amp;quot;,
or &amp;quot;n&amp;quot; to jump to a seat option. Then you can disable the promotional offers
default by pressing the spacebar while the checkbox is focused. Finally, focus
the Search button and press &lt;code&gt;Enter&lt;/code&gt; to submit the form.&lt;/p&gt;
&lt;p&gt;It&#39;s very handy to interact with a form using just the keyboard and to not have
to switch to the mouse and back to complete a task. Because all of the elements
used in the form are native HTML tags with implicit focus, the form works fine
with the keyboard, and you don&#39;t have to write any code to add or manage focus
behavior.&lt;/p&gt;
</content>
    <author>
      <name>Meggin Kearney</name>
    </author><author>
      <name>Dave Gash</name>
    </author><author>
      <name>Rob Dodson</name>
    </author>
  </entry>
  
  <entry>
    <title>Semantics and navigating content</title>
    <link href="https://web.dev/navigating-content/"/>
    <updated>2016-10-04T00:00:00Z</updated>
    <id>https://web.dev/navigating-content/</id>
    <content type="html" mode="escaped">&lt;p&gt;You&#39;ve learned about affordances, semantics, and how assistive technologies use
the accessibility tree to create an alternative user experience for their users.
You can see that writing expressive, semantic HTML gives you a lot of
accessibility with very little effort, as many standard elements have both the
semantics and supporting behavior built in.&lt;/p&gt;
&lt;p&gt;In this lesson we&#39;ll cover some less obvious semantics that are very important
to screen reader users, especially as regards navigation. In a simple page with
lots of controls but not much content, it&#39;s easy to scan the page to find what
you need. But on a content-heavy page, such as a Wikipedia entry or a news
aggregator, it&#39;s not practical to read through everything from the top down; you
need a way to efficiently navigate through the content.&lt;/p&gt;
&lt;p&gt;Developers often have the misconception that screen readers are tedious and slow
to use, or that everything on the screen has to be focusable for the screen
reader to find it. That&#39;s often not the case.&lt;/p&gt;
&lt;p&gt;Screen reader users often rely on a list of headings to locate information. Most
screen readers have easy ways to isolate and scan a list of page headings, an
important feature called the &lt;em&gt;rotor&lt;/em&gt;. Let&#39;s see how we can use HTML headings
effectively to support this feature.&lt;/p&gt;
&lt;h2 id=&quot;using-headings-effectively&quot;&gt;Using headings effectively &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/navigating-content/#using-headings-effectively&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;First, let&#39;s reiterate an earlier point: &lt;a href=&quot;https://web.dev/dom-order-matters/&quot;&gt;&lt;em&gt;DOM order
matters&lt;/em&gt;&lt;/a&gt;, not only for
focus order but for screen reader order. As you experiment with screen readers
like VoiceOver, NVDA, JAWS, and ChromeVox, you&#39;ll find the heading list follows
the DOM order rather than the visual order.&lt;/p&gt;
&lt;p&gt;This is true for screen readers in general. Because screen readers interact with
the accessibility tree, and the accessibility tree is based on the DOM tree, the
order a screen reader perceives is thus directly based on the DOM order. This
means that an appropriate heading structure is more important than ever.&lt;/p&gt;
&lt;p&gt;In most well-structured pages, the heading levels are nested to indicate
parent-child relationships among content blocks. The &lt;a href=&quot;https://webaim.org/standards/wcag/checklist&quot; rel=&quot;noopener&quot;&gt;WebAIM
checklist&lt;/a&gt; repeatedly refers to this
technique.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://webaim.org/standards/wcag/checklist#sc1.3.1&quot; class=&quot;external&quot; rel=&quot;noopener&quot;&gt;1.3.1&lt;/a&gt;
mentions &amp;quot;Semantic markup is used to designate headings&amp;quot;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://webaim.org/standards/wcag/checklist#sc2.4.1&quot; class=&quot;external&quot; rel=&quot;noopener&quot;&gt;2.4.1&lt;/a&gt;
mentions heading structure as a technique for bypassing blocks of
content&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://webaim.org/standards/wcag/checklist#sc2.4.6&quot; class=&quot;external&quot; rel=&quot;noopener&quot;&gt;2.4.6&lt;/a&gt;
discusses some details for writing useful headings&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://webaim.org/standards/wcag/checklist#sc2.4.10&quot; class=&quot;external&quot; rel=&quot;noopener&quot;&gt;2.4.10&lt;/a&gt;
states &amp;quot;individual sections of content are designated using headings,
where appropriate&amp;quot;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Not all headings have to be visible on-screen.
&lt;a href=&quot;https://www.wikipedia.org/&quot; rel=&quot;noopener&quot;&gt;Wikipedia&lt;/a&gt;, for instance, uses a technique that
deliberately places some headings off-screen to specifically make them
accessible &lt;em&gt;only&lt;/em&gt; to screen readers and other assistive technology.&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;style&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token style&quot;&gt;&lt;span class=&quot;token language-css&quot;&gt;&lt;br /&gt;    &lt;span class=&quot;token selector&quot;&gt;.sr-only&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;absolute&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;left&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;-10000px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;top&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;auto&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;1px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;1px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;overflow&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;hidden&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;style&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;h2&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;sr-only&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;This heading is offscreen.&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;h2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;aside class=&quot;aside flow bg-state-info-bg color-state-info-text&quot;&gt;&lt;div class=&quot; flow&quot;&gt; The WebAIM site discusses this technique at length in &lt;a href=&quot;https://webaim.org/techniques/css/invisiblecontent/&quot;&gt;this article on offscreen content&lt;/a&gt;. &lt;/div&gt;&lt;/aside&gt;
&lt;p&gt;For complex applications, this can be a good way to accommodate headings when
the visual design doesn&#39;t require or have room for a visible heading.&lt;/p&gt;
&lt;p&gt;Caution: It&#39;s important not to go overboard with this technique. Remember that
assistive technology users may also be able to see the screen for themselves, so
going too far down the path of creating &amp;quot;screen reader only&amp;quot; content may
actually degrade the user experience for some users. It can also create a
maintenance headache for you later.&lt;/p&gt;
&lt;h2 id=&quot;other-navigation-options&quot;&gt;Other navigation options &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/navigating-content/#other-navigation-options&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Although pages with good headings help screen reader users navigate, there are
other elements they can use to move around a page, including &lt;em&gt;links&lt;/em&gt;, &lt;em&gt;form
controls&lt;/em&gt;, and &lt;em&gt;landmarks&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Readers can use the screen reader&#39;s rotor feature (an easy way to isolate and
scan a list of page headings) to access a &lt;em&gt;list of links&lt;/em&gt; on the page.
Sometimes, as on a wiki, there are many links, so the reader might search for a
term within the links. This limits the hits to links that actually contain the
term, rather than every occurrence of the term on the page.&lt;/p&gt;
&lt;p&gt;This feature is useful only if the screen reader can find the links and the link
text is meaningful. For example, here are some common patterns that make links
hard to find.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Anchor tags without &lt;code&gt;href&lt;/code&gt; attributes. Often used in single-page
applications, these link targets cause problems for screen readers. You can
read more in &lt;a href=&quot;http://neugierig.org/software/blog/2014/02/single-page-app-links.html&quot; rel=&quot;noopener&quot;&gt;this article on single-page apps&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Buttons that are implemented with links. These cause the screen reader to
interpret the content as a link, and the button functionality is lost. For
these cases, replace the anchor tag with a real button and style it
appropriately.&lt;/li&gt;
&lt;li&gt;Images used as link content. Sometimes necessary, linked images can be
unusable to screen readers. To guarantee that the link is properly exposed to
assistive technology, make sure the image has &lt;code&gt;alt&lt;/code&gt; attribute text.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Poor link text is another problem. Clickable text such as &amp;quot;learn more&amp;quot; or &amp;quot;click
here&amp;quot; provides no semantic information about where the link goes. Instead, use
descriptive text like &amp;quot;learn more about responsive design&amp;quot; or &amp;quot;see this canvas
tutorial&amp;quot; to help screen readers provide meaningful context about links.&lt;/p&gt;
&lt;p&gt;The rotor can also retrieve a &lt;em&gt;form control list&lt;/em&gt;. Using this list, readers can
search for specific items and go directly to them.&lt;/p&gt;
&lt;p&gt;A common error that screen readers make is pronunciation. For example, a screen
reader might pronounce &amp;quot;Udacity&amp;quot; as &amp;quot;oo-dacity&amp;quot;, or read a phone number as a
large integer, or read capitalized text as though it were an acronym.
Interestingly, screen reader users are quite used to this quirk and take it into
consideration.&lt;/p&gt;
&lt;p&gt;Some developers try to ameliorate this situation by providing screen-reader-only
text that is spelled phonetically. Here&#39;s a simple rule for phonetic spelling:
&lt;strong&gt;don&#39;t do it&lt;/strong&gt;; it only makes the problem worse! If, for example, a user is using
a braille display, the word will be spelled incorrectly, leading to more
confusion. Screen readers allow words to be spelled aloud, so leave it to the
reader to control their experience and decide when this is necessary.&lt;/p&gt;
&lt;p&gt;Readers can use the rotor to see a &lt;em&gt;landmarks list&lt;/em&gt;. This list helps readers
find the main content and a set of navigational landmarks provided by HTML
landmark elements.&lt;/p&gt;
&lt;p&gt;HTML5 introduced some new elements that help define the semantic structure of
the page, including &lt;code&gt;header&lt;/code&gt;, &lt;code&gt;footer&lt;/code&gt;, &lt;code&gt;nav&lt;/code&gt;, &lt;code&gt;article&lt;/code&gt;, &lt;code&gt;section&lt;/code&gt;, &lt;code&gt;main&lt;/code&gt;, and
&lt;code&gt;aside&lt;/code&gt;. These elements specifically provide structural clues in the page
without forcing any built-in styling (which you should do with CSS anyway).&lt;/p&gt;
&lt;p&gt;Semantic structural elements replace multiple, repetitive &lt;code&gt;div&lt;/code&gt; blocks, and
provide a clearer, more descriptive way to intuitively express page structure
for both authors and readers.&lt;/p&gt;
</content>
    <author>
      <name>Meggin Kearney</name>
    </author><author>
      <name>Dave Gash</name>
    </author><author>
      <name>Alice Boxhall</name>
    </author>
  </entry>
  
  <entry>
    <title>The Accessibility Tree</title>
    <link href="https://web.dev/the-accessibility-tree/"/>
    <updated>2016-10-04T00:00:00Z</updated>
    <id>https://web.dev/the-accessibility-tree/</id>
    <content type="html" mode="escaped">&lt;p&gt;Imagine that you&#39;re building a user interface &lt;em&gt;for screen reader users only&lt;/em&gt;.
Here, you don&#39;t need to create any visual UI at all, but just provide enough
information for the screen reader to use.&lt;/p&gt;
&lt;p&gt;What you&#39;d be creating is a kind of API describing the page structure, similar
to the DOM API, but you can get away with less information and fewer nodes,
because a lot of that information is only useful for visual presentation. It
might look something like this.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;screen reader DOM API mockup&quot; decoding=&quot;async&quot; height=&quot;387&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 800px) 800px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/oVhpmyLS5pMVZOrtd6j9.jpg?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/oVhpmyLS5pMVZOrtd6j9.jpg?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/oVhpmyLS5pMVZOrtd6j9.jpg?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/oVhpmyLS5pMVZOrtd6j9.jpg?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/oVhpmyLS5pMVZOrtd6j9.jpg?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/oVhpmyLS5pMVZOrtd6j9.jpg?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/oVhpmyLS5pMVZOrtd6j9.jpg?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/oVhpmyLS5pMVZOrtd6j9.jpg?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/oVhpmyLS5pMVZOrtd6j9.jpg?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/oVhpmyLS5pMVZOrtd6j9.jpg?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/oVhpmyLS5pMVZOrtd6j9.jpg?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/oVhpmyLS5pMVZOrtd6j9.jpg?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/oVhpmyLS5pMVZOrtd6j9.jpg?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/oVhpmyLS5pMVZOrtd6j9.jpg?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/oVhpmyLS5pMVZOrtd6j9.jpg?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/oVhpmyLS5pMVZOrtd6j9.jpg?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/oVhpmyLS5pMVZOrtd6j9.jpg?auto=format&amp;w=1428 1428w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/oVhpmyLS5pMVZOrtd6j9.jpg?auto=format&amp;w=1600 1600w&quot; width=&quot;800&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;This is basically what the browser actually presents to the screen reader. The
browser takes the DOM tree and modifies it into a form that is useful to
assistive technology. We refer to this modified tree as the &lt;em&gt;Accessibility
Tree&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;You might visualize the accessibility tree as looking a bit like an old web page
from the &#39;90s: a few images, lots of links, perhaps a field and a button.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;a 1990s style web page&quot; decoding=&quot;async&quot; height=&quot;304&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 640px) 640px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/7vls7AdHtbkVikDgHFIw.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/7vls7AdHtbkVikDgHFIw.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/7vls7AdHtbkVikDgHFIw.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/7vls7AdHtbkVikDgHFIw.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/7vls7AdHtbkVikDgHFIw.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/7vls7AdHtbkVikDgHFIw.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/7vls7AdHtbkVikDgHFIw.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/7vls7AdHtbkVikDgHFIw.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/7vls7AdHtbkVikDgHFIw.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/7vls7AdHtbkVikDgHFIw.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/7vls7AdHtbkVikDgHFIw.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/7vls7AdHtbkVikDgHFIw.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/7vls7AdHtbkVikDgHFIw.png?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/7vls7AdHtbkVikDgHFIw.png?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/7vls7AdHtbkVikDgHFIw.png?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/7vls7AdHtbkVikDgHFIw.png?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/7vls7AdHtbkVikDgHFIw.png?auto=format&amp;w=1280 1280w&quot; width=&quot;640&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;Visually scanning down a page like this case gives you an experience similar to
what a screen reader user would get. The interface is there, but it is simple
and direct, much like an accessibility tree interface.&lt;/p&gt;
&lt;p&gt;The accessibility tree is what most assistive technologies interact with. The
flow goes something like this.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;An application (the browser or other app) exposes a semantic version of its
UI to assistive technology via an API.&lt;/li&gt;
&lt;li&gt;The assistive technology may use the information it reads via the API to
create an alternative user interface presentation for the user. For example,
a screen reader creates an interface in which the user hears a spoken
representation of the app.&lt;/li&gt;
&lt;li&gt;The assistive technology may also allow the user to interact with the app in
a different way. For example, most screen readers provide hooks to allow a
user to easily simulate a mouse click or finger tap.&lt;/li&gt;
&lt;li&gt;The assistive technology relays the user intent (such as &amp;quot;click&amp;quot;) back to
the app via the accessibility API. The app then has the responsibility to
interpret the action appropriately in the context of the original UI.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For web browsers, there&#39;s an extra step in each direction, because the browser
is in fact a platform for web apps that run inside it. So the browser needs to
translate the web app into an accessibility tree, and must make sure that the
appropriate events get fired in JavaScript based on the user actions that come
in from the assistive technology.&lt;/p&gt;
&lt;p&gt;But that is all the browser&#39;s responsibility. Our job as web developers is just
to be aware that this is going on, and to develop web pages that take advantage
of this process to create an accessible experience for our users.&lt;/p&gt;
&lt;p&gt;We do this by ensuring that we express the semantics of our pages correctly:
making sure that the important elements in the page have the correct accessible
roles, states, and properties, and that we specify accessible names and
descriptions. The browser can then let the assistive technology access that
information to create a customized experience.&lt;/p&gt;
&lt;h2 id=&quot;semantics-in-native-html&quot;&gt;Semantics in native HTML &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/the-accessibility-tree/#semantics-in-native-html&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A browser can transform the DOM tree into an accessibility tree because much of
the DOM has &lt;em&gt;implicit&lt;/em&gt; semantic meaning. That is, the DOM uses native HTML
elements that are recognized by browsers and work predictably on a variety of
platforms. Accessibility for native HTML elements such as links or buttons is
thus handled automatically. We can take advantage of that built-in accessibility
by writing HTML that expresses the semantics of our page elements.&lt;/p&gt;
&lt;p&gt;However, sometimes we use elements that look like native elements but aren&#39;t.
For example, this &amp;quot;button&amp;quot; isn&#39;t a button at all.&lt;/p&gt;
&lt;style&gt;
    .fancy-btn {
        display: inline-block;
        background: #BEF400;
        border-radius: 8px;
        padding: 10px;
        font-weight: bold;
        user-select: none;
        cursor: pointer;
    }
&lt;/style&gt;
&lt;div class=&quot;fancy-btn&quot;&gt;Give me tacos&lt;/div&gt;
&lt;p&gt;It might be constructed in HTML in any number of ways; one way is shown below.&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;button-ish&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Give me tacos&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;When we don&#39;t use an actual button element, the screen reader has no way to know
what it has landed on. Also, we would have to do the extra work &lt;a href=&quot;https://web.dev/using-tabindex/&quot;&gt;of adding
tabindex&lt;/a&gt; to make it
usable to keyboard-only users because, as it is coded now, it can only be used
with a mouse.&lt;/p&gt;
&lt;p&gt;We can easily fix this by using a regular &lt;code&gt;button&lt;/code&gt; element instead of a &lt;code&gt;div&lt;/code&gt;.
Using a native element also has the benefit of taking care of keyboard
interactions for us. And remember that you don&#39;t have to lose your spiffy visual
effects just because you use a native element; you can style native elements to
make them look the way you want and still retain the implicit semantics and
behavior.&lt;/p&gt;
&lt;p&gt;Earlier we noted that screen readers will announce an element&#39;s role, name,
state, and value. By using the right semantic element, role, state, and value
are covered, but we must also ensure that we make an element&#39;s name
discoverable.&lt;/p&gt;
&lt;p&gt;Broadly, there are two types of names:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Visible labels&lt;/em&gt;, which are used by all users to associate meaning with an
element, and&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Text alternatives&lt;/em&gt;, which are only used when there is no need for a visual
label.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For text-level elements, we don&#39;t need to do anything, because by definition it
will have some text content. However, for input or control elements, and visual
content like images, we need to make sure that we specify a name. In fact,
providing text alternatives for any non-text content is &lt;a href=&quot;https://webaim.org/standards/wcag/checklist#g1.1&quot; rel=&quot;noopener&quot;&gt;the very
first item on the WebAIM checklist&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;One way to do that is to follow their recommendation that &amp;quot;Form inputs have
associated text labels.&amp;quot; There are two ways to associate a label with a form
element, such as a checkbox. Either of the methods causes the label text to also
become a click target for the checkbox, which is also helpful for mouse or
touchscreen users. To associate a label with an element, either&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Place the input element inside a label element&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;checkbox&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Receive promotional offers?&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;div style=&quot;margin: 10px;&quot;&gt;
    &lt;label style=&quot;font-size: 16px; color: #212121;&quot;&gt;
        &lt;input type=&quot;checkbox&quot; /&gt;Receive promotional offers?
    &lt;/label&gt;
&lt;/div&gt;
&lt;p&gt;or&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Use the label&#39;s &lt;code&gt;for&lt;/code&gt; attribute and refer to the element&#39;s &lt;code&gt;id&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;promo&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;checkbox&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;promo&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Receive promotional offers?&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;div style=&quot;margin: 10px;&quot;&gt;
    &lt;input id=&quot;promo&quot; type=&quot;checkbox&quot; /&gt;
    &lt;label for=&quot;promo&quot;&gt;Receive promotional offers?&lt;/label&gt;
&lt;/div&gt;
&lt;p&gt;When the checkbox has been labeled correctly, the screen reader can report that
the element has a role of checkbox, is in a checked state, and is named &amp;quot;Receive
promotional offers?&amp;quot;.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;on-screen text output from VoiceOver showing the spoken label for a checkbox&quot; decoding=&quot;async&quot; height=&quot;174&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 640px) 640px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/16hxTfkqd3OTHoB8joMo.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/16hxTfkqd3OTHoB8joMo.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/16hxTfkqd3OTHoB8joMo.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/16hxTfkqd3OTHoB8joMo.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/16hxTfkqd3OTHoB8joMo.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/16hxTfkqd3OTHoB8joMo.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/16hxTfkqd3OTHoB8joMo.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/16hxTfkqd3OTHoB8joMo.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/16hxTfkqd3OTHoB8joMo.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/16hxTfkqd3OTHoB8joMo.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/16hxTfkqd3OTHoB8joMo.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/16hxTfkqd3OTHoB8joMo.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/16hxTfkqd3OTHoB8joMo.png?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/16hxTfkqd3OTHoB8joMo.png?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/16hxTfkqd3OTHoB8joMo.png?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/16hxTfkqd3OTHoB8joMo.png?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/16hxTfkqd3OTHoB8joMo.png?auto=format&amp;w=1280 1280w&quot; width=&quot;640&quot; /&gt;
&lt;/figure&gt;
&lt;aside class=&quot;aside flow bg-state-good-bg color-state-good-text&quot;&gt;&lt;p class=&quot;cluster &quot;&gt;&lt;span class=&quot;aside__icon box-block &quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot; height=&quot;24&quot; width=&quot;24&quot; fill=&quot;currentColor&quot; role=&quot;img&quot; aria-label=&quot;Check&quot;&gt;   &lt;path d=&quot;M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z&quot;&gt;&lt;/path&gt; &lt;/svg&gt;&lt;/span&gt;&lt;strong&gt;Success&lt;/strong&gt;&lt;/p&gt;&lt;div class=&quot; flow&quot;&gt; You can actually use the screen reader to find improperly-associated labels by tabbing through the page and verifying the spoken roles, states, and names. &lt;/div&gt;&lt;/aside&gt;
</content>
    <author>
      <name>Meggin Kearney</name>
    </author><author>
      <name>Dave Gash</name>
    </author><author>
      <name>Alice Boxhall</name>
    </author>
  </entry>
  
  <entry>
    <title>Using tabindex</title>
    <link href="https://web.dev/using-tabindex/"/>
    <updated>2016-10-04T00:00:00Z</updated>
    <id>https://web.dev/using-tabindex/</id>
    <content type="html" mode="escaped">&lt;p&gt;The default tab order provided by the DOM position of native elements is
convenient, but there are times when you&#39;ll want to modify the tab order, and
physically moving elements in the HTML isn&#39;t always an optimal, or even a
feasible, solution. For these cases you can use the &lt;code&gt;tabindex&lt;/code&gt; HTML attribute to
explicitly set an element&#39;s tab position.&lt;/p&gt;
&lt;div class=&quot;wdi-browser-compat&quot;&gt;
  &lt;span class=&quot;wdi-browser-compat__label&quot;&gt;Browser support&lt;/span&gt;
  &lt;ul class=&quot;wdi-browser-compat__items&quot;&gt;
    &lt;li class=&quot;wdi-browser-compat__item&quot;&gt;
    &lt;span class=&quot;wdi-browser-compat__icon&quot; data-browser=&quot;chrome&quot;&gt;
      &lt;span class=&quot;visually-hidden&quot;&gt;Chrome 1, Supported&lt;/span&gt;
    &lt;/span&gt;
    &lt;span class=&quot;wdi-browser-compat__version&quot; data-compat=&quot;yes&quot; title=&quot;Supported&quot; aria-label=&quot;Supported&quot;&gt;
      1
    &lt;/span&gt;
    &lt;/li&gt;&lt;li class=&quot;wdi-browser-compat__item&quot;&gt;
    &lt;span class=&quot;wdi-browser-compat__icon&quot; data-browser=&quot;firefox&quot;&gt;
      &lt;span class=&quot;visually-hidden&quot;&gt;Firefox 1.5, Supported&lt;/span&gt;
    &lt;/span&gt;
    &lt;span class=&quot;wdi-browser-compat__version&quot; data-compat=&quot;yes&quot; title=&quot;Supported&quot; aria-label=&quot;Supported&quot;&gt;
      1.5
    &lt;/span&gt;
    &lt;/li&gt;&lt;li class=&quot;wdi-browser-compat__item&quot;&gt;
    &lt;span class=&quot;wdi-browser-compat__icon&quot; data-browser=&quot;edge&quot;&gt;
      &lt;span class=&quot;visually-hidden&quot;&gt;Edge 12, Supported&lt;/span&gt;
    &lt;/span&gt;
    &lt;span class=&quot;wdi-browser-compat__version&quot; data-compat=&quot;yes&quot; title=&quot;Supported&quot; aria-label=&quot;Supported&quot;&gt;
      12
    &lt;/span&gt;
    &lt;/li&gt;&lt;li class=&quot;wdi-browser-compat__item&quot;&gt;
    &lt;span class=&quot;wdi-browser-compat__icon&quot; data-browser=&quot;safari&quot;&gt;
      &lt;span class=&quot;visually-hidden&quot;&gt;Safari ≤4, Supported&lt;/span&gt;
    &lt;/span&gt;
    &lt;span class=&quot;wdi-browser-compat__version&quot; data-compat=&quot;yes&quot; title=&quot;Supported&quot; aria-label=&quot;Supported&quot;&gt;
      ≤4
    &lt;/span&gt;
    &lt;/li&gt;
  &lt;/ul&gt;
  &lt;a class=&quot;wdi-browser-compat__link&quot; href=&quot;https://developer.mozilla.org/docs/Web/HTML/Global_attributes/tabindex#browser_compatibility&quot; target=&quot;_blank&quot;&gt;Source&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;&lt;code&gt;tabindex&lt;/code&gt; can be applied to any element - although it is not necessarily
useful on every element - and takes a range of integer values. Using
&lt;code&gt;tabindex&lt;/code&gt;, you can specify an explicit order for focusable page elements,
insert an otherwise unfocusable element into the tab order, and remove elements
from the tab order. For example:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;tabindex=&amp;quot;0&amp;quot;&lt;/code&gt;: Inserts an element into the natural tab order. The element can
be focused by pressing the &lt;code&gt;Tab&lt;/code&gt; key, and the element can be focused by calling
its &lt;code&gt;focus()&lt;/code&gt; method&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;custom-button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;tabindex&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;0&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Press Tab to Focus Me!&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;custom-button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;style&gt;
  custom-button {
    margin: 10px;
  }
&lt;/style&gt;
&lt;p&gt;&lt;custom-button tabindex=&quot;0&quot;&gt;Press Tab to Focus Me!&lt;/custom-button&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;tabindex=&amp;quot;-1&amp;quot;&lt;/code&gt;: Removes an element from the natural tab order, but the element
can still be focused by calling its &lt;code&gt;focus()&lt;/code&gt; method&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;foo&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;tabindex&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;-1&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;I&#39;m not keyboard focusable&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token special-attr&quot;&gt;&lt;span class=&quot;token attr-name&quot;&gt;onclick&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token value javascript language-javascript&quot;&gt;foo&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;focus&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Focus my sibling&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;&lt;button id=&quot;foo&quot; tabindex=&quot;-1&quot;&gt;I&#39;m not keyboard focusable&lt;/button&gt;
&lt;button onclick=&quot;foo.focus();&quot;&gt;Focus my sibling&lt;/button&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;tabindex=&amp;quot;5&amp;quot;&lt;/code&gt;: Any tabindex greater than 0 jumps the element to the front of
the natural tab order. If there are multiple elements with a tabindex greater
than 0, the tab order starts from the lowest value that is greater than zero and
works its way up. Using a tabindex greater than 0 is considered an
&lt;strong&gt;anti-pattern&lt;/strong&gt;.&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;I should be first&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;And I should be second&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;tabindex&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;5&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;But I jumped to the front!&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;&lt;button&gt;I should be first&lt;/button&gt;
&lt;button&gt;And I should be second&lt;/button&gt;
&lt;button tabindex=&quot;5&quot;&gt;But I jumped to the front!&lt;/button&gt;&lt;/p&gt;
&lt;p&gt;This is particularly true of non-input elements like headers, images, or article
titles. Adding &lt;code&gt;tabindex&lt;/code&gt; to those kinds of elements is counter-productive. If
possible, it&#39;s best to arrange your source code so the DOM sequence provides a
logical tab order. If you do use &lt;code&gt;tabindex&lt;/code&gt;, restrict it to custom interactive
controls like buttons, tabs, dropdowns, and text fields; that is, elements the
user might expect to provide input to.&lt;/p&gt;
&lt;p&gt;Don&#39;t worry about screen reader users missing important content because it
doesn&#39;t have a &lt;code&gt;tabindex&lt;/code&gt;. Even if the content is very important, like an image,
if it&#39;s not something the user can interact with, there&#39;s no reason to make it
focusable. Screen reader users can still understand the content of the image so
long as you provide proper &lt;code&gt;alt&lt;/code&gt; attribute support, which we&#39;ll cover shortly.&lt;/p&gt;
&lt;h2 id=&quot;managing-focus-at-the-page-level&quot;&gt;Managing focus at the page level &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/using-tabindex/#managing-focus-at-the-page-level&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Here&#39;s a scenario where &lt;code&gt;tabindex&lt;/code&gt; is not only useful, but necessary. You might
be building a robust single page with different content sections, not all of
which are simultaneously visible. In this kind of page, clicking a navigation
link might change the visible content without doing a page refresh.&lt;/p&gt;
&lt;p&gt;When this happens, you would probably identify the selected content area, give
it a &lt;code&gt;tabindex&lt;/code&gt; of -1 so that it doesn&#39;t appear in the natural tab order, and
call its &lt;code&gt;focus&lt;/code&gt; method. This technique, called &lt;em&gt;managing focus&lt;/em&gt;, keeps the
user&#39;s perceived context in sync with the site&#39;s visual content.&lt;/p&gt;
&lt;h2 id=&quot;managing-focus-in-components&quot;&gt;Managing focus in components &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/using-tabindex/#managing-focus-in-components&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Managing focus when you change something on the page is important, but sometimes
you need to manage focus at the control level — for example, if you&#39;re
building a custom component.&lt;/p&gt;
&lt;p&gt;Consider the native &lt;code&gt;select&lt;/code&gt; element. It can receive basic focus but, once
there, you can use the arrow keys to expose additional functionality (the
selectable options). If you were building a custom &lt;code&gt;select&lt;/code&gt; element, you would
want to expose these same kinds of behaviors so that users who rely primarily on
the keyboard could still interact with your control.&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- Focus the element using Tab and use the up/down arrow keys to navigate --&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;select&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;option&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Aisle seat&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;option&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;option&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Window seat&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;option&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;option&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;No preference&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;option&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;select&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;select&gt;
  &lt;option&gt;Aisle seat&lt;/option&gt;
  &lt;option&gt;Window seat&lt;/option&gt;
  &lt;option&gt;No preference&lt;/option&gt;
&lt;/select&gt;
&lt;p&gt;Knowing which keyboard behaviors to implement can be difficult, but there is a
helpful document you can refer to. The
&lt;a href=&quot;https://www.w3.org/TR/wai-aria-practices/&quot; rel=&quot;noopener&quot;&gt;Accessible Rich Internet Applications (ARIA) Authoring
Practices&lt;/a&gt;
guide lists types of components and what kinds of keyboard actions they support.
We will cover ARIA in more detail later, but for now let&#39;s use the guide to help
us add keyboard support to a new component.&lt;/p&gt;
&lt;p&gt;Perhaps you&#39;re working on some new &lt;a href=&quot;https://web.dev/custom-elements-v1/&quot;&gt;Custom
Elements&lt;/a&gt; that
resemble a set of radio buttons, but with your unique take on appearance and
behavior.&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;radio-group&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;radio-button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Water&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;radio-button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;radio-button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Coffee&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;radio-button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;radio-button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Tea&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;radio-button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;radio-button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Cola&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;radio-button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;radio-button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Ginger Ale&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;radio-button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;radio-group&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;To determine what kind of keyboard support they need, you would check the
&lt;a href=&quot;https://www.w3.org/TR/wai-aria-practices/&quot; rel=&quot;noopener&quot;&gt;ARIA Authoring Practices
guide&lt;/a&gt;.
Section 2 contains a list of design patterns, and in that list is a
&lt;a href=&quot;https://www.w3.org/TR/wai-aria-practices/#radiobutton&quot; rel=&quot;noopener&quot;&gt;characteristics table for radio
groups&lt;/a&gt;,
the existing component that most closely matches your new element.&lt;/p&gt;
&lt;p&gt;As you can see in the table, one of the common keyboard behaviors that should be
supported is the up/down/left/right arrow keys. To add this behavior to the new
component, we&#39;ll use a technique called &lt;em&gt;roving tabindex&lt;/em&gt;.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;W3C spec excerpt for radio buttons.&quot; decoding=&quot;async&quot; height=&quot;359&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 640px) 640px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/UU2j5d9g5JzYPlBi7rMo.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/UU2j5d9g5JzYPlBi7rMo.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/UU2j5d9g5JzYPlBi7rMo.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/UU2j5d9g5JzYPlBi7rMo.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/UU2j5d9g5JzYPlBi7rMo.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/UU2j5d9g5JzYPlBi7rMo.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/UU2j5d9g5JzYPlBi7rMo.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/UU2j5d9g5JzYPlBi7rMo.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/UU2j5d9g5JzYPlBi7rMo.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/UU2j5d9g5JzYPlBi7rMo.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/UU2j5d9g5JzYPlBi7rMo.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/UU2j5d9g5JzYPlBi7rMo.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/UU2j5d9g5JzYPlBi7rMo.png?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/UU2j5d9g5JzYPlBi7rMo.png?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/UU2j5d9g5JzYPlBi7rMo.png?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/UU2j5d9g5JzYPlBi7rMo.png?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/UU2j5d9g5JzYPlBi7rMo.png?auto=format&amp;w=1280 1280w&quot; width=&quot;640&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;Roving tabindex works by setting &lt;code&gt;tabindex&lt;/code&gt; to -1 for all children except the
currently-active one.&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;radio-group&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;radio-button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;tabindex&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;0&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Water&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;radio-button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;radio-button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;tabindex&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;-1&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Coffee&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;radio-button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;radio-button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;tabindex&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;-1&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Tea&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;radio-button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;radio-button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;tabindex&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;-1&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Cola&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;radio-button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;radio-button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;tabindex&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;-1&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Ginger Ale&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;radio-button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;radio-group&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;The component then uses a keyboard event listener to determine which key the
user presses; when this happens, it sets the previously focused child&#39;s
&lt;code&gt;tabindex&lt;/code&gt; to -1, sets the to-be-focused child&#39;s &lt;code&gt;tabindex&lt;/code&gt; to 0, and calls the
focus method on it.&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;radio-group&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    // Assuming the user pressed the down arrow, we&#39;ll focus the next available child&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;radio-button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;tabindex&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;-1&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Water&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;radio-button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;radio-button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;tabindex&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;0&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Coffee&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;radio-button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; // call .focus() on this element&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;radio-button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;tabindex&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;-1&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Tea&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;radio-button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;radio-button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;tabindex&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;-1&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Cola&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;radio-button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;radio-button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;tabindex&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;-1&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Ginger Ale&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;radio-button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;radio-group&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;When the user reaches the last (or first, depending on the direction they&#39;re
moving the focus) child, you will loop around and focus the first (or last)
child again.&lt;/p&gt;
&lt;p&gt;You can give the completed example a try down below. Inspect the element in the
DevTools to observe the tabindex moving from one radio to the next.&lt;/p&gt;
&lt;style&gt;
  .demo {
    margin-left: 80px;
  }
  radio-button {
    position: relative;
    display: block;
    font-size: 18px;
  }
  radio-button:focus {
    outline: none;
  }
  radio-button::before {
    content: &#39;&#39;;
    display: block;
    width: 10px;
    height: 10px;
    border: 1px solid black;
    position: absolute;
    left: -18px;
    top: 7px;
    border-radius: 50%;
  }
  radio-button:focus::before {
    box-shadow: 0 0 3px 3px #83BEFF;
  }
  radio-button[aria-checked=&quot;true&quot;]::before {
    content: &#39;&#39;;
    display: block;
    width: 10px;
    height: 10px;
    background: red;
    position: absolute;
    left: -18px;
    top: 7px;
    border-radius: 50%;
  }
&lt;/style&gt;
&lt;div class=&quot;demo&quot;&gt;
  &lt;radio-group&gt;
    &lt;radio-button&gt;Water&lt;/radio-button&gt;
    &lt;radio-button&gt;Coffee&lt;/radio-button&gt;
    &lt;radio-button&gt;Tea&lt;/radio-button&gt;
    &lt;radio-button&gt;Cola&lt;/radio-button&gt;
    &lt;radio-button&gt;Ginger Ale&lt;/radio-button&gt;
  &lt;/radio-group&gt;
&lt;/div&gt;
&lt;script src=&quot;https://www.gstatic.com/devrel-devsite/v9dcc115658e2b070ea1ae9baed63d566/developers/js/custom-elements.min.js&quot;&gt;
&lt;/script&gt;
&lt;script&gt;
  class RadioButton extends HTMLElement {
    constructor() {
      super();
    }

    connectedCallback() {
      this.setAttribute(&#39;role&#39;, &#39;radio&#39;);
      this.setAttribute(&#39;tabindex&#39;, -1);
      this.setAttribute(&#39;aria-checked&#39;, false);
    }
  }

  window.customElements.define(&#39;radio-button&#39;, RadioButton);

  // Define values for keycodes
  const VK_LEFT       = 37;
  const VK_UP         = 38;
  const VK_RIGHT      = 39;
  const VK_DOWN       = 40;

  class RadioGroup extends HTMLElement {
    constructor() {
      super();
    }

    connectedCallback() {
      this.setAttribute(&#39;role&#39;, &#39;radiogroup&#39;);
      this.radios = Array.from(this.querySelectorAll(&#39;radio-button&#39;));

      // Setup initial state
      if (this.hasAttribute(&#39;selected&#39;)) {
        let selected = this.getAttribute(&#39;selected&#39;);
        this._selected = selected;
        this.radios[selected].setAttribute(&#39;tabindex&#39;, 0);
        this.radios[selected].setAttribute(&#39;aria-checked&#39;, true);
      } else {
        this._selected = 0;
        this.radios[0].setAttribute(&#39;tabindex&#39;, 0);
      }

      this.addEventListener(&#39;keydown&#39;, this.handleKeyDown.bind(this));
      this.addEventListener(&#39;click&#39;, this.handleClick.bind(this));
    }

    handleKeyDown(e) {
      switch(e.keyCode) {

        case VK_UP:
        case VK_LEFT: {
          e.preventDefault();

          if (this.selected === 0) {
            this.selected = this.radios.length - 1;
          } else {
            this.selected--;
          }
          break;

        }

        case VK_DOWN:
        case VK_RIGHT: {
          e.preventDefault();

          if (this.selected === this.radios.length - 1) {
            this.selected = 0;
          } else {
            this.selected++;
          }
          break;
        }

      }
    }

    handleClick(e) {
      const idx = this.radios.indexOf(e.target);
      if (idx === -1) {
        return;
      }
      this.selected = idx;
    }

    set selected(idx) {
      if (isFinite(this.selected)) {
        // Set the old button to tabindex -1
        let previousSelected = this.radios[this.selected];
        previousSelected.tabIndex = -1;
        previousSelected.removeAttribute(&#39;aria-checked&#39;, false);
      }

      // Set the new button to tabindex 0 and focus it
      let newSelected = this.radios[idx];
      newSelected.tabIndex = 0;
      newSelected.focus();
      newSelected.setAttribute(&#39;aria-checked&#39;, true);

      this.setAttribute(&#39;selected&#39;, idx);
      this._selected = idx;
    }

    get selected() {
      return this._selected;
    }
  }

  window.customElements.define(&#39;radio-group&#39;, RadioGroup);
&lt;/script&gt;
&lt;p&gt;You can view
&lt;a href=&quot;https://gist.github.com/robdodson/85deb2f821f9beb2ed1ce049f6a6ed47&quot; rel=&quot;noopener&quot;&gt;the complete source for this
element&lt;/a&gt;
over on GitHub.&lt;/p&gt;
&lt;h2 id=&quot;modals-and-keyboard-traps&quot;&gt;Modals and keyboard traps &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/using-tabindex/#modals-and-keyboard-traps&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Sometimes when you&#39;re managing focus you can get into a situation you can&#39;t get
out of. Consider an autocomplete widget that tries to manage focus and captures
the tab behavior, but prevents the user from leaving it until it&#39;s complete.
This is called a &lt;em&gt;keyboard trap&lt;/em&gt;, and it can be very frustrating for the user.
Section 2.1.2 of the Web AIM checklist addresses this issue, stating that
&lt;a href=&quot;https://webaim.org/standards/wcag/checklist#sc2.1.2&quot; rel=&quot;noopener&quot;&gt;keyboard focus should never be locked or trapped at one particular page
element&lt;/a&gt;.
The user should be able to navigate to and from all page elements using only the
keyboard.&lt;/p&gt;
&lt;p&gt;Oddly, there are times when this behavior is actually desirable, like in a modal
window. Normally, when the modal is displayed, you don&#39;t want the user to access
the content behind it. You might add an overlay to cover the page visually, but
that doesn&#39;t stop keyboard focus from accidentally traveling outside the modal.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;A modal window asking the user to save their work.&quot; decoding=&quot;async&quot; height=&quot;357&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 640px) 640px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/34igvq1J0jtvgSp3Tybo.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/34igvq1J0jtvgSp3Tybo.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/34igvq1J0jtvgSp3Tybo.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/34igvq1J0jtvgSp3Tybo.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/34igvq1J0jtvgSp3Tybo.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/34igvq1J0jtvgSp3Tybo.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/34igvq1J0jtvgSp3Tybo.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/34igvq1J0jtvgSp3Tybo.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/34igvq1J0jtvgSp3Tybo.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/34igvq1J0jtvgSp3Tybo.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/34igvq1J0jtvgSp3Tybo.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/34igvq1J0jtvgSp3Tybo.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/34igvq1J0jtvgSp3Tybo.png?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/34igvq1J0jtvgSp3Tybo.png?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/34igvq1J0jtvgSp3Tybo.png?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/34igvq1J0jtvgSp3Tybo.png?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/34igvq1J0jtvgSp3Tybo.png?auto=format&amp;w=1280 1280w&quot; width=&quot;640&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;In instances like this you can implement a temporary keyboard trap to ensure
that you trap focus only while the modal is displayed and then restore focus to
the previously-focused item when the modal is closed.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;There are some proposals on how to make this easier for developers,
including the &lt;code&gt;&amp;lt;dialog&amp;gt;&lt;/code&gt; element, but they don&#39;t yet have widespread
browser support.&lt;/p&gt;
&lt;p&gt;See this &lt;a href=&quot;https://developer.mozilla.org/docs/Web/HTML/Element/dialog&quot; rel=&quot;noopener&quot;&gt;MDN
article&lt;/a&gt;
for more information on &lt;code&gt;&amp;lt;dialog&amp;gt;&lt;/code&gt;, and this
&lt;a href=&quot;https://github.com/gdkraus/accessible-modal-dialog&quot; rel=&quot;noopener&quot;&gt;modal example&lt;/a&gt; for
more information on modal windows.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Consider a modal dialog represented by a &lt;code&gt;div&lt;/code&gt; that contains a few elements, and
another &lt;code&gt;div&lt;/code&gt; that represents a background overlay. Let&#39;s walk through the basic
steps needed to implement a temporary keyboard trap in this situation.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Using &lt;code&gt;document.querySelector&lt;/code&gt;, select the modal and overlay divs and store
their references.&lt;/li&gt;
&lt;li&gt;As the modal opens, store a reference to the element that was focused when
the modal was opened so you can return focus to that element.&lt;/li&gt;
&lt;li&gt;Use a &lt;em&gt;keydown listener&lt;/em&gt; to grab keys as they are pressed while the modal is
open. You could also listen for a click on the background overlay, and close
the modal if the user clicks it.&lt;/li&gt;
&lt;li&gt;Next, get the collection of focusable elements within the modal. The first
and last focusable elements will act as &amp;quot;sentinels&amp;quot; to let you know when to
loop focus forward or backward to stay inside the modal.&lt;/li&gt;
&lt;li&gt;Display the modal window and focus the first focusable element.&lt;/li&gt;
&lt;li&gt;As the user presses &lt;code&gt;Tab&lt;/code&gt; or &lt;code&gt;Shift+Tab&lt;/code&gt;, move focus forward or backward,
looping at the last or first elements as appropriate.&lt;/li&gt;
&lt;li&gt;If the user presses &lt;code&gt;Esc&lt;/code&gt;, close the modal. This is very helpful because it
allows the user to close the modal without searching for a specific close
button, and it benefits even users who are using a mouse.&lt;/li&gt;
&lt;li&gt;When the modal is closed, hide it and the background overlay, and restore
focus to the previously-focused element saved earlier.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This procedure gives you a usable, non-frustrating modal window that everyone
can use effectively.&lt;/p&gt;
&lt;p&gt;For more details, you can examine this &lt;a href=&quot;https://github.com/udacity/ud891/blob/gh-pages/lesson2-focus/07-modals-and-keyboard-traps/solution&quot; class=&quot;external&quot; rel=&quot;noopener&quot;&gt;sample
code&lt;/a&gt;,
and view a live example from a &lt;a href=&quot;http://udacity.github.io/ud891/lesson2-focus/07-modals-and-keyboard-traps/solution/index.html&quot; class=&quot;external&quot; rel=&quot;noopener&quot;&gt;completed
page&lt;/a&gt;.&lt;/p&gt;
</content>
    <author>
      <name>Meggin Kearney</name>
    </author><author>
      <name>Dave Gash</name>
    </author><author>
      <name>Rob Dodson</name>
    </author>
  </entry>
  
  <entry>
    <title>ARIA labels and relationships</title>
    <link href="https://web.dev/aria-labels-and-relationships/"/>
    <updated>2016-10-04T00:00:00Z</updated>
    <id>https://web.dev/aria-labels-and-relationships/</id>
    <content type="html" mode="escaped">&lt;h2 id=&quot;labels&quot;&gt;Labels &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/aria-labels-and-relationships/#labels&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;ARIA provides several mechanisms for adding labels and descriptions to elements.
In fact, ARIA is the only way to add accessible help or description text. Let&#39;s
look at the properties ARIA uses to create accessible labels.&lt;/p&gt;
&lt;h3 id=&quot;aria-label&quot;&gt;aria-label &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/aria-labels-and-relationships/#aria-label&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;aria-label&lt;/code&gt; allows us to specify a string to be used as the accessible label.
This overrides any other native labeling mechanism, such as a &lt;code&gt;label&lt;/code&gt; element
— for example, if a &lt;code&gt;button&lt;/code&gt; has both text content and an &lt;code&gt;aria-label&lt;/code&gt;,
only the &lt;code&gt;aria-label&lt;/code&gt; value will be used.&lt;/p&gt;
&lt;p&gt;You might use an &lt;code&gt;aria-label&lt;/code&gt; attribute when you have some kind of visual
indication of an element&#39;s purpose, such as a button that uses a graphic instead
of text, but still need to clarify that purpose for anyone who cannot access the
visual indication, such as a button that uses only an image to indicate its
purpose.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;Using aria-label to identify an image only button.&quot; decoding=&quot;async&quot; height=&quot;268&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 575px) 575px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/ztuCT2fpHvBsKxSBJaXn.jpg?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/ztuCT2fpHvBsKxSBJaXn.jpg?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/ztuCT2fpHvBsKxSBJaXn.jpg?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/ztuCT2fpHvBsKxSBJaXn.jpg?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/ztuCT2fpHvBsKxSBJaXn.jpg?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/ztuCT2fpHvBsKxSBJaXn.jpg?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/ztuCT2fpHvBsKxSBJaXn.jpg?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/ztuCT2fpHvBsKxSBJaXn.jpg?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/ztuCT2fpHvBsKxSBJaXn.jpg?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/ztuCT2fpHvBsKxSBJaXn.jpg?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/ztuCT2fpHvBsKxSBJaXn.jpg?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/ztuCT2fpHvBsKxSBJaXn.jpg?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/ztuCT2fpHvBsKxSBJaXn.jpg?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/ztuCT2fpHvBsKxSBJaXn.jpg?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/ztuCT2fpHvBsKxSBJaXn.jpg?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/ztuCT2fpHvBsKxSBJaXn.jpg?auto=format&amp;w=1150 1150w&quot; width=&quot;575&quot; /&gt;
&lt;/figure&gt;
&lt;h3 id=&quot;aria-labelledby&quot;&gt;aria-labelledby &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/aria-labels-and-relationships/#aria-labelledby&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;aria-labelledby&lt;/code&gt; allows us to specify the ID of another element in the DOM as
an element&#39;s label.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;Using aria-labelledby to identify a radio group.&quot; decoding=&quot;async&quot; height=&quot;307&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 575px) 575px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/YQfKTKuskbWwUg1tLlos.jpg?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/YQfKTKuskbWwUg1tLlos.jpg?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/YQfKTKuskbWwUg1tLlos.jpg?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/YQfKTKuskbWwUg1tLlos.jpg?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/YQfKTKuskbWwUg1tLlos.jpg?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/YQfKTKuskbWwUg1tLlos.jpg?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/YQfKTKuskbWwUg1tLlos.jpg?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/YQfKTKuskbWwUg1tLlos.jpg?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/YQfKTKuskbWwUg1tLlos.jpg?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/YQfKTKuskbWwUg1tLlos.jpg?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/YQfKTKuskbWwUg1tLlos.jpg?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/YQfKTKuskbWwUg1tLlos.jpg?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/YQfKTKuskbWwUg1tLlos.jpg?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/YQfKTKuskbWwUg1tLlos.jpg?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/YQfKTKuskbWwUg1tLlos.jpg?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/YQfKTKuskbWwUg1tLlos.jpg?auto=format&amp;w=1150 1150w&quot; width=&quot;575&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;This is much like using a &lt;code&gt;label&lt;/code&gt; element, with some key differences.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code&gt;aria-labelledby&lt;/code&gt; may be used on any element, not just labelable elements.&lt;/li&gt;
&lt;li&gt;While a &lt;code&gt;label&lt;/code&gt; element refers to the thing it labels, the relationship is
reversed in the case of &lt;code&gt;aria-labelledby&lt;/code&gt; — the thing being
labeled refers to the thing that labels it.&lt;/li&gt;
&lt;li&gt;Only one label element may be associated with a labelable element, but
&lt;code&gt;aria-labelledby&lt;/code&gt; can take a list of IDREFs to compose a label from multiple
elements. The label will be concatenated in the order that the IDREFs are
given.&lt;/li&gt;
&lt;li&gt;You can use &lt;code&gt;aria-labelledby&lt;/code&gt; to refer to elements that are hidden and would
otherwise not be in the accessibility tree. For example, you could add a
hidden &lt;code&gt;span&lt;/code&gt; next to an element you want to label, and refer to that with
&lt;code&gt;aria-labelledby&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;However, since ARIA only affects the accessibility tree, &lt;code&gt;aria-labelledby&lt;/code&gt;
does not give you the familiar label-clicking behavior you get from using a
&lt;code&gt;label&lt;/code&gt; element.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Importantly, &lt;code&gt;aria-labelledby&lt;/code&gt; overrides &lt;strong&gt;all&lt;/strong&gt; other name sources for an
element. So, for example, if an element has both an &lt;code&gt;aria-labelledby&lt;/code&gt; and an
&lt;code&gt;aria-label&lt;/code&gt;, or an &lt;code&gt;aria-labelledby&lt;/code&gt; and a native HTML &lt;code&gt;label&lt;/code&gt;, the
&lt;code&gt;aria-labelledby&lt;/code&gt; label always takes precedence.&lt;/p&gt;
&lt;h2 id=&quot;relationships&quot;&gt;Relationships &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/aria-labels-and-relationships/#relationships&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;aria-labelledby&lt;/code&gt; is an example of a &lt;em&gt;relationship attribute&lt;/em&gt;. A relationship
attribute creates a semantic relationship between elements on the page
regardless of their DOM relationship. In the case of &lt;code&gt;aria-labelledby&lt;/code&gt;, that
relationship is &amp;quot;this element is labelled by that element&amp;quot;.&lt;/p&gt;
&lt;p&gt;The ARIA specification lists &lt;a href=&quot;https://www.w3.org/TR/wai-aria/states_and_properties#attrs_relationships&quot; rel=&quot;noopener&quot;&gt;eight relationship
attributes&lt;/a&gt;.
Six of these, &lt;code&gt;aria-activedescendant&lt;/code&gt;, &lt;code&gt;aria-controls&lt;/code&gt;, &lt;code&gt;aria-describedby&lt;/code&gt;,
&lt;code&gt;aria-labelledby&lt;/code&gt;, and &lt;code&gt;aria-owns&lt;/code&gt;, take a reference to one or more elements to
create a new link between elements on the page. The difference in each case is
what that link means and how it is presented to users.&lt;/p&gt;
&lt;h3 id=&quot;aria-owns&quot;&gt;aria-owns &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/aria-labels-and-relationships/#aria-owns&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;aria-owns&lt;/code&gt; is one of the most widely used ARIA relationships. This attribute
allows us to tell assistive technology that an element that is separate in the
DOM should be treated as a child of the current element, or to rearrange
existing child elements into a different order. For example, if a pop-up
sub-menu is visually positioned near its parent menu, but cannot be a DOM child
of its parent because it would affect the visual presentation, you can use
&lt;code&gt;aria-owns&lt;/code&gt; to present the sub-menu as a child of the parent menu to a screen
reader.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;Using aria-owns to establish a relationship between a menu and a submenu.&quot; decoding=&quot;async&quot; height=&quot;377&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 800px) 800px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/K5dAbga6rD8APoZi3IUS.jpg?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/K5dAbga6rD8APoZi3IUS.jpg?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/K5dAbga6rD8APoZi3IUS.jpg?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/K5dAbga6rD8APoZi3IUS.jpg?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/K5dAbga6rD8APoZi3IUS.jpg?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/K5dAbga6rD8APoZi3IUS.jpg?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/K5dAbga6rD8APoZi3IUS.jpg?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/K5dAbga6rD8APoZi3IUS.jpg?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/K5dAbga6rD8APoZi3IUS.jpg?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/K5dAbga6rD8APoZi3IUS.jpg?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/K5dAbga6rD8APoZi3IUS.jpg?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/K5dAbga6rD8APoZi3IUS.jpg?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/K5dAbga6rD8APoZi3IUS.jpg?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/K5dAbga6rD8APoZi3IUS.jpg?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/K5dAbga6rD8APoZi3IUS.jpg?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/K5dAbga6rD8APoZi3IUS.jpg?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/K5dAbga6rD8APoZi3IUS.jpg?auto=format&amp;w=1428 1428w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/K5dAbga6rD8APoZi3IUS.jpg?auto=format&amp;w=1600 1600w&quot; width=&quot;800&quot; /&gt;
&lt;/figure&gt;
&lt;h3 id=&quot;aria-activedescendant&quot;&gt;aria-activedescendant &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/aria-labels-and-relationships/#aria-activedescendant&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;aria-activedescendant&lt;/code&gt; plays a related role. Just as the active element of a
page is the one that has focus, setting the active descendant of an element
allows us to tell assistive technology that an element should be presented to
the user as the focused element when its parent actually has the focus. For
example, in a listbox, you might want to leave page focus on the listbox
container, but keep its &lt;code&gt;aria-activedescendant&lt;/code&gt; attribute updated to the
currently selected list item. This makes the currently selected item appear to
assistive technology as if it is the focused item.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;Using aria-activedescendant to establish a relationship in a listbox.&quot; decoding=&quot;async&quot; height=&quot;370&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 800px) 800px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/v1Ov4bak7cBYT9T6rIGT.jpg?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/v1Ov4bak7cBYT9T6rIGT.jpg?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/v1Ov4bak7cBYT9T6rIGT.jpg?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/v1Ov4bak7cBYT9T6rIGT.jpg?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/v1Ov4bak7cBYT9T6rIGT.jpg?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/v1Ov4bak7cBYT9T6rIGT.jpg?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/v1Ov4bak7cBYT9T6rIGT.jpg?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/v1Ov4bak7cBYT9T6rIGT.jpg?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/v1Ov4bak7cBYT9T6rIGT.jpg?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/v1Ov4bak7cBYT9T6rIGT.jpg?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/v1Ov4bak7cBYT9T6rIGT.jpg?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/v1Ov4bak7cBYT9T6rIGT.jpg?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/v1Ov4bak7cBYT9T6rIGT.jpg?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/v1Ov4bak7cBYT9T6rIGT.jpg?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/v1Ov4bak7cBYT9T6rIGT.jpg?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/v1Ov4bak7cBYT9T6rIGT.jpg?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/v1Ov4bak7cBYT9T6rIGT.jpg?auto=format&amp;w=1428 1428w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/v1Ov4bak7cBYT9T6rIGT.jpg?auto=format&amp;w=1600 1600w&quot; width=&quot;800&quot; /&gt;
&lt;/figure&gt;
&lt;h3 id=&quot;aria-describedby&quot;&gt;aria-describedby &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/aria-labels-and-relationships/#aria-describedby&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;aria-describedby&lt;/code&gt; provides an accessible description in the same way that
&lt;code&gt;aria-labelledby&lt;/code&gt; provides a label. Like &lt;code&gt;aria-labelledby&lt;/code&gt;, &lt;code&gt;aria-describedby&lt;/code&gt;
may reference elements that are otherwise not visible, whether hidden from the
DOM, or hidden from assistive technology users. This is a useful technique when
there is some extra explanatory text that a user might need, whether it applies
only to users of assistive technology or all users.&lt;/p&gt;
&lt;p&gt;A common example is a password input field that is accompanied by some
descriptive text explaining the minimum password requirements. Unlike a label,
this description may or may not ever be presented to the user; they may have a
choice of whether to access it, or it may come after all the other information,
or it may be pre-empted by something else. For example, if the user is entering
information, their input will be echoed back and may interrupt the element&#39;s
description. Thus, a description is a great way to communicate supplementary,
but not essential, information; it won&#39;t get in the way of more critical
information such as the element&#39;s role.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;Using aria-describedby to establish a relationship with a password field.&quot; decoding=&quot;async&quot; height=&quot;353&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 800px) 800px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/gs2BVykPBYV1Ac2tNr8K.jpg?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/gs2BVykPBYV1Ac2tNr8K.jpg?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/gs2BVykPBYV1Ac2tNr8K.jpg?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/gs2BVykPBYV1Ac2tNr8K.jpg?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/gs2BVykPBYV1Ac2tNr8K.jpg?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/gs2BVykPBYV1Ac2tNr8K.jpg?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/gs2BVykPBYV1Ac2tNr8K.jpg?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/gs2BVykPBYV1Ac2tNr8K.jpg?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/gs2BVykPBYV1Ac2tNr8K.jpg?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/gs2BVykPBYV1Ac2tNr8K.jpg?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/gs2BVykPBYV1Ac2tNr8K.jpg?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/gs2BVykPBYV1Ac2tNr8K.jpg?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/gs2BVykPBYV1Ac2tNr8K.jpg?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/gs2BVykPBYV1Ac2tNr8K.jpg?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/gs2BVykPBYV1Ac2tNr8K.jpg?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/gs2BVykPBYV1Ac2tNr8K.jpg?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/gs2BVykPBYV1Ac2tNr8K.jpg?auto=format&amp;w=1428 1428w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/gs2BVykPBYV1Ac2tNr8K.jpg?auto=format&amp;w=1600 1600w&quot; width=&quot;800&quot; /&gt;
&lt;/figure&gt;
&lt;h3 id=&quot;aria-posinset-and-aria-setsize&quot;&gt;aria-posinset &amp;amp; aria-setsize &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/aria-labels-and-relationships/#aria-posinset-and-aria-setsize&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The remaining relationship attributes are a little different, and work together.
&lt;code&gt;aria-posinset&lt;/code&gt; (&amp;quot;position in set&amp;quot;) and &lt;code&gt;aria-setsize&lt;/code&gt; (&amp;quot;size of set&amp;quot;) are about
defining a relationship between sibling elements in a set, such as a list.&lt;/p&gt;
&lt;p&gt;When the size of a set cannot be determined by the elements present in the DOM
— such as when lazy rendering is used to avoid having all of a large list
in the DOM at once — &lt;code&gt;aria-setsize&lt;/code&gt; can specify the actual set size, and
&lt;code&gt;aria-posinset&lt;/code&gt; can specify the element&#39;s position in the set. For example, in a
set that might contain 1000 elements, you could say that a particular element
has an &lt;code&gt;aria-posinset&lt;/code&gt; of 857 even though it appears first in the DOM, and then
use dynamic HTML techniques to ensure that the user can explore the full list on
demand.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;Using aria-posinset and aria-setsize to establish a relationship in a list.&quot; decoding=&quot;async&quot; height=&quot;382&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 800px) 800px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HL5MFhh74egrOD2537WO.jpg?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HL5MFhh74egrOD2537WO.jpg?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HL5MFhh74egrOD2537WO.jpg?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HL5MFhh74egrOD2537WO.jpg?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HL5MFhh74egrOD2537WO.jpg?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HL5MFhh74egrOD2537WO.jpg?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HL5MFhh74egrOD2537WO.jpg?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HL5MFhh74egrOD2537WO.jpg?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HL5MFhh74egrOD2537WO.jpg?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HL5MFhh74egrOD2537WO.jpg?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HL5MFhh74egrOD2537WO.jpg?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HL5MFhh74egrOD2537WO.jpg?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HL5MFhh74egrOD2537WO.jpg?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HL5MFhh74egrOD2537WO.jpg?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HL5MFhh74egrOD2537WO.jpg?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HL5MFhh74egrOD2537WO.jpg?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HL5MFhh74egrOD2537WO.jpg?auto=format&amp;w=1428 1428w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/HL5MFhh74egrOD2537WO.jpg?auto=format&amp;w=1600 1600w&quot; width=&quot;800&quot; /&gt;
&lt;/figure&gt;
</content>
    <author>
      <name>Meggin Kearney</name>
    </author><author>
      <name>Dave Gash</name>
    </author><author>
      <name>Alice Boxhall</name>
    </author>
  </entry>
  
  <entry>
    <title>Introduction to semantics</title>
    <link href="https://web.dev/semantics-builtin/"/>
    <updated>2016-10-04T00:00:00Z</updated>
    <id>https://web.dev/semantics-builtin/</id>
    <content type="html" mode="escaped">&lt;p&gt;You&#39;ve seen how to make a site accessible to users who can&#39;t use a mouse or
pointing device — whether due to physical impairment, a technology issue,
or personal preference — by addressing keyboard-only use. While it
requires some care and thought, it&#39;s not a huge amount of work if you plan it
from the beginning. Once that basic work is done, you&#39;re a long way down the
path to a fully accessible and more polished site.&lt;/p&gt;
&lt;p&gt;In this lesson, we&#39;ll build on that work and get you thinking about other
accessibility factors, such as how to build websites to support &lt;a href=&quot;https://web.dev/accessibility/#understanding-users-diversity&quot;&gt;users like
Victor Tsaran&lt;/a&gt;,
who can&#39;t see the screen.&lt;/p&gt;
&lt;p&gt;First, we&#39;ll get some background on &lt;em&gt;assistive technology&lt;/em&gt;, the general term for
tools like screen readers that help  users with impairments that can keep them
from accessing information.&lt;/p&gt;
&lt;p&gt;Next, we&#39;ll look at some general user experience concepts, and build on those to
take a deeper dive into the experience of users of assistive technology.&lt;/p&gt;
&lt;p&gt;Finally, we&#39;ll see how to use HTML effectively to create a good experience for
these users, and how it overlaps quite a bit with the way we addressed focus
earlier.&lt;/p&gt;
&lt;h2 id=&quot;assistive-technology&quot;&gt;Assistive technology &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/semantics-builtin/#assistive-technology&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;em&gt;Assistive technology&lt;/em&gt; is an umbrella term for devices, software, and tools that
help any person with a disability complete a task. In the broadest sense this
could be something low-tech like a crutch for walking or a magnifying glass for
reading, or something high-tech like a robotic arm or image recognition software
on a smartphone.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;Assistive technology examples including crutch magnifying glass and robotic prosthesis.&quot; decoding=&quot;async&quot; height=&quot;328&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 425px) 425px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/8H2hJ9uJOP9bmlJozkIw.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/8H2hJ9uJOP9bmlJozkIw.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/8H2hJ9uJOP9bmlJozkIw.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/8H2hJ9uJOP9bmlJozkIw.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/8H2hJ9uJOP9bmlJozkIw.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/8H2hJ9uJOP9bmlJozkIw.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/8H2hJ9uJOP9bmlJozkIw.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/8H2hJ9uJOP9bmlJozkIw.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/8H2hJ9uJOP9bmlJozkIw.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/8H2hJ9uJOP9bmlJozkIw.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/8H2hJ9uJOP9bmlJozkIw.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/8H2hJ9uJOP9bmlJozkIw.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/8H2hJ9uJOP9bmlJozkIw.png?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/8H2hJ9uJOP9bmlJozkIw.png?auto=format&amp;w=850 850w&quot; width=&quot;425&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;Assistive technology can include something as general as browser zoom, or as
specific as a custom-designed game controller. It can be a separate physical
device like a braille display, or be implemented completely in software like
voice control. It can be built-in to the operating system like some screen
readers, or it can be an add-on like a Chrome extension.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;More assistive technology examples including browser zoom braille display and voice control.&quot; decoding=&quot;async&quot; height=&quot;340&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 373px) 373px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/QACHirntVoVRCP5PbF24.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/QACHirntVoVRCP5PbF24.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/QACHirntVoVRCP5PbF24.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/QACHirntVoVRCP5PbF24.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/QACHirntVoVRCP5PbF24.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/QACHirntVoVRCP5PbF24.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/QACHirntVoVRCP5PbF24.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/QACHirntVoVRCP5PbF24.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/QACHirntVoVRCP5PbF24.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/QACHirntVoVRCP5PbF24.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/QACHirntVoVRCP5PbF24.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/QACHirntVoVRCP5PbF24.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/QACHirntVoVRCP5PbF24.png?auto=format&amp;w=746 746w&quot; width=&quot;373&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;The line between assistive technology and technology in general is blurry; after
all, all technology is meant to assist people with some task or another. And
technologies can often move into and out of the &amp;quot;assistive&amp;quot; category.&lt;/p&gt;
&lt;p&gt;For example, one of the earliest commercial speech synthesis products was a
talking calculator for the blind. Now speech synthesis is all over the place,
from driving directions to virtual assistants. Conversely, technology that was
originally general-purpose often finds an assistive use. For example, people
with low vision may use their smartphone&#39;s camera zoom to get a better look at
something small in the real world.&lt;/p&gt;
&lt;p&gt;In the context of web development, we must consider a diverse range of
technologies. People may interact with your website using a screen reader or
braille display, with a screen magnifier, via voice control, using a switch
device, or with some other form of assistive technology that adapts the page&#39;s
default interface to create a more specific interface that they can use.&lt;/p&gt;
&lt;p&gt;Many of these assistive technologies rely on &lt;em&gt;programmatically expressed
semantics&lt;/em&gt; to create an accessible user experience, and that&#39;s what most of this
lesson is about. But before we can explain programmatically expressed semantics,
we need to talk a bit about &lt;em&gt;affordances&lt;/em&gt;.&lt;/p&gt;
&lt;h2 id=&quot;affordances&quot;&gt;Affordances &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/semantics-builtin/#affordances&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;When we use a man-made tool or device, we typically look to its form and design
to give us an idea of what it does and how it works. An &lt;em&gt;affordance&lt;/em&gt; is any
object that offers, or affords, its user the opportunity to perform an action.
The better the affordance is designed, the more obvious or intuitive its use.&lt;/p&gt;
&lt;p&gt;A classic example is a kettle or teapot. You can easily recognize that you
should pick it up by the handle, not the spout, even if you&#39;ve never seen a
teapot before.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;A teapot with handle and spout.&quot; decoding=&quot;async&quot; height=&quot;446&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 640px) 640px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/X62dJMHmLHJQd6qZWWCr.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/X62dJMHmLHJQd6qZWWCr.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/X62dJMHmLHJQd6qZWWCr.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/X62dJMHmLHJQd6qZWWCr.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/X62dJMHmLHJQd6qZWWCr.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/X62dJMHmLHJQd6qZWWCr.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/X62dJMHmLHJQd6qZWWCr.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/X62dJMHmLHJQd6qZWWCr.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/X62dJMHmLHJQd6qZWWCr.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/X62dJMHmLHJQd6qZWWCr.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/X62dJMHmLHJQd6qZWWCr.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/X62dJMHmLHJQd6qZWWCr.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/X62dJMHmLHJQd6qZWWCr.png?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/X62dJMHmLHJQd6qZWWCr.png?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/X62dJMHmLHJQd6qZWWCr.png?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/X62dJMHmLHJQd6qZWWCr.png?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/X62dJMHmLHJQd6qZWWCr.png?auto=format&amp;w=1280 1280w&quot; width=&quot;640&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;That&#39;s because the affordance is similar to those you have seen on many other
objects -- watering pots, beverage pitchers, coffee mugs, and so on. You
probably &lt;em&gt;could&lt;/em&gt; pick up the pot by the spout, but your experience with similar
affordances tells you the handle is the better option.&lt;/p&gt;
&lt;p&gt;In graphical user interfaces, affordances represent actions we can take, but
they can be ambiguous because there is no physical object to interact with. GUI
affordances are thus specifically designed to be unambiguous: buttons, check
boxes, and scroll bars are meant to convey their usage with as little training
as possible.&lt;/p&gt;
&lt;p&gt;For example, you might paraphrase the use of some common form elements
(affordances) like this:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Radio buttons — &amp;quot;I can choose one of these options.&amp;quot;&lt;/li&gt;
&lt;li&gt;Check box — &amp;quot;I can choose &#39;yes&#39; or &#39;no&#39; to this option.&amp;quot;&lt;/li&gt;
&lt;li&gt;Text field — &amp;quot;I can type something into this area.&amp;quot;&lt;/li&gt;
&lt;li&gt;Dropdown — &amp;quot;I can open this element to display my options.&amp;quot;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You are able to draw conclusions about these elements &lt;em&gt;only because you can see
them&lt;/em&gt;. Naturally, someone who can&#39;t see the visual clues provided by an element
can&#39;t comprehend its meaning or intuitively grasp the value of the affordance.
So we must make sure that the information is expressed flexibly enough to be
accessed by assistive technology that can construct an alternative interface to
suit its user&#39;s needs.&lt;/p&gt;
&lt;p&gt;This non-visual exposure of an affordance&#39;s use is called its &lt;em&gt;semantics&lt;/em&gt;.&lt;/p&gt;
&lt;h2 id=&quot;screen-readers&quot;&gt;Screen readers &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/semantics-builtin/#screen-readers&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;One popular type of assistive technology is the &lt;em&gt;screen reader&lt;/em&gt;, a program that
enables visually impaired people to use computers by reading screen text aloud
in a generated voice. The user can control what is read by moving the cursor to
a relevant area with the keyboard.&lt;/p&gt;
&lt;p&gt;We asked &lt;a href=&quot;https://web.dev/accessibility/#understanding-users-diversity&quot;&gt;Victor
Tsaran&lt;/a&gt;
to explain how, as a blind person, he accesses the web using a the built-in
screen reader on OS X, called VoiceOver. See &lt;a href=&quot;https://www.youtube.com/watch?v=QW_dUs9D1oQ&quot; rel=&quot;noopener&quot;&gt;this
video&lt;/a&gt; of Victor using VoiceOver.&lt;/p&gt;
&lt;p&gt;Now, it&#39;s your turn to try using a screen reader. Here is a page with &lt;em&gt;ChromeVox
Lite&lt;/em&gt;, a minimal but functioning screen reader written in JavaScript. The screen
is purposefully blurred to simulate a low-vision experience and force the user
to complete the task with a screen reader. Of course, you&#39;ll need to use the
Chrome browser for this exercise.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://udacity.github.io/ud891/lesson3-semantics-built-in/02-chromevox-lite/&quot; rel=&quot;noopener&quot;&gt;ChromeVox lite demo page&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You can use the control panel at the bottom of the screen to control the screen
reader. This screen reader has very minimal functionality, but you can explore
the content using the &lt;code&gt;Previous&lt;/code&gt; and &lt;code&gt;Next&lt;/code&gt; buttons, and you can click things
using the &lt;code&gt;Click&lt;/code&gt; button.&lt;/p&gt;
&lt;p&gt;Try using this page with ChromeVox lite enabled to get a feel for screen reader
use. Think about the fact that a screen reader (or other assistive technology)
actually creates a complete alternate user experience for the user based on the
programmatically expressed semantics. Instead of a visual interface, the screen
reader provides an audible interface.&lt;/p&gt;
&lt;p&gt;Notice how the screen reader tells you some information about each interface
element. You should expect a well-designed reader to tell you all, or at least
most, of the following information about the elements it encounters.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The element&#39;s &lt;em&gt;role&lt;/em&gt; or type, if it is specified (it should be).&lt;/li&gt;
&lt;li&gt;The element&#39;s &lt;em&gt;name&lt;/em&gt;, if it has one (it should).&lt;/li&gt;
&lt;li&gt;The element&#39;s &lt;em&gt;value&lt;/em&gt;, if it has one (it may or may not).&lt;/li&gt;
&lt;li&gt;The element&#39;s &lt;em&gt;state&lt;/em&gt;, e.g., whether it is enabled or disabled (if
applicable).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The screen reader is able to construct this alternate UI because the native
elements contain built-in accessibility metadata. Just as the rendering engine
uses the native code to construct a visual interface, the screen reader uses the
metadata in the DOM nodes to construct an accessible version, something like
this.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;A screen reader uses the DOM to create accessible nodes.&quot; decoding=&quot;async&quot; height=&quot;306&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 800px) 800px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/9saR7Av4b4h2RwXjNiEM.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/9saR7Av4b4h2RwXjNiEM.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/9saR7Av4b4h2RwXjNiEM.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/9saR7Av4b4h2RwXjNiEM.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/9saR7Av4b4h2RwXjNiEM.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/9saR7Av4b4h2RwXjNiEM.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/9saR7Av4b4h2RwXjNiEM.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/9saR7Av4b4h2RwXjNiEM.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/9saR7Av4b4h2RwXjNiEM.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/9saR7Av4b4h2RwXjNiEM.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/9saR7Av4b4h2RwXjNiEM.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/9saR7Av4b4h2RwXjNiEM.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/9saR7Av4b4h2RwXjNiEM.png?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/9saR7Av4b4h2RwXjNiEM.png?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/9saR7Av4b4h2RwXjNiEM.png?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/9saR7Av4b4h2RwXjNiEM.png?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/9saR7Av4b4h2RwXjNiEM.png?auto=format&amp;w=1428 1428w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/9saR7Av4b4h2RwXjNiEM.png?auto=format&amp;w=1600 1600w&quot; width=&quot;800&quot; /&gt;
&lt;/figure&gt;
</content>
    <author>
      <name>Meggin Kearney</name>
    </author><author>
      <name>Dave Gash</name>
    </author><author>
      <name>Alice Boxhall</name>
    </author>
  </entry>
  
  <entry>
    <title>Text Alternatives for Images</title>
    <link href="https://web.dev/text-alternatives-for-images/"/>
    <updated>2016-10-04T00:00:00Z</updated>
    <id>https://web.dev/text-alternatives-for-images/</id>
    <content type="html" mode="escaped">&lt;p&gt;Images are an important component of most web pages, and are of course a
particular sticking point for low-vision users. We must consider the role an
image plays in a page to work out what type of text alternative it should have.
Take a look at this image.&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;article&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;h2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Study shows 9 out of 10 cats quietly judging their owners as they sleep&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;h2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;imgs/160204193356-01-cat-500.jpg&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;article&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;h2 id=&quot;study-shows-9-out-of-10-cats-quietly-judging-their-owners-as-they-sleep&quot;&gt;Study shows 9 out of 10 cats quietly judging their owners as they sleep &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/text-alternatives-for-images/#study-shows-9-out-of-10-cats-quietly-judging-their-owners-as-they-sleep&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;figure&gt;
&lt;img alt=&quot;cat&quot; decoding=&quot;async&quot; height=&quot;250&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 400px) 400px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/y9kqrXvh2GbMLAfvGANE.jpg?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/y9kqrXvh2GbMLAfvGANE.jpg?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/y9kqrXvh2GbMLAfvGANE.jpg?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/y9kqrXvh2GbMLAfvGANE.jpg?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/y9kqrXvh2GbMLAfvGANE.jpg?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/y9kqrXvh2GbMLAfvGANE.jpg?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/y9kqrXvh2GbMLAfvGANE.jpg?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/y9kqrXvh2GbMLAfvGANE.jpg?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/y9kqrXvh2GbMLAfvGANE.jpg?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/y9kqrXvh2GbMLAfvGANE.jpg?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/y9kqrXvh2GbMLAfvGANE.jpg?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/y9kqrXvh2GbMLAfvGANE.jpg?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/y9kqrXvh2GbMLAfvGANE.jpg?auto=format&amp;w=800 800w&quot; width=&quot;400&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;In the page we have a picture of a cat, illustrating an article on cats&#39;
well-known judgmental behavior. A screen reader will announce this image using
its literal name, &lt;code&gt;&amp;quot;/160204193356-01-cat-500.jpg&amp;quot;&lt;/code&gt;. That&#39;s accurate, but not at
all useful.&lt;/p&gt;
&lt;p&gt;You can use the &lt;code&gt;alt&lt;/code&gt; attribute to provide a useful text alternative to this
image — for example, &amp;quot;A cat staring menacingly off into space.&amp;quot;&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;/160204193356-01-cat-500.jpg&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;A cat staring menacingly off into space&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;Then the screen reader can announce a succinct description of the image (
seen in the black VoiceOver bar) and the user can choose whether to move on to
the article.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;an image with improved alt text&quot; decoding=&quot;async&quot; height=&quot;303&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 653px) 653px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/6UW687JO230zmcTrPwFO.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/6UW687JO230zmcTrPwFO.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/6UW687JO230zmcTrPwFO.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/6UW687JO230zmcTrPwFO.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/6UW687JO230zmcTrPwFO.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/6UW687JO230zmcTrPwFO.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/6UW687JO230zmcTrPwFO.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/6UW687JO230zmcTrPwFO.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/6UW687JO230zmcTrPwFO.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/6UW687JO230zmcTrPwFO.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/6UW687JO230zmcTrPwFO.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/6UW687JO230zmcTrPwFO.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/6UW687JO230zmcTrPwFO.png?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/6UW687JO230zmcTrPwFO.png?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/6UW687JO230zmcTrPwFO.png?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/6UW687JO230zmcTrPwFO.png?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/6UW687JO230zmcTrPwFO.png?auto=format&amp;w=1306 1306w&quot; width=&quot;653&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;A couple of comments about &lt;code&gt;alt&lt;/code&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;alt&lt;/code&gt; allows you to specify a simple string to be used any time the image
isn&#39;t available, such as when the image fails to load, or is accessed by web
crawling bot, or is encountered by a screen reader.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;alt&lt;/code&gt; differs from &lt;code&gt;title&lt;/code&gt;, or any type of caption, in that it is &lt;em&gt;only&lt;/em&gt; used
if the image is not available.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Writing useful alt text is a bit of an art. In order for a string to be a usable
text alternative, it needs to convey the same concept as the image, in the same
context.&lt;/p&gt;
&lt;p&gt;Consider a linked logo image in the masthead of a page like those shown above.
We can describe the image pretty accurately as &amp;quot;The Funion logo&amp;quot;.&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;logo&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;logo.jpg&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;The Funion logo&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;It might be tempting to give it a simpler text alternative of &amp;quot;home&amp;quot; or &amp;quot;main
page&amp;quot;, but that does a disservice to both low-vision and sighted users.&lt;/p&gt;
&lt;p&gt;But imagine a screen reader user who wants to locate the masthead logo on the
page; giving it an alt value of &amp;quot;home&amp;quot; actually creates a more confusing
experience. And a sighted user faces the same challenge — figuring out
what clicking the site logo does — as a screen reader user.&lt;/p&gt;
&lt;p&gt;On the other hand, it&#39;s not always useful to describe an image. For example,
consider a magnifying glass image inside a search button that has the text
&amp;quot;Search&amp;quot;. If the text wasn&#39;t there, you would definitely give that image an alt
value of &amp;quot;search&amp;quot;. But because we have the visible text, the screen reader will
pick up and read aloud the word &amp;quot;search&amp;quot;; thus, an identical &lt;code&gt;alt&lt;/code&gt; value on the
image is redundant.&lt;/p&gt;
&lt;p&gt;However, we know that if we leave the &lt;code&gt;alt&lt;/code&gt; text out, we&#39;ll probably hear the
image file name instead, which is both useless and potentially confusing. In
this case you can just use an empty &lt;code&gt;alt&lt;/code&gt; attribute, and the screen reader will
skip the image altogether.&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;magnifying-glass.jpg&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;To summarize, all images should have an &lt;code&gt;alt&lt;/code&gt; attribute, but they need not all
have text. Important images should have descriptive alt text that succinctly
describes what the image is, while decorative images should have empty alt
attributes — that is, &lt;code&gt;alt=&amp;quot;&amp;quot;&lt;/code&gt;.&lt;/p&gt;
</content>
    <author>
      <name>Meggin Kearney</name>
    </author><author>
      <name>Dave Gash</name>
    </author><author>
      <name>Alice Boxhall</name>
    </author>
  </entry>
  
  <entry>
    <title>Accessibility</title>
    <link href="https://web.dev/accessibility/"/>
    <updated>2016-06-26T00:00:00Z</updated>
    <id>https://web.dev/accessibility/</id>
    <content type="html" mode="escaped">&lt;p&gt;This document set is a text-based version of part of the content covered in the
&lt;a href=&quot;https://www.udacity.com/course/web-accessibility--ud891&quot; rel=&quot;noopener&quot;&gt;Udacity course on
Accessibility&lt;/a&gt;.
Rather than a direct transcription of the video course, it is meant to be a more
concise treatment of accessibility principles and practices, using the course&#39;s
original content as a base.&lt;/p&gt;
&lt;h2 id=&quot;summary&quot;&gt;Summary &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/accessibility/#summary&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Learn what accessibility means and how it applies to web development.&lt;/li&gt;
&lt;li&gt;Learn how to make websites accessible and usable for everyone.&lt;/li&gt;
&lt;li&gt;Learn how to include basic accessibility with minimal development impact.&lt;/li&gt;
&lt;li&gt;Learn what HTML features are available and how to use them to improve
accessibility.&lt;/li&gt;
&lt;li&gt;Learn about advanced accessibility techniques for creating polished
accessibility experiences.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Understanding accessibility, its scope, and its impact can make you a better web
developer. This guide is intended to help you understand how you can make your
websites accessible and usable for everyone.&lt;/p&gt;
&lt;p&gt;&amp;quot;Accessibility&amp;quot; can be difficult to spell, but it doesn&#39;t have to be difficult
to accomplish. In this guide, you will see how to get some easy wins to help
improve accessibility with minimal effort, how you can use what&#39;s built in to
HTML to create more accessible and robust interfaces, and how to leverage some
advanced techniques for creating polished accessible experiences.&lt;/p&gt;
&lt;p&gt;You&#39;ll also find that many of these techniques will help you create interfaces
that are more pleasant and easy to use for &lt;em&gt;all&lt;/em&gt; users, not just for those with
disabilities.&lt;/p&gt;
&lt;p&gt;Of course, many developers have only a hazy understanding of what accessibility
means - something to do with government contracts, checklists, and screen
readers, right? - and there are plenty of misconceptions floating around.
For example, many developers feel that addressing accessibility will force them
to choose between creating a delightful and attractive experience, and one that
is clunky and ugly but accessible.&lt;/p&gt;
&lt;p&gt;That is, of course, not the case at all, so let&#39;s clear that up before we get
into anything else. What do we mean by accessibility, and what are we here to
learn about?&lt;/p&gt;
&lt;h2 id=&quot;what-is-accessibility&quot;&gt;What is accessibility? &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/accessibility/#what-is-accessibility&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Broadly speaking, when we say a site is accessible, we mean that the site&#39;s
content is available, and its functionality can be operated, by literally
&lt;em&gt;anyone&lt;/em&gt;. As developers, it&#39;s easy to assume that all users can see and use a
keyboard, mouse, or touch screen, and can interact with your page content the
same way you do. This can lead to an experience that works well for some people,
but creates issues that range from simple annoyances to show-stoppers for
others.&lt;/p&gt;
&lt;p&gt;Accessibility, then, refers to the experience of users who might be outside the
narrow range of the &amp;quot;typical&amp;quot; user, who might access or interact with things
differently than you expect. Specifically, it concerns users who are
experiencing some type of impairment or disability - and bear in mind that
that experience might be non-physical or temporary.&lt;/p&gt;
&lt;p&gt;For example, although we tend to center our discussion of accessibility on users
with physical impairments, we can all relate to the experience of using an
interface that is not accessible to us for other reasons. Have you ever had a
problem using a desktop site on a mobile phone, or seen the message &amp;quot;This
content is not available in your area&amp;quot;, or been unable to find a familiar menu
on a tablet? Those are all accessibility issues.&lt;/p&gt;
&lt;p&gt;As you learn more, you&#39;ll find that addressing accessibility issues in this
broader, more general sense almost always improves the user experience for
everyone. Let&#39;s look at an example:&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;A form with poor accessibility.&quot; decoding=&quot;async&quot; height=&quot;308&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 575px) 575px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hcBkdjssb6gqRgOyjpzm.jpg?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hcBkdjssb6gqRgOyjpzm.jpg?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hcBkdjssb6gqRgOyjpzm.jpg?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hcBkdjssb6gqRgOyjpzm.jpg?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hcBkdjssb6gqRgOyjpzm.jpg?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hcBkdjssb6gqRgOyjpzm.jpg?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hcBkdjssb6gqRgOyjpzm.jpg?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hcBkdjssb6gqRgOyjpzm.jpg?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hcBkdjssb6gqRgOyjpzm.jpg?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hcBkdjssb6gqRgOyjpzm.jpg?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hcBkdjssb6gqRgOyjpzm.jpg?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hcBkdjssb6gqRgOyjpzm.jpg?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hcBkdjssb6gqRgOyjpzm.jpg?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hcBkdjssb6gqRgOyjpzm.jpg?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hcBkdjssb6gqRgOyjpzm.jpg?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/hcBkdjssb6gqRgOyjpzm.jpg?auto=format&amp;w=1150 1150w&quot; width=&quot;575&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;This form has several accessibility issues.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The text is low contrast, which is hard for low-vision users to read.&lt;/li&gt;
&lt;li&gt;Having labels on the left and fields on the right makes it hard for many
people to associate them, and almost impossible for someone who needs to zoom
in to use the page; imagine looking at this on a phone and having to pan
around to figure out what goes with what.&lt;/li&gt;
&lt;li&gt;The &amp;quot;Remember details?&amp;quot; label isn&#39;t associated with the checkbox, so you have
to tap or click only on the tiny square rather than just clicking the label;
also, someone using a screen reader would have trouble figuring out the
association.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now let&#39;s wave our accessibility wand and see the form with those issues fixed.
We&#39;re going to make the text darker, modify the design so that the labels are
close to the things they&#39;re labeling, and fix the label to be associated with
the checkbox so you can toggle it by clicking the label as well.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;A form with improved accessibility.&quot; decoding=&quot;async&quot; height=&quot;319&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 575px) 575px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/degxEapMFe6T27SWUZOf.jpg?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/degxEapMFe6T27SWUZOf.jpg?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/degxEapMFe6T27SWUZOf.jpg?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/degxEapMFe6T27SWUZOf.jpg?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/degxEapMFe6T27SWUZOf.jpg?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/degxEapMFe6T27SWUZOf.jpg?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/degxEapMFe6T27SWUZOf.jpg?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/degxEapMFe6T27SWUZOf.jpg?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/degxEapMFe6T27SWUZOf.jpg?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/degxEapMFe6T27SWUZOf.jpg?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/degxEapMFe6T27SWUZOf.jpg?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/degxEapMFe6T27SWUZOf.jpg?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/degxEapMFe6T27SWUZOf.jpg?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/degxEapMFe6T27SWUZOf.jpg?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/degxEapMFe6T27SWUZOf.jpg?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/degxEapMFe6T27SWUZOf.jpg?auto=format&amp;w=1150 1150w&quot; width=&quot;575&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;Which would you rather use? If you said &amp;quot;the accessible version&amp;quot;, you&#39;re on your
way to understanding a main premise of this guide. Often, something that&#39;s a
complete blocker for a few users is also a pain point for many others, so by
fixing the accessibility issue you improve the experience for everyone.&lt;/p&gt;
&lt;h2 id=&quot;web-content-accessibility-guidelines&quot;&gt;Web Content Accessibility Guidelines &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/accessibility/#web-content-accessibility-guidelines&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Throughout this guide we&#39;ll refer to the &lt;a href=&quot;https://www.w3.org/TR/WCAG20/&quot; rel=&quot;noopener&quot;&gt;Web Content Accessibility Guidelines
(WCAG) 2.0&lt;/a&gt;, a set of guidelines
and best practices put together by accessibility experts to address what
&amp;quot;accessibility&amp;quot; means in a methodical way.&lt;/p&gt;
&lt;p&gt;WCAG is organized around four principles often called by the acronym &lt;em&gt;POUR&lt;/em&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Perceivable&lt;/strong&gt;: Can users perceive the content? This helps us keep in mind
that just because something is perceivable with one sense, such as sight,
that doesn&#39;t mean that all users can perceive it.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Operable&lt;/strong&gt;: Can users use UI components and navigate the content? For
example, something that requires a hover interaction cannot be operated by
someone who can&#39;t use a mouse or touch screen.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Understandable&lt;/strong&gt;: Can users understand the content? Can users understand
the interface and is it consistent enough to avoid confusion?&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Robust&lt;/strong&gt;: Can the content be consumed by a wide variety of user agents
(browsers)? Does it work with assistive technology?&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;While WCAG provides a comprehensive overview of what it means for content to be
accessible, it can also be a bit overwhelming. To help mitigate this, the
&lt;a href=&quot;https://webaim.org/&quot; rel=&quot;noopener&quot;&gt;WebAIM&lt;/a&gt;(Web Accessibility in Mind) group has
distilled the WCAG guidelines into an easy-to-follow checklist, targeted
specifically for web content.&lt;/p&gt;
&lt;p&gt;The &lt;a href=&quot;https://webaim.org/standards/wcag/checklist&quot; rel=&quot;noopener&quot;&gt;WebAIM checklist&lt;/a&gt;
can give you a short, high-level summary of what you need to implement, while
also linking to the underlying WCAG specification if you need an expanded
definition.&lt;/p&gt;
&lt;p&gt;With this tool in hand, you can chart a direction for your accessibility work
and be confident that, as long as your project meets the outlined criteria, your
users should have a positive experience accessing your content.&lt;/p&gt;
&lt;h2 id=&quot;understanding-users-diversity&quot;&gt;Understanding users&#39; diversity &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/accessibility/#understanding-users-diversity&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;When learning about accessibility, it helps to have an understanding of the
diverse range of users in the world and the kinds of accessibility topics that
affect them. To explain further, here&#39;s an informative question/answer session
with Victor Tsaran, a Technical Program Manager at Google, who is totally blind.&lt;/p&gt;
&lt;figure&gt;
  &lt;img alt=&quot;Victor Tsaran.&quot; decoding=&quot;async&quot; height=&quot;250&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 250px) 250px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/EddhO9hBAtpLUVeWXnjA.jpg?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/EddhO9hBAtpLUVeWXnjA.jpg?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/EddhO9hBAtpLUVeWXnjA.jpg?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/EddhO9hBAtpLUVeWXnjA.jpg?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/EddhO9hBAtpLUVeWXnjA.jpg?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/EddhO9hBAtpLUVeWXnjA.jpg?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/EddhO9hBAtpLUVeWXnjA.jpg?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/EddhO9hBAtpLUVeWXnjA.jpg?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/EddhO9hBAtpLUVeWXnjA.jpg?auto=format&amp;w=500 500w&quot; width=&quot;250&quot; /&gt;
  &lt;figcaption&gt;Victor Tsaran&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;hr /&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;What do you work on at Google?&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Here at Google my job is to help ensure that our products work for all of our
diverse users, regardless of impairment or ability.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;What kinds of impairments do users have?&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;When we think about the kinds of impairments which would make it difficult for
someone to access our content, many people will immediately picture a blind user
like me. And it&#39;s true, this impairment can really make it frustrating or even
impossible to use a lot of web sites.&lt;/p&gt;
&lt;p&gt;A lot of modern web techniques have the unfortunate side effect of creating
sites which don&#39;t work well with the tools used by blind users to access the
web. However, there is actually more to accessibility than that. We find it
useful think of impairments falling into four broad buckets: visual, motor,
hearing, and cognitive.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Let&#39;s go through those one at a time. Can you give some examples of visual impairments?&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Visual impairments can be split into a few categories: Users with no vision,
like me, might use a screen reader, braille, or combination of the two.&lt;/p&gt;
&lt;figure&gt;
  &lt;img alt=&quot;A braille reader.&quot; decoding=&quot;async&quot; height=&quot;297&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 475px) 475px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/C59Cjp5DEIjceMA49Y5g.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/C59Cjp5DEIjceMA49Y5g.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/C59Cjp5DEIjceMA49Y5g.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/C59Cjp5DEIjceMA49Y5g.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/C59Cjp5DEIjceMA49Y5g.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/C59Cjp5DEIjceMA49Y5g.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/C59Cjp5DEIjceMA49Y5g.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/C59Cjp5DEIjceMA49Y5g.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/C59Cjp5DEIjceMA49Y5g.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/C59Cjp5DEIjceMA49Y5g.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/C59Cjp5DEIjceMA49Y5g.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/C59Cjp5DEIjceMA49Y5g.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/C59Cjp5DEIjceMA49Y5g.png?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/C59Cjp5DEIjceMA49Y5g.png?auto=format&amp;w=950 950w&quot; width=&quot;475&quot; /&gt;
  &lt;figcaption&gt;A braille reader&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;Now, it&#39;s actually pretty unusual to have literally no vision, but still,
there&#39;s a good chance you know or have met at least one person who can&#39;t see at
all. However there are also a much larger number of what we call low-vision
users.&lt;/p&gt;
&lt;p&gt;This is a broad range, from someone like my wife, who doesn&#39;t have any corneas - so while she can basically see things she has a hard time reading print
and is considered legally blind - to someone who might have just poor
vision and needs to wear very strong prescription glasses.&lt;/p&gt;
&lt;p&gt;There&#39;s a huge range, and so naturally there&#39;s a big range of accommodations
that people in this category use: some do use a screen reader or a braille
display (I&#39;ve even heard of one woman who reads braille displayed on-screen
because it&#39;s easier to see than printed text), or they might use text-to-speech
technology without the full screen reader functionality, or they might use a
screen magnifier which zooms in on part of the screen, or they might just use
their browser zoom to make all the fonts bigger. They might also use
high-contrast options like an operating system high-contrast mode, a
high-contrast browser extension or a high-contrast theme for a website.&lt;/p&gt;
&lt;figure&gt;
  &lt;img alt=&quot;High-contrast mode.&quot; decoding=&quot;async&quot; height=&quot;297&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 475px) 475px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/WG5G5cWGZXAjpriWuIHt.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/WG5G5cWGZXAjpriWuIHt.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/WG5G5cWGZXAjpriWuIHt.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/WG5G5cWGZXAjpriWuIHt.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/WG5G5cWGZXAjpriWuIHt.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/WG5G5cWGZXAjpriWuIHt.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/WG5G5cWGZXAjpriWuIHt.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/WG5G5cWGZXAjpriWuIHt.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/WG5G5cWGZXAjpriWuIHt.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/WG5G5cWGZXAjpriWuIHt.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/WG5G5cWGZXAjpriWuIHt.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/WG5G5cWGZXAjpriWuIHt.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/WG5G5cWGZXAjpriWuIHt.png?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/WG5G5cWGZXAjpriWuIHt.png?auto=format&amp;w=950 950w&quot; width=&quot;475&quot; /&gt;
  &lt;figcaption&gt;High-contrast mode&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;A lot of users even use a combination of these, like my friend Laura who uses a
combination of high-contrast mode, browser zoom and text-to-speech.&lt;/p&gt;
&lt;p&gt;Low vision is something a lot of people can relate to. For a start, we all
experience deteriorating vision as we age, so even if you haven&#39;t experienced it
there&#39;s a good chance you&#39;ve heard your parents complain about it. But a lot of
people experience the frustration of taking their laptop out by a sunny window
only to find they suddenly can&#39;t read anything! Or anyone who&#39;s had laser
surgery or maybe just has to read something from across the room might have used
one of those accommodations I mentioned. So I think it&#39;s pretty easy for
developers to have some empathy for low-vision users.&lt;/p&gt;
&lt;p&gt;Oh, and I shouldn&#39;t forget to mention people with poor color vision -
about 9% of males have some form of color vision deficiency! Plus about 1% of
females. They may have trouble distinguishing red and green, or yellow and blue.
Think about that the next time you design form validation.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;What about motor impairments?&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Yes, motor impairments, or dexterity impairments. This group ranges all the way
from those who would prefer not to use a mouse, because perhaps they&#39;ve had some
RSI or something and find it painful, to someone who may be physically paralyzed
and have limited range of motion for certain parts of their body.&lt;/p&gt;
&lt;figure&gt;
  &lt;img alt=&quot;A person using an eye tracking device.&quot; decoding=&quot;async&quot; height=&quot;297&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 475px) 475px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/BLk6WCwCOprDmAoTky4F.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/BLk6WCwCOprDmAoTky4F.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/BLk6WCwCOprDmAoTky4F.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/BLk6WCwCOprDmAoTky4F.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/BLk6WCwCOprDmAoTky4F.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/BLk6WCwCOprDmAoTky4F.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/BLk6WCwCOprDmAoTky4F.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/BLk6WCwCOprDmAoTky4F.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/BLk6WCwCOprDmAoTky4F.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/BLk6WCwCOprDmAoTky4F.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/BLk6WCwCOprDmAoTky4F.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/BLk6WCwCOprDmAoTky4F.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/BLk6WCwCOprDmAoTky4F.png?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/BLk6WCwCOprDmAoTky4F.png?auto=format&amp;w=950 950w&quot; width=&quot;475&quot; /&gt;
  &lt;figcaption&gt;An eye tracking device&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;Motor impaired users may use a keyboard, switch device, voice control, or even
an eye-tracking device to interact with their computer.&lt;/p&gt;
&lt;p&gt;Similar to vision impairments, mobility can also be a temporary or situational
issue: Maybe you have a broken wrist on your mouse hand. Maybe the trackpad is
broken on your laptop, or you&#39;re just riding on a shaky train. There can be a
lot of situations where a user&#39;s mobility is impeded, and by making sure we
cater for them we improve the experience overall, both for anyone with a
permanent impairment but also for anyone who temporarily finds that they can&#39;t
use a pointer-based UI.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Great, let&#39;s talk about hearing impairments.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This group can range from the profoundly deaf through to hard-of-hearing. And
much like eyesight, our hearing tends to degrade with age. Many of us use common
affordances like hearing aids to help us.&lt;/p&gt;
&lt;figure&gt;
  &lt;img alt=&quot;A television with captions at the bottom.&quot; decoding=&quot;async&quot; height=&quot;297&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 475px) 475px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/vci6EjBFLKfUPrifdIKh.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/vci6EjBFLKfUPrifdIKh.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/vci6EjBFLKfUPrifdIKh.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/vci6EjBFLKfUPrifdIKh.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/vci6EjBFLKfUPrifdIKh.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/vci6EjBFLKfUPrifdIKh.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/vci6EjBFLKfUPrifdIKh.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/vci6EjBFLKfUPrifdIKh.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/vci6EjBFLKfUPrifdIKh.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/vci6EjBFLKfUPrifdIKh.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/vci6EjBFLKfUPrifdIKh.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/vci6EjBFLKfUPrifdIKh.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/vci6EjBFLKfUPrifdIKh.png?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/vci6EjBFLKfUPrifdIKh.png?auto=format&amp;w=950 950w&quot; width=&quot;475&quot; /&gt;
  &lt;figcaption&gt;Screen captions&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;For hearing-impaired users we need to make sure that we&#39;re not relying on
sound, so making sure to use things like video captions and transcripts, and
providing some kind of alternative, if sound is part of the interface.&lt;/p&gt;
&lt;p&gt;And like we saw with vision and motor impairments, it&#39;s really easy to imagine
a situation where someone whose ears work fine would benefit from these
accommodations as well. A lot of my friends say they love it when videos have
captions and transcripts because it means that if they&#39;re in an open plan office
and didn&#39;t bring their headphones, they can still watch the video!&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;All right, can you tell us a bit about cognitive impairments?&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;There&#39;s a range of cognitive conditions like ADD, Dyslexia, and Autism,
which can mean that people want or need to access things differently. The
accommodations for these groups are naturally extremely diverse, but we
definitely find some overlap with other areas, like using zoom functionality to
make reading or concentrating easier. Also, these users may find that really
minimal design works best because it minimizes distraction and cognitive load.&lt;/p&gt;
&lt;p&gt;I think everyone can relate to the stress of cognitive overload, so it&#39;s
obvious that if we create something that works well for someone with a cognitive
impairment, we&#39;re going to be creating something which is going to be a pleasant
experience for everyone.&lt;/p&gt;
&lt;p&gt;So, how would you summarize how you think about accessibility?&lt;/p&gt;
&lt;p&gt;When you look at the broad range of abilities and disabilities that people
might have, you can see that designing and building products only for people who
have perfect vision, hearing, dexterity, and cognition seems incredibly narrow.
It&#39;s almost self-defeating, because we&#39;re creating a more stressful and less
usable experience for everyone, and for some users creating an experience which
actually excludes them altogether.&lt;/p&gt;
&lt;p&gt;In this interview, Victor identified a range of impairments, and placed them
into four broad categories: &lt;em&gt;visual&lt;/em&gt;, &lt;em&gt;motor&lt;/em&gt;, &lt;em&gt;hearing&lt;/em&gt;, and &lt;em&gt;cognitive&lt;/em&gt;. He
also pointed out that each type of impairment might be &lt;em&gt;situational&lt;/em&gt;,
&lt;em&gt;temporary&lt;/em&gt;, or &lt;em&gt;permanent&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Let&#39;s take a look at some real-world examples of access impairments and see
where they fall within those categories and types. Note that some impairments
may fall into more than one category or type.&lt;/p&gt;
&lt;table&gt;
  &lt;tr&gt;
    &lt;th&gt;&lt;/th&gt;
    &lt;th&gt;Situational&lt;/th&gt;
    &lt;th&gt;Temporary&lt;/th&gt;
    &lt;th&gt;Permanent&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;th&gt;Visual&lt;/th&gt;
    &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;concussion&lt;/td&gt;
    &lt;td&gt;blindness&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;th&gt;Motor&lt;/th&gt;
    &lt;td&gt;holding a baby&lt;/td&gt;
    &lt;td&gt;broken arm, RSI*&lt;/td&gt;
    &lt;td&gt;RSI*&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;th&gt;Hearing&lt;/th&gt;
    &lt;td&gt;noisy office&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;th&gt;Cognitive&lt;/th&gt;
    &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;concussion&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;Repetitive Strain Injury: e.g., carpal tunnel syndrome, tennis elbow, trigger
finger&lt;/p&gt;
&lt;h2 id=&quot;next-steps&quot;&gt;Next steps &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/accessibility/#next-steps&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;We&#39;ve covered quite a bit of ground already! You have read about&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;what accessibility is and why it matters for everyone&lt;/li&gt;
&lt;li&gt;the WCAG and the WebAIM accessibility checklist&lt;/li&gt;
&lt;li&gt;different types of impairments you should consider&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For the rest of the guide, we&#39;ll dive into the practical aspects of creating
accessible web sites. We&#39;ll organize this effort around three main subject
areas:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://web.dev/focus/&quot;&gt;&lt;strong&gt;Focus&lt;/strong&gt;&lt;/a&gt;: We&#39;ll look at how to
build things that can be operated with a keyboard instead of a mouse. This is
important for users with motor impairments, of course, but it also ensures
that your UI is in good shape for all users.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://web.dev/semantics-builtin/&quot;&gt;&lt;strong&gt;Semantics&lt;/strong&gt;&lt;/a&gt;: We&#39;ll
make sure that we express our user interface in a robust way that works with
a variety of assistive technologies.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://web.dev/accessible/#create-a-design-and-css-that-supports-users-with-different-needs&quot;&gt;&lt;strong&gt;Styling&lt;/strong&gt;&lt;/a&gt;: We&#39;ll consider visual
design and look at some techniques for making the visual elements of the
interface as flexible and usable as possible.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Each of those subjects could fill a whole course, so we won&#39;t cover every aspect
of creating accessible web sites. However, we&#39;ll give you enough information to
get started, and point you to some good places where you can learn more about
each topic.&lt;/p&gt;
</content>
    <author>
      <name>Meggin Kearney</name>
    </author><author>
      <name>Dave Gash</name>
    </author><author>
      <name>Alice Boxhall</name>
    </author><author>
      <name>Rob Dodson</name>
    </author>
  </entry>
</feed>
