<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Hector Osborne Rodriguez on Medium]]></title>
        <description><![CDATA[Stories by Hector Osborne Rodriguez on Medium]]></description>
        <link>https://medium.com/@hecosbornerod?source=rss-abfecb22164d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*sa-MP4MjjPe3gVbyP62-Uw.jpeg</url>
            <title>Stories by Hector Osborne Rodriguez on Medium</title>
            <link>https://medium.com/@hecosbornerod?source=rss-abfecb22164d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 07:18:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hecosbornerod/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Discounted prices- a11y Snippets]]></title>
            <link>https://hecosbornerod.medium.com/discounted-prices-a11y-snippets-91783b533b91?source=rss-abfecb22164d------2</link>
            <guid isPermaLink="false">https://medium.com/p/91783b533b91</guid>
            <dc:creator><![CDATA[Hector Osborne Rodriguez]]></dc:creator>
            <pubDate>Tue, 10 Aug 2021 21:13:10 GMT</pubDate>
            <atom:updated>2022-03-28T22:48:54.442Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V2CxZv6dEWF3XJIWGuxiGw.png" /></figure><p>Moved to…<br><a href="https://a11y.tips/blog/discounted-price/">https://a11y.tips/blog/discounted-price/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91783b533b91" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Search Box Part 1— eCommerce Accessibility]]></title>
            <link>https://hecosbornerod.medium.com/search-box-part-1-ecommerce-accessibility-c7e7f0e527a8?source=rss-abfecb22164d------2</link>
            <guid isPermaLink="false">https://medium.com/p/c7e7f0e527a8</guid>
            <category><![CDATA[a11y]]></category>
            <category><![CDATA[ecommerce]]></category>
            <category><![CDATA[web-accessibility]]></category>
            <category><![CDATA[accessibility]]></category>
            <category><![CDATA[web-accessibility-a11y]]></category>
            <dc:creator><![CDATA[Hector Osborne Rodriguez]]></dc:creator>
            <pubDate>Wed, 19 May 2021 03:26:05 GMT</pubDate>
            <atom:updated>2021-05-20T14:09:18.738Z</atom:updated>
            <content:encoded><![CDATA[<h4>Search box is shown essentially everywhere to all visitors, it makes sense that you should spend some time making it look nice, right?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n-UUlzK24NbTTFthsnYVmA.jpeg" /><figcaption>Menu photography by <a href="https://unsplash.com/@sunrisephotography">@sunrisephotography</a></figcaption></figure><p>To celebrate this year&#39;s <a href="https://globalaccessibilityawarenessday.org/">Global Accessibility Awareness Day</a> (GAAD) I started working on one of my 2021 goals, <strong>write more technical notes</strong> on eCommerce accessibility.</p><p>I will start making an assumption that not a single eCommerce website can live without a search box. It should allow users a way to discover products &amp; categories. Easier than the menu sometimes.</p><p>But what makes a search box actually useful? Let&#39;s dive in.</p><h4>Design Principle</h4><p>Let&#39;s build a search box component that allows you to type characters. and as user types, results are automatically updated showing the top X related products . These are the high level requirements:</p><ul><li>Component should be located on the header</li><li>Should have a label &amp; a magnifier icon</li><li>Should have <strong>default</strong>, <strong>:hover </strong>&amp; <strong>:focus </strong>styling</li><li>It should start showing suggestions after user has typed 2 characters. <br>(this will be develop in part 2)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*StahbmPbd5gc67Mf87PeDw.png" /><figcaption>Search box with three different visual states: default, hover, focus.</figcaption></figure><h4>Author&#39;s note</h4><p>All of the links in this article will be opening in the same window, as it is the default behaviour of this publishing platform.</p><p>I&#39;ll try to add as many source references as I can to external documentation on the topic.</p><p>A summary and resources will be added at the end of this article.</p><p>This component will be using four HTML elements: a form, an input, a button,and a icon.</p><p>Autocomplete functionality will described in the next article of this series.</p><h3><strong>Basic Code</strong></h3><pre>&lt;form action=&quot;/search&quot; method=&quot;get&quot; role=&quot;search&quot;&gt;<br>    &lt;button type=&quot;button&quot; class=&quot;search-btn&quot; aria-label=&quot;Search&quot;&gt;<br>        &lt;svg focusable=&quot;false&quot; class=&quot;search-icon&quot;&gt;<br>            &lt;use xlink:href=&quot;#icon-search&quot;&gt;&lt;/use&gt;<br>        &lt;/svg&gt;<br>    &lt;/button&gt;<br>    &lt;input id=&quot;search&quot; type=&quot;search&quot; name=&quot;q&quot; autocomplete=&quot;off&quot; autocorrect=&quot;off&quot; spellcheck=&quot;false&quot; placeholder=&quot;Search&quot; aria label=&quot;Search for products&quot;/&gt;<br>&lt;/form&gt;</pre><pre>&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot; width=&quot;0&quot; height=&quot;0&quot; style=&quot;position: absolute;&quot;&gt;<br>    &lt;symbol id=&quot;icon-search&quot; viewBox=&quot;0 0 32 32&quot;&gt;<br>        &lt;path d=&quot;M21.6 19.2h-1.264l-.448-.432a10.373 10.373 0 0 0 2.516-6.793c0-5.76-4.669-10.429-10.429-10.429S1.546 6.215 1.546 11.975c0 5.76 4.669 10.429 10.429 10.429 2.601 0 4.98-.952 6.806-2.527l-.014.011.432.448V21.6l6.8 6.8a1.686 1.686 0 0 0 2.383-2.384l.001.001zm-9.6 0a7.2 7.2 0 1 1 7.2-7.2v.01a7.19 7.19 0 0 1-7.19 7.19H12h.001z&quot;&gt;&lt;/path&gt;<br>    &lt;/symbol&gt;<br>&lt;/svg&gt;</pre><p>Wow, that’s escalated quickly! Let’s see what all this mumbo jumbo means.</p><p><a href="https://jsfiddle.net/madebyhector/b3e8fjzc/7/">Try this code in JSFiddle</a></p><h3>Element 1: Form</h3><pre>&lt;form action=&quot;/search&quot; method=&quot;get&quot;&gt;<br>...<br>&lt;/form&gt;</pre><p>The definition of the form element according to MDN is the following: <strong>HTML </strong><strong>&lt;form&gt; element</strong> represents a document section containing interactive controls for submitting information.</p><p>Aside from the method of communication <strong>method=&quot;get&quot;</strong> and the url that processes the form submission <strong>action=&quot;/search</strong>&quot; there is one area that&#39;s easily forgotten when creating a webpages and that is defining landmarks.</p><p>Landmarks can be used by assistive technology to quickly identify and navigate to large sections of the document. For example: header, footer, sidebar, search, banner. This gives shortcuts and guidance to the users of screen readers and some assistive technology on how the page is structured.</p><p>The html element<strong>&lt;form&gt;</strong>default role is &quot;form&quot;. In a page we can have multiple forms: login, search, checkout. We can overwrite the role of any HTML element using ARIA to help guide screen reader&#39;s users.</p><p>The <strong>search</strong>landmark role is used to identify a section of a the page or site. When a <strong>&lt;form&gt;</strong> is a search form, use the <strong>search</strong> role instead of <a href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/Form_Role"><strong>form</strong></a></p><pre>&lt;form action=&quot;/search&quot; method=&quot;get&quot; role=&quot;search&quot;&gt;<br>...<br>&lt;/form&gt;</pre><p>This should be our basic code to start creating our search component.</p><h3>Element 2: Input</h3><p>To receive the information the user types, we&#39;ll use an &lt;input&gt; element. But it has many layers. Let&#39;s start with a simple HTML</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bP12myPvFSeGogu5cHeARQ.png" /><figcaption>Default styling for input type</figcaption></figure><pre>&lt;form action=&quot;/search&quot; method=&quot;get&quot; role=&quot;search&quot;&gt;<br>    &lt;input <strong>type=&quot;search&quot;</strong> placeholder=&quot;Search for products&quot; /&gt;<br>&lt;/form&gt;</pre><p>While creating this component the first decision we are faced is choosing an input type element. Do we use <strong>type=&quot;text&quot;</strong>or <strong>type=&quot;search&quot;</strong>. Is there actually any difference between them?</p><p>When in doubt I always refer to some of the best documentation in the web (according to me). For any component I like to visit the following resources:</p><ul><li>For HTML / CSS / Javascript: I refer to <a href="https://developer.mozilla.org/en-US/">MDN Web Docs</a>. I like that they include long descriptions, examples, references and browser support.</li><li>For CSS: I like to use <a href="https://caniuse.com/">caniuse.com</a>. They keep all the browser support up to date, alongside with Known issues.</li><li>For ARIA: I like to refer to <a href="https://www.w3.org/TR/wai-aria-practices-1.1/">WAIA ARIA Authoring Practices 1.1</a>. I love the fact that they have documented &amp; functional components.</li><li>For Design Systems: I typically refer to <a href="https://design-system.service.gov.uk/">Government of UK Design System</a></li></ul><p>Let&#39;s see the definition of the <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input">input element</a> and the <a href="https://developer.mozilla.org/en-US/docs/Learn/Forms/HTML5_input_types#search_field">different input types</a> according to MDN:</p><p><strong>type=&quot;text&quot;</strong>: The default value. A single-line text field. Line-breaks are automatically removed from the input value.</p><p><strong>type=&quot;search&quot;: </strong>A single-line text field for entering search strings. Line-breaks are automatically removed from the input value. <strong>May include a delete icon in supporting browsers that can be used to clear the field. Displays a search icon instead of enter key on some devices with dynamic keypads. </strong>Another worth-noting feature is that the values of a search field can be automatically saved and re-used to offer auto-completion across multiple pages of the same website; this tends to happen automatically in most modern browsers.</p><p>Checking the browser support for type=&quot;search&quot; (at the time writing this article) it&#39;s supported by most modern browsers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P3irVRGuBg2xCQrJbf42hA.png" /><figcaption>Browser support for type=&quot;search&quot;</figcaption></figure><p>Is it one better than the other? I would have to say no. But since we have an specific element type created for search, that provides with more functionality and it&#39;s supported by all modern browsers, let&#39;s start using type=&quot;search&quot;.</p><p><strong>Note:</strong> I noticed the the Government of UK style guide is currently using input type=&quot;search&quot; If anyone from the team is reading this article, I would love to hear from you on the comments.</p><h4>Placeholder</h4><p>Form input <strong>placeholder</strong> attributes are helpful for providing hints to (sighted) users in forms.</p><p>The previous code relies in the usage of placeholder to display a the label for the field. This is a violation of WCAG as every field in a form should be labelled (<a href="https://www.w3.org/WAI/WCAG21/Understanding/labels-or-instructions.html">WCAG 2.1 SC 3.3.2</a>).</p><p>But why is it important to label input fields? There are two main reasons.</p><p><strong>Reason #1: </strong>Not every screen reader is capable or reading the placeholder label. Some will use the text in the placeholder to populate the accessible name in the accessibility API. However some browsers will persist this placeholder label even when the user has typed a value, announcing something like <strong>placeholder + text</strong> or <strong>text + placeholder</strong>For example: &quot;search for products shoes&quot; or &quot;shoes search for products&quot;. This is not recommended.</p><p><strong>Reason #2:</strong> For people with cognitive disabilities, distracted users, or simple long from designs with no labels, this could represent a usability problem. In any browser the placeholder disappears as soon as a value is entered into the input, and the user might not remember the label or the description might not be enough for the user to infer the expected value.</p><p>There are many ways to solution these issues. I&#39;m going to focus on only two of them.</p><p><strong>Solution #1 — Floating labels: </strong>Many organizations are moving to floating labels which move out of the field and stay visible when there is a value entered in the input. It is an actual label which is positioned over the input and moved out with CSS when content is in the input.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QZ8dT6iD9QNmbtBpzzPtwg.png" /><figcaption>Floating labels move out of the field on focus</figcaption></figure><p>Most designers would prefer a different approach that doesn&#39;t require a visual label and keeps the area clean and concise.</p><p>One of the 7 principles of Design is pattern: &quot;The human eye is naturally programmed to notice patterns.&quot; When speaking about search, it&#39;s undeniable that the search engines are the leaders of search patterns. It&#39;s their core business. Let&#39;s see what the big guys do:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e7I_ptGiQDoT4lqcPQAcgQ.png" /><figcaption>Duck Duck go search box</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g3bTscrIUO_OJAR5KmGp8Q.png" /><figcaption>Google search box</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tHWs08LAmcqzT7QIZcvDaQ.png" /><figcaption>Bing search box</figcaption></figure><p>None of these boxes (duckduckgo, google, bing) have a visible label (or placeholder). If we look implementations of eCommerce websites, typically they won&#39;t have a label either. Solution #1 — floating labels, is not the appropriate for this circumstance.</p><p><strong>Solution #3 — Use a label</strong></p><p>Using a explicit label will allow screen reader. If labels are visually hidden, confirm that placeholders have sufficient contrast.</p><p>If you want to use a &lt;label&gt;, element there are two recommended ways to go around it. Explicit and implicit labelling.</p><p><strong>Explicit labeling</strong></p><pre>&lt;label <strong>for=&quot;global-search&quot;</strong>&gt;<br>    Search for products<br>&lt;/label&gt;<br>&lt;input type=&quot;search&quot; <strong>id=&quot;global-search&quot;</strong> name=&quot;search&quot; placeholder=&quot;Search for products&quot;&gt;</pre><p>In explicit labelling the &lt;label&gt; element is sibling of &lt;input&gt;element and the attribute pair &quot;for&quot; / &quot;id&quot; is used to tie both elements.</p><p><strong>Implicit labeling</strong></p><pre>&lt;label <strong>for=&quot;global-search&quot;</strong>&gt;<br>    Search for products<br>    &lt;input type=&quot;search&quot; <strong>id=&quot;global-search&quot;</strong> name=&quot;search&quot; placeholder=&quot;Search for products&quot;&gt;<br>&lt;/label&gt;<br></pre><p>In the example above, omitting the for attribute on the label is still valid, but still best practice to include. By keeping the for attribute in place, both explicit and implicit techniques are being combined.</p><p>In both these scenarios, the label should be hidden for visually-abled users. The best way to do this is to use a utility class typically named sr-only or visually-hidden. SR stands for screen reader.</p><pre>.sr-only {<br>    border: 0;<br>    clip: rect(0 0 0 0);<br>    height: 1px;<br>    margin: -1px;<br>    overflow: hidden;<br>    padding: 0;<br>    position: absolute;<br>    width: 1px;<br>}</pre><p>This CSS allows element to be visually hidden, but announced by the Screen Readers. This utility class is most commonly used in other elements like “skip navigation”. This class should not be used for elements you actually want to hide from the users until activated like a modal or mobile menu.</p><p><strong>Solution #3 —Use a aria-label</strong></p><p>The most common practice nowadays is to use an aria-label attribute to describe the field, and for visually paired users the placeholder will give them a guidance.</p><pre>&lt;form&gt;<br>    &lt;input type=&quot;search&quot; aria-label=&quot;Search for products&quot; placeholder=&quot;Search for products&quot; /&gt;<br>&lt;/form&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*njkcYzCHA0laqcWh7uJqsQ.png" /><figcaption>A form using aria-label in the input element</figcaption></figure><p><strong>Note:</strong> this does not solves the issue that some screen readers will announce the <strong>label + placeholder</strong>.</p><p>Finally, some of the input attributes are specifically added for the autocomplete functionality that will be explained in more detail in the second part of this series: <strong>autocomoplete=&quot;off&quot;</strong> , <strong>autocorrect=&quot;off&quot;</strong> &amp; <strong>spellcheck=&quot;false&quot;</strong> If you&#39;re eager to know more <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input">check the input documentation at MDN</a>.</p><h3>Element 3: Button</h3><p>It&#39;s not required to have a button to operate a search form, especially if when having autocomplete, as it will be capturing the user key strokes using JavaScript and providing responses immediately. This JavaScript can add a listener for the keyENTERto trigger the search.</p><p>However it&#39;s a nice and recommended practice to allow users to operate the component in multiple ways or as they feel more comfortable. As I mentioned before there are well defined patterns for search, and they includes a search button to trigger the search.</p><p>The action of a form, event triggered when submitting the form, can be triggered by a <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button"><strong>&lt;button&gt;</strong></a>or <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/submit"><strong>&lt;input type=&quot;submit&quot;&gt;</strong></a>.</p><pre>&lt;input type=&quot;submit&quot; value=&quot;Search&quot; /&gt;</pre><p>If you want to create a custom button and then customize the behaviour using JavaScript, you need to use <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/button"><strong>&lt;input type=&quot;button&quot;&gt;</strong></a>, or better still, a <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button"><strong>&lt;button&gt;</strong></a> element.</p><p>If you choose to use <strong>&lt;button&gt;</strong> elements to create the buttons in your form, keep this in mind: if there&#39;s only one <strong>&lt;button&gt;</strong> inside the <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form"><strong>&lt;form&gt;</strong></a>, that button will be treated as the &quot;submit&quot; button. So you should be in the habit of expressly specifying which button is the submit button.</p><pre>&lt;button type=&quot;submit&quot;&gt;Search&lt;/button&gt;</pre><p>Both HTML elements are triggered clicking with a mouse or tapping with your fingers, and more so they can also be activated with your keyboard using ENTER or SPACE. I would encourage you to avoid using any other HTML for this purpose &lt;a&gt; ,&lt;div&gt; or &lt;span&gt; as none of these elements are intended to be used in a search box and they will require extra JavaScript &amp; CSS to emulate a button. I would recommend you reading my previous article &quot;<a href="https://hecosbornerod.medium.com/when-does-an-anchor-becomes-a-button-eca8ad5c522c">when does a button becomes an anchor</a>&quot; (never!)</p><p>Regardless of which element is used, the visual design requires that the button doesn&#39;t show any label. Actually it requires to show a magnifier icon only. Assuming we chose to use a &lt;button&gt; this is the code to show a magnifier icon using SVG.</p><pre>&lt;button type=&quot;submit&quot;&gt;<br>    &lt;svg&gt;<br>        &lt;use xlink:href=&quot;#icon-search&quot;&lt;/use&gt;<br>    &lt;/svg&gt;<br>&lt;/button&gt;</pre><p>This element in the accessibility tree, doesn&#39;t have a label, which again is a fail of (<a href="https://www.w3.org/WAI/WCAG21/Understanding/labels-or-instructions.html">WCAG 2.1 SC 3.3.2</a>).</p><p>This time we&#39;ll use aria-label to add a label description to the element. Most common names are &quot;search&quot;, &quot;go&quot;, &quot;submit&quot;. When using a Content Management System like Adobe Enterprise Manager, this label should be made authorable and mandatory.</p><pre>&lt;button type=&quot;submit&quot; <strong>aria-label=&quot;Search&quot;</strong>&gt;<br>    &lt;svg&gt;<br>        &lt;use xlink:href=&quot;#icon-search&quot;&lt;/use&gt;<br>    &lt;/svg&gt;<br>&lt;/button&gt;</pre><p>This leads me to the last element of the component.</p><h3>Element 4: SVG</h3><p>The best description to make an accessible SVG can be found in this article: <a href="https://css-tricks.com/accessible-svgs/">https://css-tricks.com/accessible-svgs/</a></p><p>Scalable Vector Graphics (SVG) are the preferred graphic format to use on the web today. Better than font images or using gif, png, jpgs.</p><p>I like to include the SVGs inline in the page template, as they have performance benefits. After they are declared you can add a reference to them by &lt;use xlink:href=&quot;#icon-search&quot;&gt;element inside the SVG.</p><p>To make them accessible we need to consider the following: <strong>&lt;svg&gt;</strong> elements inside focusable elements (like links or buttons) in Internet Explorer default to focusable=&quot;true&quot; due to a bug. This causes both the parent element and the &lt;svg&gt; to receive focus.</p><p>The focus indicator disappears when the image file receives focus, which is a problem for sighted keyboard-only users. Additionally, some screen readers read the content twice since parts of it get focus twice.</p><p>To avoid this problem add <strong>focusable=&quot;false&quot;</strong> to your SVG.</p><pre>&lt;svg focusable=”false”&gt;<br>    &lt;use xlink:href=”#icon-search”&gt;&lt;/use&gt;<br>&lt;/svg&gt;</pre><p><a href="https://github.com/svg/svgo/issues/1011">Read more about focusable=”false” discussion in this github page</a></p><h4>Possible enhancements</h4><p>The following features were intentionally left out of this component, although they can be added as progressive enhancements:</p><ul><li>Voice search</li><li>Show recently typed terms</li><li>Filter by categories</li></ul><h3>Auto Complete</h3><p>In the part 2 of this article I’ll be writing about the auto complete. Here&#39;s a preview of a basic autocomplete and a complex eCommerce specific autocomplete.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h4pOx5xtVwZLKP0-gVpdRw.png" /><figcaption>Autocomplete suggestions (Simple version)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q8UJy289chf5_Jf8o-VogA.png" /><figcaption>Autocomplete suggestions (complex version) Includes: top results, categories, recommended products &amp; see more results</figcaption></figure><h3>Summary &amp; Resources|</h3><ul><li>A search box is not a simple component. Even the core structure needs to be thought carefully.</li><li>Make a decision early if you rather use <strong>&lt;input type=&quot;text&quot;&gt;</strong> or <strong>&lt;input type=&quot;search&quot;&gt;</strong></li><li>Make a decision wether you prefer to use a <strong>&lt;button&gt;</strong> or <strong>&lt;input type=&quot;submit&quot; /&gt;</strong> for form submission</li><li>If <strong>&lt;button&gt;</strong> is provided for the magnifier icon, label the element using <strong>aria-label</strong></li><li>Make your SVG non-focusable to prevent IE issues.</li></ul><h4><strong>Resources</strong></h4><ul><li><a href="https://www.smashingmagazine.com/2018/06/placeholder-attribute/">Don&#39;t use placeholders</a> by Eric Bailey</li><li><a href="https://www.a11yproject.com/posts/2016-01-07-placeholder-input-elements/">How-to use placeholder attributes</a> by Rachel Vasquez</li><li><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input">Input element</a> by MDN</li><li><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form">Form element</a> by MDN</li><li><a href="https://www.w3.org/TR/wai-aria-practices-1.1/#aria_lh_search">WAI ARIA Practices</a></li><li><a href="https://caniuse.com/">http://canisue.com</a></li></ul><p>If you have questions or comments, leave me a comment or message me at <a href="https://twitter.com/HecOsborneRod">https://twitter.com/HecOsborneRod</a></p><p>If you want to know more about the motivation of this articles, don’t miss the first article of the series <a href="https://link.medium.com/0eGb64Iwhgb">eCommerce Accessibility</a></p><h3>Previous Articles</h3><ul><li><a href="https://hecosbornerod.medium.com/ecommerce-accessibility-a2abbca17b69">eCommerce Accessibility</a></li><li><a href="https://link.medium.com/BpXFLlWxhgb">The Product Detail Page</a></li><li><a href="https://hecosbornerod.medium.com/when-does-an-anchor-becomes-a-button-eca8ad5c522c">When does an anchor becomes a button</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c7e7f0e527a8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Product Detail Page (PDP) — eCommerce Accessibility]]></title>
            <link>https://hecosbornerod.medium.com/product-detail-page-pdp-ecommerce-accessibility-fb2bab9c2d4?source=rss-abfecb22164d------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb2bab9c2d4</guid>
            <category><![CDATA[accessibility]]></category>
            <category><![CDATA[ecommerce]]></category>
            <category><![CDATA[a11y]]></category>
            <dc:creator><![CDATA[Hector Osborne Rodriguez]]></dc:creator>
            <pubDate>Sat, 15 May 2021 01:37:21 GMT</pubDate>
            <atom:updated>2021-05-20T14:09:56.570Z</atom:updated>
            <content:encoded><![CDATA[<h3>Product Detail Page (PDP) — eCommerce Accessibility</h3><h4>One of the most important and detailed pages in eCommerce website.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UIy-kLtLQxGpwXkbJzfm7g.png" /><figcaption>Product Detail Page components by Yieldify</figcaption></figure><p>Any online buying online will tell you that it’s important to know everything there is to know about a product before purchasing it. And when you are running an eCommerce website, you want everything to be as easy as possible for your customers.</p><p>The page where you find the information of a product is called the Product Detail Page (PDP). But, what exactly is a product detail page, and what makes it effective? How can we break it into components?</p><p>The product detail page is a web page on an eCommerce website that provides information on a specific product. This information includes size, colour, price, shipping information, reviews, and other relevant information customers want to know before purchasing.</p><p>There are certain elements that must be designed in a product detail page to make it successful. Each one of these elements must be present on the PDP page, and the order and placement of these elements on the page can make differences in conversion.</p><p>I like the <a href="https://www.yieldify.com/blog/product-detail-page/">component breakdown created by Yieldify</a>: The must haves, the good to have and the fancy stuff.</p><h3>The must have</h3><ol><li>Menu / Navigation</li><li>Breadcrumbs</li><li>Product Name</li><li>Product Image / Image Viewer</li><li>Product Price</li><li>Variant Picker (colour / size)</li><li>Add to Cart (Trigger Modal?)</li><li>Product Details (Tab)</li><li>Footer (Shipping &amp; Returns)</li></ol><h3>The good to have</h3><ol><li>Banner / Show incentive</li><li>Wishlist</li><li>Reviews</li><li>Stock level indicator</li><li>Dynamic social proof.</li><li>Live chat</li><li>Customer Review (Lists)</li><li>Cross Sell / Up Sell (Carousel)</li><li>Newsletter subscription</li></ol><h3>Going beyond</h3><ol><li>360 degree viewer</li><li>Loyalty reward program</li><li>Social Media carousel (instagram)</li></ol><p>I&#39;ll start writing about these components and the unique requirements they have when in the eCommerce industry, although the majority of the advices can be applied to multiple websites.</p><p>If you have questions or comments, leave me a comment or message me at <a href="https://twitter.com/HecOsborneRod">https://twitter.com/HecOsborneRod</a></p><p>If you want to know more about the motivation of this articles, don’t miss the first article of the series <a href="https://link.medium.com/0eGb64Iwhgb">eCommerce Accessibility</a></p><h3>Next Articles</h3><ul><li><a href="https://hecosbornerod.medium.com/search-box-part-1-ecommerce-accessibility-c7e7f0e527a8">Accessible Search Box</a></li></ul><h3>Previous Articles</h3><ul><li><a href="https://hecosbornerod.medium.com/ecommerce-accessibility-a2abbca17b69">eCommerce Accessibility</a></li><li><a href="https://hecosbornerod.medium.com/when-does-an-anchor-becomes-a-button-eca8ad5c522c">When does an anchor becomes a button</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb2bab9c2d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[eCommerce Accessibility]]></title>
            <link>https://hecosbornerod.medium.com/ecommerce-accessibility-a2abbca17b69?source=rss-abfecb22164d------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2abbca17b69</guid>
            <category><![CDATA[ecomerce]]></category>
            <category><![CDATA[a11y]]></category>
            <category><![CDATA[accessibility]]></category>
            <dc:creator><![CDATA[Hector Osborne Rodriguez]]></dc:creator>
            <pubDate>Mon, 10 May 2021 01:27:46 GMT</pubDate>
            <atom:updated>2021-05-20T14:08:01.617Z</atom:updated>
            <content:encoded><![CDATA[<h4>A series of articles that will focus on the specific technical aspects of eCommerce accessibility</h4><figure><img alt="A person purchasing online using a Tablet" src="https://cdn-images-1.medium.com/max/1024/1*SBgUoswKuFxKPN_C9wsCLw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@brookelark">Brooke Lark</a></figcaption></figure><p>Accessibility in any context means access. Providing accessibility is the practice of ensuring there are no barriers that will stop anyone — regardless of disability or need — from accessing, interacting, using and benefiting from something.</p><p>COVID-19 has forced many businesses make digital transformations and move to a faceless operation. It might involve a new operational model or changes in the current operation like Curb Side Pickup.</p><p>Done properly this could be a great opportunity to reduce the access gap for many that require digital interactions to access information / products.</p><p>eCommerce allows products from every corner in the world to get to your door step even when we have been, one way or the other, forced to stay at home. From big food chains to small business owners have had the need to move to sell their products online.</p><p>Now consider he following scenarios: what if you were not able to operate (interact) with a website where you get your groceries? What if you can’t drive for In-Store Pickup? What if you arrive at the store and they asked you to call a phone number, but you&#39;re unable to? Couldn&#39;t they provide other means of communication (email, SMS)? What if you can’t open the package you received, say a box or plastic wrapping?</p><p>In our current times, where we are facing a world where external interaction is limited, it&#39;s extremely hard to ask for help to anyone outside of your &quot;bubble&quot;. If we don&#39;t consider solutions that can be accessed by anyone we&#39;re creating a barrier. eCommerce, like any other business should be thought from beginning to end. It&#39;s not only in the ordering process where barriers are being created, it&#39;s also in the supply chain and the post purchase customer interaction. This goes against Human Rights.</p><p>The aim of human rights law is to foster a society in which there are no impediments to the full and free participation of all people in the economic, social, political, and cultural life of our communities. This requires genuine inclusiveness on the part of businesses, employers, service providers, and others.</p><h3>Technical documentation</h3><p>Even when websites with more accessibility complains are in eCommerce, there&#39;s a lack of technical documentation on how to make them accessible. I&#39;m not referring to <a href="https://www.w3.org/TR/WCAG20/">WCAG</a> or <a href="https://www.w3.org/WAI/standards-guidelines/aria/">ARIA</a> detailed documentation, they are excellent sources of knowledge.</p><p>I&#39;m referring to the details anyone working in accessibility website should know. How should the &quot;Buy Now&quot; button be structured? how should products be listed in a product listing page ?what are the best practices for search boxes? should we use carousels? is quick view recommended? what at the considerations to create a colour picker?</p><p>Doing a quick search online for the term “eCommerce Accessibility” will return “Top 7 (or 10) common tips to make your website accesible”</p><p>Unfortunately they are not eCommerce specific, they can be applied to any website (blog, personal page, newspaper, etc.). There doesn’t seem to be detailed descriptions about the technical needs a eCommerce faces.</p><p>eCommerce Accessibility is no different than any other, but the beauty of eCommerce is that most websites (not to say all of them) are comprehended in a typical defined set of pages:</p><ul><li>Home</li><li>Product listing page</li><li>Product detail page</li><li>Shopping cart</li><li>Checkout</li><li>Order Summary</li></ul><p>These are the most common ones, there are other pages that constitute an eCommerce website like: store locator, store detail page, order review, login, my account, content pages, and many more.</p><p>Each one has unique content, components and specific accessibility needs.</p><h3>Closing the gap</h3><p>I don’t claim to be the absolute expert in the matter, but I have learned a few things during my road in Accessibility. I have set a personal goal to write a series of articles that will focus on the specific technical aspects of eCommerce accessibility. To help close the lack of technical documentation and share my findings and passion in the topic.</p><p>The intended audience for this series of articles are: developers, designers, testers and anyone with interested in accessibility.</p><p>Feel free to drop me a message in the comments or reach out to me in Twitter <a href="https://twitter.com/HecOsborneRod">https://twitter.com/HecOsborneRod</a></p><h3>Next Articles</h3><ul><li><a href="https://link.medium.com/BpXFLlWxhgb">The Product Detail Page</a></li><li><a href="https://hecosbornerod.medium.com/search-box-part-1-ecommerce-accessibility-c7e7f0e527a8">Accessible Search Box</a></li></ul><h3>Previous Articles</h3><ul><li><a href="https://hecosbornerod.medium.com/when-does-an-anchor-becomes-a-button-eca8ad5c522c">When does an anchor becomes a button</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2abbca17b69" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When does an anchor becomes a button?]]></title>
            <link>https://hecosbornerod.medium.com/when-does-an-anchor-becomes-a-button-eca8ad5c522c?source=rss-abfecb22164d------2</link>
            <guid isPermaLink="false">https://medium.com/p/eca8ad5c522c</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[a11y]]></category>
            <category><![CDATA[button]]></category>
            <category><![CDATA[anchor]]></category>
            <category><![CDATA[accessibility]]></category>
            <dc:creator><![CDATA[Hector Osborne Rodriguez]]></dc:creator>
            <pubDate>Thu, 29 Nov 2018 23:50:15 GMT</pubDate>
            <atom:updated>2021-05-20T14:08:47.320Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*G9VCXI0u6KMrvErO" /><figcaption>Photo by <a href="https://unsplash.com/@rawpixel?utm_source=medium&amp;utm_medium=referral">rawpixel</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>A detailed description on how to convert an anchor into a button.</h4><p>During my latest project implementation, the front end team grew from two developers to ten in less than a year. As the team grew, many new members faced the same problem over and over again: when trying to develop interaction, some of them used <strong>&lt;button&gt;</strong> and some used <strong>&lt;a&gt;</strong>.</p><p>With some CSS &amp; JS, any developer is capable of styling an element to look like a button. A<strong>&lt;div&gt;</strong> or a <strong>&lt;span&gt;</strong> can be used, but the most common approach is to use the<strong> </strong><strong>&lt;a&gt; </strong>element. It&#39;s focusable and clickable, so it seems like the best choice for any of these instances.</p><p>Within our team, anchors became the norm for icon buttons, tab sets, and other interactive elements that do an action without leaving the page. This included actions such as play video, close model, open menu, back to start, close menu, and load more articles; the choice was left to the developer’s preference. However, there is a lot to consider before you can say an anchor is a button (and maybe it will never be one, but sometimes it gets close).</p><p>In this article, we will take a journey through properly creating a button out of an anchor element, including all the implications and code required. If you want to skip all the technical gibberish and just read a to-do list, <a href="#34c3">skip to the summary</a>.</p><h4>Hypothesis</h4><p>As an example, let’s pretend we want to create a button that has the following high level requirements:</p><ul><li>The button should be black in its default state.</li><li>The button should be grey on <strong>:hover</strong>.</li><li>The button should provide a warning in the console when clicked.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vVolZMOI_6VmSnSvbW8bqw.png" /><figcaption>Default button: black background, white font. Hover button: grey background, black text.</figcaption></figure><h3><strong>Basic Code</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*59XvPGIC7N5-ze1Shy4Alw.png" /><figcaption>Chrome&#39;s user agent gives blue colour and underline style to a default anchor</figcaption></figure><pre>&lt;a href=&quot;http://www.medium.com&quot;&gt;<br>  I&#39;ll be button<br>&lt;/a&gt;</pre><p><a href="http://jsfiddle.net/madebyhector/w3cybqnt/">Try this code in JSFiddle</a></p><h3>1. Pseudo class :visited</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rJbFMByz_ac-vAPn8SmGhA.png" /><figcaption>Chrome: user agent styling for a :visited anchor is purple font</figcaption></figure><p>The first difference between an anchor and a button has to do with visited links. When using anchors, the browser&#39;s user agent applies purple font styling to any link that the user has already visited. It&#39;s important to note that the styles defined by the <strong>:visited </strong>pseudo-class will be overridden by any subsequent link-related pseudo-class ( <strong>:link</strong> ,<strong>:hover</strong>, <strong>:active</strong>) that has at least equal specificity.</p><p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:visited">Read the :visited definition by MDN</a></p><h3>2. Styling :hover</h3><p>To start this transformation let&#39;s add all the styling required to make this anchor look like a button. Add button styling, remove the underline decoration and overwrite the link <strong>:visited </strong>pseudo-class using the<strong>:hover</strong> selector.</p><pre>a {<br>    display: inline-block;<br>    background: #000;<br>    color: #FFF;<br>    border: 0;<br>    border-radius: 4px;<br>    text-align: center;<br>    padding: 20px 30px;<br>    line-height: 1;<br><strong>    text-decoration: none;</strong></pre><pre><strong>}</strong></pre><pre><strong>a:hover {<br> </strong> background: #DDD;<br>  color: #000;<strong><br></strong>}</pre><p>The button is looking better now:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vGtVBaJ_LnhgtGhymrlXrg.png" /><figcaption>Anchor has a black background with white font on default state, and grey background with black font on hover</figcaption></figure><p><a href="http://jsfiddle.net/madebyhector/Ljcounze/">Try this code in JsFiddle</a></p><p>Be wary, if the anchor doesn&#39;t have the <strong>href</strong> attribute, the cursor is changed from a pointer to a text select when you move your mouse slowly over the text. This might not seem much, but it&#39;s on the small details that we want to fix.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rn31_SB4RxGK0qQ3eeRTmQ.png" /><figcaption>Cursor changes to text selector on hover</figcaption></figure><p>Let&#39;s fix this with one CSS line:</p><pre>a {<br>    display: inline-block;<br>    background: #000;<br>    color: #FFF;<br>    border: 0;<br>    border-radius: 4px;<br>    text-align: center;<br>    padding: 20px 30px;<br>    line-height: 1;<br>    text-decoration: none;</pre><pre>    <strong>/* Make the cursor be an arrow on hover */<br>    cursor: default;</strong><br>}</pre><p><a href="http://jsfiddle.net/madebyhector/ynLaj9e7/">Try this code in JSFiddle</a></p><h3>3. Keyboard Focus</h3><p>It’s important to know that an anchor element is only keyboard accessible when it has a non-empty<strong>href</strong> attribute, most importantly you should know that an anchor is not focusable when it just have the <strong>name </strong>attribute.</p><pre>&lt;a href=&#39;#&#39;&gt;I am focusable&lt;/a&gt;<br>&lt;a name=&#39;test&#39;&gt;I am not&lt;/a&gt;<br>&lt;a&gt;I can&#39;t be focused either&lt;/a&gt;</pre><p><a href="http://jsfiddle.net/madebyhector/sphoL6vr/">Test this code in JsFiddle.net</a></p><p>Rian Rietveld writes the following:</p><h3>Rian Rietveld on Twitter</h3><p>Dear devs, please repeat after me: An &amp;lt;a&amp;gt; element is only keyboard accessible when it has a non-empty href attribute. &amp;lt;a&amp;gt; and &amp;lt;a href=&quot;&quot;&amp;gt; should not be used for links. Also: for actions there&#39;s this nice useful element called &amp;lt;button&amp;gt; See: https://t.co/Yh97Yo3Bwk</p><p>To be selectable, with keyboard (<strong>TAB</strong> or <strong>SHIFT + TAB</strong>), an empty anchor requires the attribute <strong>tabindex=&quot;0&quot;</strong>. Never set the index higher than 0, it messes up with the tab ordering on the screen.</p><pre>&lt;a tabindex=&#39;0&#39;&gt;I’m not a button, but I&#39;m focusable&lt;/a&gt;<br>&lt;a&gt;I can&#39;t be focused&lt;/a&gt;</pre><p><a href="http://jsfiddle.net/madebyhector/mf3bc5vh/5/">Test this code in JsFiddle.net</a></p><p>Did you noticed there&#39;s a focus ring around the elements when using the <strong>TAB</strong> key? It&#39;s added to indicate the keyboard users (or any super user) what current element has the focus on the page.</p><p>Please do not remove this. The use of <strong>outline:0</strong> or <strong>outline:none</strong> has a major effect upon all keyboard only users regardless of visual impairment. Removing outlines in CSS creates issues for people navigating the web with a keyboard, as stated in all these articles:</p><ul><li><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/outline#Accessibility_concerns">https://developer.mozilla.org/en-US/docs/Web/CSS/outline#Accessibility_concerns</a></li><li><a href="https://a11yproject.com/posts/never-remove-css-outlines/">https://a11yproject.com/posts/never-remove-css-outlines/</a></li><li><a href="http://www.outlinenone.com/">http://www.outlinenone.com/</a></li><li><a href="https://webaim.org/blog/plague-of-outline-0/">https://webaim.org/blog/plague-of-outline-0/</a></li></ul><h3>5. Focus ring on click</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TN05pmemjIWwxK0AikznWw.jpeg" /><figcaption>Button&#39;s are automatically focused on click showing the :focus ring</figcaption></figure><p>Another styling difference, introduced by some browsers, comes after a button is clicked. The focus will automatically be set to this element after the mouse is released. And the outline default styling is added.</p><p>This is one of the main reasons why some developers use <strong>outline:none </strong>or choose <strong>&lt;a&gt;</strong> over <strong>&lt;button&gt;,</strong> and after you use it once, it just becomes a habit. Maybe the design team didn&#39;t account for this. It could be that they are not aware. Maybe we need to communicate this information to our designers &amp; clients to make them aware that this could (and will) happen.</p><p>The complexity involved in trying to determine if the element was selected via keyboard or after a click has been described in an article by David Gilbertson; <a href="https://hackernoon.com/removing-that-ugly-focus-ring-and-keeping-it-too-6c8727fefcd2">how to remove that ugly :focus ring (and keeping it too)</a>, he provides detailed code and instructions.</p><p>Another solution to this “problem” is presented by José Perez on his article <a href="https://jmperezperez.com/outline-focus-ring-a11y/">Hiding the outline or :focus ring in an accessible way</a></p><p>There is a pseudo selector :focus-ring coming up for this use case <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-visible">https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-visible</a>. However until it&#39;s supported by all the browsers, we&#39;re stuck with CSS &amp; Javascript solutions.</p><p>There&#39;s no perfect solution for this problem yet. Do a quick search for <strong><em>suppressing focus outlines</em></strong> or head over to stackoverflow and you&#39;ll see the amount of answers that prescribe the usage of <strong>* { outline:none }</strong>.</p><p>Maybe it’s our fault for not having found a design pattern for this specific event. But it’s something that we need to solve as a community, we need to keep the focus ring while not messing up with the beautiful design.</p><h3>6. Keyboard Interaction</h3><p>Button and anchor have automatic interaction with input devices (keyboard, mouse, touchpad, or switches). For instance, a button is clickable by default, so is an anchor. However a <strong>&lt;div&gt;</strong>or a <strong>&lt;span&gt;</strong> do not have any. To simulate a button, Javascript listeners will have to be added to listen to click events and keyboard events.</p><p>When it comes to keyboard interaction, the <strong>&lt;button&gt;</strong>element is triggered with both <strong>ENTER</strong> and <strong>SPACE </strong>key<strong>, </strong>the anchor element <strong>&lt;a&gt;</strong>is only triggered with the <strong>ENTER</strong> key.</p><p>To make an anchor behave like a button, you&#39;ll need to extend your javascript code and add a listener to the <strong>SPACE</strong> key.</p><p>Adrian Roselli’s wrote about this:</p><h3>Adrian Roselli 🗯 on Twitter</h3><p>4/3] &amp;lt;a href&amp;gt; can be fired by pressing the enter key. &amp;lt;button&amp;gt; can be fired by pressing the enter key or the space bar. #HTML #a11y</p><p>So to continue with our example, let&#39;s add a selectable an id to the anchor element. (Using id is not ideal for this scenario, but this is just a quick tutorial)</p><h4><strong>HTML</strong></h4><pre>&lt;a class=&quot;anchor-btn&quot; href=&quot;#&quot;&gt;I’ll be a button&lt;/a&gt;</pre><h4>Javascript</h4><pre>(function() { <br>  const KEY_SPACE = 32,<br>        KEY_ENTER = 13;</pre><pre>var fakeButtons = document.querySelectorAll(&#39;.anchor-btn&#39;);</pre><pre>// write message in the console<br>  function doAction() {<br>    console.warn(&#39;somebody hit the button&#39;);<br>  }</pre><pre>// Handle Click Events<br>  function handleClick(e) {<br>      // because we&#39;re actually not going outside of this URL<br>      e.preventDefault();<br>      doAction();<br>  }</pre><pre>// Handle Keyboard Events<br>  function handleKeyboard(e) {<br>      switch(e.keyCode) {<br>          // Listen to Space<br>          case KEY_ENTER:<br>              console.warn(&#39;the anchor has been activated with ENTER key&#39;);<br>              doAction();<br>          break;<br>          case KEY_SPACE:<br>              console.warn(&#39;the anchor has been activated with SPACE key&#39;);<br>              doAction();<br>          break;<br>          default:<br>              console.warn(&#39;An unexpected key was used to activate this element, Keycode:&#39;, e.keyCode);<br>          break;<br>      }<br>  }</pre><pre>/**<br>       * Attach Events to elements<br>       * <a href="http://twitter.com/param">@param</a> {DOM} elem - Dom element<br>       * <a href="http://twitter.com/param">@param</a> {string|Array} event - Event or events to attach<br>       * <a href="http://twitter.com/param">@param</a> {function} fn - Function to execute<br>       * <a href="http://twitter.com/returns">@returns</a> {void}<br>       */<br>  function attachEvents(elem, event, fn) {<br>    if ((event &amp;&amp; (typeof event === &#39;string&#39; || typeof event === &#39;object&#39;)) &amp;&amp; (elem) &amp;&amp; (fn &amp;&amp; typeof fn === &#39;function&#39;)) {<br>      if (typeof event === &#39;string&#39;) {<br>        if (NodeList.prototype.isPrototypeOf(elem)) {<br>          elem.forEach(function (el) {<br>            el.addEventListener(event, fn, false);<br>          });<br>        } else {<br>          elem.addEventListener(event, fn, false);<br>        }<br>      } else {<br>        event.forEach(function (ev) {<br>          if (NodeList.prototype.isPrototypeOf(elem) &amp;&amp; typeof ev === &#39;string&#39;) {<br>            elem.forEach(function (el) {<br>              el.addEventListener(ev, fn, false);<br>            });<br>          } else if (typeof ev === &#39;string&#39;) {<br>            elem.addEventListener(ev, fn, false);<br>          }<br>        });<br>      }<br>    }<br>  }</pre><pre>// Add Event Listeners<br>  attachEvents(fakeButtons, &#39;click&#39;, handleClick);<br>  attachEvents(fakeButtons, &#39;keyup&#39;, handleKeyboard);<br>})();</pre><p>Again another interesting tweet by Adrian:</p><h3>Adrian Roselli 🗯 on Twitter</h3><p>5/3] Events triggered by space bar fire when key is released. Using Enter key will fire event as soon as you push key down. #HTML #a11y</p><p>I like using the keyup event, instead of the keydown, I don’t want to activate the anchor too early. I don’t want to continue triggering the event if the user keeps the key pressed. We could be forgiving and allow the user to move the mouse out of the element before the key is released (not a common case, but it’s nice to provide)</p><h3>7 . Role=button</h3><p>Even with all this code, our<strong>&lt;a&gt; </strong>is not a <strong>&lt;button&gt;</strong> yet. Screen readers will still announce this element as a visited link.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dKUt1aBmqKEjI7obfxSITA.jpeg" /><figcaption>Voice over announcement: visited, link, I&#39;ll be a button</figcaption></figure><p>To make it button, it requires the aria <strong>role=&quot;button&quot;</strong>.</p><p>When the button role is used, screen readers announce the element as a button, generally announcing “<strong>click</strong>” followed by the button’s accessible name. The accessible name is either the content of the element or the value of an aria label or description, if included.</p><pre>&lt;a class=&#39;anchor-btn&#39; href=&quot;http://www.medium.com&quot; role=&#39;button&#39;&gt;I’ll be a button&lt;/a&gt;</pre><pre>&lt;a class=&#39;anchor-btn&#39; tabindex=&#39;0&#39; role=&#39;button&#39; &gt;I’ll be a button&lt;/a&gt;</pre><p>Interesting fact about roles and types. A button element is by default of <strong>type=&quot;submit&quot;</strong>. When used inside a form it will execute the specified submit form action; outside of a form, it won&#39;t do anything. That&#39;s why it’s highly recommended to specify the attribute<strong> </strong><strong>type=&quot;button&quot;</strong></p><p>&lt;button type=&quot;button&quot;&gt;I&#39;m outside a form&lt;/button&gt;</p><p>The button won&#39;t do anything unless listeners are specified for click or keyboard events or by a attribute function <strong>onclick=&quot;myFunction()&quot;</strong>.</p><h3>8. One more thing</h3><p>As pointed out by <a href="https://medium.com/u/77f20bbfd035">MarcelloP</a> in the comments, this is known as an anti-pattern. As you can see from this post, trying to disguise an <strong>&lt;a&gt;</strong> as a <strong>&lt;button&gt;</strong>, is really complex to implement.</p><blockquote>If its navigating it can be an <strong>&lt;a&gt;</strong>, otherwise its a <strong>&lt;button&gt;</strong></blockquote><p>An <strong>&lt;a&gt; </strong>will never be a <strong>&lt;button&gt;</strong>. Skip all this trouble and use a button.</p><h3>Summary</h3><ol><li>Anchor provides the pseudo-class <strong>:visited</strong>. Overwrite it&#39;s style using <strong>:hover</strong></li><li>An anchor changes the cursor to text editor on hover. Change the CSS to <strong>cursor:default</strong></li><li>An anchor is underlined by default. Change the CSS to <strong>text-decoration: none</strong></li><li>An anchor is not focusable when it doesn&#39;t have the attribute <strong>href</strong> or when it has the attribute <strong>name</strong></li><li>In some browsers, a button will retain the focus and show the :focus ring after click, an anchor won&#39;t.</li><li>A button can be triggered with <strong>ENTER</strong> &amp; <strong>SPACE</strong> key, an anchor is only triggered with <strong>ENTER</strong> key.</li><li>Anchors are not announced the same way by screen readers. Use the <strong>role=&quot;button&quot;</strong> attribute to change how the element is announced.</li><li>Skip all this and use a button</li></ol><p><a href="http://jsfiddle.net/madebyhector/mscfeo65/50/">Test the final code in this JsFiddle.net</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kVBGhiXmcDHOBrLi" /><figcaption>Photo by <a href="https://unsplash.com/@lemonzandtea?utm_source=medium&amp;utm_medium=referral">Aleksandar Cvetanovic</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Conclusion &amp; Resources</h3><p>Mozilla Developer’s Network gives a clear definition for anchor and button.</p><blockquote><strong>The HTML </strong><strong><em>&lt;a&gt;</em> element (or <em>anchor</em> element) creates a hyperlink to other web pages, files, locations within the same page, email addresses, or any other URL.</strong></blockquote><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a">Anchor definition by MDN web docs</a></p><blockquote>The <strong>HTML </strong><strong><em>&lt;button&gt;</em> element</strong> represents a clickable button, which can be used in forms or anywhere in a document that needs simple, standard button functionality.</blockquote><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button">Button definition by MDN web docs</a></p><p>When should we use a button or an anchor?. If if it is navigation it could be an anchor, otherwise it should be a button.</p><p>There are many nuances that need to be done in order for an <strong>&lt;a&gt;</strong>, <strong>&lt;div&gt; </strong>or a <strong>&lt;span&gt; </strong>to become a <strong>&lt;button&gt;</strong>. It’s highly complicated an many things can go wrong. It&#39;s also know as an anti-pattern.</p><p>If you still don&#39;t trust me, because let&#39;s face it how am I, Here are some helpful resources:</p><ul><li><a href="https://www.w3.org/TR/wai-aria-practices-1.1/#button">WAI-ARIA button design pattern</a></li><li><a href="https://twitter.com/RianRietveld/status/1064514001814597633">https://twitter.com/RianRietveld/status/1064514001814597633</a> | Rian Rietveld</li><li><a href="https://marcysutton.com/links-vs-buttons-in-modern-web-applications/">Links vs. Buttons in Modern Web Applications</a> | Marcy Sutton</li><li><a href="https://davidwalsh.name/html5-buttons">The Difference Between Anchors, Inputs and Buttons</a> | David Walsh</li><li><a href="https://twitter.com/aardrian/status/734794157143785475">Some general tips on when to use an &lt;a href&gt; versus a &lt;button&gt; or &lt;input type=”submit”&gt;</a> | Adrian Roselli</li></ul><blockquote><strong>Thank you so much for taking the time to read this article :). I&#39;ll be writing more about my findings in #a11y, so feel free to follow for more.</strong></blockquote><blockquote><strong>Happy coding!</strong></blockquote><blockquote><strong>-Hector</strong></blockquote><h3>Next Articles</h3><ul><li><a href="https://hecosbornerod.medium.com/ecommerce-accessibility-a2abbca17b69">eCommerce Accessibility</a></li><li><a href="https://link.medium.com/BpXFLlWxhgb">The Product Detail Page</a></li><li><a href="https://hecosbornerod.medium.com/search-box-part-1-ecommerce-accessibility-c7e7f0e527a8">Accessible Search Box</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eca8ad5c522c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>