<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <id>https://web.dev/</id>
  <title>Rob Dodson on web.dev</title>
  <updated>2026-04-15T23:21:06Z</updated>
  <author>
    <name>Rob Dodson</name>
  </author>
  <link href="https://web.dev/authors/robdodson/feed.xml" rel="self"/>
  <link href="https://web.dev/"/>
  <icon>https://web-dev.imgix.net/image/admin/1Yk1TThRpbQr08rC9tmL.jpg?auto=format</icon>
  <logo>https://web.dev/images/shared/rss-banner.png</logo>
  <subtitle>Googler working on web stuff. I help build web.dev!</subtitle>
  
  
  <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>An example blog post used for screenshot testing.</title>
    <link href="https://web.dev/handbook/content-types/example-post/"/>
    <updated>2019-10-31T00:00:00Z</updated>
    <id>https://web.dev/handbook/content-types/example-post/</id>
    <content type="html" mode="escaped">&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum a massa
sit amet ullamcorper. Suspendisse auctor ultrices ante, nec tempus nibh varius
at. Cras ligula lacus, porta vitae maximus a, ultrices a mauris. Vestibulum
porta dolor erat, vel molestie dolor posuere in. Nam vel elementum augue. Nam
quis enim blandit, posuere justo dignissim, scelerisque diam. Fusce aliquet urna
ac blandit ullamcorper. Proin et semper nibh, sit amet imperdiet velit. Morbi at
quam sem. Integer et erat ac mi scelerisque suscipit et vitae nulla. Aliquam
scelerisque efficitur ante ut facilisis. Aenean et risus fringilla, hendrerit
sapien et, tincidunt orci. Aenean sed tellus aliquam, consectetur metus in,
tempus enim.&lt;/p&gt;
&lt;aside class=&quot;aside flow bg-quaternary-box-bg color-quaternary-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; fill=&quot;currentColor&quot; role=&quot;img&quot; aria-label=&quot;Code brackets&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;M9.41 16.59L8 18l-6-6 6-6 1.41 1.41L4.83 12l4.58 4.59zm5.18-9.18L16 6l6 6-6 6-1.41-1.41L19.17 12l-4.58-4.59z&quot;&gt;&lt;/path&gt; &lt;/svg&gt;&lt;/span&gt;&lt;strong&gt;Try it&lt;/strong&gt;&lt;/p&gt;&lt;div class=&quot; flow&quot;&gt; &lt;a href=&quot;https://web.dev/handbook/content-types/example-post/#&quot;&gt;Using Imagemin with Grunt&lt;/a&gt; &lt;/div&gt;&lt;/aside&gt;
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum a massa
sit amet ullamcorper. Suspendisse auctor ultrices ante, nec tempus nibh varius
at. Cras ligula lacus, porta vitae maximus a, ultrices a mauris. Vestibulum
porta dolor erat, vel molestie dolor posuere in. Nam vel elementum augue. Nam
quis enim blandit, posuere justo dignissim, scelerisque diam. Fusce aliquet urna
ac blandit ullamcorper. Proin et semper nibh, sit amet imperdiet velit. Morbi
quam sem. Integer et erat ac mi scelerisque suscipit et vitae nulla. Aliquam
scelerisque efficitur ante ut facilisis. Aenean et risus fringilla, hendrerit
sapien et, tincidunt orci. Aenean sed tellus aliquam, consectetur metus in,
tempus enim.&lt;/p&gt;
&lt;figure data-size=&quot;full&quot;&gt;
  &lt;img alt=&quot;&quot; decoding=&quot;async&quot; height=&quot;263&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 400px) 400px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/Z77AxApfjYjrUlRWwWdW.jpg?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/Z77AxApfjYjrUlRWwWdW.jpg?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/Z77AxApfjYjrUlRWwWdW.jpg?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/Z77AxApfjYjrUlRWwWdW.jpg?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/Z77AxApfjYjrUlRWwWdW.jpg?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/Z77AxApfjYjrUlRWwWdW.jpg?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/Z77AxApfjYjrUlRWwWdW.jpg?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/Z77AxApfjYjrUlRWwWdW.jpg?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/Z77AxApfjYjrUlRWwWdW.jpg?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/Z77AxApfjYjrUlRWwWdW.jpg?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/Z77AxApfjYjrUlRWwWdW.jpg?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/Z77AxApfjYjrUlRWwWdW.jpg?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/Z77AxApfjYjrUlRWwWdW.jpg?auto=format&amp;w=800 800w&quot; width=&quot;400&quot; /&gt;
  &lt;figcaption&gt;
    Large image.
  &lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum a massa
sit amet ullamcorper. Suspendisse auctor ultrices ante, nec tempus nibh varius
at. Cras ligula lacus, porta vitae maximus a, ultrices a mauris. Vestibulum
porta dolor erat, vel molestie dolor posuere in. Nam vel elementum augue. Nam
quis enim blandit, posuere justo dignissim, scelerisque diam. Fusce aliquet urna
ac blandit ullamcorper. Proin et semper nibh, sit amet imperdiet velit. Morbi at
quam sem.&lt;/p&gt;
&lt;figure&gt;
  &lt;img alt=&quot;&quot; decoding=&quot;async&quot; height=&quot;263&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 400px) 400px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/Z77AxApfjYjrUlRWwWdW.jpg?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/Z77AxApfjYjrUlRWwWdW.jpg?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/Z77AxApfjYjrUlRWwWdW.jpg?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/Z77AxApfjYjrUlRWwWdW.jpg?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/Z77AxApfjYjrUlRWwWdW.jpg?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/Z77AxApfjYjrUlRWwWdW.jpg?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/Z77AxApfjYjrUlRWwWdW.jpg?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/Z77AxApfjYjrUlRWwWdW.jpg?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/Z77AxApfjYjrUlRWwWdW.jpg?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/Z77AxApfjYjrUlRWwWdW.jpg?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/Z77AxApfjYjrUlRWwWdW.jpg?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/Z77AxApfjYjrUlRWwWdW.jpg?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/Z77AxApfjYjrUlRWwWdW.jpg?auto=format&amp;w=800 800w&quot; width=&quot;400&quot; /&gt;
  &lt;figcaption&gt;
    Small image.
  &lt;/figcaption&gt;
&lt;/figure&gt;
&lt;aside class=&quot;aside flow bg-state-info-bg color-state-info-text&quot;&gt;&lt;div class=&quot; flow&quot;&gt; Lorem ipsum dolor sit amet, &lt;a href=&quot;https://web.dev/handbook/content-types/example-post/#&quot;&gt;consectetur adipiscing elit&lt;/a&gt;. Proin dictum a massa sit amet ullamcorper. Suspendisse auctor ultrices ante, nec tempus nibh varius at. &lt;code&gt;Cras ligula lacus&lt;/code&gt;, porta vitae maximus a, ultrices a mauris. &lt;a href=&quot;https://web.dev/handbook/content-types/example-post/#&quot;&gt;&lt;code&gt;Vestibulum porta&lt;/code&gt;&lt;/a&gt; dolor erat, vel molestie dolor posuere in. Nam vel elementum augue. &lt;/div&gt;&lt;/aside&gt;
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum a massa
sit amet ullamcorper. Suspendisse auctor ultrices ante, nec tempus nibh varius
at. Cras ligula lacus, porta vitae maximus a, ultrices a mauris. Vestibulum
porta dolor erat, vel molestie dolor posuere in. Nam vel elementum augue. Nam
quis enim blandit, posuere justo dignissim, scelerisque diam. Fusce aliquet urna
ac blandit ullamcorper. Proin et semper nibh, sit amet imperdiet velit. Morbi at
quam sem.&lt;/p&gt;
&lt;h2 id=&quot;image,-inline&quot;&gt;Image, Inline &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/handbook/content-types/example-post/#image,-inline&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;figure data-float=&quot;right&quot;&gt;
  &lt;img alt=&quot;&quot; decoding=&quot;async&quot; height=&quot;306&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 200px) 200px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/WHh2eQoyBxylhgPdYOis.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/WHh2eQoyBxylhgPdYOis.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/WHh2eQoyBxylhgPdYOis.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/WHh2eQoyBxylhgPdYOis.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/WHh2eQoyBxylhgPdYOis.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/WHh2eQoyBxylhgPdYOis.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/WHh2eQoyBxylhgPdYOis.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/WHh2eQoyBxylhgPdYOis.png?auto=format&amp;w=400 400w&quot; width=&quot;200&quot; /&gt;
  &lt;figcaption&gt;
    Inline right, outlined image.
  &lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum a massa
sit amet ullamcorper. Suspendisse auctor ultrices ante, nec tempus nibh varius
at. Cras ligula lacus, porta vitae maximus a, ultrices a mauris. Vestibulum
porta dolor erat, vel molestie dolor posuere in. Nam vel elementum augue. Nam
quis enim blandit, posuere justo dignissim, scelerisque diam. Fusce aliquet urna
ac blandit ullamcorper. Proin et semper nibh, sit amet imperdiet velit. Morbi at
quam sem. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum
a massa sit amet ullamcorper. Suspendisse auctor ultrices ante, nec tempus nibh
varius at. Cras ligula lacus, porta vitae maximus a, ultrices a mauris.
Vestibulum porta dolor erat, vel molestie dolor posuere in. Nam vel elementum
augue. Nam quis enim blandit, posuere justo dignissim, scelerisque diam. Fusce
aliquet urna ac blandit ullamcorper. Proin et semper nibh, sit amet imperdiet
velit. Morbi at quam sem.&lt;/p&gt;
&lt;figure data-float=&quot;left&quot;&gt;
  &lt;img alt=&quot;&quot; decoding=&quot;async&quot; height=&quot;306&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 200px) 200px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/WHh2eQoyBxylhgPdYOis.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/WHh2eQoyBxylhgPdYOis.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/WHh2eQoyBxylhgPdYOis.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/WHh2eQoyBxylhgPdYOis.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/WHh2eQoyBxylhgPdYOis.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/WHh2eQoyBxylhgPdYOis.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/WHh2eQoyBxylhgPdYOis.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/WHh2eQoyBxylhgPdYOis.png?auto=format&amp;w=400 400w&quot; width=&quot;200&quot; /&gt;
  &lt;figcaption&gt;
    Inline left, outlined image.
  &lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum a massa
sit amet ullamcorper. Suspendisse auctor ultrices ante, nec tempus nibh varius
at. Cras ligula lacus, porta vitae maximus a, ultrices a mauris. Vestibulum
porta dolor erat, vel molestie dolor posuere in. Nam vel elementum augue. Nam
quis enim blandit, posuere justo dignissim, scelerisque diam. Fusce aliquet urna
ac blandit ullamcorper. Proin et semper nibh, sit amet imperdiet velit. Morbi at
quam sem. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum
a massa sit amet ullamcorper. Suspendisse auctor ultrices ante, nec tempus nibh
varius at. Cras ligula lacus, porta vitae maximus a, ultrices a mauris.
Vestibulum porta dolor erat, vel molestie dolor posuere in. Nam vel elementum
augue. Nam quis enim blandit, posuere justo dignissim, scelerisque diam. Fusce
aliquet urna ac blandit ullamcorper. Proin et semper nibh, sit amet imperdiet
velit. Morbi at quam sem.&lt;/p&gt;
&lt;figure data-screenshot=&quot;&quot;&gt;
  &lt;img alt=&quot;&quot; decoding=&quot;async&quot; height=&quot;475&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 800px) 800px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=1428 1428w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=1600 1600w&quot; width=&quot;800&quot; /&gt;
  &lt;figcaption&gt;
    Filled screenshot.
  &lt;/figcaption&gt;
&lt;/figure&gt;
&lt;aside class=&quot;aside flow bg-state-bad-bg color-state-bad-text&quot;&gt;&lt;p class=&quot;cluster color-state-bad-text&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; fill=&quot;currentColor&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; role=&quot;img&quot; aria-label=&quot;Error sign&quot;&gt;   &lt;path fill-rule=&quot;evenodd&quot; clip-rule=&quot;evenodd&quot; d=&quot;M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 15v-2h2v2h-2zm0-10v6h2V7h-2z&quot;&gt;&lt;/path&gt; &lt;/svg&gt;&lt;/span&gt;&lt;strong&gt;Caution&lt;/strong&gt;&lt;/p&gt;&lt;div class=&quot; flow&quot;&gt; &lt;a href=&quot;https://web.dev/handbook/content-types/example-post/#&quot;&gt;This type of callout&lt;/a&gt; suggests proceeding with caution. &lt;/div&gt;&lt;/aside&gt;
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum a massa
sit amet ullamcorper. Suspendisse auctor ultrices ante, nec tempus nibh varius
at. Cras ligula lacus, porta vitae maximus a, ultrices a mauris. Vestibulum
porta dolor erat, vel molestie dolor posuere in. Nam vel elementum augue. Nam
quis enim blandit, posuere justo dignissim, scelerisque diam. Fusce aliquet urna
ac blandit ullamcorper. Proin et semper nibh, sit amet imperdiet velit. Morbi at
quam sem.&lt;/p&gt;
&lt;div&gt;
  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;Image Format&lt;/th&gt;
        &lt;th&gt;Lossy Plugin(s)&lt;/th&gt;
        &lt;th&gt;Lossless Plugin(s)&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;JPEG&lt;/td&gt;
        &lt;td&gt;&lt;a href=&quot;https://web.dev/handbook/content-types/example-post/#&quot;&gt;imagemin-mozjpeg&lt;/a&gt;&lt;/td&gt;
        &lt;td&gt;&lt;a href=&quot;https://web.dev/handbook/content-types/example-post/#&quot;&gt;imagemin-jpegtran&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;PNG&lt;/td&gt;
        &lt;td&gt;&lt;a href=&quot;https://web.dev/handbook/content-types/example-post/#&quot;&gt;imagemin-pngquant&lt;/a&gt;&lt;/td&gt;
        &lt;td&gt;&lt;a href=&quot;https://web.dev/handbook/content-types/example-post/#&quot;&gt;imagemin-optipng&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;GIF&lt;/td&gt;
        &lt;td&gt;&lt;a href=&quot;https://web.dev/handbook/content-types/example-post/#&quot;&gt;imagemin-giflossy&lt;/a&gt;&lt;/td&gt;
        &lt;td&gt;&lt;a href=&quot;https://web.dev/handbook/content-types/example-post/#&quot;&gt;imagemin-gifsicle&lt;/a&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;SVG&lt;/td&gt;
        &lt;td&gt;&lt;a href=&quot;https://web.dev/handbook/content-types/example-post/#&quot;&gt;Imagemin-svgo&lt;/a&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;WebP&lt;/td&gt;
        &lt;td&gt;&lt;a href=&quot;https://web.dev/handbook/content-types/example-post/#&quot;&gt;imagemin-webp&lt;/a&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
    &lt;caption&gt;Table 1 — Imagemin plugins for filetypes.&lt;/caption&gt;
  &lt;/table&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; This type of callout is stronger than a Caution; it means &amp;quot;Don&#39;t do this.&amp;quot; &lt;/div&gt;&lt;/aside&gt;
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum a massa
sit amet ullamcorper. Suspendisse auctor ultrices ante, nec tempus nibh varius
at. Cras ligula lacus, porta vitae maximus a, ultrices a mauris. Vestibulum
porta dolor erat, vel molestie dolor posuere in. Nam vel elementum augue. Nam
quis enim blandit, posuere justo dignissim, scelerisque diam. Fusce aliquet urna
ac blandit ullamcorper. Proin et semper nibh, sit amet imperdiet velit. Morbi at
quam sem.&lt;/p&gt;
&lt;h2 id=&quot;ordered-list&quot;&gt;Ordered list &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/handbook/content-types/example-post/#ordered-list&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit.&lt;/li&gt;
&lt;li&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit.&lt;/li&gt;
&lt;li&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum a massa
sit amet ullamcorper. Suspendisse auctor ultrices ante, nec tempus nibh varius
at. Cras ligula lacus, porta vitae maximus a, ultrices a mauris. Vestibulum
porta dolor erat, vel molestie dolor posuere in. Nam vel elementum augue. Nam
quis enim blandit, posuere justo dignissim, scelerisque diam. Fusce aliquet urna
ac blandit ullamcorper. Proin et semper nibh, sit amet imperdiet velit. Morbi at
quam sem.&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum a massa
  sit amet ullamcorper.
  &lt;/li&gt;
  &lt;li&gt;
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum a massa
  sit amet ullamcorper.
  &lt;figure&gt;
    &lt;img alt=&quot;&quot; decoding=&quot;async&quot; height=&quot;475&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 800px) 800px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=1428 1428w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=1600 1600w&quot; width=&quot;800&quot; /&gt;
    &lt;figcaption&gt;
      Filled screenshot.
    &lt;/figcaption&gt;
  &lt;/figure&gt;
  &lt;/li&gt;
  &lt;li&gt;
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum a massa
  sit amet ullamcorper.
  &lt;/li&gt;
&lt;/ol&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; This type of callout describes a successful action or an error-free status. &lt;/div&gt;&lt;/aside&gt;
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum a massa
sit amet ullamcorper. Suspendisse auctor ultrices ante, nec tempus nibh varius
at. Cras ligula lacus, porta vitae maximus a, ultrices a mauris. Vestibulum
porta dolor erat, vel molestie dolor posuere in. Nam vel elementum augue. Nam
quis enim blandit, posuere justo dignissim, scelerisque diam. Fusce aliquet urna
ac blandit ullamcorper. Proin et semper nibh, sit amet imperdiet velit. Morbi at
quam sem.&lt;/p&gt;
&lt;h2 id=&quot;unordered-list&quot;&gt;Unordered list &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/handbook/content-types/example-post/#unordered-list&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit.&lt;/li&gt;
&lt;li&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit.&lt;/li&gt;
&lt;li&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum a massa
sit amet ullamcorper. Suspendisse auctor ultrices ante, nec tempus nibh varius
at. Cras ligula lacus, porta vitae maximus a, ultrices a mauris. Vestibulum
porta dolor erat, vel molestie dolor posuere in. Nam vel elementum augue. Nam
quis enim blandit, posuere justo dignissim, scelerisque diam. Fusce aliquet urna
ac blandit ullamcorper. Proin et semper nibh, sit amet imperdiet velit. Morbi at
quam sem.&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum a massa
  sit amet ullamcorper.
  &lt;/li&gt;
  &lt;li&gt;
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum a massa
  sit amet ullamcorper.
  &lt;figure&gt;
    &lt;img alt=&quot;&quot; decoding=&quot;async&quot; height=&quot;475&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 800px) 800px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=1428 1428w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/V9sy0IErc3V19nrodKb1.png?auto=format&amp;w=1600 1600w&quot; width=&quot;800&quot; /&gt;
    &lt;figcaption&gt;
      Filled screenshot.
    &lt;/figcaption&gt;
  &lt;/figure&gt;
  &lt;/li&gt;
  &lt;li&gt;
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum a massa
  sit amet ullamcorper.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum a massa
