<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Carlos Espada</title>
    <description>The latest articles on Forem by Carlos Espada (@carlosespada).</description>
    <link>https://forem.com/carlosespada</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F661690%2Fd166467f-fe0e-49d4-90b2-3729eee44bef.jpg</url>
      <title>Forem: Carlos Espada</title>
      <link>https://forem.com/carlosespada</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/carlosespada"/>
    <language>en</language>
    <item>
      <title>HTML tags | hgroup</title>
      <dc:creator>Carlos Espada</dc:creator>
      <pubDate>Thu, 16 May 2024 07:39:33 +0000</pubDate>
      <link>https://forem.com/carlosespada/html-tags-hgroup-3ii5</link>
      <guid>https://forem.com/carlosespada/html-tags-hgroup-3ii5</guid>
      <description>&lt;p&gt;It is used to &lt;strong&gt;group a heading with some type of related secondary content&lt;/strong&gt;, such as a subheading or tagline. This secondary content will go inside a &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Therefore, within a &lt;code&gt;&amp;lt;hgroup&amp;gt;&lt;/code&gt; we can only find a &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; preceding a single header from &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; to &lt;code&gt;&amp;lt;h6&amp;gt;&lt;/code&gt; and another &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; below. It is &lt;strong&gt;not allowed&lt;/strong&gt; to have more than one heading.&lt;/p&gt;

&lt;p&gt;It has an &lt;strong&gt;implicit ARIA role&lt;/strong&gt; &lt;code&gt;generic&lt;/code&gt;, so it has no impact on the page outline. This impact is given by the header it contains.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Type: &lt;em&gt;block&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Self-closing: &lt;em&gt;No&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Semantic value: &lt;em&gt;No&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/hgroup" rel="noopener noreferrer"&gt;Definition and example&lt;/a&gt; | &lt;a href="https://caniuse.com/mdn-html_elements_hgroup" rel="noopener noreferrer"&gt;Support&lt;/a&gt;&lt;/p&gt;

</description>
      <category>html</category>
      <category>tags</category>
      <category>hgroup</category>
    </item>
    <item>
      <title>HTML tags | search</title>
      <dc:creator>Carlos Espada</dc:creator>
      <pubDate>Wed, 22 Nov 2023 11:47:37 +0000</pubDate>
      <link>https://forem.com/carlosespada/html-tags-search-50e9</link>
      <guid>https://forem.com/carlosespada/html-tags-search-50e9</guid>
      <description>&lt;p&gt;It is used to &lt;strong&gt;group the elements&lt;/strong&gt; (normally form controls) &lt;strong&gt;that have the capacity to carry out a search or filtering&lt;/strong&gt;, whether related to the document, the website/webapp or the entire Internet.&lt;/p&gt;

&lt;p&gt;It should not be used to present search results, but rather these should go in the &lt;code&gt;&amp;lt;main&amp;gt;&lt;/code&gt; of the page.&lt;/p&gt;

&lt;p&gt;What does have to go inside &lt;code&gt;&amp;lt;search&amp;gt;&lt;/code&gt; are the &lt;strong&gt;search suggestions and links&lt;/strong&gt; that are part of the quick search functionality that is usually used in many search engines or filters.&lt;/p&gt;

&lt;p&gt;It has an &lt;strong&gt;implicit ARIA role&lt;/strong&gt; &lt;code&gt;search&lt;/code&gt;, thus eliminating the need to add &lt;code&gt;role="search"&lt;/code&gt; to the &lt;code&gt;&amp;lt;form&amp;gt;&lt;/code&gt;. For practical purposes, &lt;a href="https://www.scottohara.me/blog/2023/03/24/search-element.html#:~:text=Why%20would%20I%20use%20this%20instead%20of%20form%20role%3Dsearch" rel="noopener noreferrer"&gt;there is no difference&lt;/a&gt; between using one or the other, but &lt;code&gt;&amp;lt;search&amp;gt;&lt;/code&gt; respects &lt;a href="https://www.w3.org/TR/wai-aria-1.0/introduction#:~:text=When%20the%20host%20language%20provides,%2C%20state%2C%20and%20property%20indicators." rel="noopener noreferrer"&gt;the ARIA principle&lt;/a&gt; of not using ARIA roles when there is a native element that provides the same functionality.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Type: &lt;em&gt;block&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Self-closing: &lt;em&gt;No&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Semantic value: &lt;em&gt;Yes&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/search" rel="noopener noreferrer"&gt;Definition and example&lt;/a&gt; | &lt;a href="https://caniuse.com/mdn-html_elements_search" rel="noopener noreferrer"&gt;Support&lt;/a&gt;&lt;/p&gt;

</description>
      <category>html</category>
      <category>tags</category>
      <category>search</category>
    </item>
    <item>
      <title>A11y: notify user after submitting a form</title>
      <dc:creator>Carlos Espada</dc:creator>
      <pubDate>Fri, 28 Jan 2022 10:10:23 +0000</pubDate>
      <link>https://forem.com/carlosespada/a11y-notify-user-after-submitting-a-form-kco</link>
      <guid>https://forem.com/carlosespada/a11y-notify-user-after-submitting-a-form-kco</guid>
      <description>&lt;p&gt;When the user fills out a form, &lt;strong&gt;they must be informed of the result of their submission&lt;/strong&gt;, whether it is correct or contains errors. To do this, several steps must be followed, which may vary depending on whether the page is reloaded or if the submit is done asynchronously using JavaScript.&lt;/p&gt;