sit amet ullamcorper. Suspendisse auctor ultrices ante, nec tempus nibh varius
at. Cras ligula lacus, porta vitae maximus a, ultrices a mauris. Vestibulum
porta dolor erat, vel molestie dolor posuere in. Nam vel elementum augue. Nam
quis enim blandit, posuere justo dignissim, scelerisque diam. Fusce aliquet urna
ac blandit ullamcorper. Proin et semper nibh, sit amet imperdiet velit. Morbi at
quam sem.&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;const&lt;/span&gt; imagemin &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;imagemin&quot;&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;const&lt;/span&gt; imageminMozjpeg &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;imagemin-mozjpeg&quot;&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 punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;async&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;=&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;const&lt;/span&gt; files &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;imagemin&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 string&quot;&gt;&quot;source_dir/*.jpg&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;another_dir/*.jpg&quot;&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 string&quot;&gt;&quot;destination_dir&quot;&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 literal-property property&quot;&gt;plugins&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 function&quot;&gt;imageminMozjpeg&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;quality&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;50&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 punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;files&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;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;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;Objective&lt;/strong&gt;&lt;/p&gt;&lt;div class=&quot; flow&quot;&gt; This type of callout defines the goal of a procedure. &lt;/div&gt;&lt;/aside&gt;
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum a massa
sit amet ullamcorper. Suspendisse auctor ultrices ante, nec tempus nibh varius
at. Cras ligula lacus, porta vitae maximus a, ultrices a mauris. Vestibulum
porta dolor erat, vel molestie dolor posuere in. Nam vel elementum augue. Nam
quis enim blandit, posuere justo dignissim, scelerisque diam. Fusce aliquet urna
ac blandit ullamcorper. Proin et semper nibh, sit amet imperdiet velit. Morbi at
quam sem.&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;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; imagemin &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;imagemin&#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&gt;&lt;br /&gt;&lt;mark class=&quot;highlight-line highlight-line-active&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; imageminMozjpeg &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;imagemin-mozjpeg&#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;/mark&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;async&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;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; files &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;imagemin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;source_dir/*.jpg&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;another_dir/*.jpg&#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&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token string&quot;&gt;&#39;destination_dir&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token literal-property property&quot;&gt;plugins&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 function&quot;&gt;imageminMozjpeg&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;quality&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;50&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;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&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&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;files&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;br /&gt;&lt;span class=&quot;highlight-line&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 punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum a massa
sit amet ullamcorper. Suspendisse auctor ultrices ante, nec tempus nibh varius
at. Cras ligula lacus, porta vitae maximus a, ultrices a mauris.&lt;/p&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;Gotchas&lt;/strong&gt;&lt;/p&gt;&lt;div class=&quot; flow&quot;&gt; The value of the &lt;code&gt;type&lt;/code&gt; attribute should be the MIME type corresponding to the image format. An image&#39;s MIME type and its file extension are often similar, but they aren&#39;t necessarily the same thing (e.g. &lt;code&gt;.jpg&lt;/code&gt; vs. &lt;code&gt;image/jpeg&lt;/code&gt;). &lt;/div&gt;&lt;/aside&gt;
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum a massa
sit amet ullamcorper. Suspendisse auctor ultrices ante, nec tempus nibh varius
at. Cras ligula lacus, porta vitae maximus a, ultrices a mauris. Vestibulum
porta dolor erat, vel molestie dolor posuere in. Nam vel elementum augue. Nam
quis enim blandit, posuere justo dignissim, scelerisque diam. Fusce aliquet urna
ac blandit ullamcorper. Proin et semper nibh, sit amet imperdiet velit. Morbi at
quam sem.&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;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; imagemin &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;imagemin&#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&gt;&lt;br /&gt;&lt;del class=&quot;highlight-line highlight-line-remove&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; imageminMozjpeg &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;imagemin-mozjpeg&#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;/del&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;async&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;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; files &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;imagemin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;source_dir/*.jpg&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;another_dir/*.jpg&#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&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token string&quot;&gt;&#39;destination_dir&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token literal-property property&quot;&gt;plugins&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 function&quot;&gt;imageminMozjpeg&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;quality&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;50&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;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&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&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;files&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;br /&gt;&lt;span class=&quot;highlight-line&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 punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum a massa
sit amet ullamcorper. Suspendisse auctor ultrices ante, nec tempus nibh varius
at. Cras ligula lacus, porta vitae maximus a, ultrices a mauris. Vestibulum
porta dolor erat, vel molestie dolor posuere in. Nam vel elementum augue. Nam
quis enim blandit, posuere justo dignissim, scelerisque diam. Fusce aliquet urna
ac blandit ullamcorper. Proin et semper nibh, sit amet imperdiet velit. Morbi at
quam sem.&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;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; imagemin &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;imagemin&#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&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; imageminMozjpeg &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;imagemin-mozjpeg&#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&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;async&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;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; files &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;imagemin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;del class=&quot;highlight-line highlight-line-remove&quot;&gt;      &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;source_dir/*.jpg&#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;/del&gt;&lt;br /&gt;&lt;ins class=&quot;highlight-line highlight-line-add&quot;&gt;      &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;source_dir/*.jpg&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;another_dir/*.jpg&#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;/ins&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token string&quot;&gt;&#39;destination_dir&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token literal-property property&quot;&gt;plugins&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 function&quot;&gt;imageminMozjpeg&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;quality&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;50&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;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&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&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;files&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;br /&gt;&lt;span class=&quot;highlight-line&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 punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum a massa
sit amet ullamcorper. Suspendisse auctor ultrices ante, nec tempus nibh varius
at. Cras ligula lacus, porta vitae maximus a, ultrices a mauris. Vestibulum
porta dolor erat, vel molestie dolor posuere in. Nam vel elementum augue. Nam
quis enim blandit, posuere justo dignissim, scelerisque diam. Fusce aliquet urna
ac blandit ullamcorper. Proin et semper nibh, sit amet imperdiet velit. Morbi at
quam sem.&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum
    a massa sit amet ullamcorper.
  &lt;/p&gt;
  &lt;cite&gt;
    by Jon Doe
  &lt;/cite&gt;
&lt;/blockquote&gt;
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum a massa
sit amet ullamcorper. Suspendisse auctor ultrices ante, nec tempus nibh varius
at. Cras ligula lacus, porta vitae maximus a, ultrices a mauris. Vestibulum
porta dolor erat, vel molestie dolor posuere in. Nam vel elementum augue. Nam
quis enim blandit, posuere justo dignissim, scelerisque diam. Fusce aliquet urna
ac blandit ullamcorper. Proin et semper nibh, sit amet imperdiet velit. Morbi at
quam sem.&lt;/p&gt;
&lt;pullquote&gt;
  &lt;p&gt;
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum
    a massa sit amet ullamcorper.
  &lt;/p&gt;
  &lt;cite&gt;
    by Jon Doe
  &lt;/cite&gt;
&lt;/pullquote&gt;
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum a massa
sit amet ullamcorper. Suspendisse auctor ultrices ante, nec tempus nibh varius
at. Cras ligula lacus, porta vitae maximus a, ultrices a mauris. Vestibulum
porta dolor erat, vel molestie dolor posuere in. Nam vel elementum augue. Nam
quis enim blandit, posuere justo dignissim, scelerisque diam. Fusce aliquet urna
ac blandit ullamcorper. Proin et semper nibh, sit amet imperdiet velit. Morbi at
quam sem.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum
a massa sit amet ullamcorper.&lt;/p&gt;
&lt;p&gt;&lt;cite&gt;Jon Doe&lt;/cite&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum a massa
sit amet ullamcorper. Suspendisse auctor ultrices ante, nec tempus nibh varius
at. Cras ligula lacus, porta vitae maximus a, ultrices a mauris. Vestibulum
porta dolor erat, vel molestie dolor posuere in. Nam vel elementum augue. Nam
quis enim blandit, posuere justo dignissim, scelerisque diam. Fusce aliquet urna
ac blandit ullamcorper. Proin et semper nibh, sit amet imperdiet velit. Morbi at
quam sem.&lt;/p&gt;
&lt;blockquote data-type=&quot;pullquote&quot;&gt;
&lt;p&gt;&lt;a href=&quot;https://web.dev/handbook/content-types/example-post/#&quot;&gt;Lorem ipsum&lt;/a&gt; dolor sit amet, consectetur adipiscing elit. Proin dictum
a massa sit amet ullamcorper.&lt;/p&gt;
&lt;p&gt;&lt;cite&gt;Jon Doe&lt;/cite&gt;&lt;/p&gt;
&lt;/blockquote&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/tabindex-zero?attributionHidden=true&amp;sidebarCollapsed=true&amp;path=index.html&amp;previewSize=100&quot; style=&quot;height: 100%; width: 100%; border: 0;&quot; title=&quot;tabindex-zero on Glitch&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;
&lt;aside class=&quot;aside flow color-secondary-box-text bg-secondary-box-bg&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; fill=&quot;currentColor&quot; role=&quot;img&quot; aria-label=&quot;Highlighter pen&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;M10.22 9.49l-5.91 6c-.77.8-.7 2.05.08 2.85L.77 22h5.68l.74-.75c.78.81 1.95.86 2.73.05l5.96-6.05-5.66-5.76zm12.46-4l-2.82-2.87c-.78-.8-2.07-.84-2.84-.04l-5.75 5.85 5.66 5.75 5.69-5.78c.77-.81.83-2.11.06-2.91z&quot;&gt;&lt;/path&gt; &lt;/svg&gt;&lt;/span&gt;&lt;strong&gt;Key Term&lt;/strong&gt;&lt;/p&gt;&lt;div class=&quot; flow&quot;&gt; This type of callout defines important terminology. &lt;/div&gt;&lt;/aside&gt;
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum a massa
sit amet ullamcorper. Suspendisse auctor ultrices ante, nec tempus nibh varius
at. Cras ligula lacus, porta vitae maximus a, ultrices a mauris. Vestibulum
porta dolor erat, vel molestie dolor posuere in. Nam vel elementum augue. Nam
quis enim blandit, posuere justo dignissim, scelerisque diam. Fusce aliquet urna
ac blandit ullamcorper. Proin et semper nibh, sit amet imperdiet velit. Morbi at
quam sem.&lt;/p&gt;
&lt;div class=&quot;codepen-embed-wrap&quot; style=&quot;height: 300px; 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://codepen.io/robdodson/embed/GRroyyX?height=300&amp;theme-id=dark&amp;default-tab=css%2Cresult&amp;editable=true&quot; style=&quot;height: 100%; width: 100%; border: 0;&quot; title=&quot;Pen GRroyyX by robdodson on Codepen&quot;&gt;See the Pen &lt;a href=&quot;https://codepen.io/robdodson/embed/GRroyyX&quot;&gt;Pen GRroyyX by robdodson on Codepen&lt;/a&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum a massa
sit amet ullamcorper. Suspendisse auctor ultrices ante, nec tempus nibh varius
at. Cras ligula lacus, porta vitae maximus a, ultrices a mauris. Vestibulum
porta dolor erat, vel molestie dolor posuere in. Nam vel elementum augue. Nam
quis enim blandit, posuere justo dignissim, scelerisque diam. Fusce aliquet urna
ac blandit ullamcorper. Proin et semper nibh, sit amet imperdiet velit. Morbi at
quam sem.&lt;/p&gt;
&lt;div class=&quot;switcher&quot;&gt;
  &lt;figure&gt;
    &lt;img alt=&quot;&quot; decoding=&quot;async&quot; height=&quot;155&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 800px) 800px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&amp;w=1428 1428w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&amp;w=1600 1600w&quot; width=&quot;800&quot; /&gt;
    &lt;figcaption&gt;
      Small image.
    &lt;/figcaption&gt;
  &lt;/figure&gt;
  &lt;figure&gt;
    &lt;img alt=&quot;&quot; decoding=&quot;async&quot; height=&quot;155&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 800px) 800px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&amp;w=1428 1428w, https://web-dev.imgix.net/image/tcFciHGuF3MxnTr1y5ue01OGLBn2/amwrx4HVBEVTEzQspIWw.png?auto=format&amp;w=1600 1600w&quot; width=&quot;800&quot; /&gt;
    &lt;figcaption&gt;
      Small image.
    &lt;/figcaption&gt;
  &lt;/figure&gt;
&lt;/div&gt;
&lt;figure class=&quot;compare flow&quot; data-type=&quot;worse&quot; data-size=&quot;full&quot;&gt;&lt;p class=&quot;compare__label&quot;&gt;Don&#39;t&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Bad code example&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;figcaption class=&quot;compare__caption&quot;&gt;
&lt;p&gt;Explanation of why &lt;code&gt;example&lt;/code&gt; is bad.&lt;/p&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;figure class=&quot;compare flow&quot; data-type=&quot;better&quot; data-size=&quot;full&quot;&gt;&lt;p class=&quot;compare__label&quot;&gt;Do&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Good code example&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;figcaption class=&quot;compare__caption&quot;&gt;
&lt;p&gt;Explanation of why &lt;code&gt;example&lt;/code&gt; is good.&lt;/p&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum a massa
sit amet ullamcorper. Suspendisse auctor ultrices ante, nec tempus nibh varius
at. Cras ligula lacus, porta vitae maximus a, ultrices a mauris. Vestibulum
porta dolor erat, vel molestie dolor posuere in. Nam vel elementum augue. Nam
quis enim blandit, posuere justo dignissim, scelerisque diam. Fusce aliquet urna
ac blandit ullamcorper. Proin et semper nibh, sit amet imperdiet velit. Morbi at
quam sem.&lt;/p&gt;
&lt;div class=&quot;stats&quot;&gt;
  &lt;div class=&quot;stats__item&quot;&gt;
    &lt;p class=&quot;stats__figure&quot;&gt;30&lt;sub&gt;%&lt;/sub&gt;&lt;/p&gt;
    &lt;p&gt;Lower cost per conversion&lt;/p&gt;
  &lt;/div&gt;
  &lt;div class=&quot;stats__item&quot;&gt;
    &lt;p class=&quot;stats__figure&quot;&gt;13&lt;sub&gt;%&lt;/sub&gt;&lt;/p&gt;
    &lt;p&gt;Higher CTR&lt;/p&gt;
  &lt;/div&gt;
  &lt;div class=&quot;stats__item&quot;&gt;
    &lt;p class=&quot;stats__figure&quot;&gt;4&lt;sub&gt;x&lt;/sub&gt;&lt;/p&gt;
    &lt;p&gt;Faster load times&lt;/p&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;all-center&quot;&gt;
  &lt;p&gt;
    &lt;a href=&quot;https://example.com/some.pdf&quot; class=&quot;button&quot;&gt;
      &lt;svg style=&quot;width:24px;height:24px&quot; viewBox=&quot;0 0 24 24&quot;&gt;
    &lt;path fill=&quot;currentColor&quot; d=&quot;M5,20H19V18H5M19,9H15V3H9V9H5L12,16L19,9Z&quot;&gt;&lt;/path&gt;
&lt;/svg&gt;
      Download case study
    &lt;/a&gt;
  &lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum a massa
sit amet ullamcorper. Suspendisse auctor ultrices ante, nec tempus nibh varius
at. Cras ligula lacus, porta vitae maximus a, ultrices a mauris. Vestibulum
porta dolor erat, vel molestie dolor posuere in. Nam vel elementum augue. Nam
quis enim blandit, posuere justo dignissim, scelerisque diam. Fusce aliquet urna
ac blandit ullamcorper. Proin et semper nibh, sit amet imperdiet velit. Morbi at
quam sem.&lt;/p&gt;
&lt;h2 id=&quot;widget&quot;&gt;Widget &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/handbook/content-types/example-post/#widget&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;[No demo found at /demos/url-parts/.]&lt;/p&gt;
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum a massa
sit amet ullamcorper. Suspendisse auctor ultrices ante, nec tempus nibh varius
at. Cras ligula lacus, porta vitae maximus a, ultrices a mauris. Vestibulum
porta dolor erat, vel molestie dolor posuere in. Nam vel elementum augue. Nam
quis enim blandit, posuere justo dignissim, scelerisque diam. Fusce aliquet urna
ac blandit ullamcorper. Proin et semper nibh, sit amet imperdiet velit. Morbi at
quam sem.&lt;/p&gt;
&lt;details&gt;
&lt;summary&gt;
  Details &lt;em&gt;summary&lt;/em&gt;
&lt;/summary&gt;
&lt;p&gt;This is an optional preview. Make your preview text match the first paragraph
of your panel text.&lt;/p&gt;
&lt;p&gt;Lorem ipsum &lt;a href=&quot;https://web.dev/handbook/content-types/example-post/#&quot;&gt;dolor sit amet&lt;/a&gt;, consectetur adipiscing elit. Proin dictum a massa
sit amet ullamcorper. &lt;code&gt;Suspendisse&lt;/code&gt; auctor ultrices ante, nec tempus nibh varius
at.&lt;/p&gt;
&lt;/details&gt;
&lt;details&gt;
&lt;summary&gt;
  Details &lt;em&gt;summary&lt;/em&gt;
&lt;/summary&gt;
&lt;p&gt;Lorem ipsum &lt;a href=&quot;https://web.dev/handbook/content-types/example-post/#&quot;&gt;dolor sit amet&lt;/a&gt;, consectetur adipiscing elit. Proin dictum a massa
sit amet ullamcorper. &lt;code&gt;Suspendisse&lt;/code&gt; auctor ultrices ante, nec tempus nibh varius
at.&lt;/p&gt;
&lt;/details&gt;
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum a massa
sit amet ullamcorper. Suspendisse auctor ultrices ante, nec tempus nibh varius
at. Cras ligula lacus, porta vitae maximus a, ultrices a mauris. Vestibulum
porta dolor erat, vel molestie dolor posuere in. Nam vel elementum augue. Nam
quis enim blandit, posuere justo dignissim, scelerisque diam. Fusce aliquet urna
ac blandit ullamcorper. Proin et semper nibh, sit amet imperdiet velit. Morbi at
quam sem.&lt;/p&gt;
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dictum a massa
sit amet ullamcorper. Suspendisse auctor ultrices ante, nec tempus nibh varius
at. Cras ligula lacus, porta vitae maximus a, ultrices a mauris. Vestibulum
porta dolor erat, vel molestie dolor posuere in. Nam vel elementum augue. Nam
quis enim blandit, posuere justo dignissim, scelerisque diam. Fusce aliquet urna
ac blandit ullamcorper. Proin et semper nibh, sit amet imperdiet velit. Morbi at
quam sem.&lt;/p&gt;
&lt;h3 id=&quot;test-of-aside-nested-in-an-ordered-list&quot;&gt;Test of Aside nested in an ordered list &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/handbook/content-types/example-post/#test-of-aside-nested-in-an-ordered-list&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;See the &lt;a href=&quot;https://github.com/GoogleChrome/web.dev/issues/7640&quot;&gt;underlying issue&lt;/a&gt;.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;First item.
Another line.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Second item.&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; This is an &lt;code&gt;&amp;lt;aside&amp;gt;&lt;/code&gt;, including &lt;a href=&quot;https://example.com/&quot;&gt;Markdown&lt;/a&gt;. &lt;/div&gt;&lt;/aside&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Third item.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
</content>
    <author>
      <name>Rob Dodson</name>
    </author>
  </entry>
  
  <entry>
    <title>Control focus with tabindex</title>
    <link href="https://web.dev/control-focus-with-tabindex/"/>
    <updated>2018-11-18T00:00:00Z</updated>
    <id>https://web.dev/control-focus-with-tabindex/</id>
    <content type="html" mode="escaped">&lt;p&gt;Standard HTML elements such as &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt; have keyboard accessibility
built in for free. If you&#39;re building &lt;em&gt;custom&lt;/em&gt; interactive components, however,
use the &lt;code&gt;tabindex&lt;/code&gt; attribute to ensure that they&#39;re keyboard accessible.&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; Whenever possible, use a built-in HTML element rather than building your own custom version. &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt;, for example, is very easy to style and already has full keyboard support. This will save you from needing to manage &lt;code&gt;tabindex&lt;/code&gt; or add semantics with ARIA. &lt;/div&gt;&lt;/aside&gt;
&lt;h2 id=&quot;check-if-your-controls-are-keyboard-accessible&quot;&gt;Check if your controls are keyboard accessible &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/control-focus-with-tabindex/#check-if-your-controls-are-keyboard-accessible&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A tool like Lighthouse is great at detecting certain accessibility issues, but
some things can only be tested by a human.&lt;/p&gt;
&lt;p&gt;Try pressing the &lt;code&gt;Tab&lt;/code&gt; key to navigate through your site. Are you able to reach
all the interactive controls on the page? If not, you may need to use
&lt;a href=&quot;https://developer.mozilla.org/docs/Web/HTML/Global_attributes/tabindex&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;tabindex&lt;/code&gt;&lt;/a&gt;
to improve the focusability of those controls.&lt;/p&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; If you don&#39;t see a focus indicator at all, it may be hidden by your CSS. Check for any styles that mention &lt;code&gt;:focus { outline: none; }&lt;/code&gt;. You can learn how to fix this in our guide on &lt;a href=&quot;https://web.dev/style-focus&quot;&gt;styling focus&lt;/a&gt;. &lt;/div&gt;&lt;/aside&gt;
&lt;h2 id=&quot;insert-an-element-into-the-tab-order&quot;&gt;Insert an element into the tab order &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/control-focus-with-tabindex/#insert-an-element-into-the-tab-order&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Insert an element into the natural tab order using &lt;code&gt;tabindex=&amp;quot;0&amp;quot;&lt;/code&gt;. For example:&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;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;Focus me with the TAB key&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;To focus an element, press the &lt;code&gt;Tab&lt;/code&gt; key or call the element&#39;s &lt;code&gt;focus()&lt;/code&gt; method.&lt;/p&gt;
&lt;div class=&quot;codepen-embed-wrap&quot; style=&quot;height: 360px; 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://codepen.io/web-dot-dev/embed/XWzzMqp?height=360&amp;theme-id=dark&amp;default-tab=result&amp;editable=true&quot; style=&quot;height: 100%; width: 100%; border: 0;&quot; title=&quot;Pen XWzzMqp by web-dot-dev on Codepen&quot;&gt;See the Pen &lt;a href=&quot;https://codepen.io/web-dot-dev/embed/XWzzMqp&quot;&gt;Pen XWzzMqp by web-dot-dev on Codepen&lt;/a&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;h2 id=&quot;remove-an-element-from-the-tab-order&quot;&gt;Remove an element from the tab order &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/control-focus-with-tabindex/#remove-an-element-from-the-tab-order&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Remove an element using &lt;code&gt;tabindex=&amp;quot;-1&amp;quot;&lt;/code&gt;. For example:&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;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;Can&#39;t reach me with the TAB key!&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;This 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 class=&quot;codepen-embed-wrap&quot; style=&quot;height: 360px; 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://codepen.io/web-dot-dev/embed/BammWGg?height=360&amp;theme-id=dark&amp;default-tab=result&amp;editable=true&quot; style=&quot;height: 100%; width: 100%; border: 0;&quot; title=&quot;Pen BammWGg by web-dot-dev on Codepen&quot;&gt;See the Pen &lt;a href=&quot;https://codepen.io/web-dot-dev/embed/BammWGg&quot;&gt;Pen BammWGg by web-dot-dev on Codepen&lt;/a&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;p&gt;Note that applying &lt;code&gt;tabindex=&amp;quot;-1&amp;quot;&lt;/code&gt; to an element doesn&#39;t affect its children;
if they&#39;re in the tab order naturally or because of a &lt;code&gt;tabindex&lt;/code&gt; value,
they&#39;ll remain in the tab order.
To remove an element and all its children from the tab order, consider using
&lt;a href=&quot;https://github.com/WICG/inert&quot; rel=&quot;noopener&quot;&gt;the WICG&#39;s &lt;code&gt;inert&lt;/code&gt; polyfill&lt;/a&gt;.
The polyfill emulates the behavior of a proposed &lt;code&gt;inert&lt;/code&gt; attribute,
which prevents elements from being selected or read by assistive technologies.&lt;/p&gt;
&lt;aside class=&quot;aside flow bg-state-bad-bg color-state-bad-text&quot;&gt;&lt;p class=&quot;cluster color-state-bad-text&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; fill=&quot;currentColor&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; role=&quot;img&quot; aria-label=&quot;Error sign&quot;&gt;   &lt;path fill-rule=&quot;evenodd&quot; clip-rule=&quot;evenodd&quot; d=&quot;M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 15v-2h2v2h-2zm0-10v6h2V7h-2z&quot;&gt;&lt;/path&gt; &lt;/svg&gt;&lt;/span&gt;&lt;strong&gt;Caution&lt;/strong&gt;&lt;/p&gt;&lt;div class=&quot; flow&quot;&gt; The &lt;code&gt;inert&lt;/code&gt; polyfill is experimental and may not work as expected in all cases. Test carefully before using in production. &lt;/div&gt;&lt;/aside&gt;
&lt;h2 id=&quot;avoid-tabindex-greater-0&quot;&gt;Avoid &lt;code&gt;tabindex &amp;gt; 0&lt;/code&gt; &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/control-focus-with-tabindex/#avoid-tabindex-greater-0&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Any &lt;code&gt;tabindex&lt;/code&gt; greater than 0 jumps the element to the front of the natural tab
order. If there are multiple elements with a &lt;code&gt;tabindex&lt;/code&gt; greater than 0, the tab
order starts from the lowest value greater than zero and works its way up.&lt;/p&gt;
&lt;p&gt;Using a &lt;code&gt;tabindex&lt;/code&gt; greater than 0 is considered an &lt;strong&gt;anti-pattern&lt;/strong&gt; because
screen readers navigate the page in DOM order, not tab order. If you need an
element to come sooner in the tab order, it should be moved to an earlier spot
in the DOM.&lt;/p&gt;
&lt;p&gt;Lighthouse makes it easy to identify elements with a &lt;code&gt;tabindex&lt;/code&gt; &amp;gt; 0. Run the
Accessibility Audit (Lighthouse &amp;gt; Options &amp;gt; Accessibility) and look for the
results of the &amp;quot;No element has a [tabindex] value greater than 0&amp;quot; audit.&lt;/p&gt;
&lt;h2 id=&quot;create-accessible-components-with-roving-tabindex&quot;&gt;Create accessible components with &amp;quot;roving &lt;code&gt;tabindex&lt;/code&gt;&amp;quot; &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/control-focus-with-tabindex/#create-accessible-components-with-roving-tabindex&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;If you&#39;re building a complex component, you may need to add additional keyboard
support beyond focus. Consider the built-in &lt;code&gt;select&lt;/code&gt; element. It is focusable and
you can use the arrow keys to expose additional functionality (the selectable
options).&lt;/p&gt;
&lt;p&gt;To implement similar functionality in your own components, use a technique known
as &amp;quot;roving &lt;code&gt;tabindex&lt;/code&gt;&amp;quot;. Roving tabindex works by setting &lt;code&gt;tabindex&lt;/code&gt; to -1 for
all children except the currently-active one. The component then uses a keyboard
event listener to determine which key the user has pressed.&lt;/p&gt;
&lt;p&gt;When this happens, the component 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 &lt;code&gt;focus()&lt;/code&gt;
method on it.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Before&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;highlight-line&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;toolbar&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&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&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;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;Undo&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;/span&gt;&lt;br /&gt;&lt;mark class=&quot;highlight-line highlight-line-active&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;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;Redo&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;/mark&gt;&lt;br /&gt;&lt;mark class=&quot;highlight-line highlight-line-active&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;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;Cut&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;/mark&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&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 punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;&lt;strong&gt;After&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;highlight-line&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;toolbar&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&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&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;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;Undo&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;/span&gt;&lt;br /&gt;&lt;mark class=&quot;highlight-line highlight-line-active&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;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;Redo&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;/mark&gt;&lt;br /&gt;&lt;mark class=&quot;highlight-line highlight-line-active&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;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;Cut&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;/mark&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&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 punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;div class=&quot;codepen-embed-wrap&quot; style=&quot;height: 360px; 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://codepen.io/web-dot-dev/embed/LYOOWam?height=360&amp;theme-id=dark&amp;default-tab=result&amp;editable=true&quot; style=&quot;height: 100%; width: 100%; border: 0;&quot; title=&quot;Pen LYOOWam by web-dot-dev on Codepen&quot;&gt;See the Pen &lt;a href=&quot;https://codepen.io/web-dot-dev/embed/LYOOWam&quot;&gt;Pen LYOOWam by web-dot-dev on Codepen&lt;/a&gt;&lt;/iframe&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; Curious what those &lt;code&gt;role=&amp;quot;&amp;quot;&lt;/code&gt; attributes are for? They let you change the semantics of an element so it will be announced properly by a screen reader. You can learn more about them in our guide on &lt;a href=&quot;https://web.dev/semantics-and-screen-readers&quot;&gt;screen reader basics&lt;/a&gt;. &lt;/div&gt;&lt;/aside&gt;
&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;web-assessment aria-label=&quot;Check your understanding&quot;&gt;   &lt;div class=&quot;web-assessment__set-leader&quot;&gt;Test your knowledge of tab order &lt;/div&gt; &lt;web-tabs class=&quot;web-assessment__content unresolved&quot; label=&quot;samples for knowledge self check&quot;&gt;         &lt;web-question question-height=&quot;unset&quot; data-label=&quot;sample&quot;&gt;   &lt;div data-role=&quot;stimulus&quot;&gt;&lt;p&gt;This HTML renders a modal dialog:&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;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;dialog&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-labelledby&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;dialog-header&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;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;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;Close&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;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;&amp;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 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;dialog-header&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    Do you want to allow notifications from this website?&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;&amp;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;&amp;gt;&lt;/span&gt;&lt;/span&gt;No&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;&amp;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;&amp;gt;&lt;/span&gt;&lt;/span&gt;Yes&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;&amp;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;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt; &lt;/div&gt;&lt;/div&gt; &lt;web-response-tac data-role=&quot;response&quot;&gt;   &lt;p data-role=&quot;stem&quot;&gt;What is the tab order for the elements in the sample?&lt;/p&gt;      &lt;div data-role=&quot;rationale&quot;&gt;&lt;ol&gt; &lt;li&gt;The &lt;strong&gt;Close&lt;/strong&gt; button&lt;/li&gt; &lt;li&gt;The &lt;strong&gt;No&lt;/strong&gt; button&lt;/li&gt; &lt;li&gt;The &lt;strong&gt;Yes&lt;/strong&gt; button&lt;/li&gt; &lt;/ol&gt; &lt;p&gt;Only the &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt; elements are included in the tab order because they&#39;re the only standardized HTML form elements. To insert other elements into the tab order, you would add a &lt;code&gt;tabindex&lt;/code&gt; attribute.&lt;/p&gt; &lt;/div&gt; &lt;/web-response-tac&gt; &lt;/web-question&gt;         &lt;web-question question-height=&quot;unset&quot; data-label=&quot;sample&quot;&gt;   &lt;div data-role=&quot;stimulus&quot;&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;section&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;&amp;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;&amp;gt;&lt;/span&gt;&lt;/span&gt;Cat facts&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;&amp;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;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;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;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;A group of cats is called a &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;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&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;https://m-w.com/dictionary/clowder&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;clowder&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;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;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;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;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;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;Most cats are &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;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&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;https://www.catfacts.org/catnip.html&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt; unaffected by catnip&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;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;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;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;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;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;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;section&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt; &lt;/div&gt;&lt;/div&gt; &lt;web-response-tac data-role=&quot;response&quot;&gt;   &lt;p data-role=&quot;stem&quot;&gt;Which elements from the sample are included in the tab order?&lt;/p&gt;      &lt;div data-role=&quot;rationale&quot;&gt;&lt;p&gt;Only the &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; elements are included in the tab order.&lt;/p&gt; &lt;p&gt;The &lt;code&gt;&amp;lt;section&amp;gt;&lt;/code&gt; element is not in the tab order because it has a negative &lt;code&gt;tabindex&lt;/code&gt; value. (It can, however, be focused using the &lt;code&gt;focus()&lt;/code&gt; method.) The &lt;code&gt;tabindex&lt;/code&gt; value for the &lt;code&gt;&amp;lt;section&amp;gt;&lt;/code&gt; element doesn&#39;t affect its children.&lt;/p&gt; &lt;/div&gt; &lt;/web-response-tac&gt; &lt;/web-question&gt;         &lt;web-question question-height=&quot;unset&quot; data-label=&quot;sample&quot;&gt;   &lt;div data-role=&quot;stimulus&quot;&gt;&lt;p&gt;This HTML renders a popup menu followed by a search input:&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;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;menu&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;0&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;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;a&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;menuitem&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&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;/learn/&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;&amp;gt;&lt;/span&gt;&lt;/span&gt;Learn&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;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;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;a&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;menuitem&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&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;/measure/&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;&amp;gt;&lt;/span&gt;&lt;/span&gt;Measure&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;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;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;a&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;menuitem&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&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;/blog/&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;&amp;gt;&lt;/span&gt;&lt;/span&gt;Blog&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;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;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;a&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;menuitem&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&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;/about/&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;&amp;gt;&lt;/span&gt;&lt;/span&gt;About&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;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;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;&amp;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;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 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;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;search&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-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;Search&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;placeholder&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;Search&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt; &lt;/div&gt;&lt;/div&gt; &lt;web-response-tac data-role=&quot;response&quot;&gt;   &lt;p data-role=&quot;stem&quot;&gt;Which element in the sample comes first in the tab order?&lt;/p&gt;      &lt;div data-role=&quot;rationale&quot;&gt;&lt;p&gt;The &lt;strong&gt;Search&lt;/strong&gt; text input comes first in the tab order. Because it has a &lt;code&gt;tabindex&lt;/code&gt; greater than zero, it jumps to the front of the tab order.&lt;/p&gt; &lt;p&gt;(This behavior is likely to cause confusion if the menu is positioned on the page before the search input. This is an example of why having a &lt;code&gt;tabindex&lt;/code&gt; value greater than zero is considered an anti-pattern.)&lt;/p&gt; &lt;/div&gt; &lt;/web-response-tac&gt; &lt;/web-question&gt;         &lt;web-question question-height=&quot;unset&quot; data-label=&quot;sample&quot;&gt;   &lt;div data-role=&quot;stimulus&quot;&gt;&lt;p&gt;This HTML renders a custom radio group, which should have a &lt;a href=&quot;https://web.dev/control-focus-with-tabindex/#create-accessible-components-with-roving-tabindex&quot;&gt;roving &lt;code&gt;tabindex&lt;/code&gt;&lt;/a&gt;. (To keep things simpler, ignore the &lt;a href=&quot;https://web.dev/semantics-and-screen-readers&quot;&gt;&lt;code&gt;aria-*&lt;/code&gt; attributes&lt;/a&gt; for now.)&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;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;radiogroup&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-labelledby&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;breed-header&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;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;h3&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;breed-header&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;Your cat&#39;s breed&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;h3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;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;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;radio&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-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;false&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;0&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;Persian&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;&amp;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;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;radio&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-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;false&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;&amp;gt;&lt;/span&gt;&lt;/span&gt;Bengal&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;&amp;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;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;radio&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-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;false&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;&amp;gt;&lt;/span&gt;&lt;/span&gt;Maine Coon&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;&amp;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;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt; &lt;/div&gt;&lt;/div&gt; &lt;web-response-tac data-role=&quot;response&quot;&gt;   &lt;p data-role=&quot;stem&quot;&gt;When a &lt;code&gt;role=&quot;radio&quot;&lt;/code&gt; element is focused, what should happen when a user presses the &lt;code&gt;Right&lt;/code&gt; arrow key? &lt;/p&gt;      &lt;div data-role=&quot;rationale&quot;&gt;&lt;ul&gt; &lt;li&gt;Change the &lt;code&gt;tabindex&lt;/code&gt; values for all radio elements in the group to -1.&lt;/li&gt; &lt;li&gt;If there&#39;s a radio element after the one that&#39;s focused, set its &lt;code&gt;tabindex&lt;/code&gt; value to 0.&lt;/li&gt; &lt;li&gt;If there&#39;s no radio element after the one that&#39;s focused, set the &lt;code&gt;tabindex&lt;/code&gt; value of the first radio element in the group to 0.&lt;/li&gt; &lt;li&gt;Focus the radio element that now has a &lt;code&gt;tabindex&lt;/code&gt; of 0.&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;That&#39;s a lot—and it doesn&#39;t even include ARIA attributes! This is an example of why it&#39;s easier to use built-in elements with built-in keyboard behavior whenever you can.&lt;/p&gt; &lt;/div&gt; &lt;/web-response-tac&gt; &lt;/web-question&gt;       &lt;/web-tabs&gt; &lt;/web-assessment&gt;&lt;/body&gt;&lt;/html&gt;
&lt;h2 id=&quot;keyboard-access-recipes&quot;&gt;Keyboard access recipes &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/control-focus-with-tabindex/#keyboard-access-recipes&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;If you&#39;re unsure what level of keyboard support your custom components might
need, you can refer to the
&lt;a href=&quot;https://www.w3.org/TR/wai-aria-practices-1.1/&quot; rel=&quot;noopener&quot;&gt;ARIA Authoring Practices 1.1&lt;/a&gt;.
This handy guide lists common UI patterns and identifies which keys your
components should support.&lt;/p&gt;
</content>
    <author>
      <name>Rob Dodson</name>
    </author>
  </entry>
  
  <entry>
    <title>Headings and landmarks</title>
    <link href="https://web.dev/headings-and-landmarks/"/>
    <updated>2018-11-18T00:00:00Z</updated>
    <id>https://web.dev/headings-and-landmarks/</id>
    <content type="html" mode="escaped">&lt;p&gt;Screen readers have commands to quickly jump between headings or to specific
landmark regions. In fact,
&lt;a href=&quot;http://www.heydonworks.com/article/responses-to-the-screen-reader-strategy-survey&quot; rel=&quot;noopener&quot;&gt;a survey of screen reader users&lt;/a&gt;
found that they most often navigate an unfamiliar page by exploring the
headings.&lt;/p&gt;
&lt;p&gt;By using correct heading and landmark elements, you can dramatically
improve the navigation experience on your site for users of assistive technologies.&lt;/p&gt;
&lt;h2 id=&quot;use-headings-to-outline-the-page&quot;&gt;Use headings to outline the page &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/headings-and-landmarks/#use-headings-to-outline-the-page&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Use &lt;code&gt;h1&lt;/code&gt;-&lt;code&gt;h6&lt;/code&gt; elements to create a &lt;em&gt;structural&lt;/em&gt; outline for your page. The goal is
to create a skeleton or scaffold of the page such that anyone navigating by
headings can form a mental picture.&lt;/p&gt;
&lt;p&gt;A common practice is to use a single &lt;code&gt;h1&lt;/code&gt; for the primary headline or logo on a
page, &lt;code&gt;h2&lt;/code&gt; elements to designate major sections, and &lt;code&gt;h3&lt;/code&gt; elements in supporting subsections:&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;h1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Company name&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;h1&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;section&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;Section Heading&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;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;h3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Sub-section Heading&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;h3&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;section&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;dont-skip-heading-levels&quot;&gt;Don&#39;t skip heading levels &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/headings-and-landmarks/#dont-skip-heading-levels&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Developers often skip heading levels to use the browser&#39;s default styles that
closely match their design. This is considered an anti-pattern because it breaks
the outline model.&lt;/p&gt;
&lt;p&gt;Instead of relying on the browser&#39;s default font-sizing for headings, use your
own CSS, and don&#39;t skip levels.&lt;/p&gt;
&lt;p&gt;For example, this site has a section called &amp;quot;IN THE NEWS&amp;quot;, followed by two
headlines:&lt;/p&gt;
&lt;img alt=&quot;A news site with a headline, hero image, and subsections.&quot; decoding=&quot;async&quot; height=&quot;414&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 800px) 800px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/admin/CdBjBuUo2yVVHWVFnQzx.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/admin/CdBjBuUo2yVVHWVFnQzx.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/admin/CdBjBuUo2yVVHWVFnQzx.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/admin/CdBjBuUo2yVVHWVFnQzx.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/admin/CdBjBuUo2yVVHWVFnQzx.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/admin/CdBjBuUo2yVVHWVFnQzx.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/admin/CdBjBuUo2yVVHWVFnQzx.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/admin/CdBjBuUo2yVVHWVFnQzx.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/admin/CdBjBuUo2yVVHWVFnQzx.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/admin/CdBjBuUo2yVVHWVFnQzx.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/admin/CdBjBuUo2yVVHWVFnQzx.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/admin/CdBjBuUo2yVVHWVFnQzx.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/admin/CdBjBuUo2yVVHWVFnQzx.png?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/admin/CdBjBuUo2yVVHWVFnQzx.png?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/admin/CdBjBuUo2yVVHWVFnQzx.png?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/admin/CdBjBuUo2yVVHWVFnQzx.png?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/admin/CdBjBuUo2yVVHWVFnQzx.png?auto=format&amp;w=1428 1428w, https://web-dev.imgix.net/image/admin/CdBjBuUo2yVVHWVFnQzx.png?auto=format&amp;w=1600 1600w&quot; width=&quot;800&quot; /&gt;
&lt;p&gt;The section heading, &amp;quot;IN THE NEWS&amp;quot;, could be an &lt;code&gt;h2&lt;/code&gt;, and the supporting
headlines could both be &lt;code&gt;h3&lt;/code&gt; elements.&lt;/p&gt;
&lt;p&gt;Because the &lt;code&gt;font-size&lt;/code&gt; for &amp;quot;IN THE NEWS&amp;quot; is &lt;em&gt;smaller&lt;/em&gt; than the headline, it may
be tempting to make the headline for the first story an &lt;code&gt;h2&lt;/code&gt; and to make
&amp;quot;IN THE NEWS&amp;quot; an &lt;code&gt;h3&lt;/code&gt;. While that may match the browser&#39;s default styling,
it would break the outline conveyed to a screen reader user!&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; Though it may seem counterintuitive, it does not matter if &lt;em&gt;visually&lt;/em&gt; &lt;code&gt;h3&lt;/code&gt; and &lt;code&gt;h4&lt;/code&gt; elements are larger than their &lt;code&gt;h2&lt;/code&gt; or &lt;code&gt;h1&lt;/code&gt; counterparts. What matters is the outline conveyed by the elements and elements&#39; ordering. &lt;/div&gt;&lt;/aside&gt;
&lt;p&gt;You can use Lighthouse to check if your page skips any heading levels. Run the
Accessibility audit (&lt;strong&gt;Lighthouse &amp;gt; Options &amp;gt; Accessibility&lt;/strong&gt;) and look
for the results of the &lt;strong&gt;Headings don&#39;t skip levels&lt;/strong&gt; audit.&lt;/p&gt;
&lt;h2 id=&quot;use-landmarks-to-aid-navigation&quot;&gt;Use landmarks to aid navigation &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/headings-and-landmarks/#use-landmarks-to-aid-navigation&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;HTML5 elements such as &lt;code&gt;main&lt;/code&gt;, &lt;code&gt;nav&lt;/code&gt;, and &lt;code&gt;aside&lt;/code&gt; act as &lt;strong&gt;landmarks&lt;/strong&gt;, or
special regions on the page to which a screen reader can jump.&lt;/p&gt;
&lt;p&gt;Use landmark tags to define major sections of your page, instead of relying on
&lt;code&gt;div&lt;/code&gt;s. Be careful not to go overboard because having &lt;em&gt;too many&lt;/em&gt; landmarks can be
overwhelming. For example, stick to just one &lt;code&gt;main&lt;/code&gt; element instead of 3 or
4.&lt;/p&gt;
&lt;p&gt;Lighthouse recommends manually auditing your site to check that &amp;quot;HTML5 landmark
elements are used to improve navigation.&amp;quot; You can use this &lt;a href=&quot;https://www.w3.org/TR/2017/NOTE-wai-aria-practices-1.1-20171214/examples/landmarks/HTML5.html&quot; rel=&quot;noopener&quot;&gt;list of landmark
elements&lt;/a&gt;
to check your page.&lt;/p&gt;
&lt;h2 id=&quot;bypass-repetitive-content-with-skip-links&quot;&gt;Bypass repetitive content with skip links &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/headings-and-landmarks/#bypass-repetitive-content-with-skip-links&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Many sites contain repetitive navigation in their headers, which can be annoying
to navigate with assistive technology. Use a &lt;strong&gt;skip link&lt;/strong&gt; to let users bypass this content.&lt;/p&gt;
&lt;p&gt;A skip link is an offscreen anchor that is always the first focusable item in
the DOM. Typically, it contains an in-page link to the main content of the page. Because it is
the first element in the DOM, it only takes a single action from assistive technology to focus
it and bypass repetitive navigation.&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;!-- index.html --&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;a&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;skip-link&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&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;Skip to main&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;a&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;main&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;  [Main content]&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;main&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&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/* style.css */&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token selector&quot;&gt;.skip-link&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;top&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; -40px&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; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;background&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; #000000&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; white&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; 8px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token property&quot;&gt;z-index&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 100&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 selector&quot;&gt;.skip-link:focus&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;top&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&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;aside class=&quot;aside flow bg-quaternary-box-bg color-quaternary-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; fill=&quot;currentColor&quot; role=&quot;img&quot; aria-label=&quot;Code brackets&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;M9.41 16.59L8 18l-6-6 6-6 1.41 1.41L4.83 12l4.58 4.59zm5.18-9.18L16 6l6 6-6 6-1.41-1.41L19.17 12l-4.58-4.59z&quot;&gt;&lt;/path&gt; &lt;/svg&gt;&lt;/span&gt;&lt;strong&gt;Try it&lt;/strong&gt;&lt;/p&gt;&lt;div class=&quot; flow&quot;&gt; &lt;a href=&quot;https://skip-link.glitch.me/&quot;&gt;Live skip link example.&lt;/a&gt; &lt;/div&gt;&lt;/aside&gt;
&lt;p&gt;Many popular sites such as &lt;a href=&quot;https://github.com/&quot; rel=&quot;noopener&quot;&gt;GitHub&lt;/a&gt;, &lt;a href=&quot;https://www.nytimes.com/&quot; rel=&quot;noopener&quot;&gt;The NY
Times&lt;/a&gt;, and &lt;a href=&quot;https://wikipedia.org/&quot; rel=&quot;noopener&quot;&gt;Wikipedia&lt;/a&gt; all
contain skip links. Try visiting them and pressing the &lt;code&gt;TAB&lt;/code&gt; key on your
keyboard a few times.&lt;/p&gt;
&lt;p&gt;Lighthouse can help you check if your page contains a skip link. Run the
Accessibility audit again and look for the results of the &lt;strong&gt;The page contains a
heading, skip link, or landmark region&lt;/strong&gt; audit.&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; Technically, this test will also pass if your site contains any &lt;code&gt;h1&lt;/code&gt;-&lt;code&gt;h6&lt;/code&gt; elements or any of the HTML5 landmark elements. But although the test is vague in its requirements, it&#39;s still nice to pass it if you can! &lt;/div&gt;&lt;/aside&gt;
</content>
    <author>
      <name>Rob Dodson</name>
    </author>
  </entry>
  
  <entry>
    <title>Keyboard access fundamentals</title>
    <link href="https://web.dev/keyboard-access/"/>
    <updated>2018-11-18T00:00:00Z</updated>
    <id>https://web.dev/keyboard-access/</id>
    <content type="html" mode="escaped">&lt;p&gt;Many different users rely on the keyboard to navigate applications—from users