&lt;p&gt;Let's take as an example a very simple contact form, with a name, email and message.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;form&amp;gt;
  &amp;lt;div&amp;gt;
    &amp;lt;label for="name"&amp;gt;Name&amp;lt;/label&amp;gt;
    &amp;lt;input
      id="name"
      name="name"
      type="text"
      autocomplete="name"
      required
    /&amp;gt;
  &amp;lt;/div&amp;gt;
  &amp;lt;div&amp;gt;
    &amp;lt;label for="email"&amp;gt;E-mail&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;input
      id="email"
      name="email"
      type="email"
      autocomplete="email"
      required
    /&amp;gt;
  &amp;lt;/div&amp;gt;
  &amp;lt;div&amp;gt;
    &amp;lt;label for="message"&amp;gt;Message&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;textarea
      id="message"
      name="message" 
      rows="5"
      cols="70"
      required
    &amp;gt;&amp;lt;/textarea&amp;gt;
  &amp;lt;/div&amp;gt;
  &amp;lt;button&amp;gt;Send&amp;lt;/button&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In both situations, classic sending by reloading the page or made it asynchronously, the steps are these:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create an area at the beginning of the form that contains a header and a list of errors, if any.&lt;/li&gt;
&lt;li&gt;The header must contain the message reporting the result of the shipment, either correct ("&lt;em&gt;Your message has been sent&lt;/em&gt;") or erroneous ("&lt;em&gt;There are 3 errors in your form, please check it&lt;/em&gt;").&lt;/li&gt;
&lt;li&gt;If there are errors, just below the header we will put *a list reporting briefly and descriptively of each of the errors.&lt;/li&gt;
&lt;li&gt;Each item in the list will link to the corresponding form field.&lt;/li&gt;
&lt;li&gt;Each item in the list will serve as a description of the error using the &lt;code&gt;aria-describedby&lt;/code&gt; attribute.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, in our example, if we tried to submit the form with all the fields empty, we would get this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;form&amp;gt;
  &amp;lt;div&amp;gt;
    &amp;lt;h3&amp;gt;There are 3 errors in your form, please check it&amp;lt;/h3&amp;gt;
    &amp;lt;ul&amp;gt;
      &amp;lt;li&amp;gt;
        &amp;lt;a id="error-name" href="#name"&amp;gt;The name field is empty. It's a required field and must be filled in.&amp;lt;/a&amp;gt;
      &amp;lt;/li&amp;gt;
      &amp;lt;li&amp;gt;
        &amp;lt;a id="error-email" href="#email"&amp;gt;The email field is empty. It's a required field and must be filled in.&amp;lt;/a&amp;gt;
      &amp;lt;/li&amp;gt;
      &amp;lt;li&amp;gt;
        &amp;lt;a id="error-message" href="#message"&amp;gt;The message field is empty. It's a required field and must be filled in.&amp;lt;/a&amp;gt;
      &amp;lt;/li&amp;gt;
    &amp;lt;/ul&amp;gt;
  &amp;lt;/div&amp;gt;
  &amp;lt;div&amp;gt;
    &amp;lt;label for="name"&amp;gt;Name&amp;lt;/label&amp;gt;
    &amp;lt;input
      id="name"
      name="name"
      type="text"
      autocomplete="name"
      required
      aria-describedby="error-name"
    /&amp;gt;
  &amp;lt;/div&amp;gt;
  &amp;lt;div&amp;gt;
    &amp;lt;label for="email"&amp;gt;E-mail&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;input
      id="email"
      name="email"
      type="email"
      autocomplete="email"
      required
      aria-describedby="error-email"
    /&amp;gt;
  &amp;lt;/div&amp;gt;
  &amp;lt;div&amp;gt;
    &amp;lt;label for="message"&amp;gt;Message&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;textarea
      id="message"
      name="message"
      rows="5"
      cols="70"
      required
      aria-describedby="error-message"
    &amp;gt;&amp;lt;/textarea&amp;gt;
  &amp;lt;/div&amp;gt;
  &amp;lt;button&amp;gt;Send&amp;lt;/button&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This solution would be enough if &lt;strong&gt;our form is sent and validated on the server&lt;/strong&gt;. In that case, if our form is located deeper within the content, we can use the &lt;code&gt;&amp;lt;title&amp;gt;&lt;/code&gt; of the page to report the result of the submission, since it is the first thing announced by the screen reader as soon as the page is reloaded and thus the user you know immediately if it has gone right or wrong:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;title&amp;gt;Message sent - Contact form&amp;lt;/title&amp;gt;
&amp;lt;title&amp;gt;3 Errors - Contact form&amp;lt;/title&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the submission is done &lt;strong&gt;asynchronously&lt;/strong&gt; and we display the feedback information, &lt;strong&gt;a screen reader user might not notice the change&lt;/strong&gt;. To avoid this, as we already mentioned &lt;a href="https://dev.to/carlosespada/a11y-tips-alert-role-3maa"&gt;when notifying changes in the content&lt;/a&gt;, just insert it inside a &lt;code&gt;&amp;lt;div role="alert"&amp;gt;&lt;/code&gt;. As soon as you do, the screen reader will announce it and move the focus to that region.&lt;/p&gt;