with temporary and permanent motor impairments to users who use keyboard
shortcuts to be more efficient and productive. Having a good keyboard navigation
strategy for your application creates a better experience for everyone.&lt;/p&gt;
&lt;h2 id=&quot;focus-and-the-tab-order&quot;&gt;Focus and the tab order &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/keyboard-access/#focus-and-the-tab-order&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;At a given moment, &lt;strong&gt;focus&lt;/strong&gt; refers to what element in your application (such as
a field, checkbox, button, or link) currently receives input from the keyboard.
In addition to receiving keyboard events, the focused element also gets content
that is pasted from the clipboard.&lt;/p&gt;
&lt;p&gt;To move the focus on a page, use &lt;code&gt;TAB&lt;/code&gt; to navigate &amp;quot;forward&amp;quot; and &lt;code&gt;SHIFT + TAB&lt;/code&gt;
to navigate &amp;quot;backward.&amp;quot; The currently focused element is often indicated by a
&lt;strong&gt;focus ring&lt;/strong&gt;, and various browsers style their focus rings differently. The
order in which focus proceeds forward and backward through interactive elements
is called the &lt;strong&gt;tab order&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Interactive HTML elements like text fields, buttons, and select lists are
&lt;strong&gt;implicitly focusable&lt;/strong&gt;: they are automatically inserted into the tab order
based on their position in the
&lt;a href=&quot;https://developer.mozilla.org/docs/Web/API/Document_Object_Model&quot; rel=&quot;noopener&quot;&gt;DOM&lt;/a&gt;.
These interactive elements also have built-in keyboard event handling. Elements
such as paragraphs and divs are not implicitly focusable because users typically
do not need to interact with them.&lt;/p&gt;
&lt;p&gt;Implementing a logical tab order is an important part of providing your users
with a smooth keyboard navigation experience. There are two main ideas to keep
in mind when assessing and adjusting your tab order:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Arrange elements in the DOM to be in logical order&lt;/li&gt;
&lt;li&gt;Correctly set the visibility of offscreen content that should not receive
focus&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;arrange-elements-in-the-dom-to-be-in-logical-order&quot;&gt;Arrange elements in the DOM to be in logical order &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/keyboard-access/#arrange-elements-in-the-dom-to-be-in-logical-order&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;To check if your application&#39;s tab order is logical, try tabbing through your
page. In general, focus should follow reading order, moving from left to right,
from the top to the bottom of your page.&lt;/p&gt;
&lt;p&gt;If the focus order seems wrong, you should rearrange the elements in the DOM to
make the tab order more natural. &lt;strong&gt;If you want something to appear visually
earlier on the screen, move it earlier in the DOM&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Try tabbing through the two sets of buttons below to experience a logical tab
order versus an illogical tab order:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Logical tab order&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;glitch-embed-wrap&quot; style=&quot;height: 346px; 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/logical-tab-order?attributionHidden=true&amp;sidebarCollapsed=true&amp;path=index.html&amp;previewSize=100&quot; style=&quot;height: 100%; width: 100%; border: 0;&quot; title=&quot;logical-tab-order on Glitch&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Illogical tab order&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;glitch-embed-wrap&quot; style=&quot;height: 346px; 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/illogical-tab-order?attributionHidden=true&amp;sidebarCollapsed=true&amp;path=index.html&amp;previewSize=100&quot; style=&quot;height: 100%; width: 100%; border: 0;&quot; title=&quot;illogical-tab-order on Glitch&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;
&lt;p&gt;The code for these two examples is compared below:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Logical tab order&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;Kiwi&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;Peach&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;Coconut&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;strong&gt;Illogical tab order&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;mark class=&quot;highlight-line highlight-line-active&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;Kiwi&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;/mark&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&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;Peach&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;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&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;Coconut&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;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;Be careful when changing the visual position of elements using CSS to avoid
creating an illogical tab order. To fix the illogical tab order above, move the
floating &amp;quot;Kiwi&amp;quot; button so it comes after the &amp;quot;Coconut&amp;quot; button in the DOM, and
remove the inline style.&lt;/p&gt;
&lt;h2 id=&quot;correctly-set-the-visibility-of-offscreen-content&quot;&gt;Correctly set the visibility of offscreen content &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/keyboard-access/#correctly-set-the-visibility-of-offscreen-content&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Sometimes offscreen interactive elements need to be in the DOM but should not be
in your tab order. For example, if you have a responsive side-nav that opens
when you click a button, the user should not be able to focus on the side-nav
when it&#39;s closed.&lt;/p&gt;
&lt;p&gt;To prevent a particular interactive element from receiving focus, you should
give the element either of the following CSS properties:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;display: none&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;visibility: hidden&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To add the element back into the tab order, for example when the side-nav is
opened, replace the above CSS properties respectively with:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;display: block&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;visibility: visible&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;aside class=&quot;aside flow bg-state-info-bg color-state-info-text&quot;&gt;&lt;div class=&quot; flow&quot;&gt; If you can&#39;t figure out where the focus on your page is as you&#39;re tabbing, open the console and type: &lt;code&gt;document.activeElement&lt;/code&gt;. This property will return the element that currently has focus. &lt;/div&gt;&lt;/aside&gt;
&lt;h2 id=&quot;next-steps&quot;&gt;Next steps &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/keyboard-access/#next-steps&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;For users who operate their computer almost entirely with the keyboard or
another input device, a logical tab order is essential for making your
application accessible and usable. As a good habit for checking your tab order,
try &lt;strong&gt;tabbing through your application before each publish&lt;/strong&gt;.&lt;/p&gt;
</content>
    <author>
      <name>Rob Dodson</name>
    </author>
  </entry>
  
  <entry>
    <title>Labels and text alternatives</title>
    <link href="https://web.dev/labels-and-text-alternatives/"/>
    <updated>2018-11-18T00:00:00Z</updated>
    <id>https://web.dev/labels-and-text-alternatives/</id>
    <content type="html" mode="escaped">&lt;p&gt;In order for a screen reader to present a spoken UI to the user, meaningful
elements must have proper labels or text alternatives. A label or text
alternative gives an element its accessible &lt;strong&gt;name&lt;/strong&gt;, one of the key properties
for &lt;a href=&quot;https://web.dev/semantics-and-screen-readers/#semantic-properties-and-the-accessibility-tree&quot;&gt;expressing element semantics in the accessibility tree&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;When an element&#39;s name is combined with the element&#39;s &lt;strong&gt;role&lt;/strong&gt;, it gives the
user context so they can understand what type of element they&#39;re interacting
with and how it is represented on the page. If a name is not present, then a
screen reader only announces the element&#39;s role. Imagine trying to navigate
a page and hearing, &amp;quot;button,&amp;quot; &amp;quot;checkbox,&amp;quot; &amp;quot;image&amp;quot; without any additional
context. This is why labeling and text alternatives are crucial to a good,
accessible experience.&lt;/p&gt;
&lt;h2 id=&quot;inspect-an-elements-name&quot;&gt;Inspect an element&#39;s name &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/labels-and-text-alternatives/#inspect-an-elements-name&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;It&#39;s easy to check an element&#39;s accessible name using Chrome&#39;s DevTools:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Right-click on an element and choose &lt;strong&gt;Inspect&lt;/strong&gt;. This opens the DevTools
Elements panel.&lt;/li&gt;
&lt;li&gt;In the Elements panel, look for the &lt;strong&gt;Accessibility&lt;/strong&gt; pane. It may be hidden
behind a &lt;code&gt;»&lt;/code&gt; symbol.&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;Computed Properties&lt;/strong&gt; dropdown, look for the &lt;strong&gt;Name&lt;/strong&gt; property.&lt;/li&gt;
&lt;/ol&gt;
&lt;figure&gt;
  &lt;img alt=&quot;&quot; decoding=&quot;async&quot; height=&quot;471&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 800px) 800px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/admin/38c68DmamTCqt2LFxTmu.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/admin/38c68DmamTCqt2LFxTmu.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/admin/38c68DmamTCqt2LFxTmu.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/admin/38c68DmamTCqt2LFxTmu.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/admin/38c68DmamTCqt2LFxTmu.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/admin/38c68DmamTCqt2LFxTmu.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/admin/38c68DmamTCqt2LFxTmu.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/admin/38c68DmamTCqt2LFxTmu.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/admin/38c68DmamTCqt2LFxTmu.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/admin/38c68DmamTCqt2LFxTmu.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/admin/38c68DmamTCqt2LFxTmu.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/admin/38c68DmamTCqt2LFxTmu.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/admin/38c68DmamTCqt2LFxTmu.png?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/admin/38c68DmamTCqt2LFxTmu.png?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/admin/38c68DmamTCqt2LFxTmu.png?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/admin/38c68DmamTCqt2LFxTmu.png?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/admin/38c68DmamTCqt2LFxTmu.png?auto=format&amp;w=1428 1428w, https://web-dev.imgix.net/image/admin/38c68DmamTCqt2LFxTmu.png?auto=format&amp;w=1600 1600w&quot; width=&quot;800&quot; /&gt;
  &lt;figcaption&gt;
    DevTools accessibility pane showing the computed name for a button.
  &lt;/figcaption&gt;
&lt;/figure&gt;
&lt;aside class=&quot;aside flow bg-state-info-bg color-state-info-text&quot;&gt;&lt;div class=&quot; flow&quot;&gt; To learn more, check out the &lt;a href=&quot;https://developer.chrome.com/docs/devtools/accessibility/reference/&quot;&gt;DevTools Accessibility Reference&lt;/a&gt;. &lt;/div&gt;&lt;/aside&gt;
&lt;p&gt;Whether you&#39;re looking at an &lt;code&gt;img&lt;/code&gt; with &lt;code&gt;alt&lt;/code&gt; text or an &lt;code&gt;input&lt;/code&gt; with a
&lt;code&gt;label&lt;/code&gt;, all of these scenarios result in the same outcome: giving an
element its accessible name.&lt;/p&gt;
&lt;h2 id=&quot;check-for-missing-names&quot;&gt;Check for missing names &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/labels-and-text-alternatives/#check-for-missing-names&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;There are different ways to add an accessible name to an element,
depending on its type. The following table lists the most common element types
that need accessible names and links to explanations for how to add them.&lt;/p&gt;
&lt;div class=&quot;table-wrapper&quot;&gt;
  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;Element type&lt;/th&gt;
        &lt;th&gt;How to add a name&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;
          HTML document
        &lt;/td&gt;
        &lt;td&gt;
          &lt;a href=&quot;https://web.dev/labels-and-text-alternatives/#label-documents-and-frames&quot;&gt;Label documents and frames&lt;/a&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;
          &lt;code&gt;&amp;lt;frame&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;iframe&amp;gt;&lt;/code&gt; elements
        &lt;/td&gt;
        &lt;td&gt;
          &lt;a href=&quot;https://web.dev/labels-and-text-alternatives/#label-documents-and-frames&quot;&gt;Label documents and frames&lt;/a&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;
          Image elements
        &lt;/td&gt;
        &lt;td&gt;
          &lt;a href=&quot;https://web.dev/labels-and-text-alternatives/#include-text-alternatives-for-images-and-objects&quot;&gt;
            Include text alternatives for images and objects
          &lt;/a&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;
          &lt;code&gt;&amp;lt;input type=&quot;image&quot;&amp;gt;&lt;/code&gt; elements
        &lt;/td&gt;
        &lt;td&gt;
          &lt;a href=&quot;https://web.dev/labels-and-text-alternatives/#include-text-alternatives-for-images-and-objects&quot;&gt;
            Include text alternatives for images and objects
          &lt;/a&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;
          &lt;code&gt;&amp;lt;object&amp;gt;&lt;/code&gt; elements
        &lt;/td&gt;
        &lt;td&gt;
          &lt;a href=&quot;https://web.dev/labels-and-text-alternatives/#include-text-alternatives-for-images-and-objects&quot;&gt;
            Include text alternatives for images and objects
          &lt;/a&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;
          Buttons
        &lt;/td&gt;
        &lt;td&gt;
          &lt;a href=&quot;https://web.dev/labels-and-text-alternatives/#label-buttons-and-links&quot;&gt;Label buttons and links&lt;/a&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;
          Links
        &lt;/td&gt;
        &lt;td&gt;
          &lt;a href=&quot;https://web.dev/labels-and-text-alternatives/#label-buttons-and-links&quot;&gt;Label buttons and links&lt;/a&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;
          Form elements
        &lt;/td&gt;
        &lt;td&gt;
          &lt;a href=&quot;https://web.dev/labels-and-text-alternatives/#label-form-elements&quot;&gt;Label form elements&lt;/a&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;
&lt;/div&gt;
&lt;h2 id=&quot;label-documents-and-frames&quot;&gt;Label documents and frames &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/labels-and-text-alternatives/#label-documents-and-frames&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Every page should have a
&lt;a href=&quot;https://developer.mozilla.org/docs/Web/HTML/Element/title&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;title&lt;/code&gt;&lt;/a&gt;
element that briefly explains what the page is about. The &lt;code&gt;title&lt;/code&gt; element gives
the page its accessible name. When a screen reader enters the page, this is the
first text that is announced.&lt;/p&gt;
&lt;p&gt;For example, the page below has the title &amp;quot;Mary&#39;s Maple Bar Fast-Baking Recipe&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;highlight-line&quot;&gt;&lt;span class=&quot;token doctype&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;!&lt;/span&gt;&lt;span class=&quot;token doctype-tag&quot;&gt;doctype&lt;/span&gt; &lt;span class=&quot;token name&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&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;html&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;lang&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;en&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&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&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;head&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;mark class=&quot;highlight-line highlight-line-active&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;title&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Mary&#39;s Maple Bar Fast-Baking Recipe&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;title&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/mark&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&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;head&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&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;body&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    …&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&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;body&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&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;html&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&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; For tips on writing effective titles, see the &lt;a href=&quot;https://web.dev/write-descriptive-text&quot;&gt;Write descriptive titles guide&lt;/a&gt;. &lt;/div&gt;&lt;/aside&gt;
&lt;p&gt;Similarly, any &lt;code&gt;frame&lt;/code&gt; or &lt;code&gt;iframe&lt;/code&gt; elements should have &lt;code&gt;title&lt;/code&gt; attributes:&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;iframe&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;title&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;An interactive map of San Francisco&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;…&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;iframe&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 an &lt;code&gt;iframe&lt;/code&gt;&#39;s contents may contain their own internal &lt;code&gt;title&lt;/code&gt; element, a
screen reader usually stops at the frame boundary and announces the element&#39;s
role—&amp;quot;frame&amp;quot;—and its accessible name, provided by the &lt;code&gt;title&lt;/code&gt; attribute. This
lets the user decide if they wish to enter the frame or bypass it.&lt;/p&gt;
&lt;h2 id=&quot;include-text-alternatives-for-images-and-objects&quot;&gt;Include text alternatives for images and objects &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/labels-and-text-alternatives/#include-text-alternatives-for-images-and-objects&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;An &lt;code&gt;img&lt;/code&gt; should always be accompanied by an
&lt;a href=&quot;https://developer.mozilla.org/docs/Web/HTML/Element/img#Attributes&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;alt&lt;/code&gt;&lt;/a&gt;
attribute to give the image its accessible name. If the image fails to load, the
&lt;code&gt;alt&lt;/code&gt; text is used as a placeholder so users have a sense of what the image was
trying to convey.&lt;/p&gt;
&lt;p&gt;Writing good &lt;code&gt;alt&lt;/code&gt; text is a bit of an art, but there are a couple of guidelines
you can follow:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Determine if the image provides content that would otherwise be difficult to
attain from reading the surrounding text.&lt;/li&gt;
&lt;li&gt;If so, convey the content as succinctly as possible.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If the image acts as decoration and does not provide any useful content,
you can give it an empty &lt;code&gt;alt=&amp;quot;&amp;quot;&lt;/code&gt; attribute to remove it from the accessibility
tree.&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; Learn more about writing effective &lt;code&gt;alt&lt;/code&gt; text by checking out &lt;a href=&quot;https://webaim.org/techniques/alttext/&quot;&gt;WebAIM&#39;s guide to Alternative Text&lt;/a&gt;. &lt;/div&gt;&lt;/aside&gt;
&lt;h3 id=&quot;images-as-links-and-inputs&quot;&gt;Images as links and inputs &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/labels-and-text-alternatives/#images-as-links-and-inputs&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;An image wrapped in a link should use the  &lt;code&gt;img&lt;/code&gt;&#39;s &lt;code&gt;alt&lt;/code&gt; attribute to describe
where the user will navigate to if they click on the link:&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;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&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;https://en.wikipedia.org/wiki/Google&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;img&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;Google&lt;span class=&quot;token punctuation&quot;&gt;&#39;&lt;/span&gt;s wikipedia page&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;google-logo.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;a&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;Similarly, if an &lt;code&gt;&amp;lt;input type=&amp;quot;image&amp;quot;&amp;gt;&lt;/code&gt; element is used to create an image
button, it should contain &lt;code&gt;alt&lt;/code&gt; text that describes the action that occurs when
the user clicks on the button:&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;highlight-line&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 punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&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;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    Username:&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&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;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 punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&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;/span&gt;&lt;br /&gt;&lt;mark class=&quot;highlight-line highlight-line-active&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;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;image&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;Sign in&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;./sign-in-button.png&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;/mark&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&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 punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;h3 id=&quot;embedded-objects&quot;&gt;Embedded objects &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/labels-and-text-alternatives/#embedded-objects&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;&amp;lt;object&amp;gt;&lt;/code&gt; elements, which are typically used for embeds like Flash, PDFs, or
ActiveX, should also contain alternative text. Similar to images, this text is
displayed if the element fails to render. The alternative text goes inside the
&lt;code&gt;object&lt;/code&gt; element as regular text, like &amp;quot;Annual report&amp;quot; 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;object&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;application/pdf&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;data&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;/report.pdf&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;Annual report.&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;object&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;label-buttons-and-links&quot;&gt;Label buttons and links &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/labels-and-text-alternatives/#label-buttons-and-links&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Buttons and links are often crucial to the experience of a site, and it is
important that both have good accessible names.&lt;/p&gt;
&lt;h3 id=&quot;buttons&quot;&gt;Buttons &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/labels-and-text-alternatives/#buttons&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;A &lt;code&gt;button&lt;/code&gt; element always attempts to compute its accessible name using its
text content. For buttons that are not part of a &lt;code&gt;form&lt;/code&gt;, writing a clear
action as the text content may be all you need to create a good accessible
name.&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;Book Room&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;img alt=&quot;A mobile form with a &amp;#x27;Book Room&amp;#x27; button.&quot; decoding=&quot;async&quot; height=&quot;269&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 800px) 800px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/admin/tcIDzNpCHS9AlfwflQjI.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/admin/tcIDzNpCHS9AlfwflQjI.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/admin/tcIDzNpCHS9AlfwflQjI.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/admin/tcIDzNpCHS9AlfwflQjI.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/admin/tcIDzNpCHS9AlfwflQjI.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/admin/tcIDzNpCHS9AlfwflQjI.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/admin/tcIDzNpCHS9AlfwflQjI.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/admin/tcIDzNpCHS9AlfwflQjI.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/admin/tcIDzNpCHS9AlfwflQjI.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/admin/tcIDzNpCHS9AlfwflQjI.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/admin/tcIDzNpCHS9AlfwflQjI.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/admin/tcIDzNpCHS9AlfwflQjI.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/admin/tcIDzNpCHS9AlfwflQjI.png?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/admin/tcIDzNpCHS9AlfwflQjI.png?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/admin/tcIDzNpCHS9AlfwflQjI.png?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/admin/tcIDzNpCHS9AlfwflQjI.png?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/admin/tcIDzNpCHS9AlfwflQjI.png?auto=format&amp;w=1428 1428w, https://web-dev.imgix.net/image/admin/tcIDzNpCHS9AlfwflQjI.png?auto=format&amp;w=1600 1600w&quot; width=&quot;800&quot; /&gt;
&lt;p&gt;One common exception to this rule is icon buttons. An icon button may use an
image or an icon font to provide the text content for the button. For example,
the buttons used in a What You See Is What You Get (WYSIWYG) editor to format
text are typically just graphic symbols:&lt;/p&gt;
&lt;img alt=&quot;A left align icon button.&quot; decoding=&quot;async&quot; height=&quot;269&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 800px) 800px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/admin/ZmQ77kLPbqd5iFOmn4SU.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/admin/ZmQ77kLPbqd5iFOmn4SU.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/admin/ZmQ77kLPbqd5iFOmn4SU.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/admin/ZmQ77kLPbqd5iFOmn4SU.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/admin/ZmQ77kLPbqd5iFOmn4SU.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/admin/ZmQ77kLPbqd5iFOmn4SU.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/admin/ZmQ77kLPbqd5iFOmn4SU.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/admin/ZmQ77kLPbqd5iFOmn4SU.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/admin/ZmQ77kLPbqd5iFOmn4SU.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/admin/ZmQ77kLPbqd5iFOmn4SU.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/admin/ZmQ77kLPbqd5iFOmn4SU.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/admin/ZmQ77kLPbqd5iFOmn4SU.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/admin/ZmQ77kLPbqd5iFOmn4SU.png?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/admin/ZmQ77kLPbqd5iFOmn4SU.png?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/admin/ZmQ77kLPbqd5iFOmn4SU.png?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/admin/ZmQ77kLPbqd5iFOmn4SU.png?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/admin/ZmQ77kLPbqd5iFOmn4SU.png?auto=format&amp;w=1428 1428w, https://web-dev.imgix.net/image/admin/ZmQ77kLPbqd5iFOmn4SU.png?auto=format&amp;w=1600 1600w&quot; width=&quot;800&quot; /&gt;
&lt;p&gt;When working with icon buttons, it can be helpful to give them an explicit
accessible name using the &lt;code&gt;aria-label&lt;/code&gt; attribute. &lt;code&gt;aria-label&lt;/code&gt; overrides any
text content inside the button, letting you clearly describe the action to
anyone using a screen reader.&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;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;Left align&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;h3 id=&quot;links&quot;&gt;Links &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/labels-and-text-alternatives/#links&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Similar to buttons, links primarily get their accessible name from their text
content. A nice trick when creating a link is to put the most meaningful piece
of text into the link itself, rather than filler words like &amp;quot;Here&amp;quot; or &amp;quot;Read
More.&amp;quot;&lt;/p&gt;
&lt;figure class=&quot;compare flow&quot; data-type=&quot;worse&quot; data-size=&quot;full&quot;&gt;&lt;p class=&quot;compare__label&quot;&gt;Not descriptive enough&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;Check out our guide to web performance &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;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&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;/guide&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;here&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;a&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;/figure&gt;
&lt;figure class=&quot;compare flow&quot; data-type=&quot;better&quot; data-size=&quot;full&quot;&gt;&lt;p class=&quot;compare__label&quot;&gt;Useful content!&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;Check out &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;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&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;/guide&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;our guide to web performance&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;a&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;/figure&gt;
&lt;p&gt;This is especially helpful for screen readers that offer shortcuts to list all
of the links on the page. If links are full of repetitive filler text, these
shortcuts become much less useful:&lt;/p&gt;
&lt;figure&gt;
  &lt;img alt=&quot;VoiceOver&amp;#x27;s links menu filled with the word &amp;#x27;here&amp;#x27;.&quot; decoding=&quot;async&quot; height=&quot;469&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 519px) 519px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/admin/IPxS2dwHMyGRvGxGi5n2.jpg?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/admin/IPxS2dwHMyGRvGxGi5n2.jpg?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/admin/IPxS2dwHMyGRvGxGi5n2.jpg?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/admin/IPxS2dwHMyGRvGxGi5n2.jpg?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/admin/IPxS2dwHMyGRvGxGi5n2.jpg?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/admin/IPxS2dwHMyGRvGxGi5n2.jpg?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/admin/IPxS2dwHMyGRvGxGi5n2.jpg?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/admin/IPxS2dwHMyGRvGxGi5n2.jpg?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/admin/IPxS2dwHMyGRvGxGi5n2.jpg?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/admin/IPxS2dwHMyGRvGxGi5n2.jpg?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/admin/IPxS2dwHMyGRvGxGi5n2.jpg?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/admin/IPxS2dwHMyGRvGxGi5n2.jpg?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/admin/IPxS2dwHMyGRvGxGi5n2.jpg?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/admin/IPxS2dwHMyGRvGxGi5n2.jpg?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/admin/IPxS2dwHMyGRvGxGi5n2.jpg?auto=format&amp;w=1038 1038w&quot; width=&quot;519&quot; /&gt;
  &lt;figcaption&gt;
    Example of VoiceOver, a screen reader for macOS, showing the navigate by
    links menu.
  &lt;/figcaption&gt;
&lt;/figure&gt;
&lt;h2 id=&quot;label-form-elements&quot;&gt;Label form elements &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/labels-and-text-alternatives/#label-form-elements&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;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 of 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;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 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 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;Or 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;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 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;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; like in the VoiceOver example below:&lt;/p&gt;
&lt;figure&gt;
  &lt;img alt=&quot;VoiceOver text output showing &amp;#x27;Receive promotional offers?&amp;#x27;&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/admin/WklT2ymrCmceyrGUNizF.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/admin/WklT2ymrCmceyrGUNizF.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/admin/WklT2ymrCmceyrGUNizF.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/admin/WklT2ymrCmceyrGUNizF.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/admin/WklT2ymrCmceyrGUNizF.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/admin/WklT2ymrCmceyrGUNizF.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/admin/WklT2ymrCmceyrGUNizF.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/admin/WklT2ymrCmceyrGUNizF.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/admin/WklT2ymrCmceyrGUNizF.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/admin/WklT2ymrCmceyrGUNizF.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/admin/WklT2ymrCmceyrGUNizF.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/admin/WklT2ymrCmceyrGUNizF.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/admin/WklT2ymrCmceyrGUNizF.png?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/admin/WklT2ymrCmceyrGUNizF.png?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/admin/WklT2ymrCmceyrGUNizF.png?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/admin/WklT2ymrCmceyrGUNizF.png?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/admin/WklT2ymrCmceyrGUNizF.png?auto=format&amp;w=1280 1280w&quot; width=&quot;640&quot; /&gt;
&lt;/figure&gt;
&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;web-assessment aria-label=&quot;Check your understanding&quot;&gt;   &lt;div class=&quot;web-assessment__set-leader&quot;&gt;Check whether sample HTML elements have accessible names &lt;/div&gt; &lt;web-tabs class=&quot;web-assessment__content unresolved&quot; label=&quot;samples for knowledge self check&quot;&gt;         &lt;web-question question-height=&quot;unset&quot; data-label=&quot;sample&quot;&gt;   &lt;div data-role=&quot;stimulus&quot;&gt;&lt;p&gt;&lt;img src=&quot;https://web-dev.imgix.net/image/user/temp.svg&quot; alt=&quot;temp&quot; /&gt;&lt;/p&gt; &lt;/div&gt; &lt;web-response-tac data-role=&quot;response&quot;&gt;   &lt;p data-role=&quot;stem&quot;&gt;Does this image have an accessible name?&lt;/p&gt;      &lt;div data-role=&quot;rationale&quot;&gt;&lt;p&gt;&lt;strong&gt;Yes&lt;/strong&gt;. Give an image an accessible name by adding an &lt;code&gt;alt&lt;/code&gt; attribute.&lt;/p&gt; &lt;/div&gt; &lt;/web-response-tac&gt; &lt;/web-question&gt;         &lt;web-question question-height=&quot;unset&quot; data-label=&quot;sample&quot;&gt;   &lt;div data-role=&quot;stimulus&quot;&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;object&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;application/pdf&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;data&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;/report.pdf&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;Annual report&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;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;object&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt; &lt;/div&gt;&lt;/div&gt; &lt;web-response-tac data-role=&quot;response&quot;&gt;   &lt;p data-role=&quot;stem&quot;&gt;Does this object have an accessible name?&lt;/p&gt;      &lt;div data-role=&quot;rationale&quot;&gt;&lt;p&gt;&lt;strong&gt;No&lt;/strong&gt;. Give an &lt;code&gt;&amp;lt;object&amp;gt;&lt;/code&gt; element a name by providing text content. (An &lt;code&gt;alt&lt;/code&gt; attribute on an object will not be read by assistive technologies.)&lt;/p&gt; &lt;/div&gt; &lt;/web-response-tac&gt; &lt;/web-question&gt;         &lt;web-question question-height=&quot;unset&quot; data-label=&quot;sample&quot;&gt;   &lt;div data-role=&quot;stimulus&quot;&gt;&lt;p&gt;This sample renders an icon button:&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;&amp;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;svg&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;icon&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;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;use&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;xlink:&lt;/span&gt;href&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;#icon-1&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&amp;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;svg&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;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;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt; &lt;/div&gt;&lt;/div&gt; &lt;web-response-tac data-role=&quot;response&quot;&gt;   &lt;p data-role=&quot;stem&quot;&gt;Does this button have an accessible name?&lt;/p&gt;      &lt;div data-role=&quot;rationale&quot;&gt;&lt;p&gt;&lt;strong&gt;No&lt;/strong&gt;. Give a button an accessible name by providing text content, an &lt;code&gt;aria-label&lt;/code&gt; attribute, or an &lt;code&gt;aria-labelledby&lt;/code&gt; attribute.&lt;/p&gt; &lt;/div&gt; &lt;/web-response-tac&gt; &lt;/web-question&gt;         &lt;web-question question-height=&quot;unset&quot; data-label=&quot;sample&quot;&gt;   &lt;div data-role=&quot;stimulus&quot;&gt;&lt;p&gt;This sample renders an icon button with a tooltip that appears on hover and focus:&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;&amp;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;svg&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;icon&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;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;use&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;&lt;span class=&quot;token namespace&quot;&gt;xlink:&lt;/span&gt;href&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;#icon-1&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&amp;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;svg&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;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 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;tooltip hidden&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;Open menu&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;&amp;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;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt; &lt;/div&gt;&lt;/div&gt; &lt;web-response-tac data-role=&quot;response&quot;&gt;   &lt;p data-role=&quot;stem&quot;&gt;Does this button have an accessible name?&lt;/p&gt;      &lt;div data-role=&quot;rationale&quot;&gt;&lt;p&gt;&lt;strong&gt;Yes&lt;/strong&gt;. Even if the button&#39;s tooltip is visually hidden using CSS, assistive technologies can still read its text content.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Caution:&lt;/strong&gt; When visually hiding button text, use CSS rather than the &lt;code&gt;hidden&lt;/code&gt; attribute. The &lt;code&gt;hidden&lt;/code&gt; attribute removes the element from the accessibility tree.&lt;/p&gt; &lt;/div&gt; &lt;/web-response-tac&gt; &lt;/web-question&gt;         &lt;web-question question-height=&quot;unset&quot; data-label=&quot;sample&quot;&gt;   &lt;div data-role=&quot;stimulus&quot;&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;&amp;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 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;subscribe&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;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;input&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  Subscribe to the newsletter?&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;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt; &lt;/div&gt;&lt;/div&gt; &lt;web-response-tac data-role=&quot;response&quot;&gt;   &lt;p data-role=&quot;stem&quot;&gt;Does this checkbox have an accessible name?&lt;/p&gt;      &lt;div data-role=&quot;rationale&quot;&gt;&lt;p&gt;&lt;strong&gt;Yes&lt;/strong&gt;. The label is associated with the checkbox because the label is the checkbox&#39;s parent. So, assistive technologies treat the label&#39;s text content as the input&#39;s name.&lt;/p&gt; &lt;/div&gt; &lt;/web-response-tac&gt; &lt;/web-question&gt;         &lt;web-question question-height=&quot;unset&quot; data-label=&quot;sample&quot;&gt;   &lt;div data-role=&quot;stimulus&quot;&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;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 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;subscribe&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;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;input&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;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;subscribe&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;Subscribe to the newsletter?&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;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt; &lt;/div&gt;&lt;/div&gt; &lt;web-response-tac data-role=&quot;response&quot;&gt;   &lt;p data-role=&quot;stem&quot;&gt;Does this checkbox have an accessible name?&lt;/p&gt;      &lt;div data-role=&quot;rationale&quot;&gt;&lt;p&gt;&lt;strong&gt;No&lt;/strong&gt;. The checkbox&#39;s &lt;code&gt;value&lt;/code&gt; attribute indicates what text will be saved when the form is submitted, but assistive technologies don&#39;t read it. To provide an accessible name, add an &lt;code&gt;id&lt;/code&gt; attribute with the value &lt;code&gt;subscribe&lt;/code&gt; to associate the checkbox with the label.&lt;/p&gt; &lt;/div&gt; &lt;/web-response-tac&gt; &lt;/web-question&gt;       &lt;/web-tabs&gt; &lt;/web-assessment&gt;&lt;/body&gt;&lt;/html&gt;
</content>
    <author>
      <name>Rob Dodson</name>
    </author>
  </entry>
  
  <entry>
    <title>Semantics and screen readers</title>
    <link href="https://web.dev/semantics-and-screen-readers/"/>
    <updated>2018-11-18T00:00:00Z</updated>
    <id>https://web.dev/semantics-and-screen-readers/</id>
    <content type="html" mode="escaped">&lt;p&gt;Have you ever stopped to wonder &lt;em&gt;how&lt;/em&gt; assistive technology, such as a screen
reader, knows what to announce to users? The answer is that these technologies
rely on developers marking up their pages with &lt;strong&gt;semantic&lt;/strong&gt; HTML. But what are
semantics, and how do screen readers use them?&lt;/p&gt;
&lt;h2 id=&quot;affordances-and-semantics&quot;&gt;Affordances and semantics &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/semantics-and-screen-readers/#affordances-and-semantics&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Before diving into semantics, it&#39;s helpful to understand another term:
&lt;strong&gt;affordances&lt;/strong&gt;. An affordance is any object that offers, or affords, its user
the opportunity to perform an action. A classic example is the teapot:&lt;/p&gt;
&lt;figure&gt;
  &lt;img alt=&quot;&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/admin/EXqR31Kq3mosH6jv6jiG.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/admin/EXqR31Kq3mosH6jv6jiG.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/admin/EXqR31Kq3mosH6jv6jiG.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/admin/EXqR31Kq3mosH6jv6jiG.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/admin/EXqR31Kq3mosH6jv6jiG.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/admin/EXqR31Kq3mosH6jv6jiG.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/admin/EXqR31Kq3mosH6jv6jiG.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/admin/EXqR31Kq3mosH6jv6jiG.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/admin/EXqR31Kq3mosH6jv6jiG.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/admin/EXqR31Kq3mosH6jv6jiG.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/admin/EXqR31Kq3mosH6jv6jiG.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/admin/EXqR31Kq3mosH6jv6jiG.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/admin/EXqR31Kq3mosH6jv6jiG.png?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/admin/EXqR31Kq3mosH6jv6jiG.png?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/admin/EXqR31Kq3mosH6jv6jiG.png?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/admin/EXqR31Kq3mosH6jv6jiG.png?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/admin/EXqR31Kq3mosH6jv6jiG.png?auto=format&amp;w=1280 1280w&quot; width=&quot;640&quot; /&gt;
  &lt;figcaption&gt;
    A teapot&#39;s handle is a natural affordance.
  &lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;This teapot doesn&#39;t need an instruction manual; instead, its physical design
conveys to the user how it should be operated. It has a handle, and because
you&#39;ve seen other objects in the world with similar handles, you can infer how
you should pick it up and operate it.&lt;/p&gt;
&lt;p&gt;When we build graphical user interfaces, we use things like CSS to add &lt;strong&gt;visual
affordances&lt;/strong&gt; to our UI. For instance, you might give a button a drop shadow and
border so that it resembles an actual button in the real world.&lt;/p&gt;
&lt;p&gt;But if a user is unable to see the screen, then these visual affordances will
not be conveyed to them. Therefore, you need to make sure that your UI is
constructed in a way that can convey these same affordances to assistive
technology. This non-visual exposure of a UI element&#39;s affordances is called
its &lt;strong&gt;semantics&lt;/strong&gt;.&lt;/p&gt;
&lt;h2 id=&quot;use-semantic-html&quot;&gt;Use semantic HTML &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/semantics-and-screen-readers/#use-semantic-html&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The easiest way of conveying proper semantics is to use semantically rich HTML
elements.&lt;/p&gt;
&lt;p&gt;Using CSS, it&#39;s possible
to style the &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt; elements so they convey the same visual affordances,
but the two experiences are very different when using a screen reader.
A &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; is just a generic grouping element,
so a screen reader only announces the text content of the &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;.
The &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt; is announced as a &amp;quot;button,&amp;quot;
a much stronger signal to the user that it&#39;s something they can interact with.&lt;/p&gt;
&lt;p&gt;The simplest
and often best solution to this problem
is to avoid custom interactive controls altogether.
For example, replace a &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; that&#39;s acting like a button
with an actual &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&quot;semantic-properties-and-the-accessibility-tree&quot;&gt;Semantic properties and the accessibility tree &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/semantics-and-screen-readers/#semantic-properties-and-the-accessibility-tree&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Generally speaking, every HTML element will have some of the following semantic
properties:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;role&lt;/strong&gt; or type&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;name&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;value&lt;/strong&gt; (optional)&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;state&lt;/strong&gt; (optional)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;An element&#39;s &lt;strong&gt;role&lt;/strong&gt; describes its type, for example, &amp;quot;button,&amp;quot; &amp;quot;input,&amp;quot; or even just
&amp;quot;group&amp;quot; for things like &lt;code&gt;div&lt;/code&gt; and &lt;code&gt;span&lt;/code&gt; elements.&lt;/p&gt;
&lt;p&gt;An element&#39;s &lt;strong&gt;name&lt;/strong&gt; is its computed label. Screen readers typically announce
an element&#39;s name followed by its role, e.g. &amp;quot;Sign Up, button.&amp;quot; The algorithm
that determines an element&#39;s name factors in things like if there is any text
content inside the element, whether or not it has attributes such as &lt;code&gt;title&lt;/code&gt;
or &lt;code&gt;placeholder&lt;/code&gt;, whether or not the element is associated with an actual
&lt;code&gt;&amp;lt;label&amp;gt;&lt;/code&gt; element, and if the element has any ARIA attributes such as
&lt;code&gt;aria-label&lt;/code&gt; and &lt;code&gt;aria-labelledby&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Some elements &lt;em&gt;may&lt;/em&gt; have a &lt;strong&gt;value&lt;/strong&gt;. For instance, &lt;code&gt;&amp;lt;input type=&amp;quot;text&amp;quot;&amp;gt;&lt;/code&gt; may
have a value that reflects whatever the user has typed into the text field.&lt;/p&gt;
&lt;p&gt;Some elements &lt;em&gt;may&lt;/em&gt; also have a &lt;strong&gt;state&lt;/strong&gt;, which conveys their current status.
For instance, a &lt;code&gt;&amp;lt;select&amp;gt;&lt;/code&gt; element can be in either an &lt;em&gt;expanded&lt;/em&gt; or a
&lt;em&gt;collapsed&lt;/em&gt; state, depending on if it&#39;s open or closed.&lt;/p&gt;
&lt;h3 id=&quot;the-accessibility-tree&quot;&gt;The accessibility tree &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/semantics-and-screen-readers/#the-accessibility-tree&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;For each node in the DOM, the browser determines if the
node is semantically &amp;quot;interesting&amp;quot; and adds it to &lt;a href=&quot;https://web.dev/the-accessibility-tree/&quot;&gt;the accessibility
tree&lt;/a&gt;.
When assistive technology, like a screen reader, is providing an alternative UI
to the user, it is often doing so by walking this accessibility tree.&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; Browsers will often remove semantically uninteresting nodes like &lt;code&gt;div&lt;/code&gt; and &lt;code&gt;span&lt;/code&gt; from the accessibility tree, especially if they&#39;re just being used to position their children with CSS. For instance, if you have a &lt;code&gt;button&lt;/code&gt; nested inside of 5 &lt;code&gt;div&lt;/code&gt; elements, the browser may prune out some of the &lt;code&gt;div&lt;/code&gt; elements in the middle to cut down on noise. &lt;/div&gt;&lt;/aside&gt;
&lt;p&gt;Using Chrome&#39;s DevTools you can &lt;a href=&quot;https://developer.chrome.com/docs/devtools/accessibility/reference/#pane&quot; rel=&quot;noopener&quot;&gt;inspect an element&#39;s semantic
properties&lt;/a&gt;
and explore its position in the accessibility tree.&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/semantics-and-screen-readers/#next-steps&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Once you know a bit about semantics and how they aid screen reader navigation,
you can&#39;t help but look at the pages you build differently. In the next section,
we&#39;ll take a step back and consider how the entire outline of a page can be
conveyed using effective &lt;a href=&quot;https://web.dev/headings-and-landmarks/&quot;&gt;headings and landmarks&lt;/a&gt;.&lt;/p&gt;
</content>
    <author>
      <name>Rob Dodson</name>
    </author>
  </entry>
  
  <entry>
    <title>Style focus</title>
    <link href="https://web.dev/style-focus/"/>
    <updated>2018-11-18T00:00:00Z</updated>
    <id>https://web.dev/style-focus/</id>
    <content type="html" mode="escaped">&lt;p&gt;The focus indicator (often signified by a &amp;quot;focus ring&amp;quot;) identifies the currently
focused element on your page. For users who are unable to use a mouse, this
indicator is &lt;em&gt;extremely important&lt;/em&gt; because it acts as a stand-in for their
mouse-pointer.&lt;/p&gt;
&lt;p&gt;If the browser&#39;s default focus indicator clashes with your design, you can use
CSS to restyle it. Just remember to keep your keyboard users in mind!&lt;/p&gt;
&lt;h2 id=&quot;use-focus-to-always-show-a-focus-indicator&quot;&gt;Use &lt;code&gt;:focus&lt;/code&gt; to always show a focus indicator &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/style-focus/#use-focus-to-always-show-a-focus-indicator&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The &lt;a href=&quot;https://developer.mozilla.org/docs/Web/CSS/:focus&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;:focus&lt;/code&gt;&lt;/a&gt;
pseudo-class is applied any time an element is focused, regardless of the input
device (mouse, keyboard, stylus, etc.) or method used to focus it. For example,
the &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; below has a &lt;code&gt;tabindex&lt;/code&gt; which makes it focusable. It also has a
custom style for its &lt;code&gt;:focus&lt;/code&gt; state:&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;div[tabindex=&quot;0&quot;]:focus&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;outline&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 4px dashed orange&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;Regardless of whether you use a mouse to click on it or a keyboard to tab to it,
the &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; will &lt;em&gt;always&lt;/em&gt; look the same.&lt;/p&gt;
&lt;div class=&quot;glitch-embed-wrap&quot; style=&quot;height: 346px; 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/focus-style?attributionHidden=true&amp;sidebarCollapsed=true&amp;path=index.html&amp;previewSize=100&quot; style=&quot;height: 100%; width: 100%; border: 0;&quot; title=&quot;focus-style on Glitch&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;
&lt;p&gt;Unfortunately browsers can be inconsistent with how they apply focus. Whether or
not an element receives focus may depend on the browser and the operating
system.&lt;/p&gt;
&lt;p&gt;For example, the &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt; below also has a custom style for its &lt;code&gt;:focus&lt;/code&gt;
state.&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;button:focus&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;outline&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 4px dashed orange&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;If you click on the &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt; with a mouse in Chrome on macOS you should see
its custom focus style. However, you will not see the custom focus style if you
click on the &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt; in Safari on macOS. This is because in
Safari the element does not receive focus when you click on it.&lt;/p&gt;
&lt;div class=&quot;glitch-embed-wrap&quot; style=&quot;height: 346px; 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/focus-style2?attributionHidden=true&amp;sidebarCollapsed=true&amp;path=index.html&amp;previewSize=100&quot; style=&quot;height: 100%; width: 100%; border: 0;&quot; title=&quot;focus-style2 on Glitch&quot;&gt;&lt;/iframe&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; See the &lt;a href=&quot;https://developer.mozilla.org/docs/Web/HTML/Element/button#Clicking_and_focus&quot;&gt;MDN reference for &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt; focus behavior&lt;/a&gt; for a summary of which browsers and operating systems will apply focus to &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt; elements. &lt;/div&gt;&lt;/aside&gt;
&lt;p&gt;Because the behavior of focus is inconsistent, it may require a bit of testing
on different devices to ensure your focus styles are acceptable to your users.&lt;/p&gt;
&lt;h2 id=&quot;use-focus-visible-to-selectively-show-a-focus-indicator&quot;&gt;Use &lt;code&gt;:focus-visible&lt;/code&gt; to selectively show a focus indicator &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/style-focus/#use-focus-visible-to-selectively-show-a-focus-indicator&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The new
&lt;a href=&quot;https://developer.mozilla.org/docs/Web/CSS/:focus-visible&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;:focus-visible&lt;/code&gt;&lt;/a&gt;
pseudo-class is applied any time that an element receives focus and the
browser determines via heuristics that displaying a focus indicator would be
beneficial to the user. In particular, if the most recent user interaction
was via the keyboard and the key press did not include a meta, &lt;code&gt;ALT&lt;/code&gt; / &lt;code&gt;OPTION&lt;/code&gt;,
or &lt;code&gt;CONTROL&lt;/code&gt; key, then &lt;code&gt;:focus-visible&lt;/code&gt; will match.&lt;/p&gt;
&lt;p&gt;The button in the example below will &lt;em&gt;selectively&lt;/em&gt; show a focus indicator. If
you use a mouse to click on it, the results are different than if you first use
a keyboard to tab to it.&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;button:focus-visible&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;outline&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 4px dashed orange&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;div class=&quot;glitch-embed-wrap&quot; style=&quot;height: 346px; 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/focus-visible-style?attributionHidden=true&amp;sidebarCollapsed=true&amp;path=index.html&amp;previewSize=100&quot; style=&quot;height: 100%; width: 100%; border: 0;&quot; title=&quot;focus-visible-style on Glitch&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;
&lt;h2 id=&quot;use-focus-within-to-style-the-parent-of-a-focused-element&quot;&gt;Use &lt;code&gt;:focus-within&lt;/code&gt; to style the parent of a focused element &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/style-focus/#use-focus-within-to-style-the-parent-of-a-focused-element&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The
&lt;a href=&quot;https://developer.mozilla.org/docs/Web/CSS/:focus-within&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;:focus-within&lt;/code&gt;&lt;/a&gt;
pseudo-class is applied to an element either when the element itself receives
focus or when another element inside that element receives focus.&lt;/p&gt;
&lt;p&gt;It can be used to highlight a region of the page to draw the
user&#39;s attention to that area. For example, the form below receives focus both
when the form itself is selected and also when any of its radio buttons are
selected.&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;form:focus-within&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;background&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; #ffecb3&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;div class=&quot;glitch-embed-wrap&quot; style=&quot;height: 346px; 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/focus-within-style?attributionHidden=true&amp;sidebarCollapsed=true&amp;path=index.html&amp;previewSize=100&quot; style=&quot;height: 100%; width: 100%; border: 0;&quot; title=&quot;focus-within-style on Glitch&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;
&lt;h2 id=&quot;when-to-display-a-focus-indicator&quot;&gt;When to display a focus indicator &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/style-focus/#when-to-display-a-focus-indicator&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A good rule of thumb is to ask yourself, &amp;quot;If you clicked on this control while
using a mobile device, would you expect it to display a keyboard?&amp;quot;&lt;/p&gt;
&lt;p&gt;If the answer is &amp;quot;yes,&amp;quot; then the control should probably &lt;em&gt;always&lt;/em&gt; show a focus
indicator, regardless of the input device used to focus it. A good example is
the &lt;code&gt;&amp;lt;input type=&amp;quot;text&amp;quot;&amp;gt;&lt;/code&gt; element. The user will need to send input to the
element via the keyboard regardless of how the input element originally received
focus, so it&#39;s helpful to always display a focus indicator.&lt;/p&gt;
&lt;p&gt;If the answer is &amp;quot;no,&amp;quot; then the control may choose to selectively show a focus
indicator. A good example is the &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt; element. If a user clicks on it with
a mouse or touch screen, the action is complete, and a focus indicator may not
be necessary. However, if the user is &lt;em&gt;navigating&lt;/em&gt; with a keyboard, it&#39;s useful
to show a focus indicator so the user can decide whether or not they want to
click the control using the &lt;code&gt;ENTER&lt;/code&gt; or &lt;code&gt;SPACE&lt;/code&gt; keys.&lt;/p&gt;
&lt;h2 id=&quot;avoid-outline-none&quot;&gt;Avoid &lt;code&gt;outline: none&lt;/code&gt; &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/style-focus/#avoid-outline-none&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The way browsers decide when to draw a focus indicator is, frankly, very
confusing. Changing the appearance of a &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt; element with CSS or giving
an element a &lt;code&gt;tabindex&lt;/code&gt; will cause the browser&#39;s default focus ring behavior to
kick-in.&lt;/p&gt;
&lt;p&gt;A very common anti-pattern is to remove the focus indicator using CSS such as:&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 comment&quot;&gt;/* Don&#39;t do this!!! */&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token selector&quot;&gt;:focus&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;outline&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; none&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;A better way to work around this issue is to use a combination of &lt;code&gt;:focus&lt;/code&gt; and
the &lt;code&gt;:focus-visible&lt;/code&gt; polyfill. The first block of code below demonstrates how
the polyfill works, and the sample app beneath it provides an example of using
the polyfill to change the focus indicator on a button.&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 comment&quot;&gt;/*&lt;br /&gt;  This will hide the focus indicator if the element receives focus via the&lt;br /&gt;  mouse, but it will still show up on keyboard focus.&lt;br /&gt;*/&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token selector&quot;&gt;.js-focus-visible :focus:not(.focus-visible)&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;outline&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; none&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;/*&lt;br /&gt;  Optionally: Define a strong focus indicator for keyboard focus.&lt;br /&gt;  If you choose to skip this step, then the browser&#39;s default focus&lt;br /&gt;  indicator will be displayed instead.&lt;br /&gt;*/&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token selector&quot;&gt;.js-focus-visible .focus-visible&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 punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;div class=&quot;glitch-embed-wrap&quot; style=&quot;height: 346px; 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/focus-visible?attributionHidden=true&amp;sidebarCollapsed=true&amp;path=index.html&amp;previewSize=100&quot; style=&quot;height: 100%; width: 100%; border: 0;&quot; title=&quot;focus-visible on Glitch&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;
</content>
    <author>
      <name>Rob Dodson</name>
    </author>
  </entry>
  
  <entry>
    <title>Use semantic HTML for easy keyboard wins</title>
    <link href="https://web.dev/use-semantic-html/"/>
    <updated>2018-11-18T00:00:00Z</updated>
    <id>https://web.dev/use-semantic-html/</id>
    <content type="html" mode="escaped">&lt;p&gt;By using the correct semantic HTML elements you may be able to meet most or all