&lt;p&gt;Thus, the HTML that we would have to insert would be this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div role="alert"&amp;gt;
  &amp;lt;h3&amp;gt;There are 3 errors in your form, please check it&amp;lt;/h3&amp;gt;
  &amp;lt;ul&amp;gt;
    [... errors &amp;lt;li&amp;gt; ...]
  &amp;lt;/ul&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All this information and more can be found on the &lt;a href="https://www.w3.org/WAI/tutorials/forms/notifications/" rel="noopener noreferrer"&gt;W3C page dedicated to this topic&lt;/a&gt;, where very useful tips are given on how to notify the user of the result of submitting forms.&lt;/p&gt;

</description>
      <category>a11y</category>
      <category>tips</category>
      <category>html</category>
    </item>
    <item>
      <title>A11y tips: offer alternatives to any functionality</title>
      <dc:creator>Carlos Espada</dc:creator>
      <pubDate>Wed, 26 Jan 2022 07:27:08 +0000</pubDate>
      <link>https://forem.com/carlosespada/a11y-tips-offer-alternatives-to-any-functionality-26gk</link>
      <guid>https://forem.com/carlosespada/a11y-tips-offer-alternatives-to-any-functionality-26gk</guid>
      <description>&lt;p&gt;Using a mobile device allows us some interactions not available in the desktop version, such as rotating it, shaking it, using two fingers to zoom...&lt;/p&gt;

&lt;p&gt;While offering many possibilities to enrich the user experience, it opens the door to new barriers for users with some type of disability.&lt;/p&gt;

&lt;p&gt;For this reason, it is especially important to &lt;strong&gt;always offer alternatives to all these interactions&lt;/strong&gt; so that we do not prevent anyone from enjoying them.&lt;/p&gt;

&lt;p&gt;If your mobile version...&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;... can be rotated, make sure that &lt;strong&gt;the same information can be accessible and work both in portrait and landscape&lt;/strong&gt;, that your design is really responsive. There are people who may be browsing with the device fixed on a support and for whom turning it is really difficult or they cannot do it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;... can update data by shaking the device, make sure you &lt;strong&gt;put a&lt;/strong&gt; &lt;code&gt;Reload&lt;/code&gt; &lt;strong&gt;button that allows you to do the same by clicking on it&lt;/strong&gt;. There are people who may be browsing who cannot shake the device but can comfortably access a button marked in an accessible way.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;... you can zoom by sliding two fingers on the screen, &lt;strong&gt;add a&lt;/strong&gt; &lt;code&gt;+&lt;/code&gt; &lt;strong&gt;and&lt;/strong&gt; &lt;code&gt;-&lt;/code&gt; &lt;strong&gt;buttons to zoom in and out&lt;/strong&gt;. Some people can't swipe with their fingers, but with the help of assistive technology, they can hit a properly marked button.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In all these cases, it is highly recommended to &lt;strong&gt;keep the original function&lt;/strong&gt;, since it is very useful and takes advantage of the capabilities offered by mobile devices. It is not about impoverishing or making the use of our websites more boring, but about &lt;strong&gt;enriching it by making it more diverse&lt;/strong&gt; by adding multiple ways to enjoy them.&lt;/p&gt;

&lt;p&gt;To do this, it is enough to think of all users, not just the vast majority. After all, who hasn't ever broken an arm and found it difficult to use a website? &lt;strong&gt;We have the tools to keep moving forward without leaving anyone behind&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>a11y</category>
      <category>tips</category>
      <category>html</category>
    </item>
    <item>
      <title>A11y tips: let the user resize text up to 200%</title>
      <dc:creator>Carlos Espada</dc:creator>
      <pubDate>Tue, 25 Jan 2022 07:33:53 +0000</pubDate>
      <link>https://forem.com/carlosespada/a11y-tips-let-the-user-resize-text-up-to-200-5cck</link>
      <guid>https://forem.com/carlosespada/a11y-tips-let-the-user-resize-text-up-to-200-5cck</guid>
      <description>&lt;p&gt;In addition to &lt;a href="https://dev.to/carlosespada/a11y-tips-let-the-user-control-the-zoom-2p86"&gt;being able to control the general zoom&lt;/a&gt; of the page, there are users who may need to be able to &lt;strong&gt;control only the zoom of the text&lt;/strong&gt;. And by doing so they shouldn't lose any content or functionality, or create overlaps that didn't exist.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The minimum limit for this zoom is set at 200%&lt;/strong&gt; &lt;a href="https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-scale.html" rel="noopener noreferrer"&gt;by the WCAG&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The working group feels that 200% is a reasonable accommodation that can support a wide range of designs and layouts.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For this, it is recommended to &lt;strong&gt;use the text sizes in relative units&lt;/strong&gt;, with a fallback to pixels. Although browsers are increasingly capable of supporting text zoom well even if it is defined in pixels, today it is more reliable to do it with &lt;code&gt;em&lt;/code&gt; or &lt;code&gt;rem&lt;/code&gt;, which is somewhat more comfortable to use.&lt;/p&gt;

&lt;p&gt;In this &lt;a href="https://www.a11yproject.com/posts/resize-text/" rel="noopener noreferrer"&gt;interesting post from The A11Y Project&lt;/a&gt; you can find information on &lt;strong&gt;how to perform the tests&lt;/strong&gt; to see if our page meets this criteria.&lt;/p&gt;

</description>
      <category>a11y</category>
      <category>tips</category>
      <category>html</category>
    </item>
    <item>
      <title>A11y tips: don't remove focus indicator</title>
      <dc:creator>Carlos Espada</dc:creator>
      <pubDate>Mon, 24 Jan 2022 09:47:10 +0000</pubDate>
      <link>https://forem.com/carlosespada/a11y-tips-dont-remove-focus-indicator-1lpe</link>
      <guid>https://forem.com/carlosespada/a11y-tips-dont-remove-focus-indicator-1lpe</guid>
      <description>&lt;p&gt;Very often we use &lt;code&gt;outline: 0&lt;/code&gt; to remove the effect of focusing on an element. This, which initially prevents a border from wrapping around it when you click/touch on it, means that &lt;strong&gt;users navigating using the keyboard don't have a visual indicator of which element has focus&lt;/strong&gt;. And we know that &lt;a href="https://noti.st/ericwbailey/TcMJFP" rel="noopener noreferrer"&gt;every interactive element needs a focus indicator&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Therefore, it is recommended to address this problem using some of these solutions:&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Style &lt;code&gt;outline property&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Use CSS to give the outline the effect you want, for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;button:focus {
  outline: 4px dashed black;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Style element itself
&lt;/h2&gt;

&lt;p&gt;Remove the outline but design other styles for the focused element, using the CSS properties that suit you best: &lt;code&gt;border&lt;/code&gt;, &lt;code&gt;background-color&lt;/code&gt;, &lt;code&gt;text-decoration&lt;/code&gt;, &lt;code&gt;color&lt;/code&gt;... In case you choose this option, it is important to be careful &lt;a href="https://www.w3.org/TR/WCAG21/#use-of-color" rel="noopener noreferrer"&gt;not to use the color&lt;/a&gt; as the only element to provide information about the focus, since there may be colorblind people who are not able to distinguish between the normal state and the focus state.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;button:focus {
  outline: none;
  /* any accessible style you want here */
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Remove outline for mouse users only
&lt;/h2&gt;

&lt;p&gt;Since the problem occurs when mouse users click/touch on an interactive element, it seems best to remove the outline for these users only. Luckily we have a well-supported CSS pseudo-class at our disposal that allows us to do something like this: &lt;code&gt;:focus-within&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;With &lt;a href="https://caniuse.com/css-focus-visible" rel="noopener noreferrer"&gt;good browser support&lt;/a&gt; we can now do something like what &lt;a href="https://twitter.com/LeaVerou/status/1045768279753666562" rel="noopener noreferrer"&gt;Lea Vérou proposes&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;button:focus:not(:focus-visible) {
  outline:none;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This way we &lt;strong&gt;only remove the outline for users clicking/touching&lt;/strong&gt; the element, and we can complete our styles using the same pseudo-class for keyboard navigation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;button:focus-visible {
  outline: 4px dashed black;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are very good articles on this subject by &lt;a href="https://css-tricks.com/the-focus-visible-trick/" rel="noopener noreferrer"&gt;Chris Coyier&lt;/a&gt; and &lt;a href="https://www.tpgi.com/focus-visible-and-backwards-compatibility/" rel="noopener noreferrer"&gt;Patrick H. Lauke&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>a11y</category>
      <category>tips</category>
      <category>html</category>
    </item>
    <item>
      <title>A11y tips: report on elements being shown and hidden</title>
      <dc:creator>Carlos Espada</dc:creator>
      <pubDate>Thu, 20 Jan 2022 07:38:44 +0000</pubDate>
      <link>https://forem.com/carlosespada/a11y-tips-report-on-elements-being-shown-and-hidden-4lmf</link>
      <guid>https://forem.com/carlosespada/a11y-tips-report-on-elements-being-shown-and-hidden-4lmf</guid>
      <description>&lt;p&gt;Sometimes we use elements that, by clicking a button, can _&lt;strong&gt;change their state from hidden to visible&lt;/strong&gt; or vice versa. This is the case of a drop-down menu or an accordion, for example. And how can we inform the user of a screen reader of these changes? With the ARIA attribute &lt;code&gt;aria-expanded&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So, for example, we can find something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;button aria-expanded=”false”&amp;gt;Menu&amp;lt;/button&amp;gt;
&amp;lt;!-- initially hidden --&amp;gt;
&amp;lt;div class="menu"&amp;gt;
[...]
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And using the same JavaScript that triggers the &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt; and displays the menu, we change the value of the &lt;code&gt;aria-expanded&lt;/code&gt; attribute:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;button aria-expanded=”true”&amp;gt;Menu&amp;lt;/button&amp;gt;
&amp;lt;!-- will appear visible --&amp;gt;
&amp;lt;div class="menu menu--is-visible"&amp;gt;
[...]
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As seen in the example, the ideal is that &lt;strong&gt;the content that is shown or hidden is located just after the control&lt;/strong&gt; responsible for its visibility, so that when the user activates it, it is right next to it and navigation is more logical.&lt;/p&gt;

&lt;p&gt;Although we could use the same system for an accordion, these can be a special case as there are &lt;a href="https://dev.to/carlosespada/html-tags-details-summary-db5"&gt;some HTML elements&lt;/a&gt; that offer the same behavior natively &lt;strong&gt;without the need to use ARIA or JS&lt;/strong&gt;: the &lt;code&gt;&amp;lt;details&amp;gt;&lt;/code&gt;-&lt;code&gt;&amp;lt;summary&amp;gt;&lt;/code&gt; combination.&lt;/p&gt;

&lt;p&gt;Disadvantages? It is &lt;a href="https://caniuse.com/mdn-html_elements_summary" rel="noopener noreferrer"&gt;not supported by Internet Explorer&lt;/a&gt; and is still somewhat buggy on some assistive technologies, so we &lt;strong&gt;still need to test them using keyboard and screen readers&lt;/strong&gt;. To follow the evolution of their support and to know when we can use them without any problem, you can check &lt;a href="https://www.html5accessibility.com" rel="noopener noreferrer"&gt;HTML5 Accessibility&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>a11y</category>
      <category>tips</category>
      <category>html</category>
    </item>
    <item>
      <title>A11y tips: use landmarks</title>
      <dc:creator>Carlos Espada</dc:creator>
      <pubDate>Wed, 19 Jan 2022 08:23:41 +0000</pubDate>
      <link>https://forem.com/carlosespada/a11y-tips-use-landmarks-1npj</link>
      <guid>https://forem.com/carlosespada/a11y-tips-use-landmarks-1npj</guid>
      <description>&lt;p&gt;Even if the usage of landmarks &lt;a href="https://webaim.org/projects/screenreadersurvey9/#landmarks" rel="noopener noreferrer"&gt;is in continuous decline&lt;/a&gt; among users of assistive technologies, &lt;strong&gt;they are still a very used resource for navigation&lt;/strong&gt;, and if they are not used more often it may be due to the improper usage that we, developers, tend to make of them.&lt;/p&gt;

&lt;p&gt;Landmarks are used to &lt;strong&gt;define specific regions&lt;/strong&gt; within the structure of our HTML. Remember that &lt;strong&gt;all content should be included within a landmark&lt;/strong&gt;, except, if you like, &lt;a href="https://dev.to/carlosespada/a11y-tips-add-a-skip-link-222m#:~:text=the%20skip%20link%20can%20be%20located%20outside%20of%20any%20landmark"&gt;the skip link&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Landmarks have an implicit role, so in theory &lt;a href="https://www.w3.org/TR/html-aria/#h-note" rel="noopener noreferrer"&gt;it is not necessary&lt;/a&gt; to assign it unless they are repeated in the document. On this subject &lt;a href="https://www.tempertemper.net/blog/implicit-aria-landmark-roles" rel="noopener noreferrer"&gt;there are contrary opinions&lt;/a&gt; that advocate declaring it explicitly to ensure compatibility with any browser. These are some of the most used:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://dev.to/carlosespada/html-tags-header-2f84"&gt;&lt;code&gt;&amp;lt;header&amp;gt;&lt;/code&gt;&lt;/a&gt; (&lt;code&gt;role=”banner”&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://dev.to/carlosespada/html-tags-main-422k"&gt;&lt;code&gt;&amp;lt;main&amp;gt;&lt;/code&gt;&lt;/a&gt; (&lt;code&gt;role=”main”&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://dev.to/carlosespada/html-tags-aside-48hp"&gt;&lt;code&gt;&amp;lt;aside&amp;gt;&lt;/code&gt;&lt;/a&gt; (&lt;code&gt;role=”complementary”&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://dev.to/carlosespada/html-tags-footer-3of5"&gt;&lt;code&gt;&amp;lt;footer&amp;gt;&lt;/code&gt;&lt;/a&gt; (&lt;code&gt;role=”contentinfo”&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://dev.to/carlosespada/html-tags-nav-p4d"&gt;&lt;code&gt;&amp;lt;nav&amp;gt;&lt;/code&gt;&lt;/a&gt; (&lt;code&gt;role=”contentinfo”&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;&amp;lt;header&amp;gt;&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;If, in addition to the main header, it is used more than once in the document to mark the header of other areas (eg: &lt;code&gt;&amp;lt;section&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;article&amp;gt;&lt;/code&gt;), &lt;strong&gt;it must be indicated&lt;/strong&gt; that the main header has a &lt;code&gt;role="banner"&lt;/code&gt; to set it apart from the others.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;header role="banner"&amp;gt;&lt;/code&gt; &lt;strong&gt;can only appear once&lt;/strong&gt; in each document.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;&amp;lt;main&amp;gt;&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;By identifying the main content of the page &lt;strong&gt;only one can be used in each document&lt;/strong&gt;. It must exist in a mandatory way, there may be pages that are missing any other landmark but all of them &lt;strong&gt;must always have a single&lt;/strong&gt; &lt;code&gt;&amp;lt;main&amp;gt;&lt;/code&gt; element.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;&amp;lt;aside&amp;gt;&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;To know if a content has to go in an &lt;code&gt;&amp;lt;aside&amp;gt;&lt;/code&gt; we can ask ourselves the following two questions: &lt;em&gt;Is this content complementary to the main one being at the same hierarchy level? Can it be separated from it and still make sense?&lt;/em&gt; If the answer is yes in both cases, then it is an &lt;code&gt;&amp;lt;aside&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;&amp;lt;footer&amp;gt;&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;If, in addition to the main footer, it is used more than once in the document to mark the footer of other areas (eg: &lt;code&gt;&amp;lt;section&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;article&amp;gt;&lt;/code&gt;), &lt;strong&gt;it must be indicated&lt;/strong&gt; that the main footer has a &lt;code&gt;role="contentinfo"&lt;/code&gt; to set it apart from the others.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;footer role="contentinfo"&amp;gt;&lt;/code&gt; &lt;strong&gt;can only appear once&lt;/strong&gt; in each document.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;&amp;lt;nav&amp;gt;&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;It can appear several times in the same document, since it is used to mark important blocks of navigation (eg: main menu, footer sitemap...), but it should not be used excessively to mark each small group of links.&lt;/p&gt;

&lt;p&gt;If it appears more than once, add an &lt;code&gt;aria-label&lt;/code&gt; attribute to the &lt;code&gt;&amp;lt;nav&amp;gt;&lt;/code&gt; that identifies what type of navigation it represents, for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;nav aria-label="Main"&amp;gt;
&amp;lt;nav aria-label="Sitemap"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Avoid the role of the landmark as part of the value of &lt;code&gt;aria-label&lt;/code&gt;. For example, a &lt;code&gt;&amp;lt;nav&amp;gt;&lt;/code&gt; will be announced with the word "&lt;em&gt;Navigation&lt;/em&gt;" at the end, so if we use an &lt;code&gt;aria-label="Main navigation"&lt;/code&gt; it will be announced as "&lt;em&gt;Main navigation Navigation&lt;/em&gt;", which is redundant. If we just use &lt;code&gt;aria-label="Main"&lt;/code&gt; the user will just hear "&lt;em&gt;Main Navigation&lt;/em&gt;", which is nicer.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;role="search"&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Although the default role of an HTML element should not be changed, this is a particular case that arises from the agreement between specs writers and screen reader developers, so that users of assistive technologies can jump directly to the site's search form if we use this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;form role="search"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These are just some of the landmarks at our disposal, but to get to know them all in depth there is a lot of interesting information &lt;a href="https://www.w3.org/TR/wai-aria-practices/examples/landmarks/index.html" rel="noopener noreferrer"&gt;in the corresponding section&lt;/a&gt; of the W3C page.&lt;/p&gt;

</description>
      <category>a11y</category>
      <category>tips</category>
      <category>html</category>
    </item>
    <item>
      <title>A11y tips: autocomplete your form fields</title>
      <dc:creator>Carlos Espada</dc:creator>
      <pubDate>Mon, 17 Jan 2022 07:41:44 +0000</pubDate>
      <link>https://forem.com/carlosespada/a11y-tips-autocomplete-your-form-fields-njo</link>
      <guid>https://forem.com/carlosespada/a11y-tips-autocomplete-your-form-fields-njo</guid>
      <description>&lt;p&gt;The &lt;code&gt;autocomplete&lt;/code&gt; attribute allows the user agent to &lt;strong&gt;automatically fill in certain form fields&lt;/strong&gt; by obtaining the value from previous past values ​​entered by the user, or from pre-configured values. It can be &lt;strong&gt;very useful for users with a cognitive disability&lt;/strong&gt;, as well as for any user does not have to be repeating the same information over and over again in different forms.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;label for="first-name"&amp;gt;First Name&amp;lt;/label&amp;gt;
&amp;lt;input
  id="first-name"
  name=”first-name”
  type="text"
  autocomplete="given-name"
/&amp;gt;
&amp;lt;label for="last-name"&amp;gt;Last Name&amp;lt;/label&amp;gt;
&amp;lt;input
  id="last-name"
  name=”last-name”
  type="text"
  autocomplete="family-name"
/&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;a href="https://www.w3.org/TR/WCAG21/#input-purposes" rel="noopener noreferrer"&gt;W3C&lt;/a&gt; and &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete#values" rel="noopener noreferrer"&gt;MDN&lt;/a&gt; pages provide a complete list of the values ​​that the &lt;code&gt;autocomplete&lt;/code&gt; attribute can take. The &lt;strong&gt;more consistent&lt;/strong&gt; the use of these values ​​is throughout the entire site, the &lt;strong&gt;easier&lt;/strong&gt; it will be for the user agent to use them correctly and usefully for the user.&lt;/p&gt;

&lt;p&gt;In order to provide autocompletion, user-agents might require form fields (&lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;select&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;textarea&amp;gt;&lt;/code&gt;) elements to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Have a name and/or &lt;code&gt;id&lt;/code&gt; attribute&lt;/li&gt;
&lt;li&gt;Be descendants of a &lt;code&gt;&amp;lt;form&amp;gt;&lt;/code&gt; element&lt;/li&gt;
&lt;li&gt;The form to have a submit button&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are form fields that you &lt;strong&gt;should be careful&lt;/strong&gt; with when using &lt;code&gt;autocomplete&lt;/code&gt; attribute, as they contain &lt;strong&gt;sensitive information&lt;/strong&gt;, such as those related to credit cards.&lt;/p&gt;

&lt;p&gt;Some of the values &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete#administrative_levels_in_addresses" rel="noopener noreferrer"&gt;​​are based on US formats&lt;/a&gt;, so usage in other countries may be difficult to resolve for the user agent.&lt;/p&gt;

</description>
      <category>a11y</category>
      <category>tips</category>
      <category>html</category>
    </item>
    <item>
      <title>A11y tips: accesible images</title>
      <dc:creator>Carlos Espada</dc:creator>
      <pubDate>Fri, 14 Jan 2022 08:28:23 +0000</pubDate>
      <link>https://forem.com/carlosespada/a11y-tips-accesible-images-54an</link>
      <guid>https://forem.com/carlosespada/a11y-tips-accesible-images-54an</guid>
      <description>&lt;p&gt;Depending on the function they fulfill, we can distinguish two types of images:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Those that &lt;strong&gt;provide information&lt;/strong&gt;, such as the image that accompanies the news in a newspaper.&lt;/li&gt;
&lt;li&gt;Those that fulfill a &lt;strong&gt;purely decorative function&lt;/strong&gt;, such as a calendar icon next to a datepicker&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When we insert an image in our HTML using the &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; tag we &lt;strong&gt;always have to accompany it&lt;/strong&gt; with its &lt;code&gt;alt&lt;/code&gt; attribute, so that screen readers have alternative content to announce when they reach it.&lt;/p&gt;

&lt;p&gt;If we choose not to add the &lt;code&gt;alt&lt;/code&gt; attribute, when the screen reader reaches the image, it will not know how to describe it and will try to do so by reading the name of the file, which could well be something like &lt;code&gt;image-header.jpg&lt;/code&gt;, which does not provide any information.&lt;/p&gt;

&lt;h2&gt;
  
  
  Decorative images
&lt;/h2&gt;

&lt;p&gt;The theory says that &lt;strong&gt;the content must be separated from the presentation&lt;/strong&gt;, that is, that an HTML must have meaning by itself without having to rely on CSS.&lt;/p&gt;

&lt;p&gt;For this reason, images that do not fulfill any informative function, that is, that are for purely decorative reasons, should be included in the CSS using the &lt;code&gt;background-image&lt;/code&gt; property.&lt;/p&gt;

&lt;p&gt;Thus, in the example of the button that we mentioned, the most correct would be something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.button-date {
   background-image: url("ico-calendar.svg");
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sometimes these images, due to integration needs, cannot be output to external CSS files, but they can still be included inline using the &lt;code&gt;style&lt;/code&gt; attribute. It is not optimal when mixing presentation and content, but it is still valid:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;button style="background-image: url("ico-calendar.svg")&amp;gt;
  Pick date
&amp;lt;/button&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And sometimes, for whatever reason, you have to include a decorative image using the &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; tag. It is something to avoid, but if needed it can be done by leaving the &lt;code&gt;alt&lt;/code&gt; attribute empty, so that screen readers ignore the image by not adding it to the accessibility tree.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;img src="ico-calendar.svg" alt="" /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What is the difference between not including &lt;code&gt;alt&lt;/code&gt; attribute or leaving it empty? If you do not include it, the screen reader does not know if you have forgotten to do it but the image is still important, so &lt;strong&gt;it will try to offer an alternative content&lt;/strong&gt; in any way it can, and as we have commented before it will announce the name of the file. However, if you leave the &lt;code&gt;alt&lt;/code&gt; attribute empty you are clearly saying "&lt;em&gt;hey, screen reader, I have not forgotten anything, this image is decorative and you do not have to advertise it, skip it&lt;/em&gt;".&lt;/p&gt;

&lt;h2&gt;
  
  
  Informative images
&lt;/h2&gt;

&lt;p&gt;In this case we have to write a good &lt;code&gt;alt&lt;/code&gt; attribute that describes the image and how? &lt;strong&gt;Trying to be as brief and at the same time descriptive of the accompanying image&lt;/strong&gt;. It can come in handy to try to answer this question: &lt;em&gt;how would we tell the content of an image to someone who cannot see it so that they have reliable information but we do not bore them?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Since the screen reader already announces previously that the &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; element is an image, it is not necessary to start the alt with texts such as &lt;code&gt;Image of&lt;/code&gt; or similar, directly the descriptive text. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;img
  src="dog.jpg"
  alt="Dog with a bell attached to its collar."
/&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the image serves as a link, the &lt;code&gt;alt&lt;/code&gt; attribute that we add will serve to give the link an accessible name that can be read by the screen reader.&lt;/p&gt;

&lt;p&gt;More information on how to handle informational images can be found on the &lt;a href="https://www.w3.org/WAI/tutorials/images/informative/" rel="noopener noreferrer"&gt;W3C-WAI page&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;A special case are images that, by their very nature, have so much information that it is impossible to summarize it in an &lt;code&gt;alt&lt;/code&gt; attribute, such as diagrams, graphs, flow charts...&lt;/p&gt;

&lt;p&gt;In these cases there are two alternatives to offer the alternative content:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Describe the image using an HTML element located below the image, for example a &lt;code&gt;&amp;lt;figcaption&amp;gt;&lt;/code&gt; if the image is inside a &lt;code&gt;&amp;lt;figure&amp;gt;&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Make a different page with the content of the infographic and add a link to it below the image, so that the screen reader user has easy access to discover its content.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A good consequence of both options is that in addition to improving accessibility, &lt;strong&gt;SEO is also improved&lt;/strong&gt; by offering more easily indexable content as it is in text format.&lt;/p&gt;

&lt;h2&gt;
  
  
  Still have questions?
&lt;/h2&gt;

&lt;p&gt;In case you don't know how to act with an image or how to write the alt attribute, there is a very useful resource that the W3C-WAI offers, the &lt;a href="https://www.w3.org/WAI/tutorials/images/decision-tree/" rel="noopener noreferrer"&gt;Alt Decision Tree&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>a11y</category>
      <category>tips</category>
      <category>html</category>
    </item>
    <item>
      <title>A11y tips: hide content from screen readers</title>
      <dc:creator>Carlos Espada</dc:creator>
      <pubDate>Thu, 13 Jan 2022 07:28:19 +0000</pubDate>
      <link>https://forem.com/carlosespada/a11y-tips-hide-content-from-screen-readers-3mj3</link>
      <guid>https://forem.com/carlosespada/a11y-tips-hide-content-from-screen-readers-3mj3</guid>
      <description>&lt;p&gt;If you want to &lt;strong&gt;hide content for screen readers&lt;/strong&gt; but still be available to sighted or keyboard users, just use &lt;code&gt;aria-hidden="true"&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;A classic example where it is useful is to hide icons that serve as visual support for a text:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;style&amp;gt;
  .icon-star: before {content: "★"; }
&amp;lt;/style&amp;gt;

&amp;lt;span&amp;gt;
  &amp;lt;span class="icon-star" aria-hidden="true"&amp;gt;&amp;lt;/span&amp;gt;
  Favorite
&amp;lt;/span&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this way the icon that we insert with CSS only appears for sighted users, while screen readers will announce only "&lt;em&gt;Favorite&lt;/em&gt;", instead of "&lt;em&gt;Black Star Favorite&lt;/em&gt;".&lt;/p&gt;

&lt;p&gt;It is best to &lt;strong&gt;avoid using this ARIA attribute on focusable elements&lt;/strong&gt;, as being able to receive focus but hiding from screen readers can cause confusion for their users. You could use a &lt;code&gt;tabindex="- 1"&lt;/code&gt; to avoid focus but then it would be out of use for sighted keyboard users.&lt;/p&gt;

&lt;p&gt;This and other tips on the use of &lt;code&gt;aria-hidden="true"&lt;/code&gt; can be found in the &lt;a href="https://www.scottohara.me/blog/2017/04/14/inclusively-hidden.html#:~:text=Hiding%20Content%20from%20Assistive%20Technology" rel="noopener noreferrer"&gt;already named article&lt;/a&gt; by Scott O'Hara, and on the use of icon fonts in &lt;a href="https://www.filamentgroup.com/lab/bulletproof_icon_fonts.html" rel="noopener noreferrer"&gt;the article&lt;/a&gt; by Zach Leathermann, from which the example is taken.&lt;/p&gt;

</description>
      <category>a11y</category>
      <category>tips</category>
      <category>html</category>
    </item>
    <item>
      <title>A11y tips: hide content only from sighted users</title>
      <dc:creator>Carlos Espada</dc:creator>
      <pubDate>Wed, 12 Jan 2022 07:11:44 +0000</pubDate>
      <link>https://forem.com/carlosespada/a11y-tips-hide-content-only-from-sighted-users-2gof</link>
      <guid>https://forem.com/carlosespada/a11y-tips-hide-content-only-from-sighted-users-2gof</guid>
      <description>&lt;p&gt;Very often we want to &lt;strong&gt;hide items from view but we want them to still be available to screen readers and keyboard users&lt;/strong&gt;. There are two methods for this:&lt;/p&gt;

&lt;h2&gt;
  
  
  Hide with CSS
&lt;/h2&gt;

&lt;p&gt;This is the &lt;strong&gt;most common method&lt;/strong&gt;, and works best to hide text from sighted users without any disadvantage to others.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.hidden {
  overflow: hidden;
  clip: rect (1px, 1px, 1px, 1px);
  clip-path: inset (50%);
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  word-wrap: normal;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;clip-path&lt;/code&gt; property &lt;a href="https://caniuse.com/css-clip-path" rel="noopener noreferrer"&gt;is not supported&lt;/a&gt; by all browsers, so we also use the &lt;code&gt;clip&lt;/code&gt; property for those cases, even if it is deprecated.&lt;/p&gt;

&lt;p&gt;We use a &lt;code&gt;width&lt;/code&gt; and a &lt;code&gt;height&lt;/code&gt; of &lt;code&gt;1px&lt;/code&gt; instead of &lt;code&gt;0&lt;/code&gt; because in this case some screen readers could interpret that the element does not exist, as it has no dimensions, and therefore not announce it.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;word-wrap&lt;/code&gt; property must be declared since, having a width of &lt;code&gt;1px&lt;/code&gt;, some screen readers can interpret that the text is arranged vertically as it does not fit horizontally, and read it letter by letter. By declaring &lt;code&gt;word-wrap&lt;/code&gt; like this, we avoid it and it is pronounced normally.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;EDITED:&lt;/strong&gt; Even if &lt;a href="https://webaim.org/techniques/css/invisiblecontent/#:~:text=receive%20keyboard%20focus.-,CSS%20clip,-%7Bclip" rel="noopener noreferrer"&gt;WebAIM&lt;/a&gt; or the &lt;a href="https://accessibility.18f.gov/hidden-content/" rel="noopener noreferrer"&gt;United States Government&lt;/a&gt; uses a &lt;code&gt;margin: -1px&lt;/code&gt;, as @inhuofficial comments (thank you very much for all the help! 🙂) &lt;a href="https://github.com/h5bp/main.css/issues/12" rel="noopener noreferrer"&gt;it can cause an error with VoiceOVer&lt;/a&gt;, so it is better to &lt;strong&gt;leave it outside the CSS class&lt;/strong&gt;, although in many places you will see that it is included. Scott O'Hara himself also leaves it out in his magnificent article &lt;a href="https://www.scottohara.me/blog/2017/04/14/inclusively-hidden.html" rel="noopener noreferrer"&gt;Inclusively Hidden&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  CSS &lt;code&gt;opacity: 0&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;It has the same result as the previous one, but &lt;a href="https://dev.to/carlosespada/a11y-tips-hide-elements-for-all-users-3f9m"&gt;as we saw&lt;/a&gt; in the case of the CSS &lt;code&gt;visibility: hidden&lt;/code&gt; property, here the dimensions of the element are maintained (&lt;code&gt;width&lt;/code&gt; and &lt;code&gt;height&lt;/code&gt;), which makes it take up space in the layout even if it is hidden, therefore &lt;strong&gt;its use is a lot less common&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>a11y</category>
      <category>tips</category>
      <category>html</category>
    </item>
  </channel>
</rss>