of your keyboard access needs. That means less time fiddling with &lt;code&gt;tabindex&lt;/code&gt;,
and more happy users!&lt;/p&gt;
&lt;h2 id=&quot;keyboard-support-for-free-and-better-mobile-experiences&quot;&gt;Keyboard support for free (and better mobile experiences) &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/use-semantic-html/#keyboard-support-for-free-and-better-mobile-experiences&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;There are a number of built-in interactive elements with proper semantics and
keyboard support. The ones most developers use are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://developer.mozilla.org/docs/Web/HTML/Element/a&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://developer.mozilla.org/docs/Web/HTML/Element/button&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://developer.mozilla.org/docs/Web/HTML/Element/input#Form_%3Cinput%3E_types&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt; (and its many
types)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://developer.mozilla.org/docs/Web/HTML/Element/select&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;&amp;lt;select&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://developer.mozilla.org/docs/Web/HTML/Element/textarea&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;&amp;lt;textarea&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In addition, elements with the
&lt;a href=&quot;https://developer.mozilla.org/docs/Web/HTML/Global_attributes/contenteditable&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;contenteditable&lt;/code&gt;&lt;/a&gt;
attribute are sometimes used for freeform text entry.&lt;/p&gt;
&lt;p&gt;It&#39;s easy to overlook the built-in keyboard support that these elements offer.
Below are some example elements to explore. Instead of using your
mouse, try using your keyboard to operate them. You can use &lt;code&gt;TAB&lt;/code&gt; (or &lt;code&gt;SHIFT + TAB&lt;/code&gt;) to move between controls, and you can use the arrow keys and keys like
&lt;code&gt;ENTER&lt;/code&gt; and &lt;code&gt;SPACE&lt;/code&gt; to manipulate their values.&lt;/p&gt;
&lt;div class=&quot;glitch-embed-wrap&quot; style=&quot;height: 450px; 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/interactive-elements?attributionHidden=true&amp;sidebarCollapsed=true&amp;path=index.html&amp;previewSize=100&quot; style=&quot;height: 100%; width: 100%; border: 0;&quot; title=&quot;interactive-elements on Glitch&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;
&lt;p&gt;If you have a phone handy, you can see that many times these built-in elements
have unique interactions on mobile. Attempting to reproduce these mobile
interactions yourself is a lot of work! It&#39;s another good reason to stick to
built-in elements whenever possible.&lt;/p&gt;
&lt;h2 id=&quot;use-button-instead-of-div&quot;&gt;Use &lt;code&gt;button&lt;/code&gt; instead of &lt;code&gt;div&lt;/code&gt; &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/use-semantic-html/#use-button-instead-of-div&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A common accessibility anti-pattern is to treat a non-interactive element, like
a &lt;code&gt;div&lt;/code&gt; or a &lt;code&gt;span&lt;/code&gt;, as a button by adding a click handler to it.&lt;/p&gt;
&lt;p&gt;But to be considered accessible, a button should:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Be focusable via the keyboard&lt;/li&gt;
&lt;li&gt;Support being disabled&lt;/li&gt;
&lt;li&gt;Support the &lt;code&gt;ENTER&lt;/code&gt; or &lt;code&gt;SPACE&lt;/code&gt; keys to perform an action&lt;/li&gt;
&lt;li&gt;Be announced properly by a screen reader&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A &lt;code&gt;div&lt;/code&gt; button has none of these things. That means you&#39;ll need to write
additional code to replicate what the &lt;code&gt;button&lt;/code&gt; element gives you for free!&lt;/p&gt;
&lt;p&gt;For example, &lt;code&gt;button&lt;/code&gt; elements have a neat trick called &lt;strong&gt;&lt;strong&gt;synthetic click
activation&lt;/strong&gt;&lt;/strong&gt;. If you add a &amp;quot;click&amp;quot; handler to a &lt;code&gt;button&lt;/code&gt;, it will run when the
user presses &lt;code&gt;ENTER&lt;/code&gt; or &lt;code&gt;SPACE&lt;/code&gt;. A &lt;code&gt;div&lt;/code&gt; button doesn&#39;t have this feature, so
you&#39;ll need to write additional code to listen for the &lt;code&gt;keydown&lt;/code&gt; event, check
that the keycode is &lt;code&gt;ENTER&lt;/code&gt; or &lt;code&gt;SPACE&lt;/code&gt;, and then run your click handler. Ouch!
That&#39;s a lot of extra work!&lt;/p&gt;
&lt;p&gt;Compare the difference in this example. &lt;code&gt;TAB&lt;/code&gt; to either control, and use &lt;code&gt;ENTER&lt;/code&gt;
and &lt;code&gt;SPACE&lt;/code&gt; to attempt to click on them.&lt;/p&gt;
&lt;div class=&quot;glitch-embed-wrap&quot; style=&quot;height: 346px; 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/synthetic-click?attributionHidden=true&amp;sidebarCollapsed=true&amp;path=index.html&amp;previewSize=100&quot; style=&quot;height: 100%; width: 100%; border: 0;&quot; title=&quot;synthetic-click on Glitch&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;
&lt;p&gt;If you have &lt;code&gt;div&lt;/code&gt; buttons in your existing site or application, consider
swapping them out for &lt;code&gt;button&lt;/code&gt; elements. &lt;code&gt;button&lt;/code&gt; is easy to style and full of
accessibility wins!&lt;/p&gt;
&lt;h2 id=&quot;links-versus-buttons&quot;&gt;Links versus buttons &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/use-semantic-html/#links-versus-buttons&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Another common anti-pattern is to treat links as buttons by attaching JavaScript
behavior to them.&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;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&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 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;&lt;span class=&quot;token comment&quot;&gt;// perform some action&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;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;Both buttons and links support some form of synthetic click activation. So which
should you choose?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If clicking on the element will perform an &lt;em&gt;action&lt;/em&gt; on the page, use
&lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;If clicking on the element will &lt;em&gt;navigate&lt;/em&gt; the user to a new page then use
&lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt;. This includes single page web apps that load new content and update
the URL using the
&lt;a href=&quot;https://developer.mozilla.org/docs/Web/API/History&quot; rel=&quot;noopener&quot;&gt;History API&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The reason for this is that buttons and links are announced differently by
screen readers. Using the correct element helps screen reader users know which
outcome to expect.&lt;/p&gt;
&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;web-assessment aria-label=&quot;Check your understanding&quot;&gt;   &lt;div class=&quot;web-assessment__set-leader&quot;&gt;Check whether code samples should use buttons or links &lt;/div&gt; &lt;web-tabs class=&quot;web-assessment__content unresolved&quot; label=&quot;samples for knowledge self check&quot;&gt;         &lt;web-question question-height=&quot;unset&quot; data-label=&quot;sample&quot;&gt;   &lt;div data-role=&quot;stimulus&quot;&gt;&lt;div&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;See &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;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&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;https://webaim.org/intro/&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;rel&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;noopener&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;WebAIM&#39;s Introduction to Web Accessibility&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;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt; for more information.&lt;/code&gt;&lt;/pre&gt; &lt;/div&gt;&lt;/div&gt; &lt;web-response-tac data-role=&quot;response&quot;&gt;   &lt;p data-role=&quot;stem&quot;&gt;Should this sample use a button or a link?&lt;/p&gt;      &lt;div data-role=&quot;rationale&quot;&gt;&lt;p&gt;This sample should use a &lt;strong&gt;link&lt;/strong&gt;. The sample is &lt;strong&gt;correct&lt;/strong&gt;.&lt;/p&gt; &lt;p&gt;When selected, the element navigates the user to another page on a different domain, so a link is semantic.&lt;/p&gt; &lt;/div&gt; &lt;/web-response-tac&gt; &lt;/web-question&gt;         &lt;web-question question-height=&quot;unset&quot; data-label=&quot;sample&quot;&gt;   &lt;div data-role=&quot;stimulus&quot;&gt;&lt;div&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;See the &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;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&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;/semantics-and-screen-readers&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;Semantics and screen readers page&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;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt; for more information.&lt;/code&gt;&lt;/pre&gt; &lt;/div&gt;&lt;/div&gt; &lt;web-response-tac data-role=&quot;response&quot;&gt;   &lt;p data-role=&quot;stem&quot;&gt;Should this sample use a button or a link?&lt;/p&gt;      &lt;div data-role=&quot;rationale&quot;&gt;&lt;p&gt;This sample should use a &lt;strong&gt;link&lt;/strong&gt;. The sample is &lt;strong&gt;correct&lt;/strong&gt;.&lt;/p&gt; &lt;p&gt;When selected, the element navigates the user to a different page on the same domain. No matter where a resource is located, use a link to semantically indicate navigation.&lt;/p&gt; &lt;/div&gt; &lt;/web-response-tac&gt; &lt;/web-question&gt;         &lt;web-question question-height=&quot;unset&quot; data-label=&quot;sample&quot;&gt;   &lt;div data-role=&quot;stimulus&quot;&gt;&lt;p&gt;When selected, this element opens a modal dialog:&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;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&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 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;&lt;span class=&quot;token function&quot;&gt;openDialog&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;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt; &lt;/div&gt;&lt;/div&gt; &lt;web-response-tac data-role=&quot;response&quot;&gt;   &lt;p data-role=&quot;stem&quot;&gt;Should this sample use a button or a link?&lt;/p&gt;      &lt;div data-role=&quot;rationale&quot;&gt;&lt;p&gt;This sample should use a &lt;strong&gt;button&lt;/strong&gt;. The sample is &lt;strong&gt;incorrect&lt;/strong&gt;.&lt;/p&gt; &lt;p&gt;When selected, the element runs a function that opens a modal dialog on the same page; since the element isn&#39;t navigating the user to a separate page, a button is semantic.&lt;/p&gt; &lt;/div&gt; &lt;/web-response-tac&gt; &lt;/web-question&gt;         &lt;web-question question-height=&quot;unset&quot; data-label=&quot;sample&quot;&gt;   &lt;div data-role=&quot;stimulus&quot;&gt;&lt;p&gt;When selected, this element opens a navigation menu:&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;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&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 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;&lt;span class=&quot;token function&quot;&gt;openNavMenu&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;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt; &lt;/div&gt;&lt;/div&gt; &lt;web-response-tac data-role=&quot;response&quot;&gt;   &lt;p data-role=&quot;stem&quot;&gt;Should this sample use a button or a link?&lt;/p&gt;      &lt;div data-role=&quot;rationale&quot;&gt;&lt;p&gt;This sample should use a &lt;strong&gt;button&lt;/strong&gt;. The sample is &lt;strong&gt;incorrect&lt;/strong&gt;.&lt;/p&gt; &lt;p&gt;When selected, the element runs a function that opens a navigation menu on the same page. Opening the menu is an action, so a button is semantic.&lt;/p&gt; &lt;/div&gt; &lt;/web-response-tac&gt; &lt;/web-question&gt;         &lt;web-question question-height=&quot;unset&quot; data-label=&quot;sample&quot;&gt;   &lt;div data-role=&quot;stimulus&quot;&gt;&lt;p&gt;This code renders a horizontal navigation menu at the top of a website:&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;nav&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;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;&amp;gt;&lt;/span&gt;&lt;/span&gt;About&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;&amp;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;&amp;gt;&lt;/span&gt;&lt;/span&gt;Services&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;&amp;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;&amp;gt;&lt;/span&gt;&lt;/span&gt;Work&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;&amp;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;&amp;gt;&lt;/span&gt;&lt;/span&gt;Contact&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;&amp;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;nav&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt; &lt;/div&gt;&lt;/div&gt; &lt;web-response-tac data-role=&quot;response&quot;&gt;   &lt;p data-role=&quot;stem&quot;&gt;Should this sample use buttons or links?&lt;/p&gt;      &lt;div data-role=&quot;rationale&quot;&gt;&lt;p&gt;This sample should use &lt;strong&gt;links&lt;/strong&gt;. The sample is &lt;strong&gt;incorrect&lt;/strong&gt;.&lt;/p&gt; &lt;p&gt;The elements in the &lt;code&gt;&amp;lt;nav&amp;gt;&lt;/code&gt; menu navigate the user to other pages. Those pages may be separate resources in a static site, or they may be views in a &lt;a href=&quot;https://developers.google.com/web/fundamentals/architecture/app-shell&quot;&gt;single-page application&lt;/a&gt;. Either way, since the user is navigating somewhere else, links are semantic.&lt;/p&gt; &lt;/div&gt; &lt;/web-response-tac&gt; &lt;/web-question&gt;       &lt;/web-tabs&gt; &lt;/web-assessment&gt;&lt;/body&gt;&lt;/html&gt;
&lt;h2 id=&quot;styling&quot;&gt;Styling &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/use-semantic-html/#styling&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Some built-in elements, in particular &lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt;, can be difficult to style.
With a bit of clever CSS you may be able to work around some of these
limitations. The (hilariously named) &lt;a href=&quot;http://wtfforms.com/&quot; rel=&quot;noopener&quot;&gt;WTFForms&lt;/a&gt; project
contains an &lt;a href=&quot;https://github.com/mdo/wtf-forms/blob/master/wtf-forms.css&quot; rel=&quot;noopener&quot;&gt;example
stylesheet&lt;/a&gt;
that demonstrates a number of techniques for styling some of the tougher
built-in elements.&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/use-semantic-html/#next-steps&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Using built-in HTML elements can greatly improve the accessibility of your site,
and significantly cut down on your workload. Try tabbing through your site and
look for any controls which lack keyboard support. If possible, switch them out
for standardized HTML alternatives.&lt;/p&gt;
&lt;p&gt;Sometimes you may find an element that doesn&#39;t have a counterpart in HTML.
That&#39;s okay! Read on to learn how to add keyboard support to custom interactive
controls using &lt;code&gt;tabindex&lt;/code&gt;.&lt;/p&gt;
</content>
    <author>
      <name>Rob Dodson</name>
    </author>
  </entry>
  
  <entry>
    <title>What is accessibility?</title>
    <link href="https://web.dev/what-is-accessibility/"/>
    <updated>2018-11-18T00:00:00Z</updated>
    <id>https://web.dev/what-is-accessibility/</id>
    <content type="html" mode="escaped">&lt;p&gt;An accessible site is one whose content can be accessed regardless of any user&#39;s
impairments and whose functionality can also be operated by the most diverse
range of users possible.&lt;/p&gt;
&lt;p&gt;As developers, it&#39;s easy to assume that all users can see and use a keyboard,
mouse, or touch screen to interact with your page. This can lead to an
experience that works well for some people but creates issues for others that
range from simple annoyances to complete blockers.&lt;/p&gt;
&lt;h2 id=&quot;understanding-the-diverse-needs-of-your-users&quot;&gt;Understanding the diverse needs of your users &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/what-is-accessibility/#understanding-the-diverse-needs-of-your-users&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 video from Victor Tsaran,
a Technical Program Manager at Google.&lt;/p&gt;
&lt;div class=&quot;youtube&quot;&gt;  &lt;lite-youtube videoid=&quot;RHIVx4m8V4M&quot;&gt;  &lt;/lite-youtube&gt;&lt;/div&gt;
&lt;p&gt;Generally speaking, accessibility concerns can be split into four broad
categories:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Vision&lt;/li&gt;
&lt;li&gt;Motor/dexterity&lt;/li&gt;
&lt;li&gt;Auditory&lt;/li&gt;
&lt;li&gt;Cognitive&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Planning for accessibility means thinking about users who are experiencing some
type of impairment or disability in one or more of these categories. Bear
in mind that that experience might be non-physical or temporary—for instance,
trying to read a screen outside during a bright, sunny day or operating a
device one-handed while carrying a cup of coffee.&lt;/p&gt;
&lt;p&gt;When you plan for these situations upfront, you end up with an experience that
is more robust and works for more users regardless of their ability or
context.&lt;/p&gt;
&lt;h3 id=&quot;vision&quot;&gt;Vision &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/what-is-accessibility/#vision&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Vision impairments range from limited or low vision to complete blindness. Users
with low vision may use a combination of screen magnification, high contrast
themes, and text-to-speech to access content. Some users may rely on a screen
reader or braille display to navigate a page, perform actions, and read
descriptions of content and controls.&lt;/p&gt;
&lt;h3 id=&quot;motordexterity&quot;&gt;Motor/dexterity &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/what-is-accessibility/#motordexterity&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Motor and dexterity impairments may affect a user&#39;s ability to use a mouse,
touchscreen, or other pointing device. Some users may rely on alternative input
devices to access content. These devices might include a keyboard, head- or
eye-tracking software, switch devices, sip-and-puff devices, or voice access.&lt;/p&gt;
&lt;h3 id=&quot;auditory&quot;&gt;Auditory &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/what-is-accessibility/#auditory&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Auditory impairments range from difficulty hearing certain frequencies, to
speech processing issues, to a total inability to hear sound. Users
experiencing an auditory impairment may rely on captions or transcripts to
provide an alternative to sound in an interface.&lt;/p&gt;
&lt;h3 id=&quot;cognitive&quot;&gt;Cognitive &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/what-is-accessibility/#cognitive&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Cognitive impairment is a broad category, encompassing topics such as ADHD,
dyslexia, and autism, just to name a few. The accommodations for these users are
quite diverse, but generally speaking, users may seek to minimize distractions,
flashing, heavy animations, and anything which shifts the user&#39;s context around
the page in an unexpected way. Users may also use custom colors and styles to
improve readability or prevent headaches.&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/what-is-accessibility/#next-steps&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Now that you have a high level understanding of accessibility, it&#39;s time to dive
in to more specific details, starting with keyboard access.&lt;/p&gt;
</content>
    <author>
      <name>Rob Dodson</name>
    </author>
  </entry>
  
  <entry>
    <title>Replace GIFs with video</title>
    <link href="https://web.dev/codelab-replace-gifs-with-video/"/>
    <updated>2018-11-05T00:00:00Z</updated>
    <id>https://web.dev/codelab-replace-gifs-with-video/</id>
    <content type="html" mode="escaped">&lt;aside class=&quot;aside flow bg-state-info-bg color-state-info-text&quot;&gt;&lt;div class=&quot; flow&quot;&gt; This codelab uses Chrome DevTools. &lt;a href=&quot;https://www.google.com/chrome&quot;&gt;Download Chrome&lt;/a&gt; if you don&#39;t already have it. &lt;/div&gt;&lt;/aside&gt;
&lt;p&gt;In this codelab, improve performance by replacing an animated GIF with a
video.&lt;/p&gt;
&lt;h2 id=&quot;measure-first&quot;&gt;Measure first &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/codelab-replace-gifs-with-video/#measure-first&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;First measure how the website performs:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;To preview the site, press &lt;strong&gt;View App&lt;/strong&gt;. Then press
&lt;strong&gt;Fullscreen&lt;/strong&gt;
&lt;img src=&quot;https://web.dev/images/glitch/fullscreen.svg&quot; alt=&quot;fullscreen&quot; style=&quot;padding: 4px 8px; opacity: .5; border: 1px solid #c3c3c3; border-radius: 5px; margin-top: 0;&quot; /&gt;.&lt;/li&gt;
&lt;li&gt;Press `Control+Shift+J` (or `Command+Option+J` on Mac) to open DevTools.&lt;/li&gt;
&lt;li&gt;Click the &lt;strong&gt;Lighthouse&lt;/strong&gt; tab.&lt;/li&gt;
&lt;li&gt;Make sure the &lt;strong&gt;Performance&lt;/strong&gt; checkbox is selected in the &lt;em&gt;Categories&lt;/em&gt; list.&lt;/li&gt;
&lt;li&gt;Click the &lt;strong&gt;Generate report&lt;/strong&gt; button.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;When you&#39;re finished, you should see that Lighthouse has flagged the GIF as an
issue in its &amp;quot;Use video formats for animated content&amp;quot; audit.&lt;/p&gt;
&lt;h2 id=&quot;get-ffmpeg&quot;&gt;Get FFmpeg &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/codelab-replace-gifs-with-video/#get-ffmpeg&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;There are a number of ways you can convert GIFs to video; this guide uses
&lt;strong&gt;&lt;a href=&quot;https://www.ffmpeg.org/&quot; rel=&quot;noopener&quot;&gt;FFmpeg&lt;/a&gt;&lt;/strong&gt;. It&#39;s already installed in the Glitch VM,
and, if you want, you can follow &lt;a href=&quot;https://web.dev/replace-gifs-with-videos/#create-mpeg-videos&quot;&gt;these instructions to install it on your
local
machine&lt;/a&gt;
as well.&lt;/p&gt;
&lt;h2 id=&quot;open-the-console&quot;&gt;Open the console &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/codelab-replace-gifs-with-video/#open-the-console&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Double-check that FFmpeg is installed and working:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Click &lt;strong&gt;Remix to Edit&lt;/strong&gt; to make the project editable.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Terminal&lt;/strong&gt; (note: if the Terminal button does not show you may need to use the Fullscreen option).&lt;/li&gt;
&lt;li&gt;In the console, run:&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;which&lt;/span&gt; ffmpeg&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;You should get a file path back:&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;/usr/bin/ffmpeg&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;h2 id=&quot;change-gif-to-video&quot;&gt;Change GIF to video &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/codelab-replace-gifs-with-video/#change-gif-to-video&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;In the console, run &lt;code&gt;cd images&lt;/code&gt; to enter the images directory.&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;ls&lt;/code&gt; to see the contents.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You should see something like this:&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;$ &lt;span class=&quot;token function&quot;&gt;ls&lt;/span&gt;&lt;br /&gt;cat-herd.gif&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;In the console, run:&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;ffmpeg -i cat-herd.gif -b:v &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt; -crf &lt;span class=&quot;token number&quot;&gt;25&lt;/span&gt; -f mp4 -vcodec libx264 -pix_fmt yuv420p cat-herd.mp4&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;This tells FFmpeg to take the &lt;strong&gt;input&lt;/strong&gt;, signified by the &lt;code&gt;-i&lt;/code&gt; flag, of
cat-herd.gif and convert it to a video called cat-herd.mp4. This should take a
second to run. When the command finishes, you should be able to type &lt;code&gt;ls&lt;/code&gt; again
and see two files:&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;$ &lt;span class=&quot;token function&quot;&gt;ls&lt;/span&gt;&lt;br /&gt;cat-herd.gif  cat-herd.mp4&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;h2 id=&quot;create-webm-videos&quot;&gt;Create WebM videos &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/codelab-replace-gifs-with-video/#create-webm-videos&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;While MP4 has been around since 1999, WebM is a relative newcomer having been
initially released in 2010. WebM videos can be much smaller than MP4 videos, so
it makes sense to generate both. Thankfully the &lt;code&gt;&amp;lt;video&amp;gt;&lt;/code&gt; element will let you
add multiple sources, so if a browser doesn&#39;t support WebM, it can fallback to
MP4.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;In the console, run:&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;ffmpeg -i cat-herd.gif -c vp9 -b:v &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt; -crf &lt;span class=&quot;token number&quot;&gt;41&lt;/span&gt; cat-herd.webm&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;To check the file sizes run:&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;ls&lt;/span&gt; -lh&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;You should have one GIF, and two videos:&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;$ &lt;span class=&quot;token function&quot;&gt;ls&lt;/span&gt; -lh&lt;br /&gt;total &lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt;.5M&lt;br /&gt;-rw-r--r-- &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; app app &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;.7M May &lt;span class=&quot;token number&quot;&gt;26&lt;/span&gt; 00:02 cat-herd.gif&lt;br /&gt;-rw-r--r-- &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; app app 551K May &lt;span class=&quot;token number&quot;&gt;31&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;17&lt;/span&gt;:45 cat-herd.mp4&lt;br /&gt;-rw-r--r-- &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; app app 341K May &lt;span class=&quot;token number&quot;&gt;31&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;17&lt;/span&gt;:44 cat-herd.webm&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;Notice that the original GIF is 3.7M, whereas the MP4 version is 551K, and the
WebM version is only 341K. That&#39;s a huge savings!&lt;/p&gt;
&lt;h2 id=&quot;update-html-to-recreate-gif-effect&quot;&gt;Update HTML to recreate GIF effect &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/codelab-replace-gifs-with-video/#update-html-to-recreate-gif-effect&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Animated GIFs have three key traits that videos need to replicate:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;They play automatically.&lt;/li&gt;
&lt;li&gt;They loop continuously (usually, but it is possible to prevent looping).&lt;/li&gt;
&lt;li&gt;They&#39;re silent.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Luckily, you can recreate these behaviors using the &lt;code&gt;&amp;lt;video&amp;gt;&lt;/code&gt; element.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;In the &lt;code&gt;index.html&lt;/code&gt; file, replace the line with the &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; with:&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;del class=&quot;highlight-line highlight-line-remove&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;/images/cat-herd.gif&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;Cowboys herding cats.&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;/del&gt;&lt;br /&gt;&lt;ins class=&quot;highlight-line highlight-line-add&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;video&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;autoplay&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;loop&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;muted&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;playsinline&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;video&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/ins&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;A &lt;code&gt;&amp;lt;video&amp;gt;&lt;/code&gt; element using these attributes will play automatically, loop
endlessly, play no audio, and play inline (that is, not fullscreen), all the
behaviors expected of animated GIFs! 🎉&lt;/p&gt;
&lt;h2 id=&quot;specify-your-sources&quot;&gt;Specify your sources &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/codelab-replace-gifs-with-video/#specify-your-sources&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;All that&#39;s left to do is specify your video sources. The &lt;code&gt;&amp;lt;video&amp;gt;&lt;/code&gt; element requires
one or more &lt;code&gt;&amp;lt;source&amp;gt;&lt;/code&gt; child elements pointing to different video files the
browser can choose from, depending on format support.
Update the &lt;code&gt;&amp;lt;video&amp;gt;&lt;/code&gt; with &lt;code&gt;&amp;lt;source&amp;gt;&lt;/code&gt; elements that link to your cat-herd videos:&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;highlight-line&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;video&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;autoplay&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;loop&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;muted&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;playsinline&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;mark class=&quot;highlight-line highlight-line-active&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;source&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;/images/cat-herd.webm&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;video/webm&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;/mark&gt;&lt;br /&gt;&lt;mark class=&quot;highlight-line highlight-line-active&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;source&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;/images/cat-herd.mp4&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;video/mp4&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;/mark&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&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;video&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&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; Browsers don&#39;t speculate about which &lt;code&gt;&amp;lt;source&amp;gt;&lt;/code&gt; is optimal, so the order of &lt;code&gt;&amp;lt;source&amp;gt;&lt;/code&gt;s matters. For example, if you specify an MP4 video first and the browser supports WebM, browsers will skip the WebM &lt;code&gt;&amp;lt;source&amp;gt;&lt;/code&gt; and use the MPEG-4 instead. If you prefer a WebM &lt;code&gt;&amp;lt;source&amp;gt;&lt;/code&gt; be used first, specify it first! &lt;/div&gt;&lt;/aside&gt;
&lt;h2 id=&quot;preview&quot;&gt;Preview &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/codelab-replace-gifs-with-video/#preview&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;To preview the site, press &lt;strong&gt;View App&lt;/strong&gt;. Then press
&lt;strong&gt;Fullscreen&lt;/strong&gt;
&lt;img src=&quot;https://web.dev/images/glitch/fullscreen.svg&quot; alt=&quot;fullscreen&quot; style=&quot;padding: 4px 8px; opacity: .5; border: 1px solid #c3c3c3; border-radius: 5px; margin-top: 0;&quot; /&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The experience should look the same. So far so good.&lt;/p&gt;
&lt;h2 id=&quot;verify-with-lighthouse&quot;&gt;Verify with Lighthouse &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/codelab-replace-gifs-with-video/#verify-with-lighthouse&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;With the live site open:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Press `Control+Shift+J` (or `Command+Option+J` on Mac) to open DevTools.&lt;/li&gt;
&lt;li&gt;Click the &lt;strong&gt;Lighthouse&lt;/strong&gt; tab.&lt;/li&gt;
&lt;li&gt;Make sure the &lt;strong&gt;Performance&lt;/strong&gt; checkbox is selected in the &lt;em&gt;Categories&lt;/em&gt; list.&lt;/li&gt;
&lt;li&gt;Click the &lt;strong&gt;Generate report&lt;/strong&gt; button.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You should see that the &amp;quot;Use video formats for animated content&amp;quot; audit is now
passing! Woohoo! 💪&lt;/p&gt;
</content>
    <author>
      <name>Rob Dodson</name>
    </author>
  </entry>
  
  <entry>
    <title>HowTo Components – howto-checkbox</title>
    <link href="https://web.dev/components-howto-checkbox/"/>
    <updated>2017-10-02T00:00:00Z</updated>
    <id>https://web.dev/components-howto-checkbox/</id>
    <content type="html" mode="escaped">&lt;h2 id=&quot;summary&quot;&gt;Summary &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/components-howto-checkbox/#summary&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A &lt;code&gt;&amp;lt;howto-checkbox&amp;gt;&lt;/code&gt; represents a boolean option in a form. The most common type
of checkbox is a dual-type which allows the user to toggle between two
choices -- checked and unchecked.&lt;/p&gt;
&lt;p&gt;The element attempts to self apply the attributes &lt;code&gt;role=&amp;quot;checkbox&amp;quot;&lt;/code&gt; and
&lt;code&gt;tabindex=&amp;quot;0&amp;quot;&lt;/code&gt; when it is first created. The &lt;code&gt;role&lt;/code&gt; attribute helps assistive
technology like a screen reader tell the user what kind of control this is.
The &lt;code&gt;tabindex&lt;/code&gt; attribute opts the element into the tab order, making it keyboard
focusable and operable. To learn more about these two topics, check out
&lt;a href=&quot;https://web.dev/semantics-aria/#what-can-aria-do&quot;&gt;What can ARIA do?&lt;/a&gt; and &lt;a href=&quot;https://web.dev/using-tabindex/&quot;&gt;Using tabindex&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;When the checkbox is checked, it adds a &lt;code&gt;checked&lt;/code&gt; boolean attribute, and sets
a corresponding &lt;code&gt;checked&lt;/code&gt; property to &lt;code&gt;true&lt;/code&gt;. In addition, the element sets an
&lt;code&gt;aria-checked&lt;/code&gt; attribute to either &lt;code&gt;&amp;quot;true&amp;quot;&lt;/code&gt; or &lt;code&gt;&amp;quot;false&amp;quot;&lt;/code&gt;, depending on its
state. Clicking on the checkbox with a mouse, or space bar, toggles these
checked states.&lt;/p&gt;
&lt;p&gt;The checkbox also supports a &lt;code&gt;disabled&lt;/code&gt; state. If either the &lt;code&gt;disabled&lt;/code&gt; property
is set to true or the &lt;code&gt;disabled&lt;/code&gt; attribute is applied, the checkbox sets
&lt;code&gt;aria-disabled=&amp;quot;true&amp;quot;&lt;/code&gt;, removes the &lt;code&gt;tabindex&lt;/code&gt; attribute, and returns focus
to the document if the checkbox is the current &lt;code&gt;activeElement&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The checkbox is paired with a &lt;code&gt;howto-label&lt;/code&gt; element to ensure it has an
&lt;a href=&quot;https://developers.google.com/web/fundamentals/accessibility/semantics-builtin/the-accessibility-tree#semantics_in_native_html&quot; rel=&quot;noopener&quot;&gt;accessible name&lt;/a&gt;.&lt;/p&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; Just because you &lt;em&gt;can&lt;/em&gt; build a custom element checkbox, doesn&#39;t necessarily mean that you &lt;em&gt;should&lt;/em&gt;. As this example shows, you will need to add your own keyboard, labeling, and ARIA support. It&#39;s also important to note that the native &lt;code&gt;&amp;lt;form&amp;gt;&lt;/code&gt; element will NOT submit values from a custom element. You will need to wire that up yourself using AJAX or a hidden &lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt; field. For these reasons it can often be preferable to use the built-in &lt;code&gt;&amp;lt;input type=&amp;quot;checkbox&amp;quot;&amp;gt;&lt;/code&gt; instead. &lt;/div&gt;&lt;/aside&gt;
&lt;h2 id=&quot;reference&quot;&gt;Reference &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/components-howto-checkbox/#reference&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/GoogleChromeLabs/howto-components&quot; rel=&quot;noopener&quot;&gt;HowTo: Components on GitHub&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.w3.org/TR/wai-aria-practices-1.1/#checkbox&quot; rel=&quot;noopener&quot;&gt;Checkbox Pattern in ARIA Authoring Practices 1.1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://web.dev/semantics-aria/#what-can-aria-do&quot;&gt;What can ARIA Do?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://web.dev/using-tabindex/&quot;&gt;Using tabindex&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;demo&quot;&gt;Demo &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/components-howto-checkbox/#demo&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://googlechromelabs.github.io/howto-components/howto-checkbox/#demo&quot; rel=&quot;noopener&quot;&gt;View live demo on GitHub&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;example-usage&quot;&gt;Example usage &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/components-howto-checkbox/#example-usage&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;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;howto-checkbox&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;vertical-align&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; middle&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 selector&quot;&gt;howto-label&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;vertical-align&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; middle&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; inline-block&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;font-weight&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; bold&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; sans-serif&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 20px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token property&quot;&gt;margin-left&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 8px&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;howto-checkbox&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;join-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;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;howto-checkbox&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;howto-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;join-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;Join Newsletter&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;howto-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;h2 id=&quot;code&quot;&gt;Code &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/components-howto-checkbox/#code&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 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;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;Define key codes to help with handling keyboard events.&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;const&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;KEYCODE&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 constant&quot;&gt;SPACE&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;32&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;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;Cloning contents from a &lt;code&gt;&amp;lt;template&amp;gt;&lt;/code&gt; element is more performant than using innerHTML because it avoids additional HTML parse costs.&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;const&lt;/span&gt; template &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;createElement&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;template&#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;br /&gt;  template&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;innerHTML &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&lt;br /&gt;    &amp;lt;style&gt;&lt;br /&gt;      :host {&lt;br /&gt;        display: inline-block;&lt;br /&gt;        background: url(&#39;../images/unchecked-checkbox.svg&#39;) no-repeat;&lt;br /&gt;        background-size: contain;&lt;br /&gt;        width: 24px;&lt;br /&gt;        height: 24px;&lt;br /&gt;      }&lt;br /&gt;      :host([hidden]) {&lt;br /&gt;        display: none;&lt;br /&gt;      }&lt;br /&gt;      :host([checked]) {&lt;br /&gt;        background: url(&#39;../images/checked-checkbox.svg&#39;) no-repeat;&lt;br /&gt;        background-size: contain;&lt;br /&gt;      }&lt;br /&gt;      :host([disabled]) {&lt;br /&gt;        background:&lt;br /&gt;          url(&#39;../images/unchecked-checkbox-disabled.svg&#39;) no-repeat;&lt;br /&gt;        background-size: contain;&lt;br /&gt;      }&lt;br /&gt;      :host([checked][disabled]) {&lt;br /&gt;        background:&lt;br /&gt;          url(&#39;../images/checked-checkbox-disabled.svg&#39;) no-repeat;&lt;br /&gt;        background-size: contain;&lt;br /&gt;      }&lt;br /&gt;    &amp;lt;/style&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;HowToCheckbox&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;HTMLElement&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;static&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;get&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;observedAttributes&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;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;checked&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;disabled&#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;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;The element&#39;s constructor is run anytime a new instance is created. Instances are created either by parsing HTML, calling document.createElement(&#39;howto-checkbox&#39;), or calling new HowToCheckbox(); The constructor is a good place to create shadow DOM, though you should avoid touching any attributes or light DOM children as they may not be available yet.&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;constructor&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;super&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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;attachShadow&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;mode&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;open&#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 punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;shadowRoot&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;appendChild&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;template&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;content&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;cloneNode&lt;/span&gt;&lt;span class=&quot;token punctuation&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;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;&lt;code&gt;connectedCallback()&lt;/code&gt; fires when the element is inserted into the DOM. It&#39;s a good place to set the initial &lt;code&gt;role&lt;/code&gt;, &lt;code&gt;tabindex&lt;/code&gt;, internal state, and install event listeners.&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;connectedCallback&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;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;hasAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;role&#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 keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;role&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;checkbox&#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 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;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;hasAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;tabindex&#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 keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;tabindex&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&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;A user may set a property on an instance of an element, before its prototype has been connected to this class. The &lt;code&gt;_upgradeProperty()&lt;/code&gt; method will check for any instance properties and run them through the proper class setters. See the &lt;a href=&quot;https://web.dev/custom-elements-best-practices/#make-properties-lazy&quot;&gt;lazy properties&lt;/a&gt; section for more details.&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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;_upgradeProperty&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;checked&#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 keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;_upgradeProperty&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;disabled&#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;br /&gt;      &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&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;keyup&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_onKeyUp&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;this&lt;/span&gt;&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 keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_onClick&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;br /&gt;    &lt;span class=&quot;token function&quot;&gt;_upgradeProperty&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;prop&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;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;hasOwnProperty&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;prop&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;let&lt;/span&gt; value &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;prop&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;delete&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;prop&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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;prop&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; value&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;&lt;code&gt;disconnectedCallback()&lt;/code&gt; fires when the element is removed from the DOM. It&#39;s a good place to do clean up work like releasing references and removing event listeners.&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;disconnectedCallback&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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;removeEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;keyup&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_onKeyUp&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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;removeEventListener&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 keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_onClick&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;Properties and their corresponding attributes should mirror one another. The property setter for checked handles truthy/falsy values and reflects those to the state of the attribute. See the &lt;a href=&quot;https://web.dev/custom-elements-best-practices/#avoid-reentrancy-issues&quot;&gt;avoid reentrancy&lt;/a&gt; section for more details.&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;set&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;checked&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;value&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;const&lt;/span&gt; isChecked &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;Boolean&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;value&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;isChecked&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;checked&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&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;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;removeAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;checked&#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;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;get&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;checked&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;return&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;hasAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;checked&#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;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;disabled&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;value&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;const&lt;/span&gt; isDisabled &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;Boolean&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;value&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;isDisabled&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;disabled&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&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;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;removeAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;disabled&#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;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;get&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;disabled&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;return&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;hasAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;disabled&#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;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;&lt;code&gt;attributeChangedCallback()&lt;/code&gt; is called when any of the attributes in the observedAttributes array are changed. It&#39;s a good place to handle side effects, like setting ARIA attributes.&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;attributeChangedCallback&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;name&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; oldValue&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; newValue&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;const&lt;/span&gt; hasValue &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; newValue &lt;span class=&quot;token operator&quot;&gt;!==&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;null&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;name&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;checked&#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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;aria-checked&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; hasValue&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;disabled&#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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;aria-disabled&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; hasValue&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;The &lt;code&gt;tabindex&lt;/code&gt; attribute does not provide a way to fully remove focusability from an element. Elements with &lt;code&gt;tabindex=-1&lt;/code&gt; can still be focused with a mouse or by calling &lt;code&gt;focus()&lt;/code&gt;. To make sure an element is disabled and not focusable, remove the &lt;code&gt;tabindex&lt;/code&gt; attribute.&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;hasValue&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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;removeAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;tabindex&#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;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;If the focus is currently on this element, unfocus it by calling the &lt;code&gt;HTMLElement.blur()&lt;/code&gt; method&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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;blur&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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;tabindex&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;0&#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 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;br /&gt;&lt;br /&gt;    &lt;span class=&quot;token function&quot;&gt;_onKeyUp&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;event&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;Don’t handle modifier shortcuts typically used by assistive technology.&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;event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;altKey&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;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&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;event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;keyCode&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 constant&quot;&gt;KEYCODE&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;SPACE&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;br /&gt;          event&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;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;_toggleChecked&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;break&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;Any other key press is ignored and passed back to the browser.&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;default&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 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 function&quot;&gt;_onClick&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;event&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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;_toggleChecked&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;&lt;code&gt;_toggleChecked()&lt;/code&gt; calls the checked setter and flips its state. Because &lt;code&gt;_toggleChecked()&lt;/code&gt; is only caused by a user action, it will also dispatch a change event. This event bubbles in order to mimic the native behavior of &lt;code&gt;&amp;lt;input type=checkbox&amp;gt;&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;_toggleChecked&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;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;disabled&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;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;checked &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;checked&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;dispatchEvent&lt;/span&gt;&lt;span class=&quot;token punctuation&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;CustomEvent&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;change&#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;detail&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;checked&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;checked&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;bubbles&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 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 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;  customElements&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;howto-checkbox&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; HowToCheckbox&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;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;</content>
    <author>
      <name>Ewa Gasperowicz</name>
    </author><author>
      <name>Rob Dodson</name>
    </author><author>
      <name>Surma</name>
    </author>
  </entry>
  
  <entry>
    <title>Accessibility for teams</title>
    <link href="https://web.dev/a11y-for-teams/"/>
    <updated>2017-08-01T00:00:00Z</updated>
    <id>https://web.dev/a11y-for-teams/</id>
    <content type="html" mode="escaped">&lt;p&gt;Making your site more accessible can be a daunting task. If you are approaching
accessibility for the first time, the sheer breadth of the topic can leave you
wondering where to start. After all, working to accommodate a diverse range of
abilities means there are a correspondingly diverse range of issues to consider.&lt;/p&gt;
&lt;p&gt;Remember, accessibility is a team effort. Every person has a role to play. This
article outlines criteria for each of the major disciplines (project manager, UX
designer, and developer) so that they can work to incorporate accessibility best
practices into their process.&lt;/p&gt;
&lt;div class=&quot;youtube&quot;&gt;  &lt;lite-youtube videoid=&quot;A5XzoDT37iM&quot;&gt;  &lt;/lite-youtube&gt;&lt;/div&gt;
&lt;h2 id=&quot;project-manager&quot;&gt;Project manager &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/a11y-for-teams/#project-manager&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;An overriding goal for any project manager is to try to include accessibility
work in every milestone; making sure it’s just as much a priority as other
topics like performance, and user experience. Below are a few checklist items to
keep in mind when working through your process.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Make accessibility training available to the team.&lt;/li&gt;
&lt;li&gt;Identify critical user journeys in the site or application.&lt;/li&gt;
&lt;li&gt;Try to incorporate an accessibility checklist into the team process.&lt;/li&gt;
&lt;li&gt;Where possible, evaluate the site or application with user studies.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;accessibility-training&quot;&gt;Accessibility training &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/a11y-for-teams/#accessibility-training&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;There are a number of great free resources for learning about web accessibility.
Setting aside time for your team to study the topic can make it easier to
include accessibility early in the process.&lt;/p&gt;
&lt;p&gt;Some resources provided by Google include:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://bit.ly/web-a11y&quot; rel=&quot;noopener&quot;&gt;Web Accessibility by Google&lt;/a&gt; — a multi-week interactive
training course.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://bit.ly/a11y-fundamentals&quot; rel=&quot;noopener&quot;&gt;Accessibility Fundamentals&lt;/a&gt; — written
accessibility guides and best practices.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://bit.ly/a11y-material&quot; rel=&quot;noopener&quot;&gt;Material Guidelines: Accessibility&lt;/a&gt; — a set of
UX best practices for inclusive design.&lt;/p&gt;
&lt;h3 id=&quot;identifying-critical-user-journeys&quot;&gt;Identifying critical user journeys &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/a11y-for-teams/#identifying-critical-user-journeys&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Every application has some primary action that the user needs to take. For
example, if you&#39;re building an e-commerce app, then every user will need to be
able to add an item to their shopping cart.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;Primary user journey: A user can add an item to their shopping cart.&quot; decoding=&quot;async&quot; height=&quot;447&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 800px) 800px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&amp;w=1428 1428w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&amp;w=1600 1600w&quot; width=&quot;800&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;Some actions may be of secondary importance, and perhaps only performed
occasionally. For example, changing your avatar photo is a nice feature, but
may not be critical for every experience.&lt;/p&gt;
&lt;p&gt;Identifying the primary and secondary actions in your application will help you
prioritize the accessibility work ahead. Later, you can combine these actions
with an accessibility checklist to keep track of your progress and avoid
regressions.&lt;/p&gt;
&lt;h3 id=&quot;incorporating-an-accessibility-checklist&quot;&gt;Incorporating an accessibility checklist &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/a11y-for-teams/#incorporating-an-accessibility-checklist&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The topic of accessibility is quite broad, so having a checklist of
important areas to consider can help you make sure you&#39;re covering all of your
bases.&lt;/p&gt;
&lt;p&gt;There are a number of accessibility checklists out there, a few industry
examples include:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://webaim.org/standards/wcag/checklist&quot; rel=&quot;noopener&quot;&gt;WebAIM WCAG Checklist&lt;/a&gt;
&lt;a href=&quot;https://accessibility.voxmedia.com/&quot; rel=&quot;noopener&quot;&gt;Vox Accessibility Guidelines&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;With a checklist in hand, you can look over your primary and secondary actions
to start to triage what work still needs to be done. You can get pretty tactical
about this process and even build a matrix of primary and secondary actions and
determine for each step in those processes, whether there are any missing
accessibility bits.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;A table with primary use cases as rows and checklist items as columns.&quot; decoding=&quot;async&quot; height=&quot;447&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 800px) 800px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&amp;w=1428 1428w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/fIlqtDx7bDsiSDYS0XpN.jpg?auto=format&amp;w=1600 1600w&quot; width=&quot;800&quot; /&gt;
&lt;/figure&gt;
&lt;h3 id=&quot;evaluating-with-user-studies&quot;&gt;Evaluating with user studies &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/a11y-for-teams/#evaluating-with-user-studies&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Nothing beats sitting down with actual users and observing them as they try to
use your app. If you&#39;re retrofitting accessibility into an existing experience,
this process can help you quickly identify areas that need improvement. And if
you&#39;re starting a new project, early user studies can help you
avoid spending too much time developing a feature that is difficult to use.&lt;/p&gt;
&lt;p&gt;Aim to incorporate feedback from as diverse of a user population as possible.
Consider users who primarily navigate with the keyboard, or rely on assistive
technology like screen readers or screen magnifiers.&lt;/p&gt;
&lt;h2 id=&quot;ux-designer&quot;&gt;UX designer &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/a11y-for-teams/#ux-designer&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Because people tend to design using their own biases, if you don&#39;t have a
disability and don&#39;t have colleagues with disabilities, you might be
unintentionally designing for only some of your users. As you work, ask yourself
&amp;quot;what are all the types of users who might rely on this design?&amp;quot; Here are some
techniques you can try to make your process more inclusive.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Content has sufficient color contrast.&lt;/li&gt;
&lt;li&gt;The tab order is defined.&lt;/li&gt;
&lt;li&gt;Controls have accessible labels.&lt;/li&gt;
&lt;li&gt;There are multiple ways to interact with the UI.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;content-has-good-color-contrast&quot;&gt;Content has good color contrast &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/a11y-for-teams/#content-has-good-color-contrast&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The primary goal of most sites is to convey some information to the user, either
through written text or images. However, if this content is low contrast, it may
be difficult for some users (particularly those with a vision impairment) to
read. This may negatively affect their user experience. To address
this concern, aim for all text and images to have sufficient color contrast.&lt;/p&gt;
&lt;p&gt;Contrast is measured by comparing the luminance of a foreground and background
color. For smaller text (anything below 18pt or 14pt bold) a minimum ratio of
4.5:1 is recommended. For larger text, this ratio can be adjusted to 3:1.&lt;/p&gt;
&lt;p&gt;In the image below, the text on the left hand side meets these contrast
minimums, whereas the text on right hand side is low contrast.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;Side-by-side text samples. One is sufficient contrast, one is low contrast.&quot; decoding=&quot;async&quot; height=&quot;449&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 800px) 800px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/jaNjQm0xH9SCKlwlGkkr.jpg?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/jaNjQm0xH9SCKlwlGkkr.jpg?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/jaNjQm0xH9SCKlwlGkkr.jpg?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/jaNjQm0xH9SCKlwlGkkr.jpg?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/jaNjQm0xH9SCKlwlGkkr.jpg?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/jaNjQm0xH9SCKlwlGkkr.jpg?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/jaNjQm0xH9SCKlwlGkkr.jpg?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/jaNjQm0xH9SCKlwlGkkr.jpg?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/jaNjQm0xH9SCKlwlGkkr.jpg?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/jaNjQm0xH9SCKlwlGkkr.jpg?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/jaNjQm0xH9SCKlwlGkkr.jpg?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/jaNjQm0xH9SCKlwlGkkr.jpg?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/jaNjQm0xH9SCKlwlGkkr.jpg?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/jaNjQm0xH9SCKlwlGkkr.jpg?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/jaNjQm0xH9SCKlwlGkkr.jpg?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/jaNjQm0xH9SCKlwlGkkr.jpg?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/jaNjQm0xH9SCKlwlGkkr.jpg?auto=format&amp;w=1428 1428w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/jaNjQm0xH9SCKlwlGkkr.jpg?auto=format&amp;w=1600 1600w&quot; width=&quot;800&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;There are a number of tools for measuring color contrast, such as Google’s &lt;a href=&quot;https://material.io/color&quot; rel=&quot;noopener&quot;&gt;Material
Color Tool&lt;/a&gt;, &lt;a href=&quot;https://leaverou.github.io/contrast-ratio&quot; rel=&quot;noopener&quot;&gt;Lea Verou&#39;s Contrast Ratio
app&lt;/a&gt;, and Deque’s
&lt;a href=&quot;https://chrome.google.com/webstore/detail/axe/lhdoppojpmngadmnindnejefpokejbdd&quot; rel=&quot;noopener&quot;&gt;aXe&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&quot;tab-order-is-defined&quot;&gt;Tab order is defined &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/a11y-for-teams/#tab-order-is-defined&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The tab order is the order in which elements receive focus as the user
presses the tab key. For users who navigate primarily with a keyboard, the
tab key is their primary means of reaching everything on screen. Think of it
like their mouse cursor.&lt;/p&gt;
&lt;p&gt;Ideally the tab order should follow the reading order and flow from the top of
the page to the bottom, with more important items appearing higher up in the
order. This makes it more efficient for anyone using a keyboard to quickly reach
these items.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;A design comp with interactive controls numbered.&quot; decoding=&quot;async&quot; height=&quot;447&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 800px) 800px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/bXXmEcviM7CcBIOe4IY9.jpg?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/bXXmEcviM7CcBIOe4IY9.jpg?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/bXXmEcviM7CcBIOe4IY9.jpg?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/bXXmEcviM7CcBIOe4IY9.jpg?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/bXXmEcviM7CcBIOe4IY9.jpg?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/bXXmEcviM7CcBIOe4IY9.jpg?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/bXXmEcviM7CcBIOe4IY9.jpg?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/bXXmEcviM7CcBIOe4IY9.jpg?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/bXXmEcviM7CcBIOe4IY9.jpg?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/bXXmEcviM7CcBIOe4IY9.jpg?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/bXXmEcviM7CcBIOe4IY9.jpg?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/bXXmEcviM7CcBIOe4IY9.jpg?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/bXXmEcviM7CcBIOe4IY9.jpg?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/bXXmEcviM7CcBIOe4IY9.jpg?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/bXXmEcviM7CcBIOe4IY9.jpg?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/bXXmEcviM7CcBIOe4IY9.jpg?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/bXXmEcviM7CcBIOe4IY9.jpg?auto=format&amp;w=1428 1428w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/bXXmEcviM7CcBIOe4IY9.jpg?auto=format&amp;w=1600 1600w&quot; width=&quot;800&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;The mock interface above is numbered to show the tab order. Creating a mock like
this can help by identifying the intended tab order. This can then be shared
with the developers and QA testers to make sure it is properly implemented and
tested.&lt;/p&gt;
&lt;h3 id=&quot;controls-have-accessible-labels&quot;&gt;Controls have accessible labels &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/a11y-for-teams/#controls-have-accessible-labels&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;For users of assistive technology like screen readers, labels provide
information that would otherwise be visual only. For example a search button
that&#39;s just a magnifying glass icon can have an accessible label of &amp;quot;Search&amp;quot; to
help fill in the missing visual affordance.&lt;/p&gt;
&lt;p&gt;Here are a few simple suggestions to follow when designing accessible labels:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Be succinct - It can be tedious to listen to long descriptions.&lt;/li&gt;
&lt;li&gt;Try not to include control type or state - If the control is coded properly
then a screen reader will announce this automatically.&lt;/li&gt;
&lt;li&gt;Focus on action verbs - Use &amp;quot;search&amp;quot; not &amp;quot;magnifying glass&amp;quot;.&lt;/li&gt;
&lt;/ul&gt;
&lt;figure&gt;
&lt;img alt=&quot;A design comp with controls marked with their accessible labels.&quot; decoding=&quot;async&quot; height=&quot;448&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 800px) 800px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/Crox54xaTpHceNJinK7X.jpg?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/Crox54xaTpHceNJinK7X.jpg?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/Crox54xaTpHceNJinK7X.jpg?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/Crox54xaTpHceNJinK7X.jpg?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/Crox54xaTpHceNJinK7X.jpg?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/Crox54xaTpHceNJinK7X.jpg?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/Crox54xaTpHceNJinK7X.jpg?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/Crox54xaTpHceNJinK7X.jpg?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/Crox54xaTpHceNJinK7X.jpg?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/Crox54xaTpHceNJinK7X.jpg?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/Crox54xaTpHceNJinK7X.jpg?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/Crox54xaTpHceNJinK7X.jpg?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/Crox54xaTpHceNJinK7X.jpg?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/Crox54xaTpHceNJinK7X.jpg?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/Crox54xaTpHceNJinK7X.jpg?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/Crox54xaTpHceNJinK7X.jpg?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/Crox54xaTpHceNJinK7X.jpg?auto=format&amp;w=1428 1428w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/Crox54xaTpHceNJinK7X.jpg?auto=format&amp;w=1600 1600w&quot; width=&quot;800&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;You might consider creating a mock with all of your controls labeled. This can
be shared with your development team and QA team for implementation and testing.&lt;/p&gt;
&lt;h3 id=&quot;multiple-ways-to-interact-with-and-understand-ui&quot;&gt;Multiple ways to interact with and understand UI &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/a11y-for-teams/#multiple-ways-to-interact-with-and-understand-ui&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;It&#39;s easy to assume that all users interact with the
page primarily using a mouse. When designing, consider how someone will
interact with a control using a keyboard instead.&lt;/p&gt;
&lt;p&gt;Plan your focus states! This means determining what a control will look like
when the user focuses it with tab or presses the arrow keys. It&#39;s useful to have
these states planned early, rather than trying to shoehorn them into the design
later.&lt;/p&gt;
&lt;p&gt;Finally, for any point of interaction, you want to make sure that the user has
multiple ways of understanding the content. Try not to use color alone to convey
information, as these subtle cues may be missed by a user with a color vision
deficiency. A classic example is an invalid text field. Instead of just a red
underline to signify a problem, also consider adding some helper text. That
way you&#39;re covering more bases and increasing the likelihood that a user will
notice the issue.&lt;/p&gt;
&lt;h2 id=&quot;developer&quot;&gt;Developer &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/a11y-for-teams/#developer&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The developer&#39;s role is where focus management and semantics combine to form a
robust user experience. Below are a few items a developers can keep in mind as
they&#39;re working on their site or application:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The tab order is logical.&lt;/li&gt;
&lt;li&gt;Focus is properly managed and visible.&lt;/li&gt;
&lt;li&gt;Interactive elements have keyboard support.&lt;/li&gt;
&lt;li&gt;ARIA roles and attributes are applied as needed.&lt;/li&gt;
&lt;li&gt;Elements are properly labeled.&lt;/li&gt;
&lt;li&gt;Testing is automated.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;logical-tab-order&quot;&gt;Logical tab order &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/a11y-for-teams/#logical-tab-order&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Native elements like &lt;code&gt;input&lt;/code&gt;, &lt;code&gt;button&lt;/code&gt;, and &lt;code&gt;select&lt;/code&gt; get opted into the tab
order for free and are automatically focusable with the keyboard. But not all
elements receive this same behavior! In particular, generic elements like &lt;code&gt;div&lt;/code&gt;,
and &lt;code&gt;span&lt;/code&gt;, are not opted into the tab order. This means if you use a &lt;code&gt;div&lt;/code&gt; to
create an interactive control, you&#39;ll need to do additional work to make
it keyboard accessible.&lt;/p&gt;
&lt;p&gt;Two options are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Give the control a &lt;code&gt;tabindex=&amp;quot;0&amp;quot;&lt;/code&gt;. This will at least make it focusable,
though you&#39;ll likely need to do additional work to add support for keypresses.&lt;/li&gt;
&lt;li&gt;Where possible, consider using a &lt;code&gt;button&lt;/code&gt; instead of a &lt;code&gt;div&lt;/code&gt; or &lt;code&gt;span&lt;/code&gt; for any
button-like control. The native &lt;code&gt;button&lt;/code&gt; element is very easy to style and gets
keyboard support for free.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;youtube&quot;&gt;  &lt;lite-youtube videoid=&quot;CZGqnp06DnI&quot;&gt;  &lt;/lite-youtube&gt;&lt;/div&gt;
&lt;h3 id=&quot;managing-focus&quot;&gt;Managing focus &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/a11y-for-teams/#managing-focus&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;When you change the content of the page, it&#39;s important to direct the user&#39;s
attention by moving focus. A classic example of when this technique is useful is
when opening a modal dialog. If a user relying on a keyboard presses a button to
open a dialog and their focus &lt;em&gt;is not&lt;/em&gt; moved into the dialog element, then their
only course of action is to tab through the entire site until they eventually
find the new control. By moving focus into the new content as soon as it
appears, you can improve the efficiency of these users’ experiences.&lt;/p&gt;
&lt;div class=&quot;youtube&quot;&gt;  &lt;lite-youtube videoid=&quot;JS68faEUduk&quot;&gt;  &lt;/lite-youtube&gt;&lt;/div&gt;
&lt;h3 id=&quot;keyboard-support-for-interactive-elements&quot;&gt;Keyboard support for interactive elements &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/a11y-for-teams/#keyboard-support-for-interactive-elements&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;If you&#39;re building a custom control like a carousel or dropdown, then you&#39;ll
need to do some additional work to add keyboard support. The &lt;a href=&quot;https://w3.org/TR/wai-aria-practices-1.1&quot; rel=&quot;noopener&quot;&gt;ARIA Authoring
Practices Guide&lt;/a&gt; is a useful resource
which identifies various UI patterns and the kinds of keyboard actions they are
expected to support.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt=&quot;An excerpt from the ARIA Authoring Practices guide explaining how to build a radio group.&quot; decoding=&quot;async&quot; height=&quot;449&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 800px) 800px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/4fMxB2KVIG5qXWX5Nc7l.jpg?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/4fMxB2KVIG5qXWX5Nc7l.jpg?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/4fMxB2KVIG5qXWX5Nc7l.jpg?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/4fMxB2KVIG5qXWX5Nc7l.jpg?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/4fMxB2KVIG5qXWX5Nc7l.jpg?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/4fMxB2KVIG5qXWX5Nc7l.jpg?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/4fMxB2KVIG5qXWX5Nc7l.jpg?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/4fMxB2KVIG5qXWX5Nc7l.jpg?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/4fMxB2KVIG5qXWX5Nc7l.jpg?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/4fMxB2KVIG5qXWX5Nc7l.jpg?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/4fMxB2KVIG5qXWX5Nc7l.jpg?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/4fMxB2KVIG5qXWX5Nc7l.jpg?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/4fMxB2KVIG5qXWX5Nc7l.jpg?auto=format&amp;w=845 845w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/4fMxB2KVIG5qXWX5Nc7l.jpg?auto=format&amp;w=964 964w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/4fMxB2KVIG5qXWX5Nc7l.jpg?auto=format&amp;w=1098 1098w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/4fMxB2KVIG5qXWX5Nc7l.jpg?auto=format&amp;w=1252 1252w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/4fMxB2KVIG5qXWX5Nc7l.jpg?auto=format&amp;w=1428 1428w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/4fMxB2KVIG5qXWX5Nc7l.jpg?auto=format&amp;w=1600 1600w&quot; width=&quot;800&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;To learn more about adding keyboard support to an element, take a look at the
&lt;a href=&quot;https://web.dev/a11y-for-teams/(https://web.dev/control-focus-with-tabindex/#create-accessible-components-with-%22roving-tabindex%22)&quot;&gt;roving tabindex&lt;/a&gt;
section in Google’s Accessibility Fundamentals docs.&lt;/p&gt;
&lt;h3 id=&quot;aria-roles-and-attributes-are-applied-as-needed&quot;&gt;ARIA roles and attributes are applied as needed &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/a11y-for-teams/#aria-roles-and-attributes-are-applied-as-needed&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Not only do custom controls need proper keyboard support, they also need proper
semantics. After all, a &lt;code&gt;div&lt;/code&gt;, semantically, is just a generic grouping
container. If you&#39;re using a &lt;code&gt;div&lt;/code&gt; as the basis for your dropdown menu, you&#39;ll
need to rely on
&lt;a href=&quot;https://web.dev/semantics-aria/&quot;&gt;ARIA&lt;/a&gt;
to layer in additional semantics so the control type can be conveyed to
assistive technology. Here again the
&lt;a href=&quot;https://w3.org/TR/wai-aria-practices-1.1&quot; rel=&quot;noopener&quot;&gt;ARIA Authoring Practices Guide&lt;/a&gt;
can help by identifying which roles, states, and properties you should be using.
As an added bonus, many of the explanations in the ARIA guide also come with
sample code!&lt;/p&gt;
&lt;h3 id=&quot;labeling-elements&quot;&gt;Labeling elements &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/a11y-for-teams/#labeling-elements&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;For labeling native inputs, you can use the built-in
&lt;a href=&quot;https://developer.mozilla.org/docs/Web/HTML/Element/label&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;&amp;lt;label&amp;gt;&lt;/code&gt; element&lt;/a&gt;
as described on MDN. Not only will this help you create an onscreen visual
affordance, but it also gives the input an accessible name in the accessibility
tree. This name is then picked up by assistive technology (like a screen reader)
and announced to the user.&lt;/p&gt;
&lt;p&gt;Unfortunately &lt;code&gt;&amp;lt;label&amp;gt;&lt;/code&gt; &lt;em&gt;does not&lt;/em&gt; support giving an accessible name to custom
controls (like ones created using &lt;a href=&quot;https://web.dev/custom-elements-v1/&quot;&gt;Custom
Elements&lt;/a&gt;
or out of simple divs and spans). For these kinds of controls you&#39;ll need to use
the &lt;a href=&quot;https://web.dev/aria-labels-and-relationships/#labels&quot;&gt;&lt;code&gt;aria-label&lt;/code&gt; and &lt;code&gt;aria-labelledby&lt;/code&gt;
attributes&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&quot;automated-testing&quot;&gt;Automated testing &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/a11y-for-teams/#automated-testing&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Being lazy can be good, especially when it comes to testing. Wherever possible
seek to automate your accessibility tests so you don&#39;t have to do everything
manually. There are a number of great industry testing tools that exist today to
make it easy and fast to check for common accessibility issues:&lt;/p&gt;
&lt;p&gt;aXe, created by Deque systems, is available as a &lt;a href=&quot;https://chrome.google.com/webstore/detail/axe/lhdoppojpmngadmnindnejefpokejbdd&quot; rel=&quot;noopener&quot;&gt;Chrome
extension&lt;/a&gt;
and &lt;a href=&quot;https://github.com/dequelabs/axe-core&quot; rel=&quot;noopener&quot;&gt;a Node module&lt;/a&gt; (good for continuous
integration environments). This short A11ycast explains a few different ways to
incorporate aXe into your development process.&lt;/p&gt;
&lt;div class=&quot;youtube&quot;&gt;  &lt;lite-youtube videoid=&quot;jC_7NnRdYb0&quot;&gt;  &lt;/lite-youtube&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href=&quot;https://developer.chrome.com/docs/lighthouse/overview/&quot; rel=&quot;noopener&quot;&gt;Lighthouse&lt;/a&gt; is Google’s
open source project for auditing the performance of your Progressive Web Apps.
In addition to checking if your PWA has support for things like &lt;a href=&quot;https://developer.chrome.com/docs/workbox/service-worker-overview/&quot; rel=&quot;noopener&quot;&gt;Service
Worker&lt;/a&gt;
and a &lt;a href=&quot;https://web.dev/add-manifest/&quot;&gt;Web App
Manifest&lt;/a&gt;,
Lighthouse will also run a series of best practice tests, including tests for
accessibility issues.&lt;/p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/a11y-for-teams/#conclusion&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Accessibility is a team effort. Everyone has a role to play. This guide has laid
out a few key items that each team member can use to quickly ramp up on the
subject and hopefully improve the overall experience of their app.&lt;/p&gt;
&lt;p&gt;To learn more about accessibility, be sure to check out &lt;a href=&quot;https://bit.ly/web-a11y&quot; rel=&quot;noopener&quot;&gt;our free Udacity
course&lt;/a&gt; and browse &lt;a href=&quot;https://web.dev/accessible/&quot;&gt;the accessibility docs&lt;/a&gt; available here on web.dev.&lt;/p&gt;
</content>
    <author>
      <name>Rob Dodson</name>
    </author>
  </entry>
  
  <entry>
    <title>HowTo Components – howto-tabs</title>
    <link href="https://web.dev/components-howto-tabs/"/>
    <updated>2017-04-06T00:00:00Z</updated>
    <id>https://web.dev/components-howto-tabs/</id>
    <content type="html" mode="escaped">&lt;h2 id=&quot;summary&quot;&gt;Summary &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/components-howto-tabs/#summary&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;&amp;lt;howto-tabs&amp;gt;&lt;/code&gt; limit visible content by separating it into multiple panels. Only
one panel is visible at a time, while &lt;em&gt;all&lt;/em&gt; corresponding tabs are always
visible. To switch from one panel to another, the corresponding tab has to be
selected.&lt;/p&gt;
&lt;p&gt;By either clicking or by using the arrow keys the user can change the
selection of the active tab.&lt;/p&gt;
&lt;p&gt;If JavaScript is disabled, all panels are shown interleaved with the
respective tabs. The tabs now function as headings.&lt;/p&gt;
&lt;h2 id=&quot;reference&quot;&gt;Reference &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/components-howto-tabs/#reference&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/GoogleChromeLabs/howto-components&quot; rel=&quot;noopener&quot;&gt;HowTo: Components on GitHub&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.w3.org/TR/wai-aria-practices-1.1/#tabpanel&quot; rel=&quot;noopener&quot;&gt;Tabs pattern in ARIA Authoring Practices 1.1&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;demo&quot;&gt;Demo &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/components-howto-tabs/#demo&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://googlechromelabs.github.io/howto-components/howto-tabs/#demo&quot; rel=&quot;noopener&quot;&gt;View live demo on GitHub&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;example-usage&quot;&gt;Example usage &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/components-howto-tabs/#example-usage&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;style&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  howto-tab {&lt;br /&gt;    border: 1px solid black;&lt;br /&gt;    padding: 20px;&lt;br /&gt;  }&lt;br /&gt;  howto-panel {&lt;br /&gt;    padding: 20px;&lt;br /&gt;    background-color: lightgray;&lt;br /&gt;  }&lt;br /&gt;  howto-tab[selected] {&lt;br /&gt;    background-color: bisque;&lt;br /&gt;  }&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;If JavaScript does not run, the element will not match &lt;code&gt;:defined&lt;/code&gt;. In that case this style adds spacing between tabs and previous panel.&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;  howto-tabs:not(:defined), howto-tab:not(:defined), howto-panel:not(:defined) {&lt;br /&gt;    display: block;&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;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;howto-tabs&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;howto-tab&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;heading&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;slot&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;tab&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;Tab 1&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;howto-tab&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;howto-panel&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;region&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;slot&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;panel&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;Content 1&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;howto-panel&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;howto-tab&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;heading&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;slot&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;tab&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;Tab 2&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;howto-tab&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;howto-panel&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;region&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;slot&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;panel&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;Content 2&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;howto-panel&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;howto-tab&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;heading&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;slot&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;tab&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;Tab 3&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;howto-tab&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;howto-panel&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;region&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;slot&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;panel&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;Content 3&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;howto-panel&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;howto-tabs&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;code&quot;&gt;Code &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/components-howto-tabs/#code&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 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;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;Define key codes to help with handling keyboard events.&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;const&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;KEYCODE&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 constant&quot;&gt;DOWN&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;40&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token constant&quot;&gt;LEFT&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;37&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token constant&quot;&gt;RIGHT&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;39&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token constant&quot;&gt;UP&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;38&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token constant&quot;&gt;HOME&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;36&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token constant&quot;&gt;END&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;35&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;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;To avoid invoking the parser with &lt;code&gt;.innerHTML&lt;/code&gt; for every new instance, a template for the contents of the shadow DOM is shared by all &lt;code&gt;&amp;lt;howto-tabs&amp;gt;&lt;/code&gt; instances.&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;const&lt;/span&gt; template &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;createElement&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;template&#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;  template&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;innerHTML &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&lt;br /&gt;    &amp;lt;style&gt;&lt;br /&gt;      :host {&lt;br /&gt;        display: flex;&lt;br /&gt;        flex-wrap: wrap;&lt;br /&gt;      }&lt;br /&gt;      ::slotted(howto-panel) {&lt;br /&gt;        flex-basis: 100%;&lt;br /&gt;      }&lt;br /&gt;    &amp;lt;/style&gt;&lt;br /&gt;    &amp;lt;slot name=&quot;tab&quot;&gt;&amp;lt;/slot&gt;&lt;br /&gt;    &amp;lt;slot name=&quot;panel&quot;&gt;&amp;lt;/slot&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&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;HowtoTabs is a container element for tabs and panels.&lt;/p&gt;
&lt;p&gt;All children of &lt;code&gt;&amp;lt;howto-tabs&amp;gt;&lt;/code&gt; should be either &lt;code&gt;&amp;lt;howto-tab&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;howto-tabpanel&amp;gt;&lt;/code&gt;. This element is stateless, meaning that no values are cached and therefore, changes during runtime work.&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;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;HowtoTabs&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;HTMLElement&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;constructor&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;super&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;Event handlers that are not attached to this element need to be bound if they need access to &lt;code&gt;this&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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_onSlotChange &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;_onSlotChange&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;bind&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&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;For progressive enhancement, the markup should alternate between tabs and panels. Elements that reorder their children tend to not work well with frameworks. Instead shadow DOM is used to reorder the elements by using slots.&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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;attachShadow&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;mode&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;open&#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 punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;Import the shared template to create the slots for tabs and panels.&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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;shadowRoot&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;appendChild&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;template&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;content&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;cloneNode&lt;/span&gt;&lt;span class=&quot;token punctuation&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;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 keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_tabSlot &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;shadowRoot&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;slot[name=tab]&#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 keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_panelSlot &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;shadowRoot&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;slot[name=panel]&#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;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;This element needs to react to new children as it links up tabs and panel semantically using &lt;code&gt;aria-labelledby&lt;/code&gt; and &lt;code&gt;aria-controls&lt;/code&gt;. New children will get slotted automatically and cause slotchange to fire, so not MutationObserver is needed.&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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_tabSlot&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;slotchange&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_onSlotChange&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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_panelSlot&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;slotchange&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_onSlotChange&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;&lt;code&gt;connectedCallback()&lt;/code&gt; groups tabs and panels by reordering and makes sure exactly one tab is active.&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;connectedCallback&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;The element needs to do some manual input event handling to allow switching with arrow keys and &lt;kbd&gt;Home&lt;/kbd&gt; / &lt;kbd&gt;End&lt;/kbd&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;this&lt;/span&gt;&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;keydown&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_onKeyDown&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;this&lt;/span&gt;&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 keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_onClick&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 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;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;hasAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;role&#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 keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;role&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;tablist&#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;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;Up until recently, &lt;code&gt;slotchange&lt;/code&gt; events did not fire when an element was upgraded by the parser. For this reason, the element invokes the handler manually. Once the new behavior lands in all browsers, the code below can be removed.&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;      Promise&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;all&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;        customElements&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;whenDefined&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;howto-tab&#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;        customElements&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;whenDefined&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;howto-panel&#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 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 punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;_linkPanels&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 punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;&lt;code&gt;disconnectedCallback()&lt;/code&gt; removes the event listeners that &lt;code&gt;connectedCallback()&lt;/code&gt; added.&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;disconnectedCallback&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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;removeEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;keydown&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_onKeyDown&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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;removeEventListener&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 keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_onClick&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;&lt;code&gt;_onSlotChange()&lt;/code&gt; is called whenever an element is added or removed from one of the shadow DOM slots.&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;_onSlotChange&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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;_linkPanels&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;&lt;code&gt;_linkPanels()&lt;/code&gt; links up tabs with their adjacent panels using aria-controls and &lt;code&gt;aria-labelledby&lt;/code&gt;. Additionally, the method makes sure only one tab is active.&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;_linkPanels&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;const&lt;/span&gt; tabs &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;_allTabs&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;Give each panel a &lt;code&gt;aria-labelledby&lt;/code&gt; attribute that refers to the tab that controls it.&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;      tabs&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;forEach&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;tab&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;const&lt;/span&gt; panel &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; tab&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;nextElementSibling&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;panel&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;tagName&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;toLowerCase&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; &lt;span class=&quot;token string&quot;&gt;&#39;howto-panel&#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;          console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;Tab #&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;tab&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; is not a&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt;&lt;br /&gt;            &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;sibling of a &amp;lt;howto-panel&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&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;&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;        tab&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;aria-controls&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; panel&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;        panel&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;aria-labelledby&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; tab&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 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;The element checks if any of the tabs have been marked as selected. If not, the first tab is now selected.&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;const&lt;/span&gt; selectedTab &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;br /&gt;        tabs&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;find&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;tab&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; tab&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;selected&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; tabs&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&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;Next, switch to the selected tab. &lt;code&gt;_selectTab()&lt;/code&gt; takes care of marking all other tabs as deselected and hiding all other panels.&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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;_selectTab&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;selectedTab&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;&lt;code&gt;_allPanels()&lt;/code&gt; returns all the panels in the tab panel. This function could memorize the result if the DOM queries ever become a performance issue. The downside of memorization is that dynamically added tabs and panels will not be handled.&lt;/p&gt;
&lt;p&gt;This is a method and not a getter, because a getter implies that it is cheap to read.&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;_allPanels&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;return&lt;/span&gt; Array&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelectorAll&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;howto-panel&#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 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;&lt;code&gt;_allTabs()&lt;/code&gt; returns all the tabs in the tab panel.&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;_allTabs&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;return&lt;/span&gt; Array&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelectorAll&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;howto-tab&#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 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;&lt;code&gt;_panelForTab()&lt;/code&gt; returns the panel that the given tab controls.&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;_panelForTab&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;tab&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;const&lt;/span&gt; panelId &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; tab&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;aria-controls&#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 keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&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 template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;panelId&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&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;&lt;code&gt;_prevTab()&lt;/code&gt; returns the tab that comes before the currently selected one, wrapping around when reaching the first one.&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;_prevTab&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;const&lt;/span&gt; tabs &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;_allTabs&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;Use &lt;code&gt;findIndex()&lt;/code&gt; to find the index of the currently selected element and subtracts one to get the index of the previous element.&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;let&lt;/span&gt; newIdx &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; tabs&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;findIndex&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;tab&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; tab&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;selected&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&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;Add &lt;code&gt;tabs.length&lt;/code&gt; to make sure the index is a positive number and get the modulus to wrap around if necessary.&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;return&lt;/span&gt; tabs&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;newIdx &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; tabs&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;%&lt;/span&gt; tabs&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length&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;&lt;code&gt;_firstTab()&lt;/code&gt; returns the first tab.&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;_firstTab&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;const&lt;/span&gt; tabs &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;_allTabs&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;return&lt;/span&gt; tabs&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&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;&lt;code&gt;_lastTab()&lt;/code&gt; returns the last tab.&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;_lastTab&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;const&lt;/span&gt; tabs &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;_allTabs&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;return&lt;/span&gt; tabs&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;tabs&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&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;&lt;code&gt;_nextTab()&lt;/code&gt; gets the tab that comes after the currently selected one, wrapping around when reaching the last tab.&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;_nextTab&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;const&lt;/span&gt; tabs &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;_allTabs&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;let&lt;/span&gt; newIdx &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; tabs&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;findIndex&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;tab&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; tab&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;selected&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&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; tabs&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;newIdx &lt;span class=&quot;token operator&quot;&gt;%&lt;/span&gt; tabs&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length&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;&lt;code&gt;reset()&lt;/code&gt; marks all tabs as deselected and hides all the panels.&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;reset&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;const&lt;/span&gt; tabs &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;_allTabs&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;const&lt;/span&gt; panels &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;_allPanels&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;      tabs&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;forEach&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;tab&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; tab&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;selected &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&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;      panels&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;forEach&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;panel&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; panel&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;hidden &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;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;&lt;code&gt;_selectTab()&lt;/code&gt; marks the given tab as selected. Additionally, it unhides the panel corresponding to the given tab.&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;_selectTab&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;newTab&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;Deselect all tabs and hide all panels.&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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;reset&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;Get the panel that the &lt;code&gt;newTab&lt;/code&gt; is associated with.&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;const&lt;/span&gt; newPanel &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;_panelForTab&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;newTab&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;If that panel doesn’t exist, abort.&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;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;newPanel&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;throw&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Error&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;No panel with id &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;newPanelId&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&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;      newTab&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;selected &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;      newPanel&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;hidden &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      newTab&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;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;&lt;code&gt;_onKeyDown()&lt;/code&gt; handles key presses inside the tab panel.&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;_onKeyDown&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;event&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;If the keypress did not originate from a tab element itself, it was a keypress inside the a panel or on empty space. Nothing to do.&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;event&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 function&quot;&gt;getAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;role&#39;&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; &lt;span class=&quot;token string&quot;&gt;&#39;tab&#39;&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;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;Don’t handle modifier shortcuts typically used by assistive technology.&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;event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;altKey&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;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;The switch-case will determine which tab should be marked as active depending on the key that was pressed.&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;let&lt;/span&gt; newTab&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;event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;keyCode&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 constant&quot;&gt;KEYCODE&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;LEFT&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;case&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;KEYCODE&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;UP&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;br /&gt;          newTab &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;_prevTab&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;break&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 keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;KEYCODE&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;RIGHT&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;case&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;KEYCODE&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;DOWN&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;br /&gt;          newTab &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;_nextTab&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;break&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 keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;KEYCODE&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;HOME&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;br /&gt;          newTab &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;_firstTab&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;break&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 keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;KEYCODE&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;END&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;br /&gt;          newTab &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;_lastTab&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;break&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;Any other key press is ignored and passed back to the browser.&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;default&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 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 browser might have some native functionality bound to the arrow keys, home or end. The element calls &lt;code&gt;preventDefault()&lt;/code&gt; to prevent the browser from taking any actions.&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;      event&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;Select the new tab, that has been determined in the switch-case.&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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;_selectTab&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;newTab&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;&lt;code&gt;_onClick()&lt;/code&gt; handles clicks inside the tab panel.&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;_onClick&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;event&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;If the click was not targeted on a tab element itself, it was a click inside the a panel or on empty space. Nothing to do.&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;event&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 function&quot;&gt;getAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;role&#39;&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; &lt;span class=&quot;token string&quot;&gt;&#39;tab&#39;&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;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;If it was on a tab element, though, select that tab.&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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;_selectTab&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;event&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 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;  customElements&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;howto-tabs&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; HowtoTabs&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;&lt;code&gt;howtoTabCounter&lt;/code&gt; counts the number of &lt;code&gt;&amp;lt;howto-tab&amp;gt;&lt;/code&gt; instances created. The number is used to generated new, unique IDs.&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;let&lt;/span&gt; howtoTabCounter &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&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;&lt;code&gt;HowtoTab&lt;/code&gt; is a tab for a &lt;code&gt;&amp;lt;howto-tabs&amp;gt;&lt;/code&gt; tab panel. &lt;code&gt;&amp;lt;howto-tab&amp;gt;&lt;/code&gt; should always be used with &lt;code&gt;role=&amp;quot;heading&amp;quot;&lt;/code&gt; in the markup so that the semantics remain useable when JavaScript is failing.&lt;/p&gt;
&lt;p&gt;A &lt;code&gt;&amp;lt;howto-tab&amp;gt;&lt;/code&gt; declares which &lt;code&gt;&amp;lt;howto-panel&amp;gt;&lt;/code&gt; it belongs to by using that panel’s ID as the value for the aria-controls attribute.&lt;/p&gt;
&lt;p&gt;A &lt;code&gt;&amp;lt;howto-tab&amp;gt;&lt;/code&gt; will automatically generate a unique ID if none is specified.&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;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;HowtoTab&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;HTMLElement&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 keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;get&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;observedAttributes&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;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;selected&#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;br /&gt;    &lt;span class=&quot;token function&quot;&gt;constructor&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;super&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;br /&gt;    &lt;span class=&quot;token function&quot;&gt;connectedCallback&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;If this is executed, JavaScript is working and the element changes its role to &lt;code&gt;tab&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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;role&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;tab&#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 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;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&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 keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;id &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;howto-tab-generated-&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;howtoTabCounter&lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&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;Set a well-defined initial state.&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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;aria-selected&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;false&#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 keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;tabindex&#39;&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;&lt;span class=&quot;token number&quot;&gt;1&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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;_upgradeProperty&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;selected&#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;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;Check if a property has an instance value. If so, copy the value, and delete the instance property so it doesn&#39;t shadow the class property setter. Finally, pass the value to the class property setter so it can trigger any side effects. This is to safe guard against cases where, for instance, a framework may have added the element to the page and set a value on one of its properties, but lazy loaded its definition. Without this guard, the upgraded element would miss that property and the instance property would prevent the class property setter from ever being called.&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;_upgradeProperty&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;prop&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;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;hasOwnProperty&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;prop&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;let&lt;/span&gt; value &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;prop&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;delete&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;prop&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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;prop&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; value&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;Properties and their corresponding attributes should mirror one another. To this effect, the property setter for &lt;code&gt;selected&lt;/code&gt; handles truthy/falsy values and reflects those to the state of the attribute. It’s important to note that there are no side effects taking place in the property setter. For example, the setter does not set &lt;code&gt;aria-selected&lt;/code&gt;. Instead, that work happens in the &lt;code&gt;attributeChangedCallback&lt;/code&gt;. As a general rule, make property setters very dumb, and if setting a property or attribute should cause a side effect (like setting a corresponding ARIA attribute) do that work in the &lt;code&gt;attributeChangedCallback()&lt;/code&gt;. This will avoid having to manage complex attribute/property reentrancy scenarios.&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;attributeChangedCallback&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;const&lt;/span&gt; value &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;hasAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;selected&#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 keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;aria-selected&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; value&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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;tabindex&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; value &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&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;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;selected&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;value&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;      value &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;Boolean&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;value&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;value&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;selected&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&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;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;removeAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;selected&#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;br /&gt;    &lt;span class=&quot;token keyword&quot;&gt;get&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;selected&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;return&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;hasAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;selected&#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;br /&gt;&lt;br /&gt;  customElements&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;howto-tab&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; HowtoTab&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 keyword&quot;&gt;let&lt;/span&gt; howtoPanelCounter &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&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;&lt;code&gt;HowtoPanel&lt;/code&gt; is a panel for a &lt;code&gt;&amp;lt;howto-tabs&amp;gt;&lt;/code&gt; tab panel.&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;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;HowtoPanel&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;HTMLElement&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 function&quot;&gt;constructor&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;super&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;br /&gt;  &lt;span class=&quot;token function&quot;&gt;connectedCallback&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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;role&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;tabpanel&#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 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;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&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 keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;id &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;howto-panel-generated-&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;howtoPanelCounter&lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&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 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;customElements&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;howto-panel&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; HowtoPanel&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;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;</content>
    <author>
      <name>Ewa Gasperowicz</name>
    </author><author>
      <name>Rob Dodson</name>
    </author><author>
      <name>Surma</name>
    </author>
  </entry>
  
  <entry>
    <title>HowTo Components – howto-tooltip</title>
    <link href="https://web.dev/components-howto-tooltip/"/>
    <updated>2017-04-06T00:00:00Z</updated>
    <id>https://web.dev/components-howto-tooltip/</id>
    <content type="html" mode="escaped">&lt;h2 id=&quot;summary&quot;&gt;Summary &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/components-howto-tooltip/#summary&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A &lt;code&gt;&amp;lt;howto-tooltip&amp;gt;&lt;/code&gt; is a popup that displays information related to an element
when the element receives keyboard focus or the mouse hovers over it.
The element that triggers the tooltip references the tooltip element with
&lt;code&gt;aria-describedby&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The element self-applies the role &lt;code&gt;tooltip&lt;/code&gt; and sets &lt;code&gt;tabindex&lt;/code&gt; to -1, as the
tooltip itself can never be focused.&lt;/p&gt;
&lt;h2 id=&quot;reference&quot;&gt;Reference &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/components-howto-tooltip/#reference&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/GoogleChromeLabs/howto-components&quot; rel=&quot;noopener&quot;&gt;HowTo: Components on GitHub&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.w3.org/TR/wai-aria-practices-1.1/#tooltip&quot; rel=&quot;noopener&quot;&gt;Tooltip pattern in ARIA Authoring Practices 1.1&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;demo&quot;&gt;Demo &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/components-howto-tooltip/#demo&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://googlechromelabs.github.io/howto-components/howto-tooltip/#demo&quot; rel=&quot;noopener&quot;&gt;View live demo on GitHub&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;example-usage&quot;&gt;Example usage &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/components-howto-tooltip/#example-usage&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;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;text&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;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;Your name:&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;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;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;aria-describedby&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;tp1&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;howto-tooltip&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;tp1&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;Ideally your name is Batman&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;howto-tooltip&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;br&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;cheese&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;Favourite type of cheese: &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;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;cheese&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-describedby&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;tp2&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;howto-tooltip&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;tp2&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;Help I am trapped inside a tooltip message&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;howto-tooltip&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;code&quot;&gt;Code &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/components-howto-tooltip/#code&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 keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;HowtoTooltip&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;HTMLElement&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;The constructor does work that needs to be executed exactly once.&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;constructor&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;super&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;These functions are used in a bunch of places, and always need to bind the correct this reference, so do it once.&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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_show &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;_show&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;bind&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_hide &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;_hide&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;bind&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&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;&lt;code&gt;connectedCallback()&lt;/code&gt; fires when the element is inserted into the DOM. It&#39;s a good place to set the initial role, tabindex, internal state, and install event listeners.&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;connectedCallback&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;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;hasAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;role&#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 keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;role&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;tooltip&#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;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;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;hasAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;tabindex&#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 keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;tabindex&#39;&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;&lt;span class=&quot;token number&quot;&gt;1&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 keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;_hide&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;The element that triggers the tooltip references the tooltip element with &lt;code&gt;aria-describedby&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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_target &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;[aria-describedby=&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&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;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;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_target&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;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;The tooltip needs to listen to focus/blur events from the target, as well as hover events over the target.&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;this&lt;/span&gt;&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 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;focus&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_show&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;this&lt;/span&gt;&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 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;blur&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_hide&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;this&lt;/span&gt;&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 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;mouseenter&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_show&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;this&lt;/span&gt;&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 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;mouseleave&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_hide&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;&lt;code&gt;disconnectedCallback()&lt;/code&gt; unregisters the event listeners that were set up in &lt;code&gt;connectedCallback()&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;disconnectedCallback&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;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_target&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;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;Remove the existing listeners, so that they don&#39;t trigger even though there&#39;s no tooltip to show.&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;this&lt;/span&gt;&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 function&quot;&gt;removeEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;focus&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_show&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;this&lt;/span&gt;&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 function&quot;&gt;removeEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;blur&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_hide&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;this&lt;/span&gt;&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 function&quot;&gt;removeEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;mouseenter&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_show&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;this&lt;/span&gt;&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 function&quot;&gt;removeEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;mouseleave&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_hide&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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_target &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;null&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;br /&gt;  &lt;span class=&quot;token function&quot;&gt;_show&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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;hidden &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&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;br /&gt;  &lt;span class=&quot;token function&quot;&gt;_hide&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;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;hidden &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 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;customElements&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;define&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;howto-tooltip&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; HowtoTooltip&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;</content>
    <author>
      <name>Ewa Gasperowicz</name>
    </author><author>
      <name>Rob Dodson</name>
    </author><author>
      <name>Surma</name>
    </author>
  </entry>
  
  <entry>
    <title>HowTo Components – Overview</title>
    <link href="https://web.dev/components-examples-overview/"/>
    <updated>2017-04-06T00:00:00Z</updated>
    <id>https://web.dev/components-examples-overview/</id>
    <content type="html" mode="escaped">&lt;p&gt;&amp;quot;HowTo: Components&amp;quot; are a collection of web components that implement common UI
patterns. The purpose of these implementations is to be an educational resource.
You can read through the densely commented implementation of different
components and hopefully learn from them. Note that they are explicitly &lt;strong&gt;NOT&lt;/strong&gt;
a UI library and should &lt;strong&gt;NOT&lt;/strong&gt; be used in production.&lt;/p&gt;
&lt;h2 id=&quot;components&quot;&gt;Components &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/components-examples-overview/#components&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://web.dev/components-howto-checkbox/&quot;&gt;&lt;code&gt;&amp;lt;howto-checkbox&amp;gt;&lt;/code&gt;&lt;/a&gt;: represents a boolean option in a form. The most common type of
checkbox is a dual-type which allows the user to toggle between two choices—checked and unchecked.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://web.dev/components-howto-tabs/&quot;&gt;&lt;code&gt;&amp;lt;howto-tabs&amp;gt;&lt;/code&gt;&lt;/a&gt;: limits visible content by separating it into multiple panels.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://web.dev/components-howto-tooltip/&quot;&gt;&lt;code&gt;&amp;lt;howto-tooltip&amp;gt;&lt;/code&gt;&lt;/a&gt;: a popup that displays information related to an element when the element
receives keyboard focus or the mouse hovers over it.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;goals&quot;&gt;Goals &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/components-examples-overview/#goals&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Our aim is to demonstrate best practices for writing robust components that are
accessible, performant, maintainable, and easy to style. Each component is
completely self-contained so it can serve as a reference implementation.&lt;/p&gt;
&lt;h3 id=&quot;accessibility&quot;&gt;Accessibility &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/components-examples-overview/#accessibility&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The components closely follow the &lt;a href=&quot;https://www.w3.org/TR/wai-aria-practices-1.1/&quot; rel=&quot;noopener&quot;&gt;WAI ARIA Authoring
Practices&lt;/a&gt;, which is a guide to
explain and show ARIA, the &lt;a href=&quot;https://www.w3.org/TR/wai-aria-1.1/&quot; rel=&quot;noopener&quot;&gt;Accessible Rich Internet Application
standard&lt;/a&gt;. If you are unfamiliar with ARIA,
&lt;a href=&quot;https://web.dev/semantics-aria/&quot;&gt;check out our introduction on
WebFundamentals&lt;/a&gt;.
Each component links to the relevant section of the Authoring Practices. While
not strictly necessary, we do recommend reading the section of the Authoring
Practices before diving into the code.&lt;/p&gt;
&lt;h3 id=&quot;performance&quot;&gt;Performance &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/components-examples-overview/#performance&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;In web development the term &amp;quot;performance&amp;quot; can be applied to a multitude of
things. In the context of &lt;code&gt;&amp;lt;howto&amp;gt;&lt;/code&gt;, performance mostly refers to animations
consistently running at 60fps, even on mobile devices.&lt;/p&gt;
&lt;h3 id=&quot;visual-flexibility&quot;&gt;Visual Flexibility &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/components-examples-overview/#visual-flexibility&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;As much as possible, components are not styled, except for layout or to indicate
a selected or active state. This is to keep the implementation visually flexible
and focused. By not spending time on decoration, we limit the code to only what
is absolutely necessary to make the component function. If any style is required
for the component to function, the style will be marked with a comment
explaining why that is.&lt;/p&gt;
&lt;h3 id=&quot;maintainable-code&quot;&gt;Maintainable code &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/components-examples-overview/#maintainable-code&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;As HowTo: Components is a reference
implementation, we spent extra time on writing readable and easily
comprehensible code that is densely commented.&lt;/p&gt;
&lt;h2 id=&quot;non-goals&quot;&gt;Non-Goals &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/components-examples-overview/#non-goals&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id=&quot;be-a-library-framework-toolkit&quot;&gt;Be a library / framework / toolkit &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/components-examples-overview/#be-a-library-framework-toolkit&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;&amp;lt;howto&amp;gt;&lt;/code&gt; components are not published on npm, bower or any other platform
because they are not meant to be used in production. For the sake of terse,
readable code, we are using modern JavaScript APIs and are supporting modern
browsers which implement the Web Components standards. You
will be able to adapt the code to fit your own needs after reading these
implementations.&lt;/p&gt;
&lt;h3 id=&quot;be-backwards-compatible&quot;&gt;Be backwards compatible &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/components-examples-overview/#be-backwards-compatible&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The code should not be relied on directly. We might, and very likely &lt;em&gt;will&lt;/em&gt;,
drastically change the implementation and API of any element if a better
implementation is discovered. This is a living resource where we can share,
explore, and discuss best practices for building web UIs.&lt;/p&gt;
&lt;h3 id=&quot;be-complete&quot;&gt;Be complete &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/components-examples-overview/#be-complete&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;We currently don&#39;t (and probably won&#39;t) implement *&lt;em&gt;all&lt;/em&gt; *components that can be
found in the WAI ARIA Authoring Practices. However, re-using the principles used
in other &lt;code&gt;&amp;lt;howto&amp;gt;&lt;/code&gt; components should enable readers to implement any components
that are missing.&lt;/p&gt;
</content>
    <author>
      <name>Ewa Gasperowicz</name>
    </author><author>
      <name>Rob Dodson</name>
    </author><author>
      <name>Surma</name>
    </author>
  </entry>
  
  <entry>
    <title>How To Do an Accessibility Review</title>
    <link href="https://web.dev/how-to-review/"/>
    <updated>2017-03-12T00:00:00Z</updated>
    <id>https://web.dev/how-to-review/</id>
    <content type="html" mode="escaped">&lt;div class=&quot;youtube&quot;&gt;  &lt;lite-youtube videoid=&quot;cOmehxAU_4s&quot;&gt;  &lt;/lite-youtube&gt;&lt;/div&gt;
&lt;p&gt;Determining if your web site or application is accessible can seem like an
overwhelming task. If you are approaching accessibility for the first time, the
sheer breadth of the topic can leave you wondering where to start - after all,
working to accommodate a diverse range of abilities means there are a
correspondingly diverse range of issues to consider.&lt;/p&gt;
&lt;p&gt;In this post, I&#39;m going to break down these issues into a logical, step by step
process for reviewing an existing site for accessibility.&lt;/p&gt;
&lt;h2 id=&quot;start-with-the-keyboard&quot;&gt;Start with the keyboard &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/how-to-review/#start-with-the-keyboard&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;figure&gt;
&lt;img alt=&quot;Keyboard icon.&quot; class=&quot;float-right&quot; decoding=&quot;async&quot; height=&quot;24&quot; loading=&quot;lazy&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/VTpzSPKYo1nyBxd0aR8n.svg&quot; width=&quot;24&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;For users who either cannot or choose not to use a mouse, keyboard navigation is
their primary means of reaching everything on screen. This audience includes
users with motor impairments, such as Repetitive Stress Injury (RSI) or
paralysis, as well as screen reader users. For a good keyboarding experience
aim to have a logical tab order and easily discernable focus styles.&lt;/p&gt;
&lt;h3 id=&quot;key-points&quot;&gt;Key points &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/how-to-review/#key-points&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Start by tabbing through your site. The order in which elements are focused
should aim to follow the DOM order. If you’re unsure which elements should
receive focus, see &lt;a href=&quot;https://web.dev/focus/&quot;&gt;Focus
Fundamentals&lt;/a&gt;
for a refresher. The general rule of thumb is that any control a user can
interact with or provide input to should aim to be focusable and display a focus
indicator (e.g., a focus ring). It’s common practice to disable focus styles
without providing an alternative by using &lt;code&gt;outline: none&lt;/code&gt; in CSS, but this is an
anti-pattern. If a keyboard user can’t see what’s focused, they have no way of
interacting with the page. If you need to differentiate between mouse and
keyboard focus for styling, consider adding a library like
&lt;a href=&quot;https://github.com/ten1seven/what-input&quot; rel=&quot;noopener&quot;&gt;what-input&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Custom interactive controls should aim to be focusable. If you use JavaScript
to turn a &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; into a fancy dropdown, it will not automatically be inserted
into the tab order. To make a custom control focusable, give it a
&lt;code&gt;tabindex=&amp;quot;0&amp;quot;&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Avoid controls with a &lt;code&gt;tabindex&lt;/code&gt; &amp;gt; 0. These controls will jump ahead of
everything else in the tab order, regardless of their position in the DOM. This
can be confusing for screen reader users as they tend to navigate the DOM in a
linear fashion.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Non-interactive content (e.g., headings) should avoid being focusable.
Sometimes developers add a &lt;code&gt;tabindex&lt;/code&gt; to headings because they think they’re
important. This is also an anti-pattern because it makes keyboard users who can
see the screen less efficient. For screen reader users, the screen reader will
already announce these headings, so there’s no need to make them focusable.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If new content is added to the page, try to make sure that the user’s focus is
directed to that content so they can take action on it. See &lt;a href=&quot;https://web.dev/using-tabindex/#managing-focus-at-the-page-level&quot;&gt;Managing Focus at
the Page
Level&lt;/a&gt;
for examples.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Beware of completely trapping focus at any point. Watch out for autocomplete
widgets, where keyboard focus may get stuck. Focus can be temporarily trapped in
specific situations, such as displaying a modal, when you don&#39;t want the user
interacting with the rest of the page - but you should aim to provide a
keyboard-accessible method of escaping the modal as well. See the guide on
&lt;a href=&quot;https://web.dev/using-tabindex/#modals-and-keyboard-traps&quot;&gt;Modals and Keyboard
Traps&lt;/a&gt;
for an example.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;just-because-something-is-focusable-doesnt-mean-its-usable&quot;&gt;Just because something is focusable doesn’t mean it’s usable &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/how-to-review/#just-because-something-is-focusable-doesnt-mean-its-usable&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;If you’ve built a custom control, then aim for a user to be able to reach &lt;em&gt;all&lt;/em&gt;
of its functionality using only the keyboard. See &lt;a href=&quot;https://developers.google.com/web/fundamentals/accessibility/focus/using-tabindex#managing_focus_in_components&quot; rel=&quot;noopener&quot;&gt;Managing Focus In
Components&lt;/a&gt;
for techniques on improving keyboard access.&lt;/p&gt;
&lt;h3 id=&quot;dont-forget-offscreen-content&quot;&gt;Don’t forget offscreen content &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/how-to-review/#dont-forget-offscreen-content&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Many sites have offscreen content that is present in the DOM but not visible,
for example, links inside a responsive drawer menu or a button inside a modal
window that has yet to be displayed. Leaving these elements in the DOM can lead
to a confusing keyboarding experience, especially for screen readers which will
announce the offscreen content as if it’s part of the page. See &lt;a href=&quot;https://web.dev/dom-order-matters/#offscreen-content&quot;&gt;Handling
Offscreen
Content&lt;/a&gt;
for tips on how to deal with these elements.&lt;/p&gt;
&lt;h2 id=&quot;try-it-with-a-screen-reader&quot;&gt;Try it with a screen reader &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/how-to-review/#try-it-with-a-screen-reader&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;figure&gt;
&lt;img alt=&quot;speaker notes icon&quot; class=&quot;float-right&quot; decoding=&quot;async&quot; height=&quot;24&quot; loading=&quot;lazy&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/whIpvsv1QBgp1YfGIrwy.svg&quot; width=&quot;24&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;Improving general keyboard support lays some groundwork for the next step, which
is to check the page for proper labeling and semantics and any obstructions to
screen reader navigation. If you’re unfamiliar with how semantic markup gets
interpreted by assistive technology, see the &lt;a href=&quot;https://web.dev/semantics-builtin/&quot;&gt;Introduction to
Semantics&lt;/a&gt;
for a refresher.&lt;/p&gt;
&lt;h3 id=&quot;key-points-2&quot;&gt;Key points &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/how-to-review/#key-points-2&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Check all images for proper &lt;code&gt;alt&lt;/code&gt; text. The exception to this practice is when
images are primarily for presentation purposes and are not essential pieces of
content. To signify that an image should be skipped by a screen reader, set the
value of the &lt;code&gt;alt&lt;/code&gt; attribute to an empty string, e.g., &lt;code&gt;alt=&amp;quot;&amp;quot;&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Check all controls for a label. For custom controls this may require the use
of &lt;code&gt;aria-label&lt;/code&gt; or &lt;code&gt;aria-labelledby&lt;/code&gt;. See &lt;a href=&quot;https://web.dev/aria-labels-and-relationships/&quot;&gt;ARIA Labels and
Relationships&lt;/a&gt;
for examples.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Check all custom controls for an appropriate &lt;code&gt;role&lt;/code&gt; and any required ARIA
attributes that confer their state. For example, a custom checkbox will need a
&lt;code&gt;role=&amp;quot;checkbox&amp;quot;&lt;/code&gt; and &lt;code&gt;aria-checked=&amp;quot;true|false&amp;quot;&lt;/code&gt; to properly convey its state.
See the &lt;a href=&quot;https://web.dev/semantics-aria/&quot;&gt;Introduction to
ARIA&lt;/a&gt;
for a general overview of how ARIA can provide missing semantics for custom
controls.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The flow of information should make sense. Because screen readers navigate the
page in DOM order, if you’ve used CSS to visually reposition elements, they may
be announced in a nonsensical sequence. If you need something to appear earlier
in the page, try to physically move it earlier in the DOM.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Aim to support a screen reader’s navigation to all content on the page. Avoid
letting any sections of the site be permanently hidden or blocked from screen
reader access.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If content &lt;em&gt;should&lt;/em&gt; be hidden from a screen reader, for instance, if it’s
offscreen or just presentational, make sure that content is set to
&lt;code&gt;aria-hidden=&amp;quot;true&amp;quot;&lt;/code&gt;. Take a look at the guide on &lt;a href=&quot;https://web.dev/hiding-and-updating-content/#aria-hidden&quot;&gt;Hiding
content&lt;/a&gt;
for further explanation.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;familiarity-with-even-one-screen-reader-goes-a-long-way&quot;&gt;Familiarity with even one screen reader goes a long way &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/how-to-review/#familiarity-with-even-one-screen-reader-goes-a-long-way&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Though it might seem daunting to learn a screen reader, they’re actually pretty
easy to pick up. In general, most developers can get by with just a few simple
key commands.&lt;/p&gt;
&lt;p&gt;If you’re on a Mac check out &lt;a href=&quot;https://www.youtube.com/watch?v=5R-6WvAihms&amp;amp;list=PLNYkxOF6rcICWx0C9LVWWVqvHlYJyqw7g&amp;amp;index=6&quot; rel=&quot;noopener&quot;&gt;this video on using
VoiceOver&lt;/a&gt;,
the screen reader that comes with Mac OS. If you’re on a PC check out &lt;a href=&quot;https://www.youtube.com/watch?v=Jao3s_CwdRU&amp;amp;list=PLNYkxOF6rcICWx0C9LVWWVqvHlYJyqw7g&amp;amp;index=4&quot; rel=&quot;noopener&quot;&gt;this
video on using
NVDA&lt;/a&gt;,
a donation supported, open source screen reader for Windows.&lt;/p&gt;
&lt;h3 id=&quot;aria-hidden-does-not-prevent-keyboard-focus&quot;&gt;&lt;code&gt;aria-hidden&lt;/code&gt; does not prevent keyboard focus &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/how-to-review/#aria-hidden-does-not-prevent-keyboard-focus&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;It’s important to understand that ARIA can only affect the &lt;em&gt;semantics&lt;/em&gt; of an
element; it has no effect on the &lt;em&gt;behavior&lt;/em&gt; of the element. While you can make
an element hidden to screen readers with &lt;code&gt;aria-hidden=&amp;quot;true&amp;quot;&lt;/code&gt;, that does not
change the focus behavior for that element. For offscreen interactive content,
you will often need to combine &lt;code&gt;aria-hidden=&amp;quot;true&amp;quot;&lt;/code&gt; and &lt;code&gt;tabindex=&amp;quot;-1&amp;quot;&lt;/code&gt; to make
sure it’s truly removed from the keyboard flow. The proposed &lt;a href=&quot;https://github.com/WICG/inert&quot; rel=&quot;noopener&quot;&gt;inert
attribute&lt;/a&gt; aims to make this easier by combining
the behavior of both attributes.&lt;/p&gt;
&lt;h2 id=&quot;interactive-elements-like-links-and-buttons-should-indicate-their-purpose-and-state&quot;&gt;Interactive elements like links and buttons should indicate their purpose and state &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/how-to-review/#interactive-elements-like-links-and-buttons-should-indicate-their-purpose-and-state&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Providing visual hints about what a control will do helps people operate and navigate
your site. These hints are called affordances. Providing affordances makes it possible
for people to use your site on a wide variety of devices.&lt;/p&gt;
&lt;h3 id=&quot;key-points-3&quot;&gt;Key points &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/how-to-review/#key-points-3&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Interactive elements, like links and buttons, should be distinguishable from
non-interactive elements. It is difficult for users to navigate a site or app
when they cannot tell if an element is clickable. There are many valid methods to
accomplish this goal. One common practice is underlining links to differentiate them
from their surrounding text.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Similar to the focus requirement, interactive elements like links and buttons require
a hover state for mouse users so they know if they are hovering over something clickable.
However, the interactive element still must be distinguishable on its own. Relying on a
hover state alone to indicate clickable elements does not help touch screen devices.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;take-advantage-of-headings-and-landmarks&quot;&gt;Take advantage of headings and landmarks &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/how-to-review/#take-advantage-of-headings-and-landmarks&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;figure&gt;
&lt;img alt=&quot;map icon&quot; class=&quot;float-right&quot; decoding=&quot;async&quot; height=&quot;24&quot; loading=&quot;lazy&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/IXa3zFYhxyfzaNYn7ism.svg&quot; width=&quot;24&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;Headings and landmark elements imbue your page with semantic structure, and
greatly increase the navigating efficiency of assistive technology users. Many
screen reader users report that, when they first land on an unfamiliar page,
they typically try to &lt;a href=&quot;http://www.heydonworks.com/article/responses-to-the-screen-reader-strategy-survey&quot; rel=&quot;noopener&quot;&gt;navigate by
headings&lt;/a&gt;.
Similarly, screen readers also offer the ability to jump to important landmarks
like &lt;code&gt;&amp;lt;main&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;nav&amp;gt;&lt;/code&gt;. For these reasons it’s important to consider how the
structure of your page can be used to guide the user’s experience.&lt;/p&gt;
&lt;h3 id=&quot;key-points-4&quot;&gt;Key points &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/how-to-review/#key-points-4&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Make proper use of &lt;code&gt;h1-h6&lt;/code&gt; hierarchy. Think of headings as tools to create an
outline for your page. Don’t rely on the built-in styling of headings; instead,
consider all headings as if they were the same size and use the semantically
appropriate level for primary, secondary, and tertiary content. Then use CSS to
make the headings match your design.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Use landmark elements and roles so users can bypass repetitive content. Many
assistive technologies provide shortcuts to jump to specific parts of the page,
such as those defined by &lt;code&gt;&amp;lt;main&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;nav&amp;gt;&lt;/code&gt; elements. These elements have
implicit landmark roles. You can also use the ARIA &lt;code&gt;role&lt;/code&gt; attribute to
explicitly define regions on the page, e.g., &lt;code&gt;&amp;lt;div role=&amp;quot;search&amp;quot;&amp;gt;&lt;/code&gt;. See &lt;a href=&quot;https://web.dev/navigating-content/&quot;&gt;the
guide on headings and
landmarks&lt;/a&gt;
for more examples.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Avoid &lt;code&gt;role=&amp;quot;application&amp;quot;&lt;/code&gt; unless you have prior experience working with it.
The &lt;code&gt;application&lt;/code&gt; landmark role will tell assistive technology to disable its
shortcuts and pass through all key presses to the page. This means that the keys
screen reader users typically use to move around the page will no longer work,
and you will need to implement &lt;em&gt;all&lt;/em&gt; keyboard handling yourself.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;quickly-review-headings-and-landmarks-with-a-screen-reader&quot;&gt;Quickly review headings and landmarks with a screen reader &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/how-to-review/#quickly-review-headings-and-landmarks-with-a-screen-reader&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Screen readers like VoiceOver and NVDA provide a context menu for skipping to
important regions on the page. If you’re doing an accessibility check, you can
use these menus to get a quick overview of the page and determine if heading
levels are appropriate and which landmarks are in use. To learn more check out
these instructional videos on the basics of
&lt;a href=&quot;https://www.youtube.com/watch?v=5R-6WvAihms&amp;amp;index=6&amp;amp;list=PLNYkxOF6rcICWx0C9LVWWVqvHlYJyqw7g&quot; rel=&quot;noopener&quot;&gt;VoiceOver&lt;/a&gt;
and
&lt;a href=&quot;https://www.youtube.com/watch?v=Jao3s_CwdRU&amp;amp;list=PLNYkxOF6rcICWx0C9LVWWVqvHlYJyqw7g&amp;amp;index=4&quot; rel=&quot;noopener&quot;&gt;NVDA&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;automate-the-process&quot;&gt;Automate the process &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/how-to-review/#automate-the-process&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;figure&gt;
&lt;img alt=&quot;wrench icon&quot; class=&quot;float-right&quot; decoding=&quot;async&quot; height=&quot;24&quot; loading=&quot;lazy&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/xZuiMwQPghjN1XUilhn2.svg&quot; width=&quot;24&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;Manually testing a site for accessibility can be tedious and error prone.
Eventually you’ll want to automate the process as much as possible. This can be
done through the use of browser extensions, and command line accessibility test
suites.&lt;/p&gt;
&lt;h3 id=&quot;key-points-5&quot;&gt;Key points &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/how-to-review/#key-points-5&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Does the page pass all the tests from either the
&lt;a href=&quot;https://chrome.google.com/webstore/detail/axe/lhdoppojpmngadmnindnejefpokejbdd&quot; rel=&quot;noopener&quot;&gt;aXe&lt;/a&gt;
or
&lt;a href=&quot;https://chrome.google.com/webstore/detail/wave-evaluation-tool/jbbplnpkjmmeebjpijfedlgcdilocofh&quot; rel=&quot;noopener&quot;&gt;WAVE&lt;/a&gt;
browser extensions? These extensions are just two available options and can be a
useful addition to any manual test process as they can quickly pick up on subtle
issues like failing contrast ratios and missing ARIA attributes. If you prefer
to do things from the command line,
&lt;a href=&quot;https://github.com/dequelabs/axe-cli&quot; rel=&quot;noopener&quot;&gt;axe-cli&lt;/a&gt; provides the same functionality
as the aXe browser extension, but can be easily run from your terminal.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;To avoid regressions, especially in a continuous integration environment,
incorporate a library like &lt;a href=&quot;https://github.com/dequelabs/axe-core&quot; rel=&quot;noopener&quot;&gt;axe-core&lt;/a&gt;
into your automated test suite. axe-core is the same engine that powers the aXe
chrome extension, but in an easy-to-run command line utility.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If you’re using a framework or library, does it provide its own accessibility
tools? Some examples include
&lt;a href=&quot;https://github.com/angular/protractor-accessibility-plugin/&quot; rel=&quot;noopener&quot;&gt;protractor-accessibility-plugin&lt;/a&gt;
for Angular, and
&lt;a href=&quot;https://github.com/Polymer/web-component-tester#a11ysuite&quot; rel=&quot;noopener&quot;&gt;a11ysuite&lt;/a&gt; for
Polymer and Web Components. Take advantage of available tools whenever possible
to avoid reinventing the wheel.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;if-youre-building-a-progressive-web-app-consider-giving-lighthouse-a-shot&quot;&gt;If you’re building a Progressive Web App consider giving Lighthouse a shot &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/how-to-review/#if-youre-building-a-progressive-web-app-consider-giving-lighthouse-a-shot&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;figure&gt;
&lt;img alt=&quot;Lighthouse logo.&quot; class=&quot;float-right&quot; decoding=&quot;async&quot; height=&quot;146&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 260px) 260px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/RDyW10Rdfl0xyMiaBUzB.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/RDyW10Rdfl0xyMiaBUzB.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/RDyW10Rdfl0xyMiaBUzB.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/RDyW10Rdfl0xyMiaBUzB.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/RDyW10Rdfl0xyMiaBUzB.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/RDyW10Rdfl0xyMiaBUzB.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/RDyW10Rdfl0xyMiaBUzB.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/RDyW10Rdfl0xyMiaBUzB.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/RDyW10Rdfl0xyMiaBUzB.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/RDyW10Rdfl0xyMiaBUzB.png?auto=format&amp;w=520 520w&quot; width=&quot;260&quot; /&gt;
&lt;/figure&gt;
&lt;p&gt;Lighthouse is a tool to help measure the performance of your progressive web
app, but it also uses the axe-core library to power a set of accessibility
tests. If you’re already using Lighthouse, keep an eye out for failing
accessibility tests in your report. Fixing these will help improve the overall
user experience of your site.&lt;/p&gt;
&lt;h2 id=&quot;wrapping-up&quot;&gt;Wrapping Up &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/how-to-review/#wrapping-up&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Making accessibility reviews a regular part of your team process, and doing
these checks early and often, can help improve the overall experience of using
your site. Remember, good accessibility equals good UX!&lt;/p&gt;
&lt;h3 id=&quot;additional-resources&quot;&gt;Additional Resources &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/how-to-review/#additional-resources&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://bit.ly/web-a11y&quot; rel=&quot;noopener&quot;&gt;Web Accessibility by Google&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://web.dev/accessibility/&quot;&gt;Accessibility Fundamentals&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/playlist?list=PLNYkxOF6rcICWx0C9LVWWVqvHlYJyqw7g&quot; rel=&quot;noopener&quot;&gt;A11ycasts&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content>
    <author>
      <name>Rob Dodson</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>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>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>
