<?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" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ a11y - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ a11y - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Mon, 18 May 2026 10:47:43 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/a11y/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ Everything You Need to Know About Web Accessibility ]]>
                </title>
                <description>
                    <![CDATA[ The web is a great place to access information and connect with people. It has opened up countless opportunities, making life more convenient in many ways. But not everyone experiences the web in the same way. Websites are difficult to use for people... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/the-web-accessibility-handbook/</link>
                <guid isPermaLink="false">67d9aa58a50edbbdc70e2941</guid>
                
                    <category>
                        <![CDATA[ Accessibility ]]>
                    </category>
                
                    <category>
                        <![CDATA[ a11y ]]>
                    </category>
                
                    <category>
                        <![CDATA[ handbook ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Development ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Design ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Kunal Nalawade ]]>
                </dc:creator>
                <pubDate>Tue, 18 Mar 2025 17:16:08 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1742318086251/103cec5f-3330-4559-8554-4ec76b16ec76.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>The web is a great place to access information and connect with people. It has opened up countless opportunities, making life more convenient in many ways.</p>
<p>But not everyone experiences the web in the same way. Websites are difficult to use for people who have visual, hearing, or mobility impairments. These barriers make it harder to navigate content, and in some cases, make the web completely inaccessible.</p>
<p>This handbook will help you understand accessibility and how to implement it. Whether you are a beginner or an intermediate developer, you'll learn basic accessibility practices and some advanced techniques. This will help you make your website more inclusive.</p>
<p>Let’s get started.</p>
<h2 id="heading-table-of-contents">Table of Contents</h2>
<ul>
<li><p><a class="post-section-overview" href="#heading-what-is-accessibility">What is Accessibility?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-basic-accessibility-practices">Basic Accessibility Practices</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-semantic-and-non-semantic-html">Semantic and Non-Semantic HTML</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-text-content">Text Content</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-page-layouts">Page Layouts</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-interactive-elements">Interactive Elements</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-keyboard-accessibility">Keyboard Accessibility</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-form-labels">Form Labels</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-links">Links</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-table-accessibility">Table Accessibility</a></p>
</li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-additional-css-and-javascript-practices">Additional CSS and JavaScript Practices</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-styling-form-elements">Styling Form Elements</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-color-contrast">Color Contrast</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-javascript-practices">JavaScript Practices</a></p>
</li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-advanced-accessibility-practices-wai-aria">Advanced Accessibility Practices: WAI-ARIA</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-the-role-attribute">The role attribute</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-aria--attribute">aria-* attribute</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-dynamic-content-attributes">Dynamic Content Attributes</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-form-validation-and-errors">Form Validation and Errors</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-using-non-semantic-elements-as-buttons">Using non-semantic elements as buttons</a></p>
</li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-multimedia-accessibility">Multimedia Accessibility</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-mobile-accessibility">Mobile Accessibility</a></p>
</li>
</ul>
<h2 id="heading-what-is-accessibility">What is Accessibility?</h2>
<p>Accessibility (A11y) is an important practice in web development that aims to make the website usable (accessible) for all people. This includes people who have disabilities that make it difficult for them to use websites. By making a website accessible to everyone, including people with disabilities, we ensure that they have the same opportunities as we do. We’re also helping to make the web a more inclusive place overall.</p>
<p>What kind of disabilities should we consider? In broad terms:</p>
<ul>
<li><p>Visual impairments: blindness, blurred vision, and colour blindness</p>
</li>
<li><p>Hearing impairments: low to no hearing</p>
</li>
<li><p>Mobility Impairments: difficulty with physical movement(s)</p>
</li>
<li><p>Cognitive Impairments: like Dyslexia and ADHD</p>
</li>
</ul>
<p>People with visual impairments commonly use devices like <a target="_blank" href="https://axesslab.com/what-is-a-screen-reader/">screen readers</a> to visualise and understand a website’s content, for example. So a big part of web accessibility is designing a website that can be easily accessed by a screen reader.</p>
<p>There are various practices that you, as a developer, can follow to make a website accessible, which I’ll cover in this handbook.</p>
<h2 id="heading-basic-accessibility-practices">Basic Accessibility Practices</h2>
<p>Accessibility is not just an added feature on top of a website you’ve already developed. It is a practice that needs to be followed throughout the development process. Whenever you are creating content on the web page, ask yourself if it is really accessible.</p>
<p>Another important point is that accessibility is not just for people with impairments. It benefits everybody by making a website easier to use, thus improving overall user experience.</p>
<p>How do you achieve good accessibility? Well, there are some practices that you should follow while writing HTML, CSS, and JavaScript code. We’ll discuss some basic practices in this section.</p>
<p>Before we get into it, let’s start by understanding what semantic and non-semantic HTML tags are:</p>
<h3 id="heading-semantic-and-non-semantic-html">Semantic and Non-semantic HTML</h3>
<p>Non-semantic HTML tags do not convey specific meaning or purpose. They can be used for anything, depending on the CSS styling and JavaScript functionality. Examples of non-semantic tags are: <code>&lt;div&gt;</code> and <code>&lt;span&gt;</code>. These tags are mostly used as containers for wrapping other elements.</p>
<p>Semantic HTML tags clearly describe their purpose to the browser and the developers through their names. They improve code readability and also help with <a target="_blank" href="https://seo.co/semantic-html/">SEO (Search Engine Optimisation)</a>. Examples of semantic tags include: <code>&lt;button&gt;</code>, <code>&lt;a&gt;</code>, <code>&lt;header&gt;</code>, <code>&lt;footer&gt;</code>.</p>
<p>You can find a list of all semantic elements <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Glossary/Semantics#semantic_elements">here</a>.</p>
<h4 id="heading-importance-of-using-semantic-html">Importance of using semantic HTML</h4>
<p>An essential part of accessibility is using the correct HTML element for its intended purpose. This means, for example, using a <code>&lt;button&gt;</code> tag when you want to render a button.</p>
<p>But why use semantic elements? After all, you can use CSS to make a <code>&lt;div&gt;</code> look like a button. True, but using semantic elements is important for the following reasons:</p>
<ul>
<li><p>Semantic elements have built-in styles and functionality that you otherwise would need to add through CSS and JavaScript. This makes them easier to use.</p>
</li>
<li><p>They make the code easier to read and maintain, as you can actually see the elements being used rather than seeing a bunch of divs everywhere.</p>
</li>
<li><p>Screen readers can easily read and interpret semantic elements, helping people with visual impairments.</p>
</li>
</ul>
<p>In the following sections, we’ll understand basic accessibility practices for each type of content you render on HTML. We'll explore how to use the correct HTML tags for each situation, helping you see how choosing the right tag for its purpose improves accessibility.</p>
<p>Feel free to test each example with a screen reader. On Mac, use ⌘+F5 to activate VoiceOver, Mac’s built-in screen reader. For Windows, you can use the built-in screen reader called Narrator by pressing Ctrl + Windows Key + Enter.</p>
<h3 id="heading-text-content">Text Content</h3>
<p>When writing text content, it’s important to use the correct elements for headings, paragraphs, and lists. Let’s understand with the following examples.</p>
<p>Let’s say you write headings and paragraphs in the following way:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">span</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"heading1"</span>&gt;</span>Heading 1<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">br</span> /&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">br</span> /&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">span</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"heading2"</span>&gt;</span>Heading 2<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">br</span> /&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">br</span> /&gt;</span>
This is one paragraph
<span class="hljs-tag">&lt;<span class="hljs-name">br</span> /&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">br</span> /&gt;</span>
This is another paragraph
</code></pre>
<p>This approach has the following problems:</p>
<ul>
<li><p>The screen reader won’t be able to distinguish between headings and paragraphs – it would just read out the contents in one go, thus confusing people who depend on screen readers.</p>
</li>
<li><p>It’s difficult to style individual paragraphs, since there are no selectors. Even if you add a <code>&lt;span&gt;</code> to each one, it requires extra CSS styling.</p>
</li>
<li><p>It also contains unnecessary line breaks which can be avoided by using the right elements.</p>
</li>
</ul>
<p>The above code is an example of bad semantics. This is what you should do instead:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>Heading 1<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>Heading 2<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>This is one paragraph<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>This is another paragraph<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
</code></pre>
<p>Here, we have used the right semantic elements for the text content, which has the following benefits:</p>
<ul>
<li><p>A screen reader is able to distinguish the headings from the paragraph text by reading out the heading level before reading the text.</p>
</li>
<li><p><code>h1</code>, <code>h2</code>, and <code>p</code> come with built-in styles and they each render on a new line. This eliminates the need to use line breaks.</p>
</li>
<li><p>The code looks cleaner and is much more readable.</p>
</li>
</ul>
<h4 id="heading-lists">Lists</h4>
<p>To render a list of items, we have the following approaches. The non-semantic approach just groups a bunch of divs together and applies CSS styles to them.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>TODO List<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"mylist"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>Make Breakfast<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>Do Laundry<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>Complete blog post<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>Again, this achieves the desired output but it’s difficult for screen readers to identify this content as a list of items. Instead, use semantic elements:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>TODO List<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">ul</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"mylist"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>Make Breakfast<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>Do Laundry<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>Complete blog post<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span>
</code></pre>
<p>This helps screen readers identify the element as an unordered list and read out each item. <code>&lt;ul&gt;</code> also comes with default styles and bullet points for each list item. You can also use <code>&lt;ol/&gt;</code> for numbered lists, where the screen reader reads out the number on each list item.</p>
<p>You can test the above examples with Mac’s VoiceOver to see the difference.</p>
<h4 id="heading-emphasized-text">Emphasized Text</h4>
<p>Emphasized text refers to highlighted text that gives importance to certain words or phrases within a piece of content. When adding emphasized text, it’s important to use the right semantic elements like <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/strong"><code>&lt;strong&gt;</code></a> and <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/em"><code>&lt;em&gt;</code></a>.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>For best results, use <span class="hljs-tag">&lt;<span class="hljs-name">em</span>&gt;</span>fresh ingredients<span class="hljs-tag">&lt;/<span class="hljs-name">em</span>&gt;</span> when cooking.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>The process of water turning into gas is called <span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span>evaporation<span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span>.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
</code></pre>
<p>These elements add some built-in styles to the text like <em>bold</em> and <em>italic</em>. Also, if you test with VoiceOver, you’ll notice that it puts some emphasis on the text inside these elements. This helps people using screen readers identify emphasised text.</p>
<p>You may also add some colour to the emphasized text. But, there’s no need to add a lot of styles, else it may cause confusion. Visit <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Structuring_content/Emphasis_and_importance">MDN Docs-Emphasis and Importance</a> to learn more about text emphasis in HTML.</p>
<h4 id="heading-abbreviations">Abbreviations</h4>
<p>Next, when writing abbreviations (or acronyms), it’s a good practice to make them visually different and also include the full expansion of the acronym. You can also add some simple styling to the abbreviation. Learn more about abbreviations in <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Structuring_content/Advanced_text_features#abbreviations">MDN Docs-Abbreviations</a>.</p>
<h4 id="heading-other-best-practices">Other best practices</h4>
<p>Apart from the above, there are a few other practices that are good to follow:</p>
<ul>
<li><p>Use clear language, wherever possible. For example, expand abbreviations: instead of Jan, write January.</p>
</li>
<li><p>When writing ranges, avoid using dashes if possible, write 1 to 5 instead of 1-5.</p>
</li>
<li><p>Avoid using characters that may confuse users when a screen reader reads them out, for example <code>~</code> or <code>*</code>.</p>
</li>
<li><p>Avoid excessive exclamations and emojis.</p>
</li>
</ul>
<p>Also, when writing CSS for text content, remember these practices:</p>
<ul>
<li><p>When using styles like font sizes, line height, and letter spacing, ensure that the text is comfortable to read.</p>
</li>
<li><p>Your headings should stand out from the other text, in case you are using CSS styles. Usually, this is achieved by just using the right heading tags.</p>
</li>
<li><p>Text color should have 4.5:1 contrast with the background. See the <a class="post-section-overview" href="#heading-color-contrast">Color Contrast</a> section for details.</p>
</li>
</ul>
<p>If you want more tips on styling text, visit <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Text_styling">MDN Docs - CSS Text Styling</a>.</p>
<h3 id="heading-page-layouts">Page Layouts</h3>
<p>Page layout is concerned with how the content is laid out on the screen. When you start designing a web page, your first thought is how your content should be positioned on the screen.</p>
<p>Typically, a web page consists of a header, nav bar, footer, main content, and sidebar. In the <em>bad old days</em> (phrase borrowed from the docs, sorry), developers used tables to create page layouts consisting of these elements.</p>
<p>But tables made the layouts incredibly complex and hard to maintain. Table layouts are also difficult for screen readers to read, affecting accessibility.</p>
<p>Nowadays, there are much better ways to write page layouts. If you are including a header, nav bar, and footer along with the main content, you can use the following semantic elements:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">header</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>Header<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">nav</span>&gt;</span>
    <span class="hljs-comment">&lt;!-- main navigation in here --&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">nav</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">header</span>&gt;</span>

<span class="hljs-comment">&lt;!-- Here is our page's main content --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">main</span>&gt;</span>
  <span class="hljs-comment">&lt;!-- Main content here --&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">main</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">footer</span>&gt;</span>
  <span class="hljs-comment">&lt;!-- footer content in here --&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">footer</span>&gt;</span>
</code></pre>
<p>Let’s understand each tag used above (skip if you already know):</p>
<ul>
<li><p><code>&lt;header&gt;</code>: Represents the introductory section of a webpage, typically containing headings, logos, or navigation links.</p>
</li>
<li><p><code>&lt;nav&gt;</code>: Defines a navigation section that contains links to other parts of the website or page, providing easy access to important sections.</p>
</li>
<li><p><code>&lt;main&gt;</code>: Represents the main content area that focusses on the primary purpose of the page or the website, excluding common elements like header, footer, or sidebar (may include sidebar depending on the website).</p>
</li>
<li><p><code>&lt;footer&gt;</code>: Represents the bottom section of the web page, typically containing metadata, copyright information, or links to related resources.</p>
</li>
</ul>
<p>These elements are called <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element#content_sectioning">sectioning elements</a>. Following are advantages of using these elements:</p>
<ul>
<li><p>The layout is clear with each element clearly describing its purpose, making the code readable and maintainable.</p>
</li>
<li><p>Using the right semantic elements makes screen readers identify each part of the layout, thus helping visually impaired users understand how the website is structured.</p>
</li>
</ul>
<p>Of course, you can write the above layouts by using divs, but sectioning elements provide good semantics and help users understand the type of content they are navigating.</p>
<h3 id="heading-interactive-elements">Interactive Elements</h3>
<p>These consist of elements through which a user interacts with the web page. These elements include buttons, form fields, links, and so on.</p>
<h4 id="heading-keyboard-accessibility">Keyboard Accessibility</h4>
<p>Each interactive element on a web page should be navigable through the keyboard. This gives a user flexibility while navigating your website. Keyboard accessibility is really helpful for people with mobility impairments that may struggle to use a mouse.</p>
<p>For instance, visit <a target="_blank" href="https://mdn.github.io/learning-area/tools-testing/cross-browser-testing/accessibility/native-keyboard-accessibility.html">this</a> page and try to navigate to each interactive element by pressing Tab on your keyboard. You can also press Enter/Spacebar to click on a button or a link. This should give you an idea of what a keyboard-accessible website looks like.</p>
<p>For the most part, using the right semantic elements should ensure keyboard accessibility, as they come with built-in functionality. Check out the following example:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>
  Visit my blog at 
  <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"https://www.freecodecamp.org/news/author/KunalN25/"</span>&gt;</span>freecodecamp.org<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">button</span>&gt;</span>Click me<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">button</span>&gt;</span>Click me again<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> <span class="hljs-attr">placeholder</span>=<span class="hljs-string">"Enter your name"</span> /&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>Here, we have used the correct semantic elements for the hyperlink, button, and input element. All these elements can be accessed through Tab and interacted with using Enter/Spacebar. Check out other form-related elements in this <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element#forms">list</a>.</p>
<p>Some people use a <code>div</code> or <code>span</code> and make them look like an anchor tag or a button with CSS styling. But this is bad for accessibility for two reasons:</p>
<ul>
<li><p><code>div</code> and <code>span</code> are not tab-able by default. So, even if you do make a <code>div</code> look like a button, the user cannot navigate to it using the keyboard.</p>
</li>
<li><p>Screen readers won’t be able to identify them as buttons, while in the case of semantic elements, they read these elements out as buttons or links.</p>
</li>
</ul>
<p>But if you absolutely have to use a <code>div</code> to create a clickable element, include the following attributes:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"customButton"</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"button"</span> <span class="hljs-attr">tabindex</span>=<span class="hljs-string">"0"</span>&gt;</span>Click me<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>Here, we have added two attributes, <code>tabindex</code> and <code>role</code>. We’ll understand the <code>role</code> attribute in a later section.</p>
<p>The <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex"><code>tabindex</code></a> attribute takes an integer that specifies the tab order of tab-able elements, instead of the default top to bottom tab order. A positive integer means the element is focussed in an order specified by the attribute’s value.</p>
<p>But using tabindex to change the default tab order is not recommended, as it may cause confusion for keyboard navigators and affect accessibility. And frankly, it’s not necessary.</p>
<p>You should only ever use the following two values:</p>
<ul>
<li><p><code>tabindex=”0”</code> makes an element tab-able which means it can be accessed through a keyboard in the natural tab order.</p>
</li>
<li><p><code>tabindex=”-1”</code> means the element is not reachable via keyboard navigation.</p>
</li>
</ul>
<p>These attributes make the <code>div</code> behave like a button, but there’s a small piece of JS code you still need to add to make the button clickable via Enter/Return:</p>
<pre><code class="lang-javascript"><span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">"customButton"</span>).addEventListener(<span class="hljs-string">"keydown"</span>, <span class="hljs-function">(<span class="hljs-params">event</span>) =&gt;</span> {
  <span class="hljs-keyword">if</span> (event.key === <span class="hljs-string">"Enter"</span>) {
    <span class="hljs-built_in">document</span>.activeElement.click();
  }
});
</code></pre>
<p>Here, we have added an event listener to the element that listens for the keydown event. If the key pressed is Enter, then it calls the element’s <code>onclick</code> method.</p>
<p>If you are using a non-semantic element as a button, you need to add this extra code to make it work like a button. So, only use it if it's absolutely necessary. Otherwise, it's always better to use the correct semantic element in the first place.</p>
<p>Keyboard Accessibility is important for audio and video controls too. We’ll discuss this in the <a class="post-section-overview" href="#heading-multimedia-accessibility">Multimedia Accessibility</a> section.</p>
<h3 id="heading-form-labels">Form Labels</h3>
<p>A form label is some text that describes what you need to enter in a form field. Adding labels to form fields is a necessary practice since it lets the user know how to fill the form. But using the right semantic elements is important.</p>
<p>You could do the following and still achieve the desired output:</p>
<pre><code class="lang-xml">Enter name: <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"name"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"name"</span> /&gt;</span>
</code></pre>
<p>This is not good for screen reader users, as it does not read out what the input field is for. Even if it reads out “Enter name”, the user may not associate it with the input field. Instead, use the <code>&lt;label&gt;</code> element for form labels.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">for</span>=<span class="hljs-string">"name"</span>&gt;</span>Enter name:<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"nameField"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"name"</span> /&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>The <code>for</code> attribute associates the label with the input field. With this, when the screen reader’s focus is on the input field, it reads out the label, followed by “edit field” to let the user know they should enter their name in the input field.</p>
<p>Check out the <a target="_blank" href="https://mdn.github.io/learning-area/accessibility/html/good-form.html">form with the label</a> and <a target="_blank" href="https://mdn.github.io/learning-area/accessibility/html/bad-form.html">form without the label</a> in these examples for more clarity. Use Mac’s Voiceover (⌘+F5) or Windows’ Narrator (Ctrl+Windows+Enter) to see how it reads out the form elements.</p>
<p>Using <code>&lt;label&gt;</code> offers more advantages:</p>
<ul>
<li><p>By linking a <code>&lt;label&gt;</code> to an input field with the <code>for</code> attribute (clickable association), clicking on the label focuses on the input field.</p>
</li>
<li><p>Clickable association with input field helps the user’s select small inputs like <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox">checkboxes</a> or <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/radio">radio buttons</a>.</p>
</li>
<li><p>It follows semantic HTML and specifies that the text is being used as a form label.</p>
</li>
</ul>
<p>Lastly, remember that the label text should clearly describe what the user should enter into the field. For examples, “Enter name” or “Enter email”.</p>
<p>This applies to buttons as well. Ensure that button text is descriptive enough to tell the user what they are clicking on. Vague texts like “Click me!” or “Click here!” are not helpful. Examples of descriptive text are “Submit Form” or “Download Report” that give the users a clear idea of the button’s action.</p>
<p>Along with these, links also come under interactive elements. But since there are a lot of examples for Links, I’ll discuss them in their own section now.</p>
<h3 id="heading-links">Links</h3>
<p>Links are a key part of web pages as they allow the user to navigate the website. Links serve different purposes: going to a different page in the same website, going to an external website, or downloading something. In this section, you’ll learn about several practices with links that contribute towards accessibility.</p>
<h4 id="heading-linking-to-external-websites">Linking to External Websites</h4>
<p>When you add a link that lets users open an external website, including the <code>target=_blank</code> attribute opens the link in a new tab.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"https://www.wikipedia.org/"</span> <span class="hljs-attr">target</span>=<span class="hljs-string">"_blank"</span>&gt;</span> Wikipedia <span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
</code></pre>
<p>This is helpful for users as they don’t need to exit the website, saving them from the hassle of navigating back to the website.</p>
<p>Also, if your link opens in a new tab, it’s a good idea to mention it so the screen readers can read it out and help visually impaired users.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"https://www.wikipedia.org/"</span> <span class="hljs-attr">target</span>=<span class="hljs-string">"_blank"</span> &gt;</span>
Wikipedia (opens in new tab)
<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
</code></pre>
<p>Similarly, if your link opens a non-HTML file, like a pdf or docx, you should mention it:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">target</span>=<span class="hljs-string">"_blank"</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"jan-salary-slip.pdf"</span>&gt;</span>
Salary-January (PDF)
<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
</code></pre>
<p>Alternatively, you can use an icon to indicate a link opening in new tab.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"https://www.wikipedia.org/"</span> <span class="hljs-attr">target</span>=<span class="hljs-string">"_blank"</span>&gt;</span>
  Wikipedia
  <span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"new-tab-icon.png"</span> <span class="hljs-attr">alt</span>=<span class="hljs-string">"Opens in new tab"</span> <span class="hljs-attr">style</span>=<span class="hljs-string">"width:16px; height:16px; margin-left:5px;"</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
</code></pre>
<p>When using an icon, make sure that you include the alt attribute with description about the image. We’ll understand its purpose in the <a class="post-section-overview" href="#heading-multimedia-accessibility">Multimedia Accessibility</a> section.</p>
<h4 id="heading-skip-links">Skip Links</h4>
<p>A skip link is a link element placed at the top of a page that links directly to the main content of the page. This allows the users to skip the headers and all the navigation menus, and directly jump to the main content of the page. This is helpful on websites where there’s lot of repetitive content on top like menus or banners.</p>
<p>Skip links are especially helpful for people who are visually impaired and who might be using screen readers. These links provide a way to bypass repetitive navigation menus and directly access the main content. This also helps keyboard navigators, thus saving time and enhancing the user experience.</p>
<p>To add a skip link, add an anchor tag at the very top, just under the body tag, and link it to the main content.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
 <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"#main"</span>&gt;</span>Skip to main content<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">header</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>Page Title<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">nav</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">ul</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"nav-links"</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"/"</span>&gt;</span>Home<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"/about"</span>&gt;</span>About<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"/blog"</span>&gt;</span>Blog<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
          <span class="hljs-comment">&lt;!-- other nav links --&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span>
      <span class="hljs-tag">&lt;/<span class="hljs-name">nav</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">header</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">main</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"main"</span>&gt;</span>
      <span class="hljs-comment">&lt;!-- Main Content --&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">main</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
</code></pre>
<p>The skip link is keyboard accessible and is also read out by the screen reader. Clicking on it takes you straight to the main content. Visit <a target="_blank" href="https://webaim.org/">WebAIM</a> and press Tab on your keyboard to see skip links in action.</p>
<h4 id="heading-link-styling">Link Styling</h4>
<p>By default, links created with the anchor tag are visually different from non-link text. This is because the anchor tag has built-in styles like colour, <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration">text-decoration</a>, focus-ring (displays when you tab on to the link with the keyboard) and hover effects.</p>
<p>Links should look different from the other text so they’re easily distinguishable. As you saw above, the browser does that for you, so you don’t need to do much. But if you are adding custom styles to the link that fit in better with your theme, you need to follow some best practices:</p>
<ul>
<li><p>Links should have different colors for default, <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/CSS/:visited">visited</a>, <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/CSS/:focus">focus</a> and <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/CSS/:hover">hover</a> states.</p>
</li>
<li><p>Link text color should be different from the non-link text and should have different styling.</p>
</li>
<li><p>Link text color should have a contrast of 3:1 between other text and 4.5:1 contrast between background color. See the <a class="post-section-overview" href="#heading-color-contrast">Color Contrast</a> section for more understanding</p>
</li>
</ul>
<p>An example of custom styling for links is shown below (from the Docs):</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">a</span> {
  <span class="hljs-attribute">color</span>: <span class="hljs-number">#ff0000</span>;
}

<span class="hljs-selector-tag">a</span><span class="hljs-selector-pseudo">:hover</span>,
<span class="hljs-selector-tag">a</span><span class="hljs-selector-pseudo">:visited</span>,
<span class="hljs-selector-tag">a</span><span class="hljs-selector-pseudo">:focus</span> {
  <span class="hljs-attribute">color</span>: <span class="hljs-number">#a60000</span>;
  <span class="hljs-attribute">text-decoration</span>: none;
}

<span class="hljs-selector-tag">a</span><span class="hljs-selector-pseudo">:active</span> {
  <span class="hljs-attribute">color</span>: <span class="hljs-number">#000000</span>;
  <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#a60000</span>;
}
</code></pre>
<p>With the help of <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes">pseudo-classes</a>, this adds different styles for when link is hovered, previously visited, focussed (with the keyboard), or active (when the link is being clicked).</p>
<p>You can experiment with different colors and styles, but don’t remove the <code>cursor: pointer</code> or <code>outline</code> properties. Both are important for people using keyboard navigation.</p>
<p>Remember, links already have built-in styles for all the link states. Only add your own if you want something in line with your website’s theme.</p>
<h4 id="heading-avoid-using-onclick-handlers">Avoid using onclick handlers</h4>
<p>Links are used to navigate to another web page on the same website or navigate to an external website. Specifying the link in the <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#href">href</a> attribute does this for you without any need to add JavaScript code.</p>
<p>But some people add an <code>onclick</code> attribute to anchor elements, to make them behave like buttons and set <code>href=”#”</code> or <code>href="javascript:void(0)"</code> to avoid page refresh. This causes unexpected behaviour and may lead to the following problems:</p>
<ul>
<li><p>Copying or dragging this link adds an unnecessary <code>#</code> or <code>void(0)</code> to the URL, which does not make sense.</p>
</li>
<li><p>Clicking the link immediately scrolls the page to the top, which may lead to the user losing track of where they were.</p>
</li>
<li><p>If JavaScript is still downloading, clicking the link does nothing and the web page becomes unresponsive.</p>
</li>
</ul>
<p>It is also bad for semantics and accessibility, as people using screen readers may get confused. If you want to add JavaScript functionality on click of an element, just use a <code>&lt;button&gt;</code>. Only use links when navigating to a proper URL.</p>
<h4 id="heading-meaningful-link-text">Meaningful Link Text</h4>
<p>Similar to buttons, when writing link text, keep it meaningful and descriptive and avoid using “Click here” or “Click this”.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>
  For more information about accessibility
  <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"https://developer.mozilla.org/en-US/docs/Web/Accessibility"</span>&gt;</span>
    click here
  <span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
</code></pre>
<p>Instead of the above, do this:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>
  For more information about accessibility, visit
  <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"https://developer.mozilla.org/en-US/docs/Web/Accessibility"</span>&gt;</span>
    MDN Docs - Accessibility
  <span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
</code></pre>
<p>Check out the <a target="_blank" href="https://mdn.github.io/learning-area/accessibility/html/good-links.html">Good Links</a> and <a target="_blank" href="https://mdn.github.io/learning-area/accessibility/html/bad-links.html">Bad Links</a> examples from the docs. You can also test them with VoiceOver (⌘+F5).</p>
<h4 id="heading-link-proximity">Link Proximity</h4>
<p>If your web page has a lot of interactive elements like links and buttons, ensure that they are spaced properly to prevent accidental clicks. This helps people with <a target="_blank" href="https://axesslab.com/hand-tremors/">Motor Control Issues</a> that may click on the wrong link.</p>
<p>Using the <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/CSS/margin"><code>margin</code></a> property should be enough to ensure spacing.</p>
<h3 id="heading-table-accessibility">Table Accessibility</h3>
<p>In the page layouts section, we saw that using tables for creating page layouts is an outdated practice. However, tables can still be used if you want to display a large amount of data in tabular form. Incorporating accessibility in tables helps screen readers interpret them and help visually impaired users.</p>
<p>Check out <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Structuring_content/Table_accessibility">MDN Docs - Table Accessibility</a> to understand best practices.</p>
<h2 id="heading-additional-css-and-js-practices">Additional CSS and JS Practices</h2>
<p>Most of your accessibility goals should be achieved with HTML alone. But there are certain things to keep in mind when writing CSS and JavaScript to ensure you don't break accessibility.</p>
<h3 id="heading-styling-form-elements">Styling Form Elements</h3>
<p>When styling form elements, remember the following:</p>
<ul>
<li><p>Do not remove the default styles for focus outlines, hover, and disabled state in form elements. You may modify them as per your site design, but they should still be visible.</p>
</li>
<li><p>Ensure that your labels and placeholder texts are visually clear. Follow colour contrast practices (next section).</p>
</li>
<li><p>For clickable areas like buttons and inputs, ensure they are large enough so the user can click comfortably.</p>
</li>
<li><p>Success and Error messages should be physically distinguishable from labels and other text content.</p>
</li>
</ul>
<h3 id="heading-color-contrast">Color Contrast</h3>
<p>When you choose colors for your website, your text and background colour should have a good colour contrast. A good color contrast ensures that the text is easily readable by all users (and it also helps people with color blindness in particular).</p>
<p>The WCAG (Web Content Accessibility Guidelines) recommends the following contrast ratios:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736175276741/40ee7fe4-110c-4dd1-95f3-4cb7620de032.png" alt="Recommended Color contrast ratios" class="image--center mx-auto" width="1566" height="498" loading="lazy"></p>
<p>Let’s understand the colour contrast ratings:</p>
<ul>
<li><p>AA rating refers to the minimum ratio your colour contrast should be such that the site’s content is readable. As you can see in the table above, this requires a 4.5:1 minimum ratio for body text, a 3:1 ratio for large-scale text, and a 3:1 ratio for active user interface components and graphical objects.</p>
</li>
<li><p>AAA rating is the ideal standard for accessibility that ensures high contrast for your website. This requires a 7:1 ratio for body text, a 4.5:1 ratio for large-scale text, and isn’t defined for UI components/graphical objects.</p>
</li>
</ul>
<p>Choose a contrast ratio that aligns well with your design, but try to keep it to at least AA rating. To check colour contrast ratio between two colors, you can use the following tools:</p>
<ul>
<li><p><a target="_blank" href="https://webaim.org/resources/contrastchecker/">Color Contrast Checker</a></p>
</li>
<li><p><a target="_blank" href="https://developer.chrome.com/docs/devtools/accessibility/contrast">Chrome Developer Tools</a> - Identifies text in your website not meeting AA and AAA ratings</p>
</li>
</ul>
<h3 id="heading-javascript-practices">JavaScript Practices</h3>
<h4 id="heading-mouse-specific-events">Mouse-specific events</h4>
<p>When you have functionality triggered by events like <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/API/Element/mouseover_event">mouse-over</a> and <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/API/Element/mouseout_event">mouse-out</a>, they cannot be accessed by people that depend on keyboard navigation. So, to make the functionality accessible by keyboard, you need to add the same event handlers to events like <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/API/Element/focus_event">focus</a> and <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/API/Element/blur_event">blur</a>.</p>
<h4 id="heading-client-side-form-validations">Client side form validations</h4>
<p>When you submit data through a form, the data is validated to check if you have entered valid data. Often, when the data is sent to the server, the server validates the data and lets the UI know if the validation has failed.</p>
<p>To make the website user-friendly, it helps to add form validations on the client-side, so users can get instant feedback if they have entered incorrect data, since the server-side mechanism may take time. This is a very small step towards improving user experience.</p>
<p>Check out the <a target="_blank" href="https://mdn.github.io/learning-area/accessibility/css/form-validation.html">Form Validation</a> Example to understand more.</p>
<p>Apart from the above, one thing you should remember is not to use JavaScript for anything and everything. JavaScript can be used to generate any form of HTML and dynamically apply CSS styling. It is very helpful if you have dynamic content on your website.</p>
<p>But if you have too much HTML generated by JavaScript, it gets hard for screen readers to keep track of the dynamic changes. This makes the website difficult to read for impaired users. So, make sure you don't overuse JavaScript when simple HTML would be enough.</p>
<p>Accessibility for dynamic content updates is covered in the next section.</p>
<h2 id="heading-advanced-accessibility-practices-wai-aria">Advanced Accessibility Practices: WAI-ARIA</h2>
<p>As applications started to get bigger and more complex, developers started needing a new set of accessibility features. Semantic elements alone were not enough, especially for complex elements like date pickers and custom widgets.</p>
<p>Depending on semantic HTML does not help when content is updated dynamically on the web page. Nowadays, all websites built with JavaScript have content that isn’t loaded initially, but updated dynamically based on user interactions.</p>
<p>WAI-ARIA (Web Accessibility Initiative - Accessible Rich Internet Applications) was introduced to add more accessibility features wherever they were needed. It defines a set of HTML attributes that you can use to provide additional semantics to your website and improve accessibility.</p>
<p>In the following sections, you’ll learn which attributes were introduced and how you can use them to enhance accessibility.</p>
<h3 id="heading-the-role-attribute">The <code>role</code> attribute</h3>
<p>The <code>role</code> attribute helps add semantic information to non-semantic elements by defining their “role” on the web page. With roles, screen readers can accurately read non-semantic elements and help identify them for people with disabilities.</p>
<p>W3C defines several roles that you can use, depending on their purpose. But keep in mind that you should only use <code>role</code> when necessary. In most cases, it’s better to just use the right semantic elements like <code>&lt;button&gt;</code>, <code>&lt;nav&gt;</code>, <code>&lt;header&gt;</code>, and so on.</p>
<p>But, when semantic elements are not fulfilling your purpose, roles can help. So, let’s understand how to use them with some examples:</p>
<p>If you want to create a button with custom <code>div</code>, adding the <code>role</code> attribute specifies that this element is being used as a button.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"button"</span> <span class="hljs-attr">tabindex</span>=<span class="hljs-string">"0"</span>&gt;</span>Click Me<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>When you test this with Mac’s VoiceOver (⌘+F5), it reads out the element as a button. As discussed before, always include the <code>tabindex</code> attribute.</p>
<p>But if you want to use a <code>div</code> instead of a button, you still need to add JavaScript functionality, as explained in the the <a class="post-section-overview" href="#heading-keyboard-accessibility">Keyboard Accessibility</a> section.</p>
<p>Another example is if you are writing a custom link. You can use the following role, so that the screen reader interprets this as a link:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"link"</span>&gt;</span>Visit our website<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>Apart from interactive elements, <code>role</code> attribute can also be used to define elements as navigation menus, side bars, banners, etc. If you are using non-semantic elements for these purposes, always include a role, like the following:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"navigation"</span>&gt;</span>
    <span class="hljs-comment">&lt;!-- Navigation menu items --&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>In this case, the screen reader announces this as a navigation area.</p>
<p>Also, if you have an element that serves as an alert for the user, including the following role makes the screen reader announce it as soon as it shows up on the screen, even if it doesn’t have focus:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"alert"</span>&gt;</span>
  Please respond to this alert
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>You can find the full list of available roles at <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles">MDN Docs: WAI-ARIA Roles</a>.</p>
<h3 id="heading-aria-attributes">aria-* attributes</h3>
<p>Apart from <code>role</code>, ARIA (Accessible Rich Internet Applications) defines extra attributes to enhance the accessibility of web applications. These attributes give screen readers more information about elements, helping people with disabilities better understand them.</p>
<p>If native semantic elements or the <code>role</code> attribute alone are not sufficient, aria-* attributes can provide extra context. You can find a full list of these attributes in <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes">MDN Docs-ARIA</a>.</p>
<p>In the following sections, we’ll see how role and aria-* attributes can improve accessibility. We won’t cover all the attributes here, but we’ll focus on the most commonly used ones.</p>
<h3 id="heading-dynamic-content-updates">Dynamic Content Updates</h3>
<p>When a web page loads for the first time, its content is read out by the screen reader. But screen readers cannot capture dynamic content, that is content that gets added or removed.</p>
<p>For example, when a web page is showing live sport updates, it gets updated almost every minute. Screen readers will only read out the content displayed when the page is first rendered, but don’t show dynamic updates.</p>
<p>This is not really a problem for many users, but for people with visual impairments, screen readers may not be able to read the changes on the page. Most modern websites are dynamic in nature, so it’s important to consider accessibility of dynamic content updates.</p>
<p>Check out the <a target="_blank" href="https://mdn.github.io/learning-area/accessibility/aria/aria-no-live.html">aria-no-live</a> example from MDN Docs. It loads a new quote every 10 seconds, which you can see clearly as a user with no visual impairment. But the screen reader only reads the initial page content and does not announce the updates. This is not good for accessibility.</p>
<p>To fix this, WAI-ARIA provides the <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-live"><code>aria-live</code></a> attribute that makes the screen reader read out content that is updated. You can add this attribute to the element that contains the dynamic content.</p>
<p>It takes the following three values:</p>
<ul>
<li><p><code>aria-live="off"</code>: Default value that means no content is read out</p>
</li>
<li><p><code>aria-live="polite"</code> Updates only announced when the user is idle</p>
</li>
<li><p><code>aria-live="assertive"</code>: Content read out as soon as it is updated.</p>
</li>
</ul>
<p>Depending on the importance of the update, you can decide which value to use.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">aria-live</span>=<span class="hljs-string">"polite"</span>&gt;</span>
    <span class="hljs-comment">&lt;!-- Dynamic Content here --&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>In this case, the screen reader waits till the user is done with their current task before announcing the update.</p>
<p>You can add more detail here. With the above attribute, only the text that is updated is read out. But, screen reader users may get confused as to which part of the page is being read out. So, it is helpful if the entire element is read out.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">aria-live</span>=<span class="hljs-string">"assertive"</span> <span class="hljs-attr">aria-atomic</span>=<span class="hljs-string">"true"</span>&gt;</span>
    <span class="hljs-comment">&lt;!-- Dynamic Content here --&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>The <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-atomic"><code>aria-atomic</code></a> attribute tells screen readers to read out the entire element as a single atomic unit. This avoids confusion for visually impaired users. Check out the <a target="_blank" href="https://mdn.github.io/learning-area/accessibility/aria/aria-live.html">aria-live</a> example from MDN Docs with Mac’s VoiceOver (⌘+F5). It reads out the entire element when the content is updated.</p>
<h3 id="heading-form-validation-and-errors">Form Validation and Errors</h3>
<p>Let’s say you have added some validation to your form through JavaScript. When the validation fails, an error message gets added on the screen. For example, a required message shows up if you have missed a field.</p>
<p>The implementation for error handling involves creating an element containing an error message or a list of errors that render on certain conditions, depending on the JavaScript code. Just as we discussed in the previous section, the screen reader does not read out new content updates.</p>
<p>So, we should make sure that the screen reader reads out the error message as soon as it shows up, to let visually impaired users know that an error has been thrown. We can use the following attributes for this purpose:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"errors"</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"alert"</span> <span class="hljs-attr">aria-relevant</span>=<span class="hljs-string">"all"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">ul</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>The <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/alert_role"><code>alert</code></a> role does two things. It semantically identifies this element as a piece of important information. Secondly, this role turns the element into a <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions">live</a> region which means the screen reader is notified immediately if there are any changes.</p>
<p>The <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-relevant"><code>aria-relevant</code></a> attribute describes what changes need to be announced in a live region. The attribute takes a space-separated list of the following values:</p>
<ul>
<li><p><code>additions</code>: Announces new content added to the live region</p>
</li>
<li><p><code>removals</code>: Content removed from the live region is read out</p>
</li>
<li><p><code>text</code>: Announces any modifications to existing content.</p>
</li>
</ul>
<p>It also takes a value <code>all</code> which is a shorthand for <code>additions removals text</code>, meaning all three types of content are read out.</p>
<p>You can check the <a target="_blank" href="https://mdn.github.io/learning-area/accessibility/css/form-validation.html">Form Validation Example</a> from the MDN Docs.</p>
<p>Next, let’s see what to do if we want to mark certain fields as required. Normally, we’d add visual cues like a <code>*</code> and the following message at the top of the form:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Fields marked with an asterisk (*) are required.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
</code></pre>
<p>This is helpful for regular users, but visually impaired users may get confused as to which fields are required. To make it easier for them, we can use the <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-required"><code>aria-required</code></a> attribute.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"name"</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"name"</span> <span class="hljs-attr">aria-required</span>=<span class="hljs-string">"true"</span> /&gt;</span>
</code></pre>
<p>With this attribute, the screen reader mentions this field as “required” while reading it out.</p>
<p>When you are creating input fields, it’s important to include a label, as some screen readers do not read out placeholder text. If you don’t want to include a label field, here are the following alternatives:</p>
<p>You can use the <code>aria-label</code> attribute to add labels to input fields that do not have a label associated with them.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"email"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"email"</span> <span class="hljs-attr">aria-label</span>=<span class="hljs-string">"Enter email"</span> /&gt;</span>
</code></pre>
<p>This attribute provides some text to be read out by a screen reader to describe the input field.</p>
<p>You can go one step further and use the <code>aria-labelledby</code> attribute that uses another element to act as a label for the input field. For example:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">span</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"emailLabel"</span>&gt;</span>Enter your email<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"email"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"email"</span> <span class="hljs-attr">aria-labelledby</span>=<span class="hljs-string">"emailLabel"</span> /&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>The screen reader reads out the text inside the <code>&lt;span&gt;</code> element to describe the input element. This is similar to having a <code>&lt;label&gt;</code> with a <code>for</code> attribute. You can also use this attribute to reference other interactive elements like <code>&lt;button&gt;</code> or <code>&lt;a&gt;</code> that do not have a label field to reference them.</p>
<p>Keep in mind that the <code>aria-labelledby</code> attribute only defines an accessible name for the element – it does not provide other functionality like clicking on the label to focus on the input element. It’s better to use <code>&lt;label&gt;</code> with a <code>for</code> attribute.</p>
<p>We have already discussed form labels in the <a class="post-section-overview" href="#heading-interactive-elements">Interactive Elements</a> section.</p>
<p>You’ve now seen some of the different attributes that WAI-ARIA offers and how they enhance accessibility. You can visit <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Accessibility/WAI-ARIA_basics#accessibility_of_non-semantic_controls_2">MDN Docs: WAI-ARIA</a> to check out additional details I may have missed.</p>
<p>Before we move on, remember one thing: <em>use WAI-ARIA only when necessary</em>. Usually, semantic elements are able to achieve majority of your accessibility goals. Don’t over-use WAI-ARIA as they might end up complicating your code.</p>
<h2 id="heading-multimedia-accessibility">Multimedia Accessibility</h2>
<p>A website’s content is not restricted to text. It also often consists of multimedia content like images, audio, and video. In a lot of cases, multimedia content is easier to understand than text content. While this is true for many users, it poses challenges for users with disabilities.</p>
<p>People with visual impairments cannot see images and people who are deaf or hard of hearing cannot easily interpret audio content. So, as developers, it’s our job to make this type of content accessible for everyone. Let’s understand how to make this possible:</p>
<h3 id="heading-images">Images</h3>
<p>Since people with visual impairments cannot see images, they depend on a screen reader to describe the image. Just writing an <code>img</code> tag with <code>src</code> attribute does not help.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"temple.jpg"</span> /&gt;</span>
</code></pre>
<p>By default, the screen reader reads out the file path or URL of the image. A file name might give some idea of the image, but still does not describe it.</p>
<p>So, it’s helpful to add an <code>alt</code> attribute to an <code>img</code>. The <code>alt</code> attribute provides an alternate text for the image, and its purpose is to describe the image.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">img</span>
  <span class="hljs-attr">src</span>=<span class="hljs-string">"temple.jpg"</span>
  <span class="hljs-attr">alt</span>=<span class="hljs-string">"The Meenakshi Temple, situated in Madurai, a South Indian City is dedicated to goddess Meenakshi, a form of Parvati"</span>
/&gt;</span>
</code></pre>
<p>Here, instead of reading the file path, the screen reader reads out the alternate text – that is, the value of the <code>alt</code> attribute. The alternate text should provide a description of the image to help users understand what it’s conveying. So, instead of just saying “Temple”, the user knows which temple is being depicted in the image.</p>
<p>You can also add extra context to the image with the <code>title</code> attribute.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">img</span>
  <span class="hljs-attr">src</span>=<span class="hljs-string">"temple.jpg"</span>
  <span class="hljs-attr">alt</span>=<span class="hljs-string">"The Meenakshi Temple, situated in Madurai, a South Indian City is dedicated to goddess Meenakshi, a form of Parvati"</span>
  <span class="hljs-attr">title</span>=<span class="hljs-string">"The Meenakshi Temple"</span>
/&gt;</span>
</code></pre>
<p>When focussed on the image, the screen reader reads out the <code>alt</code> text and the title.</p>
<p>Let’s take another example which uses an alternative to the <code>alt</code> attribute:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"temple.jpg"</span> <span class="hljs-attr">aria-labelledby</span>=<span class="hljs-string">"temple-label"</span> /&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">p</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"temple-label"</span>&gt;</span>
  The Meenakshi Temple, situated in Madurai, a South Indian City is dedicated to
  goddess Meenakshi, a form of Parvati
<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
</code></pre>
<p>Here, instead of using the <code>alt</code> attribute, we have used the <code>aria-labelledby</code> attribute to link the paragraph element to the image. The text inside <code>p</code> acts as an alternate text for the image. This is helpful if you need to use the same text as an alternate text for different images.</p>
<p>Sometimes, we use images as icons for headers and navigation menus, just for decoration. Usually, these images are not relevant to understand the content of the page. In these cases, you add an empty <code>alt</code> attribute.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">h3</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"page-icon.png"</span> <span class="hljs-attr">alt</span>=<span class="hljs-string">""</span> /&gt;</span>
  History of Meenakshi Temple 
<span class="hljs-tag">&lt;/<span class="hljs-name">h3</span>&gt;</span>
</code></pre>
<p>If you skip the <code>alt</code> attribute, the screen reader reads out the entire image URL. To avoid this, use an empty <code>alt</code> attribute, so the screen reader simply announces it as an image and moves on, preventing unnecessary distractions for users.</p>
<p>You can also use <code>role=”presentation”</code> to skip reading the image path or alternative text.</p>
<h3 id="heading-audio-and-video">Audio and video</h3>
<p>When using the <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio">&lt;audio&gt;</a> and <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video">&lt;video&gt;</a> elements, remember to include multiple sources – that is, provide the audio and video in different formats. For browsers that do not support the formats you have mentioned, include a fallback download link so they can access the resource.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">audio</span> <span class="hljs-attr">controls</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">source</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"audio.mp3"</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"audio/mpeg"</span> /&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">source</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"audio.ogg"</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"audio/ogg"</span> /&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>
    Your browser doesn't support HTML video. Here is a
    <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"video.mp3"</span>&gt;</span>link to the video<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span> instead.
  <span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">audio</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">video</span> <span class="hljs-attr">controls</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">source</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"video.mp4"</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"video/mp4"</span> /&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">source</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"video.webm"</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"video/webm"</span> /&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>
    Your browser doesn't support HTML5 video. Here is a
    <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"video.mp4"</span>&gt;</span>link to the video<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span> instead.
  <span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">video</span>&gt;</span>
</code></pre>
<p>Next, let’s understand the shortcomings of using native HTML controls for audio and video.</p>
<ul>
<li><p>They cannot be styled with CSS, so they may not align with your website’s theme.</p>
</li>
<li><p>The play/pause buttons are not keyboard accessible.</p>
</li>
<li><p>They don’t have functionality to forward or rewind the video.</p>
</li>
</ul>
<p>To overcome these limitations, we’ll create our custom video player in the next steps. To start, let’s create a container for the video content:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"controls"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"play-pause"</span>&gt;</span>Play<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"stop"</span>&gt;</span>Reset Video<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>These will work as the play/pause and reset buttons. Then, let’s remove the <code>controls</code> attribute from the <code>&lt;video&gt;</code> to replace them with our custom controls.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> videoPlayer = <span class="hljs-built_in">document</span>.querySelector(<span class="hljs-string">"video"</span>);
videoPlayer.removeAttribute(<span class="hljs-string">"controls"</span>);
</code></pre>
<p>Why do we remove it at run time? Let’s say JavaScript does not load due to some issue. In this case, the user can still use the native controls. Next, let’s add some functionality to our buttons:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> playPauseBtn = <span class="hljs-built_in">document</span>.querySelector(<span class="hljs-string">".play-pause"</span>);
<span class="hljs-keyword">const</span> resetBtn = <span class="hljs-built_in">document</span>.querySelector(<span class="hljs-string">".reset"</span>);

playPauseBtn.onclick = <span class="hljs-function">() =&gt;</span> {
  <span class="hljs-keyword">if</span> (videoPlayer.paused) {
    videoPlayer.play();
    playPauseBtn.textContent = <span class="hljs-string">"Pause"</span>;
  } <span class="hljs-keyword">else</span> {
    videoPlayer.pause();
    playPauseBtn.textContent = <span class="hljs-string">"Play"</span>;
  }
};

resetBtn.onclick = <span class="hljs-function">() =&gt;</span> {
  videoPlayer.pause();
  videoPlayer.currentTime = <span class="hljs-number">0</span>;
  playPauseBtn.textContent = <span class="hljs-string">"Play"</span>;
};
</code></pre>
<ul>
<li><p>The video player object is of type <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement"><code>HTMLMediaElement</code></a>, that contains several methods you can use to control the video.</p>
</li>
<li><p>For the play/pause button, we add a toggling functionality, with the <code>play()</code> and <code>pause()</code> methods.</p>
</li>
<li><p>To reset the video, we pause it and set the current time to 0.</p>
</li>
</ul>
<p>Now, our custom video player is keyboard accessible, and able to be styled with CSS. You can also add additional functionality like forward/rewind, a timer, and a progress bar. The steps are similar for a custom audio player.</p>
<p>Check out the <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Accessibility/Multimedia#creating_custom_audio_and_video_controls">MDN Docs</a> for more detail about this functionality.</p>
<h4 id="heading-audio-transcripts">Audio Transcripts</h4>
<p>People who are deaf or hard of hearing cannot easily access audio content. So to make it accessible, you need to add transcripts under any audio or video form of content.</p>
<p>If you run a business, you could pay a professional to do the transcripts. Check out the <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Accessibility/Multimedia#audio_transcripts">docs</a> for options. To show the transcript on the UI, you could use a show/hide panel. Referring to the docs, see the <a target="_blank" href="https://mdn.github.io/learning-area/accessibility/multimedia/audio-transcript-ui/">audio transcript UI</a> (<a target="_blank" href="https://github.com/mdn/learning-area/tree/main/accessibility/multimedia/audio-transcript-ui">source code</a>) for an example.</p>
<p>If the audio is a recording of some presentation, you should attach links to any documents or presentation decks. Also, include a description for any visual content being referenced.</p>
<h4 id="heading-video-closed-captioning-and-subtitles">Video Closed Captioning and Subtitles</h4>
<p>First, let’s understand the difference between captions and subtitles. They are implemented in a similar way and visually, they look the same – but their purposes are different.</p>
<p>Captions denote who’s speaking and describe other sound effects in the video. They are mostly added with people who are deaf or hard of hearing in mind. Subtitles help people who don’t understand the language being spoken in the video, by translating it to text that uses the language of their choice.</p>
<p>Let’s see how to add subtitles to your videos. We write subtitles in WebVTT, a format that contains text along with the range of timestamps indicating which text you want in each part of the video. Following is an example of a subtitles file:</p>
<pre><code class="lang-javascript">WEBVTT

<span class="hljs-number">1</span>
<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">01.230</span> --&gt; <span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">02.606</span>
This is the first subtitle.

<span class="hljs-number">2</span>
<span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">04.739</span> --&gt; <span class="hljs-number">00</span>:<span class="hljs-number">00</span>:<span class="hljs-number">06.074</span>
This is the second.
</code></pre>
<p>Save this file and name it with a <code>.vtt</code> extension. To link this file to your video, include it in a <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/track"><code>&lt;track&gt;</code></a> element:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">video</span> <span class="hljs-attr">controls</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">source</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"video.mp4"</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"video/mp4"</span> /&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">track</span>
    <span class="hljs-attr">src</span>=<span class="hljs-string">"captions.vtt"</span>
    <span class="hljs-attr">kind</span>=<span class="hljs-string">"subtitles"</span>
    <span class="hljs-attr">srclang</span>=<span class="hljs-string">"en"</span>
    <span class="hljs-attr">label</span>=<span class="hljs-string">"English"</span>
    <span class="hljs-attr">default</span>
  /&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">video</span>&gt;</span>
</code></pre>
<p>You should include the <code>&lt;track&gt;</code> element inside the <code>&lt;video&gt;</code> element and placed after all the sources. It has the following attributes:</p>
<ul>
<li><p><code>kind</code> mentions the type of file being referenced.</p>
</li>
<li><p><code>srclang</code> indicates the language the subtitles are in.</p>
</li>
<li><p><code>label</code> indicates the text that is shown while the user is selecting a language</p>
</li>
<li><p><code>src</code> is the path or URL of the subtitles file, that is the <code>.vtt</code> file we created previously.</p>
</li>
</ul>
<p>This will show subtitles for the specified timestamps. This will not only help people with hearing impairments, but is also useful for people who don’t understand the language, or those who are working in a noisy environment.</p>
<p>For people who are visually impaired, you could also include text that describes certain visuals in parts of the video. This text would be read out by screen reader.</p>
<p>You can also add custom styling to subtitle menu and subtitle text. Check out <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/Media/Guides/Audio_and_video_delivery/Adding_captions_and_subtitles_to_HTML5_video">MDN Docs - Adding captions and subtitles to HTML video</a> for the implementation.</p>
<h2 id="heading-mobile-accessibility">Mobile Accessibility</h2>
<p>We have covered many key accessibility practices so far, and they should work well on mobile phones as well. But there are some additional considerations you can follow for mobile users.</p>
<p>First, let’s talk about mouse-specific events. We have already seen how to make mouse-specific events accessible in the <a class="post-section-overview" href="#heading-javascript-practices">JavaScript Practices</a> section. Events like <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/API/Element/mousedown_event">mousedown</a> or <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/API/Element/mouseup_event">mouseup</a> are often used for drag and drop functionalities.</p>
<p>But these are not accessible for touchscreen users, so you should add the same functionality to touch-specific events like <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/API/Element/touchstart_event">touchstart</a> and <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/API/Element/touchend_event">touchend</a>. The following example is in the context of drag and drop:</p>
<pre><code class="lang-javascript">source.ontouchstart = <span class="hljs-function">(<span class="hljs-params">e</span>) =&gt;</span> {
  <span class="hljs-comment">// initiate drag</span>
};

dest.ontouchend = <span class="hljs-function">(<span class="hljs-params">e</span>) =&gt;</span> {
   <span class="hljs-comment">// drop</span>
};
</code></pre>
<p>Next, you have to ensure that you are following responsive design when designing your web pages. Responsive designs make sure the website looks good on both desktop and mobile phones. I have written a detailed guide on <a target="_blank" href="https://medium.com/gitconnected/read-this-to-make-your-website-responsive-35af4ab7992b">responsive design</a>, so check it out if you are interested.</p>
<p>Some other mobile accessibility practices that are good to know:</p>
<ul>
<li><p>Do not disable zoom on your website. Both fully-sighted users as well as those who have visual impairments may need to zoom in to read the website’s content on smaller screens.</p>
</li>
<li><p>When writing navigation menus, you’d normally conceal it and provide a hamburger icon to open it, as the screen is much shorter/smaller on a mobile phone. In these cases, the hamburger menu should be easily accessible. Check out the example of a <a target="_blank" href="https://fritz-weisshart.de/meg_men/">good hamburger menu</a> from the docs, in mobile view.</p>
</li>
<li><p>When creating forms, try to minimise the amount of typing the user needs to do, as it can get annoying for mobile users. This is especially important if your website is primarily designed for mobile users. Check out the <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Accessibility/Mobile#user_input">docs</a> for examples.</p>
</li>
</ul>
<p>Visit <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Accessibility/Mobile">MDN Docs-Mobile Accessibility</a> if you want to learn more.</p>
<h2 id="heading-testing-accessibility-with-tools">Testing Accessibility with Tools</h2>
<p>There are several tools you can use to test the accessibility of your page. <a target="_blank" href="https://developer.chrome.com/docs/lighthouse/overview">Lighthouse</a> in Chrome Developer Tools is an open source tool that analyses a web page for performance, accessibility, SEO, and more. It generates a report on how a page performs in these areas.</p>
<p>Let’s see how it helps in analysing the accessibility of a page:</p>
<p>Open Chrome Dev Tools and navigate to the Lighthouse tab. Click on “Analyse Page Load” and wait for a few seconds. It will show a report that contains info on how your web page scored on Accessibility and other metrics. It will list down any accessibility issues you may have.</p>
<p>Let’s take the following example:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>Welcome<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"image.jpg"</span> /&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">tabindex</span>=<span class="hljs-string">"2"</span>&gt;</span>Click Here<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">onclick</span>=<span class="hljs-string">"alert('Clicked!')"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"button"</span>&gt;</span>Click Me<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">form</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> /&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">form</span>&gt;</span>
</code></pre>
<p>When tested with the Lighthouse audit, it yields the following results:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1739631885589/c886f304-aba2-44ac-8d75-88fac2f60c55.png" alt="Lighthouse audit with accessibility issues" class="image--center mx-auto" width="3024" height="1794" loading="lazy"></p>
<p>As you can see, it’s scored 74 on accessibility, meaning there is room for improvement. It has also shown the accessibility issues within your HTML code, as you might have guessed looking at the code:</p>
<ul>
<li><p>Image elements do not have <code>alt</code> attribute</p>
</li>
<li><p>Form input does not have a label</p>
</li>
<li><p><code>tabindex</code> value is greater than 0.</p>
</li>
</ul>
<p>Let’s correct these issues and run the test again:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1739632090527/2db4798a-53d3-4010-9756-83de8b0f208a.png" alt="Lighthouse audit with good accessibility" class="image--center mx-auto" width="3000" height="1774" loading="lazy"></p>
<p>This time, it has scored 100 on Accessibility since we have followed all the basic practices.</p>
<p>As you can see, this is a really simple HTML page, and it’s much harder to achieve a score of 100 for large websites. But, you should aim to achieve as high a score as possible. This shouldn’t be too challenging if you make accessibility a part of your development process.</p>
<p>The accessibility score on it’s own does not mean your website is fully accessible. You also need to test the following:</p>
<ul>
<li><p>Manual testing with a screen reader (Mac’s Voiceover or Windows’ Narrator).</p>
</li>
<li><p>Keyboard accessibility – test whether each and every part of your website is keyboard accessible</p>
</li>
<li><p>Simulating your website with different color contrasts for different visual impairments.</p>
</li>
</ul>
<p>For simulating, Chrome Developer Tools provides a Rendering tool to emulate your website on different preferences, like light/dark mode, high/low color contrast, reduced motion and various visual impairments.</p>
<p>To access it, open Developer Tools, do ⌘+shift+P (Ctrl+Shift+P on Windows) and type “Rendering”. It will open the following window:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1741959781294/36f6c233-9326-4acb-a551-e95a56a87d8a.png" alt="Rendering tool" class="image--center mx-auto" width="1596" height="1484" loading="lazy"></p>
<p>If you have added media queries like the following, you can select these preferences and test whether your website behaves accordingly:</p>
<pre><code class="lang-css"><span class="hljs-keyword">@media</span> (prefers-reduced-motion) {
    * {
        <span class="hljs-attribute">animation</span>: none;
    }
}
</code></pre>
<p>So, when you select <code>prefers-reduced-motion</code>, you can test if all the animations have been disabled, and how your website functions.</p>
<p>Apart from the Developer Tools, there’s an NPM plugin called <a target="_blank" href="https://www.npmjs.com/package/eslint-plugin-jsx-a11y">eslint-plugin-jsx-a11y</a> that evaluates React JSX code for accessibility issues.</p>
<p>You can find all the code snippets on <a target="_blank" href="https://github.com/KunalN25/accessibilityguide">GitHub</a>.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Accessibility isn’t just a feature added on top of your code – it should be a part of the development process. When you make a website accessible to everyone, it not only increases your user base, but also promotes inclusivity.</p>
<p>Even though the primary benefactors of accessibility are people with disabilities, it also benefits other users by making the website easier to use overall. A lot of the practices mentioned in the article, like using semantic elements, adding the right attributes, and so on are very easy to follow and go a long way towards ensuring accessibility.</p>
<p>If you are a beginner, you have already done a great job learning about accessibility. Start including simple accessibility practices in your projects. Over time, including these practices will become a natural habit.</p>
<p>I hope this handbook becomes your go-to resource for anything related to accessibility. If you think I've missed something or need clarification on any concepts, feel free to reach out to me on Twitter. For more content on web development, check out out my profile.</p>
<h3 id="heading-references">References</h3>
<ul>
<li><p><a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/Accessibility">MDN Docs-Accessibility</a></p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/watch?v=2oiBKSjOOFE">Web Dev Simplified- Guide on Accessibility</a></p>
</li>
</ul>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Use CSS to Improve Web Accessibility ]]>
                </title>
                <description>
                    <![CDATA[ Did you know that CSS can play a significant role in web accessibility? While CSS primarily handles the visual presentation of a webpage, when you use it properly it can enhance the user’s experience and improve accessibility. In this article, I'll s... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-use-css-to-improve-web-accessibility/</link>
                <guid isPermaLink="false">66eb0a282e5bd4267b92ca10</guid>
                
                    <category>
                        <![CDATA[ CSS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ frontend ]]>
                    </category>
                
                    <category>
                        <![CDATA[ a11y ]]>
                    </category>
                
                    <category>
                        <![CDATA[ webdev ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Design ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Elizabeth Lola ]]>
                </dc:creator>
                <pubDate>Wed, 18 Sep 2024 17:13:12 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1726577970240/02631676-6492-4b83-a057-b9c2048709ee.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Did you know that CSS can play a significant role in web accessibility? While CSS primarily handles the visual presentation of a webpage, when you use it properly it can enhance the user’s experience and improve accessibility.</p>
<p>In this article, I'll share some ways CSS can support accessibility so you can start using these techniques in your own projects.</p>
<h2 id="heading-prerequisites"><strong>Prerequisites</strong></h2>
<p>To follow along with this tutorial, you should have a basic understanding of HTML, CSS, and a little bit of Javascript.</p>
<h2 id="heading-update-focus-styles">Update Focus Styles</h2>
<p>The browser provides default focus styles for interactive elements like buttons or input fields. But sometimes these default focus styles might not be ideal for your design system – especially if the colors used in your design are too close to the default colors. This might make it difficult to notice.</p>
<p>Also, different browsers have different default focus styles and you might want to standardize the focus styles to ensure uniformity.</p>
<p>You can change the default focus style of an element in CSS using the <code>:focus</code> pseudo-class. For example, the default focus style for an input element is a blue outline in Chrome and a blue outline with outline offset in Firefox, to update the default focus styles of an input element you can do this:</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">input</span><span class="hljs-selector-pseudo">:focus</span> {
  <span class="hljs-attribute">outline</span>: <span class="hljs-number">2px</span> solid <span class="hljs-number">#007BFF</span>;
  <span class="hljs-attribute">outline-offset</span>: <span class="hljs-number">2px</span>;
  <span class="hljs-attribute">border-radius</span>: <span class="hljs-number">1rem</span>;
}
</code></pre>
<h2 id="heading-avoid-content-shifts">Avoid Content Shifts</h2>
<p>Content shifts can happen when you’re lazy loading images, where images load progressively as the user scrolls down the page. Sometimes the image pushes the content around it downwards, shifting the text you're reading out of place.</p>
<p>Content shifts can also happen during dynamic content fetching, especially when new content like text, images, or ads is added to the page without reserving space for it in advance.</p>
<p>Content shifts can be frustrating, especially for users:</p>
<ul>
<li><p>With cognitive disabilities who may lose track of where they are in the content.</p>
</li>
<li><p>Using screen magnifiers, where the shift can cause them to lose their zoomed-in focus.</p>
</li>
<li><p>Navigating with a keyboard, as it can mess up the natural tab order and make navigation confusing.</p>
</li>
</ul>
<p>You can pre-allocate space for content to prevent shifts by using the <code>min-height</code> or <code>aspect-ratio</code> properties. Here's how you can allocate space for an image to prevent content shift before the image has fully loaded.</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">img</span> {
    <span class="hljs-attribute">width</span>: <span class="hljs-number">100%</span>;
    <span class="hljs-attribute">height</span>: auto;
    <span class="hljs-attribute">aspect-ratio</span>: <span class="hljs-number">16</span>/<span class="hljs-number">9</span>;
    <span class="hljs-attribute">object-fit</span>: cover; <span class="hljs-comment">/* Ensures the image fits well within the allocated space */</span>
}
</code></pre>
<p>You can also use animations or transitions when dynamically loading content to add smooth transitions for new content. So, instead of a sudden shift, the content slides in gracefully, reducing the perception of disruption.</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.new-content</span> {
    <span class="hljs-attribute">transition</span>: margin <span class="hljs-number">0.3s</span> ease-in-out, opacity <span class="hljs-number">0.3s</span> ease-in-out;
}
</code></pre>
<h2 id="heading-reduce-motion">Reduce Motion</h2>
<p>Rapid animations or really complex transitions can be disorienting for users with motion sensitivity, which could lead to discomfort like headaches, dizziness, or vertigo (for users with vestibular disorders).</p>
<p>You can use CSS’s <code>prefers-reduced-motion</code> media query to reduce or disable animations for users.</p>
<p>Personally, instead of disabling animations completely, I replace complex, distracting animations with more subtle ones to maintain functionality while respecting user preferences.</p>
<p>Here's how to use <code>prefers-reduced-motion</code> to create a simpler animation:</p>
<pre><code class="lang-css"><span class="hljs-comment">/* Default animation */</span>
<span class="hljs-keyword">@keyframes</span> complexAnimation {
    0% { <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">translateX</span>(<span class="hljs-number">0</span>); <span class="hljs-attribute">opacity</span>: <span class="hljs-number">0</span>; }
    50% { <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">translateX</span>(<span class="hljs-number">100px</span>); <span class="hljs-attribute">opacity</span>: <span class="hljs-number">0.5</span>; }
    100% { <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">translateX</span>(<span class="hljs-number">0</span>); <span class="hljs-attribute">opacity</span>: <span class="hljs-number">1</span>; }
}

<span class="hljs-selector-class">.element</span> {
    <span class="hljs-attribute">animation</span>: complexAnimation <span class="hljs-number">2s</span> ease-in-out;
}

<span class="hljs-comment">/* Simpler animation for reduced motion preference */</span>
<span class="hljs-keyword">@media</span> (<span class="hljs-attribute">prefers-reduced-motion:</span> reduce) {
    <span class="hljs-keyword">@keyframes</span> simpleAnimation {
        0% { <span class="hljs-attribute">opacity</span>: <span class="hljs-number">0</span>; }
        100% { <span class="hljs-attribute">opacity</span>: <span class="hljs-number">1</span>; }
    }

    <span class="hljs-selector-class">.element</span> {
        <span class="hljs-attribute">animation</span>: simpleAnimation <span class="hljs-number">1s</span> ease-in-out;
    }
}
</code></pre>
<p>Here’s an example from the code above. If you have reduced motion enabled you’ll see a fading ball instead of a moving ball:</p>
<div class="embed-wrapper">
        <iframe width="100%" height="350" src="https://codepen.io/leezee/embed/preview/PorrrQW?default-tab=result&amp;editable=true" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="CodePen embed" scrolling="no" allowtransparency="true" allowfullscreen="true" loading="lazy"></iframe></div>
<p> </p>
<p><strong>Note</strong>: If you want to see the reduced motion in action, you can enable it in the <a target="_blank" href="https://developer.chrome.com/docs/devtools/rendering">rendering tab on Google Chrome</a>.</p>
<h2 id="heading-focus-within-for-nested-elements">Focus Within for Nested Elements</h2>
<p>You can highlight or style a parent element when any of its child elements receive focus to make it clear which group (like form inputs or dropdown menus) is currently being interacted with.</p>
<p>To do this, you can use CSS’s <code>:focus-within</code> pseudo-class which is used to style an element when any of its descendants receive focus either through keyboard navigation or user interaction.</p>
<p>For example, to highlight a fieldset when any item in the group is focused in a grouped control, you can do this:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">style</span>&gt;</span><span class="css">
 <span class="hljs-selector-tag">fieldset</span> {
   <span class="hljs-attribute">padding</span>: <span class="hljs-number">10px</span>;
   <span class="hljs-attribute">border</span>: <span class="hljs-number">1px</span> solid <span class="hljs-number">#ccc</span>;
 }

 <span class="hljs-selector-tag">fieldset</span><span class="hljs-selector-pseudo">:focus-within</span> {
   <span class="hljs-attribute">border-color</span>: <span class="hljs-number">#007BFF</span>; <span class="hljs-comment">/* highlight the fieldset when a user focuses on any input */</span>
 }
</span><span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">fieldset</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">legend</span>&gt;</span>Choose a color:<span class="hljs-tag">&lt;/<span class="hljs-name">legend</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">label</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"radio"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"color"</span> <span class="hljs-attr">value</span>=<span class="hljs-string">"red"</span>&gt;</span> Red<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">label</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"radio"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"color"</span> <span class="hljs-attr">value</span>=<span class="hljs-string">"green"</span>&gt;</span> Green<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">label</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"radio"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"color"</span> <span class="hljs-attr">value</span>=<span class="hljs-string">"blue"</span>&gt;</span> Blue<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">fieldset</span>&gt;</span>
</code></pre>
<h2 id="heading-customize-contrast-options">Customize Contrast Options</h2>
<p>Sometimes you may be working on a design that uses lots of colors and might not maintain high contrast between text and background to fit an aesthetic. Or perhaps you're working on a design with lots of bright colors. In these cases, you should consider how your application renders for different users.</p>
<p>Some users with low vision or certain types of color blindness might need high contrast mode to differentiate text from the background more clearly. Other users sensitive to bright colors might prefer a softer, less jarring visual experience.</p>
<p>Some of these users might have their systems set to high or low contrast to help improve their experience. To customize their experience, you can use the CSS <code>prefers-contrast</code> media query.</p>
<p>The <code>prefers-contrast</code> media query allows you to tailor the contrast of your website or application based on the user's system settings.</p>
<p>Here's an example of using <code>prefers-contrast</code>:</p>
<pre><code class="lang-css"><span class="hljs-comment">/* default styling preference */</span>
<span class="hljs-selector-tag">body</span> {
    <span class="hljs-attribute">background-color</span>: white;
    <span class="hljs-attribute">color</span>: black;
}

<span class="hljs-comment">/* high contrast preference */</span>
<span class="hljs-keyword">@media</span> (<span class="hljs-attribute">prefers-contrast:</span> more) {
    <span class="hljs-selector-tag">body</span> {
        <span class="hljs-attribute">background-color</span>: black;
        <span class="hljs-attribute">color</span>: white;
    }
    <span class="hljs-selector-tag">a</span> {
        <span class="hljs-attribute">color</span>: yellow;
    }
}
<span class="hljs-comment">/* low contrast preference */</span>

<span class="hljs-keyword">@media</span> (<span class="hljs-attribute">prefers-contrast:</span> less) {
    <span class="hljs-selector-tag">body</span> {
        <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#f0f0f0</span>;
        <span class="hljs-attribute">color</span>: <span class="hljs-number">#333</span>;
    }
    <span class="hljs-selector-tag">a</span> {
        <span class="hljs-attribute">color</span>: <span class="hljs-number">#555</span>;
    }
}
</code></pre>
<div class="embed-wrapper">
        <iframe width="100%" height="350" src="https://codepen.io/leezee/embed/preview/dyBBxgV?default-tab=result&amp;editable=true" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="CodePen embed" scrolling="no" allowtransparency="true" allowfullscreen="true" loading="lazy"></iframe></div>
<p> </p>
<p>In the example above, the <code>prefers-contrast: more</code> option ensures that when a user prefers high contrast, the background is black and the text is white, with yellow links for better visibility.</p>
<p>The <code>prefers-contrast: less</code> adjusts the color scheme to a softer color for users who prefer less contrast. The default style is used if the user has no specific contrast preference or if their preference is not detected.</p>
<p><strong>Note</strong>: If your design uses minimal colors and maintains high contrast between text and background or you're working with a design where text is minimal and the focus is on visual content (like image galleries or video players), you might not need <code>prefers-contrast</code> as much. But it's still good practice to consider contrasts.</p>
<h2 id="heading-enable-dark-mode">Enable Dark Mode</h2>
<p>You can use CSS to accommodate users’ preferences for dark or light modes. You can achieve this through the CSS <code>prefers-color-scheme</code> media query. The browser can detect the user's color preference and apply the style if provided in CSS.</p>
<p>Here's an example of how you can add a dark mode style to your site using CSS variables:</p>
<pre><code class="lang-css"><span class="hljs-selector-pseudo">:root</span> {
  <span class="hljs-attribute">--background-color</span>: <span class="hljs-number">#ffffff</span>;
  <span class="hljs-attribute">--text-color</span>: <span class="hljs-number">#000000</span>;
}

<span class="hljs-keyword">@media</span> (<span class="hljs-attribute">prefers-color-scheme:</span> dark) {
  <span class="hljs-selector-pseudo">:root</span> {
    <span class="hljs-attribute">--background-color</span>: <span class="hljs-number">#000000</span>;
    <span class="hljs-attribute">--text-color</span>: <span class="hljs-number">#ffffff</span>;
  }
}

<span class="hljs-selector-tag">body</span> {
  <span class="hljs-attribute">background-color</span>: <span class="hljs-built_in">var</span>(--background-color);
  <span class="hljs-attribute">color</span>: <span class="hljs-built_in">var</span>(--text-color);
}
</code></pre>
<p>In the example above, the variables get updated if the browser detects a dark color scheme preference.</p>
<p>If you want to allow users to toggle between modes manually, you can use JavaScript for this:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">style</span>&gt;</span><span class="css">
 <span class="hljs-comment">/* Default light mode styles */</span>
  <span class="hljs-selector-tag">body</span> {
   <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#ffffff</span>;
   <span class="hljs-attribute">color</span>: <span class="hljs-number">#000000</span>;
  }
 <span class="hljs-comment">/* Dark mode styles */</span>
  <span class="hljs-selector-tag">body</span><span class="hljs-selector-class">.dark-mode</span> {
   <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#000000</span>;
   <span class="hljs-attribute">color</span>: <span class="hljs-number">#ffffff</span>;
  }
</span><span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"toggle-theme"</span>&gt;</span>Toggle Theme<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript">
  <span class="hljs-keyword">const</span> toggleButton = <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'toggle-theme'</span>);
  toggleButton.addEventListener(<span class="hljs-string">'click'</span>, <span class="hljs-function">() =&gt;</span> {
   <span class="hljs-built_in">document</span>.body.classList.toggle(<span class="hljs-string">'dark-mode'</span>);
  });
</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
</code></pre>
<h2 id="heading-use-rem-units-for-responsive-typography">Use <code>rem</code> Units for Responsive Typography</h2>
<p>Using <code>rem</code> units for responsive typography can help enhance accessibility to adapt more dynamically to a user's preference. Since <code>rem</code> is relative to the root font size (typically set by the browser or user), it scales with changes in the base font size. This helps ensure that text remains readable without breaking layouts.</p>
<p>Users can set a preferred font size in their browser or operating system for better readability. When you use <code>rem</code>, the website content scales according to this setting which ensures that the text is not too small or too large for the users (which can happen when using fixed units like <code>px</code>).</p>
<p>When users zoom in using browser settings or increase their preferred text size, the <code>rem</code>-based text will scale appropriately.</p>
<p>The default root font size (usually 16px) is typically inherited from the browser, but you can set it explicitly if needed:</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">html</span> {
  <span class="hljs-attribute">font-size</span>: <span class="hljs-number">100%</span>; <span class="hljs-comment">/* Default 16px */</span>
}
</code></pre>
<p>After setting the root font size, you can use <code>rem</code> unit for the rest of your content. For example:</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">h1</span> {
  <span class="hljs-attribute">font-size</span>: <span class="hljs-number">2.5rem</span>; <span class="hljs-comment">/* Equivalent to 40px if root is 16px */</span>
}

<span class="hljs-selector-tag">p</span> {
  <span class="hljs-attribute">font-size</span>: <span class="hljs-number">1rem</span>; <span class="hljs-comment">/* Equivalent to 16px */</span>
}
</code></pre>
<h2 id="heading-use-animations-to-enhance-ux">Use Animations to Enhance UX</h2>
<p>CSS animations can enhance accessibility when used thoughtfully. They can help create an engaging and understandable experience for users.</p>
<p>Here are some ways that animations can help improve accessibility:</p>
<ul>
<li><p>You can use animations to indicate loading state to visually communicate to users that the system is working on a task.</p>
</li>
<li><p>Using animated text effects, like fades or scaling on headlines or important sections, can help guide users' eyes to important content. This can be useful for people with cognitive disabilities who benefit from clear visual hierarchies.</p>
</li>
<li><p>Subtle transitions for state change instead of having abrupt changes (like a modal popping up instantly) can create smoother transitions between different interface states.</p>
</li>
<li><p>Using animated highlights or shaking effects on form fields can provide visual feedback to users about input errors. You should pair these animations with labels or ARIA attributes to make it clear what the user needs to correct.</p>
</li>
<li><p>Animations can help users track focus, especially keyboard users or those with visual impairments. CSS transitions that highlight focused elements (for example by enlarging buttons or changing the border) assist users in understanding where they are within the page.</p>
</li>
</ul>
<h3 id="heading-best-practices">Best Practices:</h3>
<ul>
<li><p>Ensure animations are used purposefully, not just for aesthetic reasons.</p>
</li>
<li><p>Avoid overly long or continuous animations that can distract or annoy users.</p>
</li>
<li><p>Combine animations with other accessible features, such as screen reader announcements, to ensure all users understand content changes.</p>
</li>
</ul>
<h2 id="heading-conclusion">Conclusion</h2>
<p>When considering accessibility, well-structured HTML forms the foundation of an accessible page – but CSS also plays a vital role in enhancing that structure.</p>
<p>CSS alone cannot fix poorly structured HTML. But when it’s applied thoughtfully to a solid foundation, it ensures a more inclusive and engaging experience by improving visual hierarchy, readability, and interaction for users of all abilities.</p>
<p>Combining accessible HTML with CSS not only improves the user interface but also provides support for assistive technologies.</p>
<p>Thank you so much for reading this article. If you found it helpful, consider sharing. Happy coding!</p>
<p>You can connect with me on <a target="_blank" href="https://www.linkedin.com/in/elizabeth-meshioye/">LinkedIn</a>.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Use HTML Attributes to Make Your Websites and Apps More Accessible ]]>
                </title>
                <description>
                    <![CDATA[ Have you ever used an attribute in HTML without fully understanding its purpose? You're not alone! Over time, I've dug into the meaning behind many HTML attributes, especially those that are crucial for accessibility. In this in-depth tutorial, I'll ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-use-html-attributes-to-make-your-websites-and-apps-more-accessible/</link>
                <guid isPermaLink="false">66db603bf7f8b7688af503af</guid>
                
                    <category>
                        <![CDATA[ HTML ]]>
                    </category>
                
                    <category>
                        <![CDATA[ a11y ]]>
                    </category>
                
                    <category>
                        <![CDATA[ aria ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Accessibility ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Elizabeth Lola ]]>
                </dc:creator>
                <pubDate>Fri, 06 Sep 2024 20:04:11 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1725281991044/7edb0d70-c31e-4a41-bc24-232c75d0fae3.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Have you ever used an attribute in HTML without fully understanding its purpose? You're not alone! Over time, I've dug into the meaning behind many HTML attributes, especially those that are crucial for accessibility.</p>
<p>In this in-depth tutorial, I'll break down some key HTML attributes that enhance accessibility, explaining what they do, and when to use them effectively.</p>
<h2 id="heading-prerequisites">Prerequisites</h2>
<p>To follow along with this tutorial, you should have a basic understanding of HTML and a little bit of Javascript knowledge as well.</p>
<h2 id="heading-table-of-contents">Table of Contents</h2>
<ol>
<li><p><a class="post-section-overview" href="#heading-what-are-aria-attributes">What are ARIA Attributes?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-the-alt-attribute">The <code>alt</code> Attribute</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-the-aria-label-attribute">The <code>aria-label</code> Attribute</a></p>
<ul>
<li><a class="post-section-overview" href="#heading-best-practices-for-using-aria-label">Best practices for Using <code>aria-label</code></a></li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-the-aria-labelledby-attribute">The <code>aria-labelledby</code> Attribute</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-how-is-aria-label-different-from-aria-labelledby">How is <code>aria-label</code> Different from <code>aria-labelledby</code>?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-best-practices-for-using-aria-labelledby">Best Practices for Using <code>aria-labelledby</code></a></p>
</li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-the-aria-describedby-attribute">The <code>aria-describedby</code> Attribute</a></p>
<ul>
<li><a class="post-section-overview" href="#heading-best-practices-for-using-aria-describedby">Best Pracices for Using <code>aria-describedby</code></a></li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-the-role-attribute">The <code>role</code> Attribute</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-common-role-values">Common <code>role</code> Values</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-best-practices-for-using-the-role-attribute">Best Practices for Using the <code>role</code> Attribute</a></p>
</li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-the-aria-controls-attribute">The <code>aria-controls</code> Attribute</a></p>
<ul>
<li><a class="post-section-overview" href="#heading-best-practices-for-using-aria-controls">Best Practices for Using <code>aria-controls</code></a></li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-the-aria-selected-attribute">The <code>aria-selected</code> Attribute</a></p>
<ul>
<li><a class="post-section-overview" href="#heading-best-practices-for-using-aria-selected">Best Practices for Using <code>aria-selected</code></a></li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-the-tabindex-attribute">The <code>tabindex</code> Attribute</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-possible-tabindex-values">Possible <code>tabindex</code> Values</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-best-practices-for-using-tabindex">Best Practices for Using <code>tabindex</code></a></p>
</li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-the-title-attribute">The <code>title</code> Attribute</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-accessibility-concerns-with-the-title-attribute">Accessibility Concerns with <code>title</code></a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-best-practices-for-using-the-title-attribute">Best Practices for Using the <code>title</code> Attribute</a></p>
</li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-using-the-for-attribute-in-label">Using the <code>for</code> Attribute in <code>label</code></a></p>
<ul>
<li><a class="post-section-overview" href="#heading-best-practices-for-using-the-for-attribute">Best Practices for Using the <code>for</code> Attribute</a></li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-the-scope-attribute">The <code>scope</code> Attribute</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-possible-scope-values">Possible <code>scope</code> Values</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-best-practices-for-using-the-scope-attribute">Best Practices for Using <code>scope</code></a></p>
</li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-the-aria-hidden-attribute">The <code>aria-hidden</code> Attribute</a></p>
<ul>
<li><a class="post-section-overview" href="#heading-best-practices-for-using-aria-hidden">Best Practices for Using <code>aria-hidden</code></a></li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-the-inert-attribute">The <code>inert</code> Attribute</a></p>
<ul>
<li><a class="post-section-overview" href="#heading-best-practices-for-using-the-inert-attribute">Best Practices for Using <code>inert</code></a></li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-the-aria-live-attribute">The <code>aria-live</code> Attribute</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-possible-values-for-aria-live">Possible Values for <code>aria-live</code></a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-best-practices-for-using-aria-live">Best Practices for Using <code>aria-live</code></a></p>
</li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-the-aria-roledescription-attribute">The <code>aria-roledescription</code> Attribute</a></p>
<ul>
<li><a class="post-section-overview" href="#heading-best-practices-for-using-aria-roledescription">Best Practices for Using <code>aria-roledescription</code></a></li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-the-aria-atomic-attribute">The <code>aria-atomic</code> Attribute</a></p>
<ul>
<li><a class="post-section-overview" href="#heading-the-aria-atomic-attribute">Best Practices for Using <code>aria-atomic</code></a></li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-conclusion">Conclusion</a></p>
</li>
</ol>
<h2 id="heading-what-are-aria-attributes">What Are ARIA Attributes?</h2>
<p>Most of the attributes listed in this article are ARIA attributes. ARIA, which stands for <strong>Accessible Rich Internet Applications</strong>, is a set of attributes defined by the W3C (World Wide Web Consortium) to enhance the accessibility of web applications.</p>
<p>ARIA attributes provide additional information to assistive technologies like screen readers. Using them correctly can make complex web applications more accessible to individuals with visual, auditory, or motor impairments.</p>
<p>One key principle of using ARIA is that sometimes it's best not to use it. Although this might seem contradictory, you should only ARIA attributes when necessary. Overusing ARIA can disrupt the experience for users relying on assistive technologies. While sighted users might not notice any issues, excessive or improper use of ARIA can negatively impact accessibility.</p>
<h2 id="heading-the-alt-attribute">The <code>alt</code> Attribute</h2>
<p>The <code>alt</code> attribute likely isn't new to you if you've used HTML images. You use it to provide <em>alternative</em> text that displays when an image isn't properly shown on the screen.</p>
<p>But the most important use of the <code>alt</code> attribute is for accessibility. If the <code>alt</code> attribute is not present in an image element, then a screen reader may announce the name of the image file or the URL of the image instead of explaining what it's showing. This can be unhelpful and we don't want that.</p>
<p>The content in the <code>alt</code> attribute should be concise because its primary purpose is to briefly describe an image for those who cannot see it. This includes users who rely on screen readers, search engines, and users with slow internet connections where images may not load. If the <code>alt</code> text is too long, it may include unnecessary details that don't add value to the user's understanding.</p>
<p>The <code>alt</code> attribute is different from an image caption. Captions are visible and can provide more context or additional information about an image. Using a caption as <code>alt</code> text can make it too long and redundant.</p>
<p>If the image is purely decorative, then the alt attribute should be left empty. If an image has an empty alt attribute, an assistive tool will skip it. This is important to help keep users focused on the content and not distract them with unnecessary information.</p>
<p>Here's an example of how you can use the alt attribute:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Lions are remarkable for their powerful roars, 
which can be heard up to five miles away. 
These roars are used to communicate with other 
members of the pride, as well as to ward off rival lions and intruders. 
Although lions are often associated with the African savannah, 
a small population of Asiatic lions still exists in India's Gir Forest, 
making them one of the world's most endangered big cats.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"lion.jpg"</span> <span class="hljs-attr">alt</span>=<span class="hljs-string">"a lion"</span> /&gt;</span> <span class="hljs-comment">&lt;!-- brief and gives context to the paragraph --&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"background-stars.png"</span> <span class="hljs-attr">alt</span>=<span class="hljs-string">""</span> /&gt;</span> <span class="hljs-comment">&lt;!-- This image is purely for 
decoration so it's left empty --&gt;</span>
</code></pre>
<h2 id="heading-the-aria-label-attribute">The <code>aria-label</code> Attribute</h2>
<p>The <code>aria-label</code> attribute is used to provide an accessible name to an element that might not have visible text. A common example of this is a button that contains an image or SVG.</p>
<p>A lot of elements have an accessible name – the accessible name is the content inside the element. The accessible name for the heading in this example is "Frequently Asked Questions"</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>Frequently Asked Questions<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
</code></pre>
<p>Everyone, including people using assistive technology, would clearly understand the meaning of the example above because it contains visible content.</p>
<p>But in the example below, a user relying on a screen reader might miss the content in the button if it doesn't have an <code>aria-label</code>. This is because the content in the button is an SVG and the SVG does not contain any visible content:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">aria-label</span>=<span class="hljs-string">"Search"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">svg</span>
      <span class="hljs-attr">fill</span>=<span class="hljs-string">"#000000"</span> 
      <span class="hljs-attr">height</span>=<span class="hljs-string">"20px"</span>
      <span class="hljs-attr">width</span>=<span class="hljs-string">"20px"</span>
      <span class="hljs-attr">xmlns</span>=<span class="hljs-string">"http://www.w3.org/2000/svg"</span> 
      <span class="hljs-attr">viewBox</span>=<span class="hljs-string">"0 0 488.4 488.4"</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">g</span> <span class="hljs-attr">stroke-width</span>=<span class="hljs-string">"0"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">g</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">g</span> <span class="hljs-attr">stroke-linecap</span>=<span class="hljs-string">"round"</span> <span class="hljs-attr">stroke-linejoin</span>=<span class="hljs-string">"round"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">g</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">g</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">g</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">g</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">path</span> <span class="hljs-attr">d</span>=<span class="hljs-string">"M0,203.25c0,112.1,91.2,203.2,203.2,203.2c51.6,0,98.8-19.4,134.7-51.2l129.5,129.5c2.4,2.4,5.5,3.6,8.7,3.6 s6.3-1.2,8.7-3.6c4.8-4.8,4.8-12.5,0-17.3l-129.6-129.5c31.8-35.9,51.2-83,51.2-134.7c0-112.1-91.2-203.2-203.2-203.2 S0,91.15,0,203.25z M381.9,203.25c0,98.5-80.2,178.7-178.7,178.7s-178.7-80.2-178.7-178.7s80.2-178.7,178.7-178.7 S381.9,104.65,381.9,203.25z"</span> /&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">g</span>&gt;</span> 
        <span class="hljs-tag">&lt;/<span class="hljs-name">g</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">g</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">svg</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
</code></pre>
<p>Do not overuse the <code>aria-label</code>. Not all content needs an <code>aria-label</code> – for example, if you have a button that contains an image with <code>alt</code>, or an SVG with a <code>title</code>, then those attributes act as the accessible name for that element.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">button</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"search-icon.png"</span> <span class="hljs-attr">alt</span>=<span class="hljs-string">"Search"</span> /&gt;</span> <span class="hljs-comment">&lt;!-- no need for aria-label --&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>

<span class="hljs-comment">&lt;!-- Another example --&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">button</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">svg</span>
    <span class="hljs-attr">fill</span>=<span class="hljs-string">"#000000"</span>
    <span class="hljs-attr">height</span>=<span class="hljs-string">"20px"</span>
    <span class="hljs-attr">width</span>=<span class="hljs-string">"20px"</span>
    <span class="hljs-attr">role</span>=<span class="hljs-string">"image"</span>
    <span class="hljs-attr">xmlns</span>=<span class="hljs-string">"http://www.w3.org/2000/svg"</span>
    <span class="hljs-attr">viewBox</span>=<span class="hljs-string">"0 0 488.4 488.4"</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>Search Icon<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span> <span class="hljs-comment">&lt;!-- Accessible name --&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">g</span> <span class="hljs-attr">stroke-width</span>=<span class="hljs-string">"0"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">g</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">g</span> <span class="hljs-attr">stroke-linecap</span>=<span class="hljs-string">"round"</span> <span class="hljs-attr">stroke-linejoin</span>=<span class="hljs-string">"round"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">g</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">g</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">g</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">g</span>&gt;</span>
         <span class="hljs-tag">&lt;<span class="hljs-name">path</span> <span class="hljs-attr">d</span>=<span class="hljs-string">"M0,203.25c0,112.1,91.2,203.2,203.2,203.2c51.6,0,98.8-19.4,134.7-51.2l129.5,129.5c2.4,2.4,5.5,3.6,8.7,3.6 s6.3-1.2,8.7-3.6c4.8-4.8,4.8-12.5,0-17.3l-129.6-129.5c31.8-35.9,51.2-83,51.2-134.7c0-112.1-91.2-203.2-203.2-203.2 S0,91.15,0,203.25z M381.9,203.25c0,98.5-80.2,178.7-178.7,178.7s-178.7-80.2-178.7-178.7s80.2-178.7,178.7-178.7 S381.9,104.65,381.9,203.25z"</span> /&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">g</span>&gt;</span> 
        <span class="hljs-tag">&lt;<span class="hljs-name">g</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">g</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">svg</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
</code></pre>
<p>You should use the <code>aria-label</code> sparingly and appropriately. Overusing the attribute can lead to several issues:</p>
<ul>
<li><p>The <code>aria-label</code> content is not visible to sighted users. If a user with a cognitive disability is using a screen reader for support, they might not understand why they’re hearing different information from what they see on the screen.</p>
</li>
<li><p>Using <code>aria-label</code> extensively across a large codebase can make the HTML harder to maintain. You may struggle to track where labels are coming from, especially if they’re set programmatically or in multiple places.</p>
</li>
</ul>
<h3 id="heading-best-practices-for-using-aria-label">Best Practices for Using <code>aria-label</code></h3>
<ul>
<li><p>Whenever possible, use visible text labels. They’re easier to understand and maintain, and they ensure consistent experiences for all users.</p>
</li>
<li><p>When Possible: If there is already a visible label on the page, use <code>aria-labelledby</code> to link the element to the existing text instead of creating a new label with <code>aria-label</code> (we'll talk about this below).</p>
</li>
<li><p>If you use <code>aria-label</code>, keep the text short and to the point. It should describe the element’s purpose in as few words as possible.</p>
</li>
</ul>
<h2 id="heading-the-aria-labelledby-attribute">The <code>aria-labelledby</code> Attribute</h2>
<p>The <code>aria-labelledby</code> attribute is used to associate an element with another element that serves as its label. It links the target element to one or more other elements on the page that contain the text that should be used as the label.</p>
<p>You can use this attribute when there is already a visible text label or when the label needs to be composed of multiple text elements.</p>
<p>For example, you can use <code>aria-labelledby</code> in a <code>&lt;section&gt;</code> element to associate it with a heading or other text that serves as a label for the entire section.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">h2</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"about-heading"</span>&gt;</span>About Us<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span> 
<span class="hljs-tag">&lt;<span class="hljs-name">section</span> <span class="hljs-attr">aria-labelledby</span>=<span class="hljs-string">"about-heading"</span>&gt;</span> <span class="hljs-comment">&lt;!-- use the id of the h2 --&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>We are a company dedicated to providing excellent service...<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">section</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">h2</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"services-heading"</span>&gt;</span>Our Services<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">section</span> <span class="hljs-attr">aria-labelledby</span>=<span class="hljs-string">"services-heading"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>We offer a wide range of services including...<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">section</span>&gt;</span>
</code></pre>
<p>Sometimes, you might want to combine multiple pieces of text as the label. You can do this by listing multiple IDs in the <code>aria-labelledby</code> attribute:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">h1</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"dialog-title"</span>&gt;</span>Confirmation Required<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">p</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"dialog-description"</span>&gt;</span>Are you sure you want to delete this item?<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">aria-labelledby</span>=<span class="hljs-string">"dialog-title dialog-description"</span>&gt;</span>Yes<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
</code></pre>
<p>The <code>aria-labelledby</code> is similar to the <code>aria-label</code> in that its purpose is to provide an accessible element.</p>
<h3 id="heading-how-is-aria-label-different-from-aria-labelledby">How is <code>aria-label</code> Different from <code>aria-labelledby</code>?</h3>
<p><code>aria-label</code> directly assigns a string of text as a label for an element. This text is not visible on the screen but is announced by assistive technologies like screen readers. It’s typically used when there is no visible text label.</p>
<p><code>aria-labelledby</code> points to one or more existing elements on the page (using their <code>id</code> attributes) that should be used as the label for the element. The label text is visible to all users because it’s part of the content of another element.</p>
<h3 id="heading-best-practices-for-using-aria-labelledby">Best Practices for Using <code>aria-labelledby</code></h3>
<ul>
<li><p>Use <code>aria-labelledby</code> over <code>aria-label</code> when there is already text on the page that can serve as the label. This reduces redundancy and ensures that both sighted users and screen reader users see the same content.</p>
</li>
<li><p>The <code>id</code> attributes referenced by <code>aria-labelledby</code> must be unique on the page and correctly point to existing elements. If the ID is missing or incorrect, the label won’t work, leading to accessibility issues.</p>
</li>
<li><p>When combining multiple labels, ensure that the resulting label makes sense when read together. The order of IDs in <code>aria-labelledby</code> matters, as screen readers will read the labels in the order they are listed.</p>
</li>
<li><p>Like <code>aria-label</code>, avoid overusing <code>aria-labelledby</code> in situations where a simpler approach (like using a visible <code>label</code> element directly) would suffice. This helps keep the code maintainable and reduces the cognitive load for users.</p>
</li>
</ul>
<h2 id="heading-the-aria-describedby-attribute">The <code>aria-describedby</code> Attribute</h2>
<p>The <code>aria-describedby</code> attribute is used to associate an element with one or more elements that provide additional descriptive information about it. The <code>aria-describedby</code> attribute is used to provide additional context or instructions to an element.</p>
<p>Unlike <code>aria-labelledby</code>, which is meant to provide a label or name, <code>aria-describedby</code> is intended to give users more detailed information or context about an element, often to supplement what they already know from the label.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"full-name"</span>&gt;</span>Full name<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> <span class="hljs-attr">aria-labelledby</span>=<span class="hljs-string">"full-name"</span> <span class="hljs-attr">aria-describedby</span>=<span class="hljs-string">"info"</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">span</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"info"</span>&gt;</span>Enter your full name.<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>
</code></pre>
<p>When both <code>aria-labelledby</code> and <code>aria-describedby</code> are used on the same element, screen readers will first announce the label (from <code>aria-labelledby</code>), then the role of the element (for example, "button"), and finally the description (from <code>aria-describedby</code>).</p>
<h3 id="heading-best-practices-for-using-aria-describedby">Best Practices for Using <code>aria-describedby</code></h3>
<ul>
<li><p>Apply <code>aria-describedby</code> when you need to provide users with additional context or instructions that go beyond the label. This is particularly useful for forms, complex controls, or any element that might require clarification.</p>
</li>
<li><p>While <code>aria-describedby</code> is meant for more detailed descriptions, avoid overly long text. Keep the description focused on what the user needs to know to interact with the element effectively.</p>
</li>
<li><p>Just like with <code>aria-labelledby</code>, ensure that the elements referenced by <code>aria-describedby</code> have unique and relevant <code>id</code> attributes. The content of these elements should be directly relevant to the element they describe.</p>
</li>
</ul>
<h2 id="heading-the-role-attribute">The <code>role</code> Attribute</h2>
<p>The role attribute is used to specify the role of an element. You can use it to override the default role of a semantic element. It helps assistive technologies understand how an element should be interpreted or interacted with.</p>
<p>When using non-semantic elements (like <code>&lt;div&gt;</code> or <code>&lt;span&gt;</code>) to create interactive controls (buttons, dialogs, tabs, and so on), the <code>role</code> attribute informs assistive technologies of the element’s intended behavior. You can also use the role to define landmark roles that assist in navigation, such as <code>banner</code> or <code>complementary</code>, which defines the structure of the page for screen reader users.</p>
<h3 id="heading-common-role-values">Common <code>role</code> Values</h3>
<p>Roles for Landmark Regions:</p>
<ul>
<li><p><code>banner</code>: Represents the site header.</p>
</li>
<li><p><code>navigation</code>: Defines a navigation section of the page, often for site or page navigation links.</p>
</li>
<li><p><code>main</code>: Marks the main content of a document, distinct from sidebars, footers, and so on.</p>
</li>
<li><p><code>contentinfo</code>: Represents the footer information.</p>
</li>
</ul>
<p>This example below is just for demonstration purposes – you should use the right semantic element when possible:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"banner"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>My Website<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"navigation"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">ul</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"#home"</span>&gt;</span>Home<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"#about"</span>&gt;</span>About<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"main"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>Welcome to My Website<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Here is some main content...<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"contentinfo"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span><span class="hljs-symbol">&amp;copy;</span> 2024 My Website<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>Roles for Widgets and Interactive Elements:</p>
<ul>
<li><p><code>button</code>: Represents a button element, which users can click to trigger an action.</p>
</li>
<li><p><code>dialog</code>: Marks a dialog box or modal that requires user interaction.</p>
</li>
<li><p><code>alert</code>: Identifies an element as an important message or alert that requires user attention.</p>
</li>
<li><p><code>tablist</code>, <code>tab</code>, <code>tabpanel</code>: Used for tabbed interfaces, where <code>tablist</code> contains the tabs, and each <code>tab</code> controls the visibility of its corresponding <code>tabpanel</code>.</p>
</li>
</ul>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"button"</span> <span class="hljs-attr">tabindex</span>=<span class="hljs-string">"0"</span> <span class="hljs-attr">onclick</span>=<span class="hljs-string">"submitForm()"</span>&gt;</span>Submit<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"dialog"</span> <span class="hljs-attr">aria-labelledby</span>=<span class="hljs-string">"dialog-title"</span> <span class="hljs-attr">aria-modal</span>=<span class="hljs-string">"true"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">h2</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"dialog-title"</span>&gt;</span>Confirmation<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Are you sure you want to proceed?<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">onclick</span>=<span class="hljs-string">"closeDialog()"</span>&gt;</span>Close<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>Example of Tabbed panel:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"tablist"</span> <span class="hljs-attr">aria-label</span>=<span class="hljs-string">"Sample Tabs"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"tab"</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"tab-1"</span> <span class="hljs-attr">aria-controls</span>=<span class="hljs-string">"panel-1"</span> <span class="hljs-attr">aria-selected</span>=<span class="hljs-string">"true"</span> <span class="hljs-attr">tabindex</span>=<span class="hljs-string">"0"</span>&gt;</span>Tab 1<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"tab"</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"tab-2"</span> <span class="hljs-attr">aria-controls</span>=<span class="hljs-string">"panel-2"</span> <span class="hljs-attr">aria-selected</span>=<span class="hljs-string">"false"</span> <span class="hljs-attr">tabindex</span>=<span class="hljs-string">"-1"</span>&gt;</span>Tab 2<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"tab"</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"tab-3"</span> <span class="hljs-attr">aria-controls</span>=<span class="hljs-string">"panel-3"</span> <span class="hljs-attr">aria-selected</span>=<span class="hljs-string">"false"</span> <span class="hljs-attr">tabindex</span>=<span class="hljs-string">"-1"</span>&gt;</span>Tab 3<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"tabpanel"</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"panel-1"</span> <span class="hljs-attr">aria-labelledby</span>=<span class="hljs-string">"tab-1"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>Content for Tab 1<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>This is the content of the first tab.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"tabpanel"</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"panel-2"</span> <span class="hljs-attr">aria-labelledby</span>=<span class="hljs-string">"tab-2"</span> <span class="hljs-attr">hidden</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>Content for Tab 2<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>This is the content of the second tab.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"tabpanel"</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"panel-3"</span> <span class="hljs-attr">aria-labelledby</span>=<span class="hljs-string">"tab-3"</span> <span class="hljs-attr">hidden</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>Content for Tab 3<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>This is the content of the third tab.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<h3 id="heading-best-practices-for-using-the-role-attribute">Best Practices for Using the <code>role</code> Attribute</h3>
<ul>
<li><p>Always prefer using native HTML elements that already have the appropriate role (for example, <code>&lt;button&gt;</code>, <code>&lt;header&gt;</code>, <code>&lt;nav&gt;</code>, <code>&lt;main&gt;</code>). This provides better accessibility support across a wider range of browsers and devices.</p>
</li>
<li><p>Don't <strong>overuse</strong> or <strong>misuse</strong> the <code>role</code> attribute as this can lead to confusion and reduced accessibility. Use <code>role</code> to enhance or clarify when needed, not to replace semantic HTML.</p>
</li>
<li><p>Understand implicit roles. Many HTML elements have implicit roles. For example, an <code>&lt;a&gt;</code> element with an <code>href</code> attribute automatically has the <code>link</code> role. Avoid adding redundant <code>role</code> attributes to these elements.</p>
</li>
</ul>
<h2 id="heading-the-aria-controls-attribute">The <code>aria-controls</code> Attribute</h2>
<p>The <code>aria-controls</code> attribute informs a screen reader that the element is controlled or affected by another element. It's commonly used to indicate that a component (like a button or a tab) controls or interacts with another part of the page (like a panel or a menu). It is also used in interactive components such as tabs, accordions, and sliders to describe which parts of the page are affected when the user interacts with the component.</p>
<p>For example, you can use <code>aria-controls</code> on a tab button to indicate which panel each button controls:</p>
<pre><code class="lang-xml"><span class="hljs-comment">&lt;!-- Tab Buttons --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"tab1"</span> <span class="hljs-attr">aria-controls</span>=<span class="hljs-string">"panel1"</span>&gt;</span>Tab 1<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"tab2"</span> <span class="hljs-attr">aria-controls</span>=<span class="hljs-string">"panel2"</span>&gt;</span>Tab 2<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>

<span class="hljs-comment">&lt;!-- Content Panels --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"panel1"</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"tabpanel"</span>&gt;</span>Content for Tab 1<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"panel2"</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"tabpanel"</span>&gt;</span>Content for Tab 2<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<h3 id="heading-best-practices-for-using-aria-controls">Best Practices for Using <code>aria-controls</code></h3>
<ul>
<li><p>Ensure that the ID used in <code>aria-controls</code> matches the <code>id</code> of the controlled element exactly.</p>
</li>
<li><p>Use <code>aria-controls</code> in conjunction with role and state attributes like <code>aria-selected</code>, or <code>role="tabpanel"</code> to provide more complete information about the controlled elements and their states.</p>
</li>
<li><p>Apply <code>aria-controls</code> to interactive elements such as buttons or links that have a direct effect on other elements. It is not typically used for non-interactive content.</p>
</li>
</ul>
<h2 id="heading-the-aria-selected-attribute">The <code>aria-selected</code> Attribute</h2>
<p>The <code>aria-selected</code> attribute is used to indicate the current selection state of an element within a group of selectable items. A selectable item could be an option in a menu, a tab in a tabbed panel, or an item in a list box.</p>
<p>Here's an example of the selection state in a list box. <code>aria-selected="true"</code> in option 1 indicates that Option 1 is currently selected.</p>
<pre><code class="lang-xml"><span class="hljs-comment">&lt;!-- Listbox --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">ul</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"listbox"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">li</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"option"</span> <span class="hljs-attr">aria-selected</span>=<span class="hljs-string">"true"</span>&gt;</span>Option 1<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">li</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"option"</span> <span class="hljs-attr">aria-selected</span>=<span class="hljs-string">"false"</span>&gt;</span>Option 2<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">li</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"option"</span> <span class="hljs-attr">aria-selected</span>=<span class="hljs-string">"false"</span>&gt;</span>Option 3<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span>
</code></pre>
<h3 id="heading-best-practices-for-using-aria-selected">Best Practices for Using <code>aria-selected</code></h3>
<ul>
<li><p>Use <code>aria-selected="true"</code> for the selected item and <code>aria-selected="false"</code> for non-selected items. The value should be a string, not a boolean.</p>
</li>
<li><p>Ensure that the visual state of the element (for example, active tab or selected option) matches the <code>aria-selected</code> value. Inconsistent states can lead to confusion for users of assistive technologies.</p>
</li>
<li><p>Use <code>aria-selected</code> in conjunction with appropriate <code>role</code> attributes (for example, <code>role="option"</code> for listbox items) to provide complete context.</p>
</li>
<li><p>Ensure that <code>aria-selected</code> is updated dynamically as users interact with the interface. For example, when a user selects a new option, update the <code>aria-selected</code> attribute accordingly.</p>
</li>
</ul>
<h2 id="heading-the-tabindex-attribute">The <code>tabindex</code> Attribute</h2>
<p>The <code>tabindex</code> attribute is used to control the keyboard navigation of an element. You can use it to activate focus for non-interactive elements like <code>div</code>, <code>p</code>, or <code>span</code> or disable focus for interactive elements like <code>button</code>, <code>a</code>, <code>input</code>. You can also use it to control focus order on a page.</p>
<h3 id="heading-possible-tabindex-values">Possible <code>tabindex</code> Values</h3>
<p><strong>Positive values:</strong> Elements with positive values become focusable and are included in the tab order with their numbers determining the order in which they are focused. Elements with lower numbers are focused before elements with higher numbers.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">tabindex</span>=<span class="hljs-string">"2"</span>&gt;</span>Cancel<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span> <span class="hljs-comment">&lt;!-- This will recieve focus last --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">tabindex</span>=<span class="hljs-string">"1"</span>&gt;</span>Submit<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span> <span class="hljs-comment">&lt;!-- This will recieve focus first --&gt;</span>
</code></pre>
<p>Elements with the same values will be navigated in the order in which they appear.</p>
<p><strong>Note:</strong> Using positive <code>tabindex</code> values can lead to a confusing and non-intuitive tab order. It is generally better to use <code>tabindex="0"</code> for elements that should be part of the natural tab order.</p>
<p><strong>Zero:</strong> You use this to make an element focusable and include it in the natural tab order based on its position in the document. It's useful for making elements focusable that are not normally focusable (like <code>&lt;div&gt;</code> or <code>&lt;span&gt;</code>).</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"button"</span> <span class="hljs-attr">tabindex</span>=<span class="hljs-string">"0"</span>&gt;</span>Submit<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span> 
<span class="hljs-comment">&lt;!-- The element becomes focusable using the keyboard --&gt;</span>
</code></pre>
<p><strong>Negative values:</strong> You use this to remove an element from the tab order, meaning it cannot be focused using the <code>Tab</code> key. But it can still be focused programmatically (via JavaScript). It's useful for elements that should not be focusable by default but may need to be focusable under certain conditions.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"name"</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"other-names"</span> <span class="hljs-attr">tabindex</span>=<span class="hljs-string">"-1"</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> <span class="hljs-attr">placeholder</span>=<span class="hljs-string">"email"</span>&gt;</span>

<span class="hljs-comment">&lt;!-- other-names will be skipped when tabbing through the inputs; 
only name and email will receive focus --&gt;</span>
</code></pre>
<h3 id="heading-best-practices-for-using-tabindex">Best Practices for Using <code>tabindex</code></h3>
<ul>
<li><p>Rely on the natural tab order as much as possible. Use <code>tabindex="0"</code> to include elements in the tab order and avoid using positive values unless absolutely necessary.</p>
</li>
<li><p>Using positive <code>tabindex</code> values can create an unpredictable tab order and make it harder for users to navigate. It's better to use the default flow and <code>tabindex="0"</code>.</p>
</li>
<li><p>Use <code>tabindex="-1"</code> for elements not intended to be focused.</p>
</li>
<li><p>Ensure that the focus order follows a logical and intuitive sequence, which matches the visual layout and interaction flow of the page.</p>
</li>
<li><p>Test with keyboard and assistive technologies.</p>
</li>
<li><p>When dynamically adding or removing focusable elements (for example, through JavaScript), ensure that focus management is handled properly to maintain a smooth experience.</p>
</li>
</ul>
<h2 id="heading-the-title-attribute">The <code>title</code> Attribute</h2>
<p>The <code>title</code> attribute in HTML is used to provide additional information about an element. The content in the attribute shows in a tooltip when a user hovers over the element containing the title. It can be applied to most HTML elements, including links, images, and form fields.</p>
<p>You can use the title attribute to provide a brief explanation or description of the content of an element. For example, you can use it to clarify the meaning of abbreviations or acronyms when used with the <code>&lt;abbr&gt;</code> tag.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">abbr</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"World Wide Web"</span>&gt;</span>WWW<span class="hljs-tag">&lt;/<span class="hljs-name">abbr</span>&gt;</span>
<span class="hljs-comment">&lt;!-- Hovering over "WWW" displays the tooltip "World Wide Web," 
explaining the abbreviation. --&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"logo.png"</span> 
<span class="hljs-attr">alt</span>=<span class="hljs-string">"Company Logo"</span> 
<span class="hljs-attr">title</span>=<span class="hljs-string">"This is the logo of our company"</span>&gt;</span>
<span class="hljs-comment">&lt;!-- Users will see "This is the logo of our company" 
when hovering over the image. --&gt;</span>
</code></pre>
<h3 id="heading-accessibility-concerns-with-the-title-attribute">Accessibility Concerns with the <code>title</code> Attribute</h3>
<p>The title attribute can be useful, but it comes with some accessibility concerns:</p>
<ul>
<li><p>Screen readers do not consistently announce the <code>title</code> attribute, especially when there is also an <code>alt</code> attribute – or they may ignore it altogether. Users of assistive technologies may miss out on the information provided by the <code>title</code> attribute, especially if they rely solely on screen readers.</p>
</li>
<li><p>The tooltip generated by the <code>title</code> attribute typically appears only on hover with a mouse or trackpad. Users who navigate with a keyboard or touch screen may not have access to this information.</p>
</li>
<li><p>The content of the <code>title</code> attribute is hidden by default and only revealed on hover. This makes it less accessible to users who don't know they need to hover to get additional information.</p>
</li>
<li><p>Tooltips can be difficult to read because they often disappear quickly, and their content might be truncated or too long to fit within the tooltip window.</p>
</li>
</ul>
<h3 id="heading-best-practices-for-using-the-title-attribute">Best Practices for Using the <code>title</code> Attribute</h3>
<ul>
<li><p>Avoid relying solely on the <code>title</code> attribute. Ensure that critical information is available in a more accessible manner, such as visible text or ARIA attributes.</p>
</li>
<li><p>Use the <code>title</code> attribute for supplementary, non-essential information that enhances user experience but isn’t critical to understanding the content.</p>
</li>
<li><p>For form inputs, use the <code>aria-describedby</code> attribute to associate additional instructions with a form element. Use visible labels or descriptions instead of or in addition to the <code>title</code> attribute to ensure that all users have access to the information.</p>
</li>
<li><p>If you use the <code>title</code> attribute, keep the text brief and to the point. Long tooltips can be difficult to read and may get truncated.</p>
</li>
</ul>
<h2 id="heading-using-the-for-attribute-in-label">Using the <code>for</code> Attribute in <code>label</code></h2>
<p>The <code>for</code> attribute, when used in <code>&lt;label&gt;</code>, is used to connect a label to its corresponding form control element – that is <code>&lt;input&gt;</code>, <code>&lt;select&gt;</code>, or <code>&lt;textarea&gt;</code>. Screen readers will announce the label when the assigned input is focused. When used correctly, clicking on the label will focus on the corresponding input.</p>
<p>The value of the <code>for</code> attribute should match the <code>id</code> of the input it is associated with:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">for</span>=<span class="hljs-string">"fullname"</span>&gt;</span>Full Name<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"fullname"</span>&gt;</span>
<span class="hljs-comment">&lt;!-- When the user clicks on the "Full Name" label, 
the cursor will focus on the corresponding input field. --&gt;</span>
</code></pre>
<h3 id="heading-best-practices-for-using-the-for-attribute">Best Practices for Using the <code>for</code> Attribute</h3>
<ul>
<li><p>Ensure that each form control has a unique <code>id</code> attribute so that the <code>for</code> attribute can correctly reference it. Avoid using duplicate <code>id</code> values on the same page.</p>
</li>
<li><p>Avoid empty <code>for</code> attributes. If there’s no associated form control, it can confuse users of assistive technologies.</p>
</li>
<li><p>Position labels close to their associated form controls. Typically, labels should be placed above or to the left of the form controls for optimal readability and usability.</p>
</li>
</ul>
<h2 id="heading-the-scope-attribute">The <code>scope</code> Attribute</h2>
<p>The <code>scope</code> attribute is used in HTML tables to define the relationship between table headers and the cells they describe. The attribute is particularly important for accessibility because it helps screen readers and other assistive technologies understand the structure of the table and convey the correct information to users.</p>
<p>The <code>scope</code> attribute is applied to <code>&lt;th&gt;</code> (table header) elements to specify whether the header applies to a row, a column, or a group of rows or columns</p>
<h3 id="heading-possible-scope-values">Possible <code>scope</code> Values</h3>
<ul>
<li><code>row</code>: Indicates that the <code>&lt;th&gt;</code> element is a header for a row. In the example below, <code>scope="row"</code> is used for the first <code>&lt;th&gt;</code> element in each row, indicating that the header applies to the entire row.</li>
</ul>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">table</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">tbody</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">tr</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">th</span> <span class="hljs-attr">scope</span>=<span class="hljs-string">"row"</span>&gt;</span>Product A<span class="hljs-tag">&lt;/<span class="hljs-name">th</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span>$1000<span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span>$1200<span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span>$1100<span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">tr</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">tr</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">th</span> <span class="hljs-attr">scope</span>=<span class="hljs-string">"row"</span>&gt;</span>Product B<span class="hljs-tag">&lt;/<span class="hljs-name">th</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span>$900<span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span>$950<span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span>$1000<span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">tr</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">tbody</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">table</span>&gt;</span>
</code></pre>
<ul>
<li><code>col</code>: Indicates that the <code>&lt;th&gt;</code> element is a header for a column.</li>
</ul>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">table</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">thead</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">tr</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">th</span> <span class="hljs-attr">scope</span>=<span class="hljs-string">"col"</span>&gt;</span>Name<span class="hljs-tag">&lt;/<span class="hljs-name">th</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">th</span> <span class="hljs-attr">scope</span>=<span class="hljs-string">"col"</span>&gt;</span>Age<span class="hljs-tag">&lt;/<span class="hljs-name">th</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">th</span> <span class="hljs-attr">scope</span>=<span class="hljs-string">"col"</span>&gt;</span>Occupation<span class="hljs-tag">&lt;/<span class="hljs-name">th</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">tr</span>&gt;</span>
<span class="hljs-comment">&lt;!-- The scope="col" attribute indicates that each &lt;th&gt; element 
serves as a header for the corresponding column beneath it. --&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">thead</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">tbody</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">tr</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span>Jane<span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span>30<span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span>Engineer<span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">tr</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">tr</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span>Tobe<span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span>25<span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span>Designer<span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">tr</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">tbody</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">table</span>&gt;</span>
</code></pre>
<ul>
<li><code>rowgroup</code>: Indicates that the <code>&lt;th&gt;</code> element is a header for a group of rows. In the example below, the rows "Marketing Department" and "Sales Department" have the <code>scope="rowgroup"</code> attribute to indicate that these rows act as headers for the groups of rows that follow:</li>
</ul>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">table</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">thead</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">tr</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">th</span> <span class="hljs-attr">scope</span>=<span class="hljs-string">"col"</span>&gt;</span>Department<span class="hljs-tag">&lt;/<span class="hljs-name">th</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">th</span> <span class="hljs-attr">scope</span>=<span class="hljs-string">"col"</span>&gt;</span>Employee Name<span class="hljs-tag">&lt;/<span class="hljs-name">th</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">th</span> <span class="hljs-attr">scope</span>=<span class="hljs-string">"col"</span>&gt;</span>Position<span class="hljs-tag">&lt;/<span class="hljs-name">th</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">th</span> <span class="hljs-attr">scope</span>=<span class="hljs-string">"col"</span>&gt;</span>Salary<span class="hljs-tag">&lt;/<span class="hljs-name">th</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">tr</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">thead</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">tbody</span>&gt;</span>
    <span class="hljs-comment">&lt;!-- Row Group for the Marketing Department --&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">tr</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">th</span> <span class="hljs-attr">scope</span>=<span class="hljs-string">"rowgroup"</span> <span class="hljs-attr">colspan</span>=<span class="hljs-string">"4"</span>&gt;</span>Marketing Department<span class="hljs-tag">&lt;/<span class="hljs-name">th</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">tr</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">tr</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">th</span> <span class="hljs-attr">scope</span>=<span class="hljs-string">"row"</span>&gt;</span>Amari Pere<span class="hljs-tag">&lt;/<span class="hljs-name">th</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span>Marketing Manager<span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span>$75,000<span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">tr</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">tr</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">th</span> <span class="hljs-attr">scope</span>=<span class="hljs-string">"row"</span>&gt;</span>Uyati Hope<span class="hljs-tag">&lt;/<span class="hljs-name">th</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span>SEO Specialist<span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span>$65,000<span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">tr</span>&gt;</span>

    <span class="hljs-comment">&lt;!-- Row Group for the Sales Department --&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">tr</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">th</span> <span class="hljs-attr">scope</span>=<span class="hljs-string">"rowgroup"</span> <span class="hljs-attr">colspan</span>=<span class="hljs-string">"4"</span>&gt;</span>Sales Department<span class="hljs-tag">&lt;/<span class="hljs-name">th</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">tr</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">tr</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">th</span> <span class="hljs-attr">scope</span>=<span class="hljs-string">"row"</span>&gt;</span>Timini Prosper<span class="hljs-tag">&lt;/<span class="hljs-name">th</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span>Sales Manager<span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span>$80,000<span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">tr</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">tr</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">th</span> <span class="hljs-attr">scope</span>=<span class="hljs-string">"row"</span>&gt;</span>Delilu Pink<span class="hljs-tag">&lt;/<span class="hljs-name">th</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span>Account Executive<span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span>$70,000<span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">tr</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">tbody</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">table</span>&gt;</span>
</code></pre>
<ul>
<li><code>colgroup</code>: Indicates that the <code>&lt;th&gt;</code> element is a header for a group of columns. In the example below, <code>scope="colgroup"</code> is used to indicate that the first row of headers applies to groups of columns (Q1 and Q2), while <code>scope="col"</code> and <code>scope="row"</code> are used for individual columns and rows.</li>
</ul>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">table</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">thead</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">tr</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">th</span> <span class="hljs-attr">scope</span>=<span class="hljs-string">"colgroup"</span>&gt;</span>Region<span class="hljs-tag">&lt;/<span class="hljs-name">th</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">th</span> <span class="hljs-attr">scope</span>=<span class="hljs-string">"colgroup"</span>&gt;</span>Q1<span class="hljs-tag">&lt;/<span class="hljs-name">th</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">th</span> <span class="hljs-attr">scope</span>=<span class="hljs-string">"colgroup"</span>&gt;</span>Q2<span class="hljs-tag">&lt;/<span class="hljs-name">th</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">tr</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">tr</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">th</span> <span class="hljs-attr">scope</span>=<span class="hljs-string">"col"</span>&gt;</span>Sales<span class="hljs-tag">&lt;/<span class="hljs-name">th</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">th</span> <span class="hljs-attr">scope</span>=<span class="hljs-string">"col"</span>&gt;</span>Profit<span class="hljs-tag">&lt;/<span class="hljs-name">th</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">th</span> <span class="hljs-attr">scope</span>=<span class="hljs-string">"col"</span>&gt;</span>Sales<span class="hljs-tag">&lt;/<span class="hljs-name">th</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">th</span> <span class="hljs-attr">scope</span>=<span class="hljs-string">"col"</span>&gt;</span>Profit<span class="hljs-tag">&lt;/<span class="hljs-name">th</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">tr</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">thead</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">tbody</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">tr</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">th</span> <span class="hljs-attr">scope</span>=<span class="hljs-string">"row"</span>&gt;</span>North<span class="hljs-tag">&lt;/<span class="hljs-name">th</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span>$2000<span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span>$400<span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span>$2500<span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span>$500<span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">tr</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">tr</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">th</span> <span class="hljs-attr">scope</span>=<span class="hljs-string">"row"</span>&gt;</span>South<span class="hljs-tag">&lt;/<span class="hljs-name">th</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span>$1500<span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span>$300<span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span>$1800<span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">td</span>&gt;</span>$350<span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">tr</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">tbody</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">table</span>&gt;</span>
</code></pre>
<h3 id="heading-best-practices-for-using-the-scope-attribute">Best Practices for Using the <code>scope</code> Attribute</h3>
<ul>
<li><p>Always define <code>scope</code> for complex tables to clarify the relationship between headers and data cells.</p>
</li>
<li><p>Simplify table structures when possible. While the <code>scope</code> attribute helps with accessibility, consider simplifying table structures where possible. If a table is too complex, it might be difficult for all users to understand, even with proper markup.</p>
</li>
<li><p>For particularly complex tables, consider using ARIA attributes like <code>aria-labelledby</code> or <code>aria-describedby</code> to provide additional context and ensure that all users can navigate the table effectively.</p>
</li>
<li><p>After applying the <code>scope</code> attribute, test the table with screen readers to ensure that the relationships between headers and data cells are announced correctly.</p>
</li>
<li><p>Don’t use <code>scope</code> in situations where it’s unnecessary. For simple tables where each header is clearly associated with a single row or column, HTML’s default behavior is usually sufficient.</p>
</li>
</ul>
<h2 id="heading-the-aria-hidden-attribute">The <code>aria-hidden</code> Attribute</h2>
<p>The aria-hidden attribute is used to control the visibility of an element for assistive technologies while it's still visible on the screen. You can use it to hide purely decorative elements, like icons or images, that don't add meaningful information to the content. This helps prevent screen readers from reading unnecessary information.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">button</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">span</span> <span class="hljs-attr">aria-hidden</span>=<span class="hljs-string">"true"</span>&gt;</span>🔍<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>
    Search
<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
</code></pre>
<p>You can also use it to hide content that has already been announced to prevent redundancy in what screen readers announce. For content that is toggled on and off (like modals, or expandable sections), you can use <code>aria-hidden</code> to hide the inactive content from screen readers, ensuring that they only interact with the visible, active content.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">button</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">span</span> <span class="hljs-attr">aria-hidden</span>=<span class="hljs-string">"true"</span>&gt;</span>✉<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span> <span class="hljs-comment">&lt;!-- hide decorative icon --&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span>Messages<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
</code></pre>
<p>You can also use <code>aria-hidden</code> when creating complex widgets (like carousels or tabbed interfaces) to hide inactive panels or slides from assistive technologies, focusing their attention on the active part of the widget.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"menu"</span> <span class="hljs-attr">aria-hidden</span>=<span class="hljs-string">"true"</span>&gt;</span>
    <span class="hljs-comment">&lt;!-- Menu content here --&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">onclick</span>=<span class="hljs-string">"toggleMenu()"</span>&gt;</span>Toggle Menu<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript">
    <span class="hljs-keyword">const</span> toggleMenu = <span class="hljs-function">() =&gt;</span> {
        <span class="hljs-keyword">const</span> menu = <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'menu'</span>);
        <span class="hljs-keyword">const</span> isHidden = menu.getAttribute(<span class="hljs-string">'aria-hidden'</span>) === <span class="hljs-string">'true'</span>;

        menu.setAttribute(<span class="hljs-string">'aria-hidden'</span>, !isHidden);
    }
</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
</code></pre>
<h3 id="heading-best-practices-for-using-aria-hidden">Best Practices for Using <code>aria-hidden</code></h3>
<ul>
<li><p>Only use <code>aria-hidden</code> when you need to hide content from screen readers to avoid overwhelming users with redundant or irrelevant information.</p>
</li>
<li><p>Do not use on elements that users need to interact with, like buttons or links.</p>
</li>
<li><p>Ensure that <code>aria-hidden</code> accurately reflects the visibility of elements on the screen. If an element becomes visible or hidden via JavaScript or CSS, update <code>aria-hidden</code> accordingly to maintain accessibility.</p>
</li>
<li><p>In a team environment, document why and where <code>aria-hidden</code> is used in your codebase, so that other team members understand its purpose and can maintain it properly.</p>
</li>
</ul>
<h2 id="heading-the-inert-attribute">The <code>inert</code> Attribute</h2>
<p>The <code>inert</code> attribute prevents an element and all of its descendants from being focusable, interactive, or perceivable by assistive technologies. When an element has the <code>inert</code> attribute, it cannot receive focus, be clicked on, or be interacted with in any way. It's also hidden from assistive technologies like screen readers.</p>
<p>Unlike <code>aria-hidden</code>, which only affects accessibility, <code>inert</code> applies to all user interactions. The inert attribute can be used to disable sections of a page that are temporarily irrelevant, such as during form validation errors, while loading data, or when a certain section is hidden but still in the DOM. It can also be used in complex user interfaces like multi-step forms or wizards to ensure that users only interact with the current step or section</p>
<p>The most common use of inert, however, is in a modal, where you want to prevent users from interacting with the background content while the modal is open.</p>
<p>Like in the example below, when the modal is open the <code>inert</code> attribute is added to the main content, making it non-interactive and hidden from screen readers. When the modal is closed, the <code>inert</code> attribute is removed, and the main content becomes interactive again.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"main-content"</span> <span class="hljs-attr">inert</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>This is the main content of the page. It will be inactive when the modal is open.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"modal"</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"dialog"</span> <span class="hljs-attr">aria-modal</span>=<span class="hljs-string">"true"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>Modal Title<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>This is the content inside the modal.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">onclick</span>=<span class="hljs-string">"closeModal()"</span>&gt;</span>Close Modal<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript">
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">openModal</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'main-content'</span>).setAttribute(<span class="hljs-string">'inert'</span>, <span class="hljs-string">''</span>);
    <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'modal'</span>).style.display = <span class="hljs-string">'block'</span>;
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">closeModal</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'main-content'</span>).removeAttribute(<span class="hljs-string">'inert'</span>);
    <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'modal'</span>).style.display = <span class="hljs-string">'none'</span>;
}
</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
</code></pre>
<h3 id="heading-best-practices-for-using-the-inert-attribute">Best Practices for Using the <code>inert</code> Attribute</h3>
<ul>
<li><p>Ensure that when you use <code>inert</code>, the visually inactive or disabled state of elements is clear to sighted users. For example, dimming or blurring background content when a modal is open can complement the <code>inert</code> attribute.</p>
</li>
<li><p>Don't overuse <code>inert</code>, as doing so might unintentionally make significant portions of your page non-interactive and inaccessible. Use it judiciously to manage user focus and interaction only when necessary.</p>
</li>
<li><p>When dynamically adding and removing the <code>inert</code> attribute, ensure that it is properly removed when no longer needed so that users can regain access to previously disabled content.</p>
</li>
</ul>
<h2 id="heading-the-aria-live-attribute">The <code>aria-live</code> Attribute</h2>
<p>You can use the <code>aria-live</code> attribute to notify assistive technologies about dynamic content changes on a webpage. When <code>aria-live</code> is applied to an element, screen readers are alerted when the content inside that element is updated, ensuring that users are informed about important changes that occur after the page has initially loaded.</p>
<p>This attribute can be useful for content that updates dynamically, such as notifications, alerts, chat messages, or stock prices. It ensures that users are aware of changes that might otherwise go unnoticed.</p>
<h3 id="heading-possible-values-for-aria-live">Possible Values for <code>aria-live</code></h3>
<p>There are three main values: <code>off</code>, <code>polite</code>, and <code>assertive</code>.</p>
<ul>
<li><p><code>off</code>: Default value, updates to the element will not be announced by screen readers.</p>
</li>
<li><p><code>polite</code>: Updates will be announced by the screen reader, but only after the user has finished interacting with the current task or reading other content. This ensures that the update does not interrupt the user’s current activity.</p>
</li>
</ul>
<p>In the example below, each new message is added to the <code>#messages</code> container, which has <code>aria-live="polite"</code>. The screen reader will announce the new message only after the user finishes their current activity.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"chat-window"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"messages"</span> <span class="hljs-attr">aria-live</span>=<span class="hljs-string">"polite"</span>&gt;</span>
        <span class="hljs-comment">&lt;!-- Existing messages are here --&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>John: Hello!<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>You: Hi there!<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">onclick</span>=<span class="hljs-string">"addMessage()"</span>&gt;</span>Send Message<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript">
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">addMessage</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">const</span> newMessage = <span class="hljs-built_in">document</span>.createElement(<span class="hljs-string">'div'</span>);
    newMessage.textContent = <span class="hljs-string">'Alice: How are you?'</span>;
    <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'messages'</span>).appendChild(newMessage);
}
</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
</code></pre>
<ul>
<li><code>assertive</code>: Updates will be announced immediately, interrupting whatever the screen reader is currently announcing. Use this for urgent or critical information that requires the user’s immediate attention.</li>
</ul>
<p>In the example below, updates to the stock prices are placed within a container that has <code>aria-live="assertive"</code>.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"stock-ticker"</span> <span class="hljs-attr">aria-live</span>=<span class="hljs-string">"assertive"</span>&gt;</span>
    <span class="hljs-comment">&lt;!-- Initial stock prices --&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"stock1"</span>&gt;</span>Stock A: $100<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"stock2"</span>&gt;</span>Stock B: $150<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">onclick</span>=<span class="hljs-string">"updateStockPrices()"</span>&gt;</span>Update Prices<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript">
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">updateStockPrices</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'stock1'</span>).textContent = <span class="hljs-string">'Stock A: $95'</span>;
    <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'stock2'</span>).textContent = <span class="hljs-string">'Stock B: $155'</span>;
}
</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
</code></pre>
<h3 id="heading-best-practices-for-using-aria-live">Best Practices for Using <code>aria-live</code></h3>
<ul>
<li><p>Use <code>aria-live="polite"</code> for non-critical updates to avoid disrupting the user’s experience. Reserve <code>aria-live="assertive"</code> for urgent updates that require immediate attention, such as critical errors or security warnings.</p>
</li>
<li><p>Be mindful of how often you use <code>aria-live</code> elements on a page. Overusing it can lead to an overstimulating experience for users who rely on screen readers, as they may be overwhelmed by frequent announcements.</p>
</li>
<li><p>Don’t use <code>aria-live</code> on content that doesn’t need to be announced, or on content that’s already being communicated to the user in another way.</p>
</li>
<li><p><code>aria-live</code> is particularly useful for content that is updated dynamically, such as live sports scores, breaking news, or chat applications. Make sure that the user is kept informed of important updates as they occur.</p>
</li>
</ul>
<h2 id="heading-the-aria-roledescription-attribute">The <code>aria-roledescription</code> Attribute</h2>
<p>You can use <code>aria-roledescription</code> to provide a human-readable, localized description for the role of an element. It overrides the implicit or explicit <code>role</code> value for screen readers, and allows developers to create more intuitive and context-specific descriptions for complex or unconventional user interface components that may not have a standard role name.</p>
<p>You can use it to provide a clearer explanation of the element’s purpose or functionality.</p>
<p>In the example below, screen readers will announce it as "Bookmark Button" instead of just "Button."</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"button"</span> <span class="hljs-attr">aria-roledescription</span>=<span class="hljs-string">"Bookmark Button"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">span</span> <span class="hljs-attr">aria-hidden</span>=<span class="hljs-string">"true"</span>&gt;</span>⭐<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span> Save this page
<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
</code></pre>
<p>You can also use it to support internationalization, like providing role descriptions in different languages.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"button"</span> <span class="hljs-attr">aria-roledescription</span>=<span class="hljs-string">"Search Button"</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">"en"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">span</span> <span class="hljs-attr">aria-hidden</span>=<span class="hljs-string">"true"</span>&gt;</span>🔍<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span> Search
<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"button"</span> <span class="hljs-attr">aria-roledescription</span>=<span class="hljs-string">"Botón de busqueda"</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">"es"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">span</span> <span class="hljs-attr">aria-hidden</span>=<span class="hljs-string">"true"</span>&gt;</span>🔍<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span> Buscar
<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"button"</span> <span class="hljs-attr">aria-roledescription</span>=<span class="hljs-string">"Bouton de recherche"</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">"fr"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">span</span> <span class="hljs-attr">aria-hidden</span>=<span class="hljs-string">"true"</span>&gt;</span>🔍<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span> Recherche
<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
</code></pre>
<h3 id="heading-best-practices-for-using-aria-roledescription">Best Practices for Using <code>aria-roledescription</code></h3>
<ul>
<li><p>Only use <code>aria-roledescription</code> when the standard role does not sufficiently describe the element's purpose.</p>
</li>
<li><p>The description should be short, clear, and directly related to the element's function. Avoid using jargon or overly technical language.</p>
</li>
<li><p><code>aria-roledescription</code> should be used alongside an appropriate ARIA role, not as a replacement. The <code>role</code> provides the foundational context (like <code>"button"</code> or <code>"listbox"</code>), while the description adds clarity.</p>
</li>
<li><p>If your application supports multiple languages, ensure that the <code>aria-roledescription</code> values are localized to match the user's language preferences. This helps provide a consistent and understandable experience.</p>
</li>
<li><p>Ensure that the <code>aria-roledescription</code> does not repeat or conflict with other ARIA attributes or element labels. It should complement, not duplicate, the information already provided.</p>
</li>
</ul>
<h2 id="heading-the-aria-atomic-attribute">The <code>aria-atomic</code> Attribute</h2>
<p>You can use the <code>aria-atomic</code> attribute to control how updates to an element are announced by assistive technologies. When <code>aria-atomic</code> is set to <code>true</code>, it indicates that when changes occur within the element, the entire content of the element should be treated as a single unit and announced in full by the screen reader (rather than announcing only the changed parts).</p>
<p>In cases where updates to part of an element might make the overall context unclear, <code>aria-atomic</code> helps by providing a full announcement of the element's content, giving users a complete understanding of the context.</p>
<p>It is often used in conjunction with <code>aria-live</code>. While <code>aria-live</code> determines how updates are announced (politely or assertively), <code>aria-atomic</code> controls whether the entire content is read or just the changes.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"news-ticker"</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"region"</span> <span class="hljs-attr">aria-live</span>=<span class="hljs-string">"polite"</span> <span class="hljs-attr">aria-atomic</span>=<span class="hljs-string">"true"</span>&gt;</span>
  Breaking News: Major storm expected this weekend.
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">onclick</span>=<span class="hljs-string">"updateHeadline()"</span>&gt;</span>Update Headline<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript">
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">updateHeadline</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'news-ticker'</span>).innerText = <span class="hljs-string">'Breaking News: Stock market hits record high!'</span>;
}
</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
</code></pre>
<h3 id="heading-best-practices-for-using-aria-atomic">Best Practices for Using <code>aria-atomic</code></h3>
<ul>
<li><p>Apply <code>aria-atomic="true"</code> only to elements where a full announcement of updates is essential for understanding the context.</p>
</li>
<li><p>When using <code>aria-atomic="true"</code>, ensure that the content within the element provides consistent and complete context to users.</p>
</li>
<li><p>Use <code>aria-atomic</code> in combination with <code>aria-live</code> to specify how updates should be announced. This ensures that the updates are announced in the appropriate manner and with full context.</p>
</li>
</ul>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Understanding and effectively using HTML attributes for accessibility is crucial for creating inclusive web experiences. By understanding and using these attributes appropriately, you can ensure that your application has a great user experience for all visitors.</p>
<h3 id="heading-resources">Resources</h3>
<ul>
<li><p><a target="_blank" href="https://www.w3.org/WAI/ARIA/apg/practices/names-and-descriptions/">Providing Accessible Names and Descriptions</a></p>
</li>
<li><p><a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA">MDN ARIA</a></p>
</li>
<li><p><a target="_blank" href="https://www.w3.org/WAI/ARIA/apg/practices/read-me-first/">No ARIA is better than Bad ARIA</a></p>
</li>
<li><p><a target="_blank" href="https://www.w3.org/WAI/ARIA/apg/example-index/#examples_by_props_label">ARIA examples by properties and states</a></p>
</li>
</ul>
<p>Thank you so much for reading, I hope this guide helps you create more accessible web content. If you found it helpful, consider sharing.</p>
<p>You can connect with me on <a target="_blank" href="https://www.linkedin.com/in/elizabeth-meshioye/">LinkedIn</a>.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Build an Accessible Modal – with Example Code ]]>
                </title>
                <description>
                    <![CDATA[ We often use modals or popups to display important information or prompt users to take action. Unlike regular pop-ups that can be opened in new windows or tabs, these dialogues keep the user on the same page by overlaying the existing content. This e... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-build-an-accessible-modal-with-example-code/</link>
                <guid isPermaLink="false">66cdec7e3bcefa4703267811</guid>
                
                    <category>
                        <![CDATA[ a11y ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Accessibility ]]>
                    </category>
                
                    <category>
                        <![CDATA[ frontend ]]>
                    </category>
                
                    <category>
                        <![CDATA[ HTML5 ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Elizabeth Lola ]]>
                </dc:creator>
                <pubDate>Tue, 27 Aug 2024 15:10:54 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1724337698676/aa23c219-2ffb-4424-bb34-3195a905d973.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>We often use modals or popups to display important information or prompt users to take action. Unlike regular pop-ups that can be opened in new windows or tabs, these dialogues keep the user on the same page by overlaying the existing content. This ensures that users remain focused on the task at hand.</p>
<p>Modals are common and sometimes required. And if they're not implemented correctly, they can be a significant barrier. Ensuring that modals are accessible means they are usable by everyone, including people who rely on assistive technologies.</p>
<p>In this article, we'll <strong>build a modal</strong> and follow the guidelines to make it accessible.</p>
<h2 id="heading-prerequisites"><strong>Prerequisites</strong></h2>
<p>To follow along with this tutorial, you should have:</p>
<ol>
<li><p><strong>Basic HTML knowledge:</strong> Understand how HTML elements and attributes work.</p>
</li>
<li><p><strong>Basic JavaScript knowledge:</strong> Familiarity with basic JavaScript concepts like functions, event handling, and DOM manipulation is helpful.</p>
</li>
<li><p><strong>Understanding of ARIA:</strong> While the tutorial explains ARIA roles and attributes, having a basic understanding of accessibility concepts can be beneficial.</p>
</li>
</ol>
<h2 id="heading-when-should-you-use-a-modal">When Should You Use a Modal?</h2>
<p>Using modals effectively requires careful consideration of the user experience. Here are some guidelines to help you decide if you should use a modal or not:</p>
<ul>
<li><p>You should use modals when the user needs to make a critical decision, such as confirming a potentially destructive action (for example, deleting an item) or agreeing to terms and conditions</p>
</li>
<li><p>You can use a modal when a task requires the user’s complete focus and does not rely on information from the rest of the page (for example, filling out a form or completing a payment process).</p>
</li>
<li><p>You can use a modal for displaying temporary or transient information that doesn’t need to be permanently visible on the page (for example, alerts, notifications, or brief messages).</p>
</li>
<li><p>You should avoid using modals for tasks that require extensive interaction or input, such as lengthy forms or complex workflows. These can be frustrating in a modal because of limited space and navigation constraints.</p>
</li>
<li><p>You should avoid using modals for actions a user will need to perform frequently, as this can become repetitive and annoying. Inline options or tooltips might be better for repetitive actions.</p>
</li>
<li><p>You should not use modals if they interrupt the user’s natural flow on the site, especially if the content or action in the modal is not urgent or important.</p>
</li>
</ul>
<h2 id="heading-modal-accessibility-guidelines">Modal Accessibility Guidelines</h2>
<p>Here are some tips to help you build useful and accessible modals:</p>
<ul>
<li>Provide a descriptive <code>aria-labelledby</code> attribute that points to the modal's title or heading. If there is no title, use <code>aria-label</code> to provide a short, descriptive label.</li>
</ul>
<ul>
<li><p>Always include a visible and easily accessible close button within the modal, usually in the top-right corner. Label this button clearly, for example, with the text "Close" or an icon with <code>aria-label="Close"</code>.</p>
</li>
<li><p>When the modal opens, move the keyboard focus to the first interactive element within the modal (usually a close button). When the modal closes, return the focus to the element that triggered the modal.</p>
</li>
<li><p>Keep the keyboard focus within the modal while it is open.</p>
</li>
<li><p>Allow users to close the modal by pressing the <code>Escape</code> key.</p>
</li>
</ul>
<p>Following these guidelines, let's build a modal.</p>
<p>I prefer using the right HTML tags to build components, and in this case I'll be doing exactly that using the <code>dialog</code> tag.</p>
<h2 id="heading-how-to-build-a-modal-using-the-dialog-tag">How to Build a Modal Using the <code>dialog</code> Tag</h2>
<p>In case you're not familiar with the <code>dialog</code> tag, it was introduced in HTML5. You use it to create dialog boxes like popups, alerts, and modals. It offers built-in methods and attributes that make it easier to manage dialog behavior without needing extensive JavaScript. The javascript built-in methods are <code>show()</code>, <code>showModal()</code>, and <code>close()</code>.</p>
<h3 id="heading-show-and-showmodal"><code>show()</code> and <code>showModal()</code></h3>
<p>The <code>show()</code> method is useful for a non-blocking dialog. This means that the dialog appears on top of the current content, but users can still interact with other parts of the webpage (clicking buttons, links, and so on) while the dialog is open.</p>
<p>This is useful in situations where the dialog is providing information that doesn’t require the user’s immediate attention. Here's an example:</p>
<pre><code class="lang-xml"><span class="hljs-comment">&lt;!-- Previous content here --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">dialog</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"dialog-box"</span>&gt;</span>
<span class="hljs-comment">&lt;!-- More content here --&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">dialog</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript">
    <span class="hljs-keyword">const</span> dialog = <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'dialog-box'</span>);
    dialog.show();
</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
</code></pre>
<p>Result:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1723822375653/a592c09a-747c-4248-84e2-9cd76c8f6498.png" alt="a non-modal dialog" class="image--center mx-auto" width="1988" height="724" loading="lazy"></p>
<p>The <code>showModal()</code> method opens the dialog in a modal mode. This means that the dialog takes focus, and interaction with the rest of the webpage is blocked until the dialog is closed. The user cannot click on or interact with any other part of the page.</p>
<p>Depending on the browser, a semi-transparent backdrop appears behind the dialog, visually indicating that the rest of the page is not interactable.</p>
<p>When a dialog is opened with <code>showModal()</code>, focus is automatically trapped within the dialog. The user can only tab through elements inside the dialog, and the focus will loop within the dialog’s content until it is closed. Here's an example:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">dialog</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"dialog-box"</span>&gt;</span>
<span class="hljs-comment">&lt;!-- More content here --&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">dialog</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript">
    <span class="hljs-keyword">const</span> dialog = <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'dialog-box'</span>);
    dialog.showModal();
</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
</code></pre>
<p>Result:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1723823970852/1ca30713-199d-4b94-b12a-ad1a27a9063f.png" alt="a modal dialog" class="image--center mx-auto" width="1724" height="1060" loading="lazy"></p>
<p>The <code>&lt;dialog&gt;</code> element has default styles but can be customized using CSS to match your design. You can style the dialog box, add animations, or modify the backdrop. The backdrop can be styled using the <code>::backdrop</code> selector. For example:</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">dialog</span><span class="hljs-selector-pseudo">::backdrop</span> {
    <span class="hljs-attribute">background</span>: <span class="hljs-built_in">rgba</span>(<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0.7</span>);
}
</code></pre>
<p>The dialog also comes with some built-in accessibility features like focus management, backdrop, automatic announcement on open, and pressing the <code>ESC</code> key will close the dialog.</p>
<p>You can add the <code>autofocus</code> attribute to the first interactive element in the modal, such as the first input in a form or the close button. Alternatively, you can rely on the <code>&lt;dialog&gt;</code> element's native focus management.</p>
<p>Avoid using <code>tabindex</code> on the <code>&lt;dialog&gt;</code> element, as it is not an interactive element like a button or link. The <code>&lt;dialog&gt;</code> serves as a container for interactive content, and it is not intended to receive direct user focus.</p>
<p>The <code>&lt;dialog&gt;</code> element provides a native way to create modals. If you're building a custom modal, make sure its accessibility features match those of the native <code>&lt;dialog&gt;</code> element.</p>
<p>Bringing it all together:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">style</span>&gt;</span><span class="css">
    <span class="hljs-selector-tag">dialog</span><span class="hljs-selector-pseudo">::backdrop</span> {
        <span class="hljs-attribute">background</span>: <span class="hljs-built_in">rgba</span>(<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0.7</span>);
    }
</span><span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"open-dialog"</span>&gt;</span>Open Dialog<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">dialog</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"dialog-box"</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>Modal title<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
          <span class="hljs-comment">&lt;!-- More content here --&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"close-dialog"</span> <span class="hljs-attr">autofocus</span>&gt;</span>Close<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">dialog</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript">
    <span class="hljs-keyword">const</span> dialog = <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">"dialog-box"</span>);
    <span class="hljs-keyword">const</span> openButton = <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">"open-dialog"</span>);
    <span class="hljs-keyword">const</span> closeButton = <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">"close-dialog"</span>);

    openButton.addEventListener(<span class="hljs-string">"click"</span>, <span class="hljs-function">() =&gt;</span> {
      dialog.showModal();
    });
    closeButton.addEventListener(<span class="hljs-string">"click"</span>, <span class="hljs-function">() =&gt;</span> {
      dialog.close();
    });
</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
</code></pre>
<p>You'll notice that I didn't use the <code>aria-label</code> attribute on the dialog as I listed in the guidelines. Well, that's because the dialog element, if well-structured, doesn't necessarily need one. In this case, there's a visible label in the dialog element (the <code>h2</code> element).</p>
<p>If there are no visible labels present then you need to add one. Like in this example:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">dialog</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"confimation-dialog"</span> <span class="hljs-attr">aria-label</span>=<span class="hljs-string">"Confirmation Dialog"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Are you sure you want to proceed?<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"close-dialog"</span> <span class="hljs-attr">autofocus</span>&gt;</span>Close<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">dialog</span>&gt;</span>
</code></pre>
<h2 id="heading-what-is-the-inert-attribute">What is the <code>inert</code> Attribute?</h2>
<p>When a modal is open, a screen reader might still navigate to and around content outside the modal. You would generally want the user's focus to be restricted to the modal itself, or stop the user from accidentally clicking on elements outside the modal to prevent confusion and errors. In these cases, you'll need the <code>inert</code> attribute.</p>
<p>The <code>inert</code> attribute makes an element and all of its descendants non-interactive and inaccessible to assistive technologies. When a modal is open, using the <code>inert</code> attribute on the rest of the page content will ensure that only the modal content can be accessed, making the dialog experience clearer.</p>
<h3 id="heading-how-to-use-the-inert-attribute">How to Use the <code>inert</code> Attribute</h3>
<p>When a modal is opened, you can apply the <code>inert</code> attribute to the rest of the page content (typically the <code>&lt;main&gt;</code> element). When the modal is closed, you remove the <code>inert</code> attribute.</p>
<p>Here's an example showing how to use <code>inert</code> with a modal dialog:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">header</span>&gt;</span>Site Header<span class="hljs-tag">&lt;/<span class="hljs-name">header</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">main</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"main-content"</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"open-dialog"</span>&gt;</span>Open modal<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>This is the main content of the page.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
        <span class="hljs-comment">&lt;!-- More content here --&gt;</span>

    <span class="hljs-tag">&lt;/<span class="hljs-name">main</span>&gt;</span>
    <span class="hljs-comment">&lt;!-- Move the dialog outside the main element --&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">dialog</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"dialog"</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>Modal Title<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>This is the content inside the modal.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"close-dialog"</span> <span class="hljs-attr">autofocus</span>&gt;</span>Close<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">dialog</span>&gt;</span>

    <span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript">
        <span class="hljs-keyword">const</span> dialog = <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'dialog'</span>);
        <span class="hljs-keyword">const</span> mainContent = <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'main-content'</span>);
        <span class="hljs-keyword">const</span> openButton = <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'open-dialog'</span>);
        <span class="hljs-keyword">const</span> closeButton = <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'close-dialog'</span>);

        openButton.addEventListener(<span class="hljs-string">"click"</span>, <span class="hljs-function">() =&gt;</span> {
           mainContent.setAttribute(<span class="hljs-string">'inert'</span>, <span class="hljs-string">''</span>);
          dialog.showModal();
        });

        closeButton.addEventListener(<span class="hljs-string">"click"</span>, <span class="hljs-function">() =&gt;</span> {
           dialog.close();
        });

        <span class="hljs-comment">// the dialog elemnt has a close event, which is called when a user calls the close() method or presses the esc key</span>
        dialog.addEventListener(<span class="hljs-string">"close"</span>, <span class="hljs-function">(<span class="hljs-params">event</span>) =&gt;</span> {
           mainContent.removeAttribute(<span class="hljs-string">"inert"</span>);
        });
    </span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
</code></pre>
<h2 id="heading-how-to-animate-the-open-and-close-states">How to Animate the Open and Close States</h2>
<p>When a modal appears (open state) or disappears (close state), it can be jarring for users if this transition happens abruptly. Animating these states can create a smoother user experience by gradually introducing or removing the modal, making it feel more natural.</p>
<h4 id="heading-why-animate-the-open-and-close-states">Why Animate the Open and Close States?</h4>
<p>Animating the open and close states of a modal can:</p>
<ul>
<li><p><strong>Enhance User Experience</strong>: A smooth animation can make the transition less abrupt and more engaging.</p>
</li>
<li><p><strong>Draw Attention</strong>: Subtle animations can help guide the user's focus to the modal content when it appears.</p>
</li>
<li><p><strong>Maintain Consistency</strong>: Consistent animations across your UI can create a cohesive and professional feel.</p>
</li>
</ul>
<p>By default, the dialog is set to <code>display:none</code> when closed and <code>display:block</code> when open. You cannot transition from <code>none</code> to <code>block</code> in CSS, but you can combine the display properties with <code>transform</code> or <code>opacity</code>. The <code>transform</code> property can be used to scale or move the modal, while <code>opacity</code> controls its transparency.</p>
<p>Here’s an example of how you might animate a modal:</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">dialog</span> {
  <span class="hljs-attribute">animation</span>: zoom-out <span class="hljs-number">0.5s</span> ease-out;
}

<span class="hljs-comment">/* an open attribute is added to the dialog when it is open  */</span>
<span class="hljs-selector-tag">dialog</span><span class="hljs-selector-attr">[open]</span> {
    <span class="hljs-attribute">animation</span>: zoom-in <span class="hljs-number">0.5s</span> ease-out;
}

<span class="hljs-comment">/* The display property in the keyframes is critical 
because it toggles the modal’s visibility on and off.  */</span>
<span class="hljs-keyword">@keyframes</span> zoom-in {
    0% {
      <span class="hljs-attribute">opacity</span>: <span class="hljs-number">0</span>;
      <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">scale</span>(<span class="hljs-number">0.1</span>);
      <span class="hljs-attribute">display</span>:  none;
    }
    100% {
      <span class="hljs-attribute">opacity</span>: <span class="hljs-number">1</span>;
      <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">scale</span>(<span class="hljs-number">1</span>);
      <span class="hljs-attribute">display</span>: block;
    }
}

<span class="hljs-keyword">@keyframes</span> zoom-out {
    0% {
      <span class="hljs-attribute">opacity</span>: <span class="hljs-number">1</span>;
      <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">scale</span>(<span class="hljs-number">1</span>);
      <span class="hljs-attribute">display</span>: block;
    }
    100% {
      <span class="hljs-attribute">opacity</span>: <span class="hljs-number">0</span>;
      <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">scale</span>(<span class="hljs-number">0</span>);
      <span class="hljs-attribute">display</span>: none;
    }
}
</code></pre>
<p>Final result:</p>
<div class="embed-wrapper">
        <iframe width="100%" height="350" src="https://codepen.io/leezee/embed/preview/XWLVBgp?default-tab=result&amp;editable=true" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="CodePen embed" scrolling="no" allowtransparency="true" allowfullscreen="true" loading="lazy"></iframe></div>
<p> </p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>The <code>&lt;dialog&gt;</code> element is the native way to create modals. It provides built-in accessible features for both keyboard and screen reader users</p>
<p>The <code>&lt;dialog&gt;</code> element is of two types, modal and non-modal. You can create a non-modal dialog using the <code>show()</code> method, and the <code>showModal()</code> method will create a modal dialog.</p>
<p>When you're not using the native dialog element, ensure your custom modal matches the native dialog in terms of accessibility to ensure a uniform experience for all users</p>
<p>You should also always remember to autofocus the most immediate interactive element, the dialog can do this by default.</p>
<p>Finally, you can use the <code>inert</code> attribute on other elements to prevent those elements from being accessed when the modal is open.</p>
<h3 id="heading-resources">Resources:</h3>
<ul>
<li><p><a target="_blank" href="https://w3c.github.io/aria/#dialog">W3c Dialog role</a></p>
</li>
<li><p><a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog">MDN: The Dialog element</a></p>
</li>
</ul>
<p>Thank you so much for reading this article. If you found it helpful, consider sharing. Happy coding!</p>
<p>You can connect with me on <a target="_blank" href="https://www.linkedin.com/in/elizabeth-meshioye/">LinkedIn</a>.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Write Accessible Technical Documentation – Best Practices with Examples ]]>
                </title>
                <description>
                    <![CDATA[ When you're writing technical documentation for a project or a tool you're working on, you'll want it to be accessible. This means that it will cater to and be usable by the diverse global audience on the web. Web accessibility aims to make it possib... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/best-practices-for-writing-accessible-technical-documentation/</link>
                <guid isPermaLink="false">66d84fe57211ea6be29e1b6d</guid>
                
                    <category>
                        <![CDATA[ a11y ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Accessibility ]]>
                    </category>
                
                    <category>
                        <![CDATA[ best practices ]]>
                    </category>
                
                    <category>
                        <![CDATA[ documentation ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ EZINNE ANNE EMILIA ]]>
                </dc:creator>
                <pubDate>Thu, 11 Apr 2024 23:03:04 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2024/04/20240401_161256_0000.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>When you're writing technical documentation for a project or a tool you're working on, you'll want it to be accessible. This means that it will cater to and be usable by the diverse global audience on the web.</p>
<p>Web accessibility aims to make it possible for anyone to access web content. There are common accessibility best practices for designers, developers, and writers. This article will cover some best practices for creating technical content.‌</p>
<h2 id="heading-what-is-web-accessibility">What is Web Accessibility?</h2>
<p><a target="_blank" href="https://www.freecodecamp.org/news/web-accessibility-for-devs/">Web accessibility</a> is the practice of making it possible for anyone to consume or create content on the web, regardless of any health, economic, geographic, or language challenges they may have.</p>
<h2 id="heading-why-is-web-accessibility-important">Why is Web Accessibility Important?</h2>
<p>It is important to apply web accessibility best practices in your projects for a number of reasons.</p>
<p>First, it'll help you reach a wider audience. When a person who may have different abilities comes across some data on the web – say on your website – they'll want to learn more or use the data. But if they are not able to access it, you will not be happy or have a good experience.</p>
<p>Imagine how many people are unable to utilize the web because they are not considered when devs and designers are making decisions about how the product, website, or tool will be built.</p>
<p>Another important thing about accessibility is that it improves your brand's quality. Letting people know you are an accessibility-oriented person or company by implementing it in your work shows that you want your information to be available t everyone. It also displays your versatility in your craft and your ability to improve and adapt with changing times and trends.</p>
<p>Also, as an individual, applying accessibility best practices benefits you as well. There are possible employment opportunities for developers and designers with great accessibility skills.</p>
<p>Good accessibility practices mean good SEO practices too, which can result in more visibility for your work.</p>
<p>Finally, accessibility is enforced by law in certain countries around the world, and web accessibility strategies are implemented by certain countries. There could be legal consequences if you overlook accessibility on your websites and apps.</p>
<h2 id="heading-how-to-write-accessible-technical-documentation">How to Write Accessible Technical Documentation</h2>
<p>Software engineers have a key role in making the web accessible. But when it comes to writing documentation, technical writers also have a role to play in improving web accessibility.</p>
<p>Technical writers help write various types of content, like user guides, tutorials, API references, code documentation, and so on.</p>
<p>Now, let's look at some of the best practices for implementing web accessibility in technical writing. These strategies will help improve your documentation and make it more user-friendly and accessible to everyone.</p>
<h3 id="heading-use-clear-headings-and-paragraphs">Use clear headings and paragraphs</h3>
<p>When writing content, you should make sure to use headings – along with the proper heading hierarchy (H1 for the title of the page/article, H2 for major headings, H3 for subheadings, and so on).</p>
<p>Also, make sure to break your content up into paragraphs so it's easier to read and understand.</p>
<p>When you introduce a new topic, use a heading to call that out. When you talk about smaller topics within that section, use subheadings to alert the reader.</p>
<p>Headings are also important to help screen readers understand a page's contents and how to navigate through them. So use headings to help guide readers through the text in a logical manner.</p>
<p>You denote headings in markdown with hashes. Here's an example of headings in hierarchical order.‌</p>
<pre><code class="lang-css"># <span class="hljs-selector-tag">Use</span> <span class="hljs-selector-tag">H1</span> <span class="hljs-selector-tag">for</span> <span class="hljs-selector-tag">the</span> <span class="hljs-selector-tag">page</span> <span class="hljs-selector-tag">title</span>

## <span class="hljs-selector-tag">Use</span> <span class="hljs-selector-tag">H2</span> <span class="hljs-selector-tag">for</span> <span class="hljs-selector-tag">major</span> <span class="hljs-selector-tag">headings</span> 
<span class="hljs-selector-tag">This</span> <span class="hljs-selector-tag">heading</span> <span class="hljs-selector-tag">is</span> <span class="hljs-selector-tag">a</span> <span class="hljs-selector-tag">main</span> <span class="hljs-selector-tag">heading</span> <span class="hljs-selector-tag">for</span> <span class="hljs-selector-tag">the</span> <span class="hljs-selector-tag">main</span> <span class="hljs-selector-tag">section</span> <span class="hljs-selector-tag">content</span>. 

### <span class="hljs-selector-tag">Use</span> <span class="hljs-selector-tag">H3</span> <span class="hljs-selector-tag">for</span> <span class="hljs-selector-tag">subheadings</span> 
<span class="hljs-selector-tag">This</span> <span class="hljs-selector-tag">heading</span> <span class="hljs-selector-tag">is</span> <span class="hljs-selector-tag">a</span> <span class="hljs-selector-tag">subheading</span> <span class="hljs-selector-tag">that</span> <span class="hljs-selector-tag">goes</span> <span class="hljs-selector-tag">deeper</span> <span class="hljs-selector-tag">into</span> <span class="hljs-selector-tag">one</span> <span class="hljs-selector-tag">of</span> <span class="hljs-selector-tag">the</span> <span class="hljs-selector-tag">main</span> <span class="hljs-selector-tag">section</span>'<span class="hljs-selector-tag">s</span> <span class="hljs-selector-tag">points</span>.
</code></pre>
<h3 id="heading-make-your-content-clear-and-concise">Make your content clear and concise</h3>
<p>Overall, try to keep your sentences quite short in your docs. This makes them easier to read and understand (for everyone). You can also use images or videos to provide more details if needed.</p>
<p>Make sure you give the full meanings of any acronyms you are using for the first time. Also, always use simple sentences, and try not to use ambiguous words.</p>
<p>Here's an example of an overly complex, long sentence with difficult vocabulary:</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">The</span> <span class="hljs-selector-tag">web3</span> <span class="hljs-selector-tag">running</span> <span class="hljs-selector-tag">on</span> <span class="hljs-selector-tag">the</span> <span class="hljs-selector-tag">Blockchain</span> <span class="hljs-selector-tag">structure</span> <span class="hljs-selector-tag">which</span> <span class="hljs-selector-tag">is</span> <span class="hljs-selector-tag">transparent</span>, <span class="hljs-selector-tag">secure</span>, <span class="hljs-selector-tag">immutable</span>, <span class="hljs-selector-tag">decentralized</span> <span class="hljs-selector-tag">would</span> <span class="hljs-selector-tag">require</span> <span class="hljs-selector-tag">the</span> <span class="hljs-selector-tag">processes</span> <span class="hljs-selector-tag">of</span> <span class="hljs-selector-tag">artificial</span> <span class="hljs-selector-tag">intelligence</span>, <span class="hljs-selector-tag">where</span> <span class="hljs-selector-tag">it</span> <span class="hljs-selector-tag">would</span> <span class="hljs-selector-tag">read</span> <span class="hljs-selector-tag">data</span>, <span class="hljs-selector-tag">process</span>, <span class="hljs-selector-tag">and</span> <span class="hljs-selector-tag">store</span> <span class="hljs-selector-tag">information</span>.
</code></pre>
<p>This is better:</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">Web3</span> <span class="hljs-selector-tag">is</span> <span class="hljs-selector-tag">built</span> <span class="hljs-selector-tag">on</span> <span class="hljs-selector-tag">the</span> <span class="hljs-selector-tag">transparent</span>, <span class="hljs-selector-tag">secure</span>, <span class="hljs-selector-tag">unchangable</span>, <span class="hljs-selector-tag">and</span> <span class="hljs-selector-tag">decentralized</span> <span class="hljs-selector-tag">structure</span> <span class="hljs-selector-tag">of</span> <span class="hljs-selector-tag">the</span> <span class="hljs-selector-tag">blockchain</span>. <span class="hljs-selector-tag">It</span> <span class="hljs-selector-tag">uses</span> <span class="hljs-selector-tag">artificial</span> <span class="hljs-selector-tag">intelligence</span> <span class="hljs-selector-tag">processes</span> <span class="hljs-selector-tag">to</span> <span class="hljs-selector-tag">read</span>, <span class="hljs-selector-tag">process</span>, <span class="hljs-selector-tag">and</span> <span class="hljs-selector-tag">store</span> <span class="hljs-selector-tag">information</span>.
</code></pre>
<p>Your content should contain the main points you're trying to make, removing all forms of ambiguity.‌ ‌</p>
<h3 id="heading-use-informative-link-text">Use informative link text</h3>
<p>All your in-line links should use clear, detailed, and descriptive text. You can describe the link's purpose or the company's name if it is a brand, for example.</p>
<p>Links are important for improving the ranking of a page. And using links like "Click here" or "Read More" is not all that helpful, as they don't tell the reader much about what they'll find at that link.</p>
<p>For instance, if I wanted to link a W3C (World Wide Web Consortium) accessibility tutorial to this article, I could use the following format: Check out <a target="_blank" href="https://www.w3.org/WAI/roles/writers/">these resources for content writers by W3C</a>.</p>
<h3 id="heading-add-alt-text-and-captions-to-media-content">Add alt text and captions to media content</h3>
<h4 id="heading-images">Images</h4>
<p>Adding descriptive text to the alt text attribute allows screen readers to be able to read out the alt text associated with an image. Alt text also helps search engine bots that crawl the page know how to classify that content.</p>
<p>When you're adding alt text, describe the purpose of the image and not what the image is. For instance, let's say you're using an image that shows some shipping containers in a section that is about containerization.‌</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/04/containers-1.jpeg" alt="Various containers on a ship in motion to illustrate the packaging structure and process of a digital container." width="600" height="400" loading="lazy"></p>
<p><em>Various containers on a ship in motion to illustrate the packaging structure and process of a digital container.</em></p>
<p>Instead of writing alt text like "various containers on a ship in motion", you could write "various containers on a ship in motion to illustrate the packaging structure and process of a digital container."</p>
<p>While alt text serves as an alternative for the image, captions give more details about the image. You can use HTML to insert image captions. Markdown does not support image captions, but markdown documentation sites usually have a way around it (for example, through plugins – ReadTheDocs, MkDocs – or inserting HTML via a custom component –Docusaurus).</p>
<p>As an example, I'll show you how to add image captions in Docusaurus.</p>
<p><strong>How to add image captions in a Docusaurus .md file:</strong></p>
<ul>
<li><p>Create a folder <code>components</code> in the <code>src</code> folder.</p>
</li>
<li><p>Create a file named <code>figure.jsx</code>.</p>
</li>
<li><p>Add this line of code to it:</p>
</li>
</ul>
<pre><code class="lang-css"><span class="hljs-selector-tag">import</span> <span class="hljs-selector-tag">React</span> <span class="hljs-selector-tag">from</span> "<span class="hljs-selector-tag">react</span>"; 
<span class="hljs-selector-tag">import</span> <span class="hljs-selector-tag">useBaseUrl</span> <span class="hljs-selector-tag">from</span> "<span class="hljs-keyword">@docusaurus</span>/useBaseUrl"; 
<span class="hljs-selector-tag">export</span> <span class="hljs-selector-tag">default</span> <span class="hljs-selector-tag">function</span> <span class="hljs-selector-tag">Figure</span>({ src, caption }) {
  return ( 
  &lt;figure&gt; &lt;img src={useBaseUrl(src)} <span class="hljs-selector-tag">alt</span>={caption} /&gt; 
  &lt;<span class="hljs-selector-tag">figcaption</span>&gt;{`<span class="hljs-attribute">Figure</span>: ${caption}`}&lt;/<span class="hljs-selector-tag">figcaption</span>&gt; &lt;/<span class="hljs-selector-tag">figure</span>&gt; 
  ); 
}
</code></pre>
<ul>
<li>Go to the <code>.md</code> file where you have the image and import the code.</li>
</ul>
<pre><code class="lang-css"><span class="hljs-selector-tag">import</span> <span class="hljs-selector-tag">Figure</span> <span class="hljs-selector-tag">from</span> '<span class="hljs-keyword">@site</span>/src/components/figure'; 
<span class="hljs-selector-tag">import</span> <span class="hljs-selector-tag">figure1</span> <span class="hljs-selector-tag">from</span> '<span class="hljs-selector-tag">path-to-image</span>';
</code></pre>
<ul>
<li>Add it to the file.</li>
</ul>
<pre><code class="lang-css">&lt;<span class="hljs-selector-tag">Figure</span> <span class="hljs-selector-tag">caption</span>="<span class="hljs-selector-tag">This</span> <span class="hljs-selector-tag">is</span> <span class="hljs-selector-tag">a</span> <span class="hljs-selector-tag">caption</span> <span class="hljs-selector-tag">for</span> <span class="hljs-selector-tag">the</span> <span class="hljs-selector-tag">image</span>" <span class="hljs-selector-tag">alt</span>="<span class="hljs-selector-tag">This</span> <span class="hljs-selector-tag">is</span> <span class="hljs-selector-tag">alt</span> <span class="hljs-selector-tag">text</span>" <span class="hljs-selector-tag">src</span>={figure1} /&gt;
</code></pre>
<p>The image will now display with a caption.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/04/Screenshot_13-3.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>A screenshot example of image caption</em></p>
<h4 id="heading-videos">‌Videos</h4>
<p>To caption videos, HTML is a great option. But if you are using markdown, you can embed videos from YouTube and Vimeo using the <code>&lt;iframe&gt;</code> tag. These apps offer in-built caption support so you can enable captions before adding the embed code.</p>
<p>You could also install third-party plugins for this purpose.</p>
<p>Here's another tip: avoid flashing content in your videos as it could lead to seizure triggers. If your video has flashing bright colours, ensure that it does not exceed two times within a second.</p>
<h3 id="heading-add-transcripts-to-audios-and-videos">Add transcripts to audios and videos</h3>
<p>It's a good idea to add transcripts to your audio and video content. Not everyone will want to watch or listen to the content. But they may be curious to know what it is about.</p>
<p>By adding a transcript, you make it easier for anyone to navigate through the content and get the information that they need.</p>
<h4 id="heading-transcript-for-audio">Transcript for audio</h4>
<p>For audio content, you can insert transcripts using HTML. Here's an example:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">audio</span> <span class="hljs-attr">controls</span> <span class="hljs-attr">muted</span>&gt;</span><span class="hljs-comment">&lt;!--Always set your audios to muted--&gt;</span> 
    <span class="hljs-tag">&lt;<span class="hljs-name">source</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"ringtone.mp3"</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"audio/mpeg"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">source</span>&gt;</span> 
<span class="hljs-tag">&lt;/<span class="hljs-name">audio</span>&gt;</span> 
<span class="hljs-tag">&lt;<span class="hljs-name">code</span>&gt;</span> 
    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Here is a transcription of the text<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span> 
    00:03 = I am going to be productive today<span class="hljs-tag">&lt;<span class="hljs-name">br</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">br</span>&gt;</span> 
    00:05 = I am going to be productive today<span class="hljs-tag">&lt;<span class="hljs-name">br</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">br</span>&gt;</span> 
    00:08 = I am going to be productive today<span class="hljs-tag">&lt;<span class="hljs-name">br</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">br</span>&gt;</span> 
    00:10 = I need to be productive today<span class="hljs-tag">&lt;<span class="hljs-name">br</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">br</span>&gt;</span> 
    00:11 = I have to be productive today<span class="hljs-tag">&lt;<span class="hljs-name">br</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">br</span>&gt;</span> 
    00:13 = I should be productive today<span class="hljs-tag">&lt;<span class="hljs-name">br</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">br</span>&gt;</span> 
    00:16 = I am going to be productive today<span class="hljs-tag">&lt;<span class="hljs-name">br</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">br</span>&gt;</span> 
    00:18 = I ought to be productive today<span class="hljs-tag">&lt;<span class="hljs-name">br</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">br</span>&gt;</span> 
    00:21 = I have to be productive today<span class="hljs-tag">&lt;<span class="hljs-name">br</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">br</span>&gt;</span> 
    00:23 = Productivity matters to me <span class="hljs-tag">&lt;<span class="hljs-name">br</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">br</span>&gt;</span> 
<span class="hljs-tag">&lt;/<span class="hljs-name">code</span>&gt;</span>
</code></pre>
<p>For markdown documentation sites like Docusaurus, you can create a custom component.‌</p>
<ul>
<li><p>In your <code>src/components</code> folder, create a file named <code>transcript.jsx</code>.</p>
</li>
<li><p>Insert this code:</p>
</li>
</ul>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> React, { useState } <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>; 
<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Transcript</span>(<span class="hljs-params">{ }</span>) </span>{ 
  <span class="hljs-keyword">const</span> [showTranscript, setShowTranscript] = useState(<span class="hljs-literal">false</span>); 
  <span class="hljs-keyword">const</span> toggleTranscript = <span class="hljs-function">() =&gt;</span> { 
    setShowTranscript(!showTranscript); 
  }; 
  <span class="hljs-keyword">return</span> ( 
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span> <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"#"</span> <span class="hljs-attr">onClick</span>=<span class="hljs-string">{toggleTranscript}</span>&gt;</span> { 
    showTranscript ? 'Hide transcript' : 'View transcript'
    } 
    <span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span> {showTranscript &amp;&amp; ( <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"transcriptText"</span>&gt;</span> (insert your transcript text here) <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span> )} 
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span> 
  ); 
}
</code></pre>
<ul>
<li>Go to your markdown file and import it.</li>
</ul>
<pre><code class="lang-css"><span class="hljs-selector-tag">import</span> <span class="hljs-selector-tag">Transcript</span> <span class="hljs-selector-tag">from</span> '<span class="hljs-keyword">@site</span>/src/components/transcript'; 

&lt;<span class="hljs-selector-tag">Transcript</span> /&gt;
</code></pre>
<p>‌</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/04/Screenshot_17-6.png" alt="A screenshot of the audio transcript output on a documentation site" width="600" height="400" loading="lazy"></p>
<p><em>A screenshot of the audio transcript output</em></p>
<p>‌<strong>Note:</strong> I added some tweaks to the code to make transcript display optional. You can edit it if you want the transcript to show as the page loads.</p>
<h4 id="heading-transcript-for-video">Transcript for video</h4>
<p>Now for videos, YouTube is a great option. It provides inbuilt transcripts for your videos. So, you can always embed YouTube videos in your docs.</p>
<p>The transcript is in the video description after the main details. The transcript will display with the timestamps when you click the "Show Transcript" button.</p>
<h3 id="heading-add-code-snippets-and-use-the-colour-contrast-technique">Add code snippets and use the colour contrast technique</h3>
<h4 id="heading-how-to-add-code-snippets">How to add code snippets</h4>
<p>Use code blocks within the text to explain code instead of images. You could also use code snippets to showcase the output of your code. Unless it is necessary to add an image, you should use code snippets.</p>
<p>For instance,</p>
<p><code>index.html</code></p>
<pre><code class="lang-html"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span> 
<span class="hljs-tag">&lt;<span class="hljs-name">html</span>&gt;</span> 
    <span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span> 
        <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">http-equiv</span>=<span class="hljs-string">"content-type"</span> <span class="hljs-attr">content</span>=<span class="hljs-string">"text/html; charset=utf-8"</span> /&gt;</span> <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>A calculator app<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span> 
        <span class="hljs-tag">&lt;<span class="hljs-name">link</span> <span class="hljs-attr">rel</span>=<span class="hljs-string">"stylesheet"</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"styles.css"</span>/&gt;</span> 
    <span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span> 
    <span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span> 
    <span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span> 
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<p>This will allow screen readers to read through the code, which they are not able to do with screenshots.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/04/Screenshot_14-2.png" alt="A screenshot of the above code" width="600" height="400" loading="lazy"></p>
<p><em>A screenshot of the above code</em></p>
<h4 id="heading-colour-contrast-technique">Colour contrast technique</h4>
<p>The colour contrast technique implies using colours that are opposite or heavily contrasting.</p>
<p>For example, using black text on a white background has a high contrast, as opposed to using light brown text on a brown background.</p>
<p>When combining colours, you could use an <a target="_blank" href="http://colorsafe.co/">accessible colour palette like Color Safe</a>.‌</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/04/Screenshot_15-4.png" alt="Using a pale white colour on a green background gotten from Color Safe" width="600" height="400" loading="lazy"></p>
<p><em>Using a pale white colour on a green background gotten from Color Safe</em></p>
<h3 id="heading-add-translation-options">Add translation options</h3>
<p>There are documentation sites that provide translation options where you can build your docs in multiple languages, websites like Jekyll. <a target="_blank" href="https://leo3418.github.io/collections/multilingual-jekyll-site/add-language-switcher.html">This is an example</a>.</p>
<p>Docusaurus is also another doc site that provides multilingual options using Crowdin or Git.</p>
<ul>
<li><p><a target="_blank" href="https://docusaurus.io/docs/i18n/git">Follow through this guide</a> to set up translation and localization on Docusaurus using Git.</p>
</li>
<li><p><a target="_blank" href="https://docusaurus.io/docs/i18n/crowdin">Follow through this guide</a> to set up translation and localization on Docusaurus using Crowdin.‌</p>
</li>
</ul>
<h3 id="heading-use-accessibility-testing-tools">Use accessibility testing tools</h3>
<p>There are tools you can use to check for errors in accessibility in your docs. Some examples are <a target="_blank" href="https://wave.webaim.org/">WAVE (Web Accessibility Evaluation Tool)</a> and <a target="_blank" href="https://www.deque.com/axe/">AXE (Accessibility Engine)</a>.</p>
<p>Also, you can get the <a target="_blank" href="https://www.nvaccess.org/download/">NVDA(NonVisual Desktop Access) screen reader</a> to test out your content. This software will let you know how the content of your documentation will be perceived by a user using a screen reader.‌</p>
<h3 id="heading-set-up-an-improvement-or-suggestion-box">Set up an improvement or suggestion box</h3>
<p>Finally, it may not be possible to cover the needs of every user. So you could add a suggestion or improvement box, allowing users to send feedback about how you could further improve the content. Hearing firsthand from users can help you know how best to make the docs accessible for them.</p>
<p>To add an improvement box, you could use an external form link that stores the users' inputs or you could set up the suggestion box in the docs.</p>
<h4 id="heading-how-to-add-an-external-form-link-in-docusaurus">How to add an external form link in Docusaurus</h4>
<p>You would need to create a custom component for that.</p>
<ul>
<li><p>Go to <code>src/components</code> folder and create a file <code>feedback.jsx</code>.</p>
</li>
<li><p>Add this code:</p>
</li>
</ul>
<pre><code class="lang-css"><span class="hljs-selector-tag">import</span> <span class="hljs-selector-tag">React</span> <span class="hljs-selector-tag">from</span> '<span class="hljs-selector-tag">react</span>'; 

<span class="hljs-selector-tag">export</span> <span class="hljs-selector-tag">default</span> <span class="hljs-selector-tag">function</span> <span class="hljs-selector-tag">FeedbackButton</span>({ href }) {
  return ( &lt;a href={href} <span class="hljs-selector-tag">target</span>="_<span class="hljs-selector-tag">blank</span>" <span class="hljs-selector-tag">rel</span>="<span class="hljs-selector-tag">noopener</span> <span class="hljs-selector-tag">noreferrer</span>" &gt; <span class="hljs-selector-tag">Give</span> <span class="hljs-selector-tag">Feedback</span> &lt;/<span class="hljs-selector-tag">a</span>&gt; ); 
};
</code></pre>
<ul>
<li>In your markdown file import it:</li>
</ul>
<pre><code class="lang-css"><span class="hljs-selector-tag">import</span> <span class="hljs-selector-tag">FeedbackButton</span> <span class="hljs-selector-tag">from</span> '<span class="hljs-keyword">@site</span>/src/components/feedbackbutton';
</code></pre>
<ul>
<li>Insert the link</li>
</ul>
<pre><code class="lang-css">&lt;<span class="hljs-selector-tag">FeedbackButton</span> <span class="hljs-selector-tag">href</span>="<span class="hljs-selector-tag">https</span>://<span class="hljs-selector-tag">forms</span><span class="hljs-selector-class">.google</span><span class="hljs-selector-class">.com</span>" /&gt;
</code></pre>
<p>When you run it on your docs, it should showcase a link to Google forms. Google Forms is an example, you could add the link to your company website or server. Here's what it'll look like:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/04/Screenshot_18-3.png" alt="A feedback link that states &quot;Give feedback&quot; for suggestion or improvement on a docusaurus docs site that leads users to an external site which is Google Forms" width="600" height="400" loading="lazy"></p>
<p><em>A feedback link for suggestion in a docs site</em></p>
<h2 id="heading-summary">Summary</h2>
<p>To follow and implement these accessibility best practices, you can consider creating or using an already made style guide. This can help you consistently implement these practices and make it easier for you and other technical writers on your team.</p>
<p>There are style guides focused on accessibility for technical writers, such as the following:</p>
<ol>
<li><p><a target="_blank" href="https://github.com/heyawhite/tech-writing-tools/blob/main/accessibility/style.md">Accessibility style guide by Heyawhite</a></p>
</li>
<li><p><a target="_blank" href="https://developers.google.com/style/accessibility">Write accessible documentation by Google for developers</a></p>
</li>
<li><p><a target="_blank" href="https://styleguide.mailchimp.com/writing-for-accessibility/">Writing for Accessibility by MailChimp content style guide</a></p>
</li>
</ol>
<p>That sums up my tips about web accessibility practices in writing. I'm a technical writer, and you can reach out to me on <a target="_blank" href="https://www.instagram.com/ezinneanneemilia/">Instagram</a> or hire me via <a target="_blank" href="https://www.upwork.com/freelancers/~013e195fa64f8b3456?mp_source=share">Upwork</a>. Thank you for reading.‌</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Web Accessibility Best Practices – How to Ensure Everyone Can Use Your Website ]]>
                </title>
                <description>
                    <![CDATA[ In the dynamic world of web development, creating websites that are accessible to all users, including those with disabilities, is not just a best practice – it's a necessity.  Web accessibility ensures that everyone, regardless of their abilities, c... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/web-accessibility-best-practices/</link>
                <guid isPermaLink="false">66bae6bcac70cebcb65690af</guid>
                
                    <category>
                        <![CDATA[ a11y ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Accessibility ]]>
                    </category>
                
                    <category>
                        <![CDATA[ best practices ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Sudheer Kumar Reddy Gowrigari ]]>
                </dc:creator>
                <pubDate>Sun, 17 Dec 2023 21:27:27 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/12/accessibility-2-1.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>In the dynamic world of web development, creating websites that are accessible to all users, including those with disabilities, is not just a best practice – it's a necessity. </p>
<p>Web accessibility ensures that everyone, regardless of their abilities, can perceive, understand, navigate, and interact with the web. This inclusivity not only broadens your audience but also reflects social responsibility and compliance with legal standards.</p>
<h3 id="heading-heres-what-well-cover">Here's what we'll cover:</h3>
<ol>
<li><a class="post-section-overview" href="#heading-what-is-web-accessibility">What is Web Accessibility?</a></li>
<li><a class="post-section-overview" href="#heading-best-practices-for-web-accessibility">Best Practices for Web Accessibility</a><br>– <a class="post-section-overview" href="#heading-use-semantic-html">Use semantic HTML</a><br>– <a class="post-section-overview" href="#heading-use-sufficient-contrast">Use sufficient contrast</a><br>– <a class="post-section-overview" href="#heading-make-all-functionality-keyboard-accessible">Make all functionality keyboard accessible</a><br>– <a class="post-section-overview" href="#heading-provide-alt-text-for-images">Provide alt text for images</a><br>– <a class="post-section-overview" href="#heading-use-aria-accessible-rich-internet-applications-roles-when-necessary">Use ARIA roles when necessary</a><br>– <a class="post-section-overview" href="#heading-ensure-forms-are-accessible">Ensure forms are accessible</a><br>– <a class="post-section-overview" href="#heading-caption-and-transcribe-audio-and-video">Caption and transcribe audio and video</a><br>– <a class="post-section-overview" href="#heading-design-consistent-predictable-navigation">Design consistent, predictable navigation</a></li>
<li><a class="post-section-overview" href="#heading-automation-tools-for-accessibility-testing">Automation Tools for Accessibility Testing</a></li>
<li><a class="post-section-overview" href="#heading-embrace-accessibility-as-a-cornerstone-of-web-development">Wrapping Up</a></li>
</ol>
<h2 id="heading-what-is-web-accessibility">What is Web Accessibility?</h2>
<p>Accessibility in web design means creating web pages that can be used by people with a wide range of abilities and disabilities. This encompasses auditory, cognitive, neurological, physical, speech, and visual impairments.</p>
<h3 id="heading-key-principles-of-accessibility">Key Principles of Accessibility</h3>
<p>The Web Content Accessibility Guidelines (WCAG) provide a framework for making web content more accessible to people with a wide range of abilities and disabilities. These guidelines are based on four key principles, often summarized as POUR, each crucial for creating a universally accessible web. </p>
<p>Here's a deeper look into what these principles mean in practice:</p>
<ol>
<li><strong>Perceivable</strong>: Information and user interface components must be presented in ways that all users can perceive. This means providing text alternatives for non-text content (like images), creating content that can be presented in different ways without losing information (such as using a simpler layout), and making it easier for users to see and hear content.<br><strong>Example</strong>: Providing alt text for images. Alt text allows screen reader users to understand the content and context of the images, making visual content accessible.</li>
<li><strong>Operable</strong>: User interface components and navigation must be operable by everyone. This includes ensuring all functionalities are accessible via keyboard, giving users enough time to read and use content, and not designing content in a way that is known to cause seizures.<br><strong>Example</strong>: Implementing keyboard navigation. All interactive elements like links, buttons, and form fields should be accessible using a keyboard, making them accessible to users who cannot use a mouse.</li>
<li><strong>Understandable</strong>: Information and operation of the user interface must be understandable. This means making text readable and understandable, and ensuring that web pages appear and operate in predictable ways.<br><strong>Example</strong>: Using consistent navigation menus. Keeping navigation menus consistent across a website helps users with cognitive disabilities learn and remember how to navigate.</li>
<li><strong>Robust</strong>: Content must be robust enough to be reliably interpreted by a wide variety of user agents, including assistive technologies. This includes ensuring compatibility with current and future user tools.<br><strong>Example</strong>: Using clean, validated HTML. Well-structured and standard-compliant HTML ensures content can be interpreted by different browsers and assistive technologies.</li>
</ol>
<p>By integrating these principles into web design, developers and designers can create more accessible and inclusive digital environments. Each principle plays a crucial role in ensuring that the web is a space for everyone, regardless of their abilities or disabilities.</p>
<h2 id="heading-best-practices-for-web-accessibility">Best Practices for Web Accessibility</h2>
<h3 id="heading-use-semantic-html">Use Semantic HTML</h3>
<p>Semantic HTML involves using HTML elements according to their intended purpose rather than just for presentation. It's about structuring your website with elements that describe their meaning and role in the document structure. </p>
<p>This practice is crucial for assistive technologies, like screen readers, which rely on this structure to interpret and navigate content. </p>
<h3 id="heading-how-to-implement-semantic-html">How to implement semantic HTML</h3>
<p>Consider a typical webpage layout comprising a header, main content, a navigation menu, and a footer. Instead of using non-semantic <code>&lt;div&gt;</code> tags for these sections, you should use the semantic elements <code>&lt;header&gt;</code>, <code>&lt;main&gt;</code>, <code>&lt;nav&gt;</code>, and <code>&lt;footer&gt;</code> respectively.</p>
<p>Here's an example:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">header</span>&gt;</span>
  <span class="hljs-comment">&lt;!-- Site logo, header content --&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">header</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">nav</span>&gt;</span>
  <span class="hljs-comment">&lt;!-- Navigation links --&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">nav</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">main</span>&gt;</span>
  <span class="hljs-comment">&lt;!-- Main content --&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">main</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">footer</span>&gt;</span>
  <span class="hljs-comment">&lt;!-- Footer content --&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">footer</span>&gt;</span>
</code></pre>
<h3 id="heading-why-semantic-html-is-useful">Why semantic HTML is useful:</h3>
<ol>
<li><strong>Accessibility</strong>: Screen readers can easily navigate and interpret the content. For example, a user can skip directly to the main content or easily find the navigation menu.</li>
<li><strong>SEO benefits</strong>: Search engines favor well-structured content. Semantic elements make it easier for search engine bots to understand the content of a webpage, potentially improving search rankings.</li>
<li><strong>Maintainability</strong>: Semantic HTML leads to cleaner, more readable code, making it easier for developers to understand and maintain.</li>
</ol>
<p>Using semantic HTML is the foundation of web accessibility, ensuring content is accessible and meaningful to all users, including those using assistive technologies.</p>
<h3 id="heading-use-sufficient-contrast">Use Sufficient Contrast</h3>
<p>Contrast refers to the difference in color and brightness between the text and its background. Ensuring sufficient contrast is vital for readability, especially for users with visual impairments like color blindness or low vision. High contrast between text and background makes it easier for these users to read and understand content.</p>
<h3 id="heading-how-to-implement-good-contrast">How to implement good contrast</h3>
<p>Imagine a webpage with light gray text on a white background. This combination might look aesthetically pleasing but can be hard to read for many users. </p>
<p>To improve contrast, you could change the text color to a much darker shade, like black or dark gray.</p>
<pre><code class="lang-css"><span class="hljs-comment">/* Low contrast example */</span>
<span class="hljs-selector-class">.low-contrast-text</span> {
  <span class="hljs-attribute">color</span>: <span class="hljs-number">#757575</span>; <span class="hljs-comment">/* Light gray */</span>
  <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#fff</span>; <span class="hljs-comment">/* White */</span>
}

<span class="hljs-comment">/* Improved contrast */</span>
<span class="hljs-selector-class">.high-contrast-text</span> {
  <span class="hljs-attribute">color</span>: <span class="hljs-number">#000</span>; <span class="hljs-comment">/* Black */</span>
  <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#fff</span>; <span class="hljs-comment">/* White */</span>
}
</code></pre>
<h3 id="heading-why-contrast-is-useful">Why contrast is useful:</h3>
<ol>
<li><strong>Enhanced readability</strong>: High contrast makes the text legible to users with visual impairments and those reading under challenging lighting conditions.</li>
<li><strong>Inclusivity</strong>: It caters to a wider audience, including users with deteriorating vision and those with temporary or situational impairments.</li>
<li><strong>Legal compliance</strong>: Many regions have regulations requiring accessible web content, and sufficient contrast is a common requirement.</li>
</ol>
<p>Tools like the <a target="_blank" href="https://webaim.org/resources/contrastchecker/">WebAIM Contrast Checker</a> can help you evaluate your color choices, ensuring they meet accessibility standards like WCAG. By ensuring sufficient contrast, you not only make your website more accessible but also improve the overall user experience.</p>
<h3 id="heading-make-all-functionality-keyboard-accessible">Make All Functionality Keyboard Accessible</h3>
<p>Ensuring that all functionalities on a website are accessible via keyboard is essential for users who cannot use a mouse due to physical disabilities, temporary injuries, or personal preference. This includes navigating menus, activating buttons and links, filling out forms, and using interactive widgets.</p>
<h3 id="heading-how-to-make-content-keyboard-accessible">How to make content keyboard accessible</h3>
<p>Consider a dropdown menu on a website. Typically, users hover over the menu with a mouse to view the options. </p>
<p>To make this keyboard-accessible, you need to ensure that users can navigate to the menu using the Tab key and expand the menu using the Enter or Space key.</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">ul</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">li</span> <span class="hljs-attr">tabindex</span>=<span class="hljs-string">"0"</span>&gt;</span>Menu Item 1
    <span class="hljs-tag">&lt;<span class="hljs-name">ul</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"dropdown-content"</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">li</span> <span class="hljs-attr">tabindex</span>=<span class="hljs-string">"0"</span>&gt;</span>Sub Item 1<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">li</span> <span class="hljs-attr">tabindex</span>=<span class="hljs-string">"0"</span>&gt;</span>Sub Item 2<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">li</span> <span class="hljs-attr">tabindex</span>=<span class="hljs-string">"0"</span>&gt;</span>Menu Item 2<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span>
</code></pre>
<pre><code class="lang-js"><span class="hljs-built_in">document</span>.querySelectorAll(<span class="hljs-string">'li[tabindex="0"]'</span>).forEach(<span class="hljs-function"><span class="hljs-params">item</span> =&gt;</span> {
  item.addEventListener(<span class="hljs-string">'keypress'</span>, <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">e</span>) </span>{
    <span class="hljs-keyword">if</span> (e.key === <span class="hljs-string">'Enter'</span> || e.key === <span class="hljs-string">' '</span>) {
      <span class="hljs-comment">// Code to toggle dropdown</span>
    }
  });
});
</code></pre>
<h3 id="heading-why-keyboard-navigation-is-useful">Why keyboard navigation is useful:</h3>
<ol>
<li><strong>Accessibility for all</strong>: Keyboard accessibility ensures that users with motor disabilities or those who prefer keyboard navigation can use the website effectively.</li>
<li><strong>Enhanced usability</strong>: Keyboard shortcuts can speed up navigation, offering an enhanced experience even for users who can use a mouse.</li>
<li><strong>Compliance with accessibility standards</strong>: Adhering to standards like WCAG and ADA (Americans with Disabilities Act) often requires keyboard accessibility.</li>
</ol>
<p>In practice, keyboard accessibility may involve more than just basic navigation. It also includes managing focus, creating keyboard shortcuts for complex actions, and ensuring custom widgets are keyboard-friendly. By prioritizing keyboard accessibility, you make your website more inclusive and user-friendly.</p>
<h3 id="heading-provide-alt-text-for-images">Provide Alt Text for Images</h3>
<p>Alt text (alternative text) is a concise description of an image's content and function. It's crucial for visually impaired users who rely on screen readers to understand image content. Alt text ensures that even if users can't see the images on a web page, their purpose and message can still be conveyed.</p>
<h3 id="heading-how-to-add-alt-text-to-images">How to add alt text to images</h3>
<p>Suppose your website has an image of a company logo. The alt text should describe the logo, not just state "logo". For instance, <code>alt="FreeCodeCamp's campfire Logo"</code>.</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"freecodecamp-logo.png"</span> <span class="hljs-attr">alt</span>=<span class="hljs-string">"FreeCodeCamp's campfire Logo"</span>&gt;</span>
</code></pre>
<p>For purely decorative images that don't add informational content, use an empty alt attribute (<code>alt=""</code>) to indicate that they can be skipped by screen readers.</p>
<h3 id="heading-why-alt-text-is-useful">Why alt text is useful:</h3>
<ol>
<li><strong>Accessibility Compliance</strong>: Providing alt text is a fundamental aspect of web accessibility, required under WCAG guidelines.</li>
<li><strong>SEO Benefits</strong>: Alt text improves SEO by providing better image context/descriptions, helping search engines index an image properly.</li>
<li><strong>Fallback Content</strong>: If an image fails to load, the alt text will be displayed, helping all users understand what was supposed to be there.</li>
</ol>
<p>Properly implemented alt text makes your website more accessible and inclusive, ensuring that all users, regardless of their ability to see, have access to the information conveyed by images. It's a simple yet impactful practice that enhances the overall user experience.</p>
<h3 id="heading-use-aria-accessible-rich-internet-applications-roles-when-necessary">Use ARIA (Accessible Rich Internet Applications) Roles When Necessary</h3>
<p>ARIA roles and attributes enhance the accessibility of web content, particularly for dynamic content and advanced user interface controls developed with Ajax, HTML, JavaScript, and related technologies. ARIA helps make web content and web applications more accessible to people with disabilities, especially when HTML can't accomplish it alone.</p>
<h3 id="heading-how-to-implement-aria-roles-and-attributes">How to implement ARIA roles and attributes</h3>
<p>Consider a web application with a dynamic content update section, such as a live news feed. Standard HTML alone may not be able to convey the dynamic nature of this content to screen readers. </p>
<p>By using ARIA roles, you can make it clear to assistive technologies that this section of the page is a live region and its updates are important. For instance:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">aria-live</span>=<span class="hljs-string">"polite"</span> <span class="hljs-attr">aria-atomic</span>=<span class="hljs-string">"true"</span>&gt;</span>
  <span class="hljs-comment">&lt;!-- Dynamic content here, like live news updates --&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>In this example, <code>aria-live="polite"</code> indicates that updates to this region should be announced by screen readers, but not interrupt the current task, while <code>aria-atomic="true"</code> ensures that the entire region is read as a whole, not just the updated part.</p>
<h3 id="heading-why-aria-is-useful">Why ARIA is useful:</h3>
<ol>
<li><strong>Enhanced screen reader experience</strong>: ARIA roles provide screen reader users with a more comprehensive understanding of what's happening on the page, particularly for dynamic and complex content.</li>
<li><strong>Greater interactivity</strong>: ARIA can make web applications more interactive and usable for people with disabilities, facilitating operations that standard HTML can't handle.</li>
<li><strong>Custom widget accessibility</strong>: For custom widgets that lack semantic HTML equivalents, ARIA roles can define the widget's function, making it accessible.</li>
</ol>
<p>While ARIA is powerful, it's important to use it only when necessary. Native HTML elements should be the first choice as they inherently carry semantic meaning and accessibility features. ARIA should be used as a supplement to enhance accessibility when HTML's semantics don't suffice.</p>
<h3 id="heading-ensure-forms-are-accessible">Ensure Forms are Accessible</h3>
<p>Accessible forms are vital for users with disabilities to interact with a site, input data, and utilize services. Ensuring that form elements are accessible means they can be easily navigated, understood, and filled out by everyone, including those using screen readers or keyboard navigation.</p>
<h3 id="heading-how-to-make-forms-accessible">How to make forms accessible</h3>
<p>Imagine a simple contact form with fields for name, email, and a message. For each form element, use a <code>&lt;label&gt;</code> tag to provide a clear description. Ensure that each <code>&lt;label&gt;</code> is associated with its respective form control using the <code>for</code> attribute, which matches the <code>id</code> of the input element. This is crucial for screen reader users to understand what each field represents.</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">form</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">for</span>=<span class="hljs-string">"name"</span>&gt;</span>Name:<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"name"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"name"</span>&gt;</span>

  <span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">for</span>=<span class="hljs-string">"email"</span>&gt;</span>Email:<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"email"</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"email"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"email"</span>&gt;</span>

  <span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">for</span>=<span class="hljs-string">"message"</span>&gt;</span>Message:<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">textarea</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"message"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"message"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">textarea</span>&gt;</span>

  <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"submit"</span>&gt;</span>Submit<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">form</span>&gt;</span>
</code></pre>
<h3 id="heading-why-accessible-forms-are-useful">Why accessible forms are useful:</h3>
<ol>
<li><strong>Clarity and context</strong>: Labels provide context to users, especially those using screen readers, about what type of information is expected in each field.</li>
<li><strong>Error handling</strong>: Accessible forms should also handle errors clearly, informing users about what went wrong and how to fix it. This can include real-time validation feedback and error messages that are announced by screen readers.</li>
<li><strong>Keyboard navigation</strong>: All form controls should be navigable using the keyboard, allowing users who can't use a mouse to interact fully with the form.</li>
</ol>
<p>Accessible forms not only comply with accessibility standards but also enhance the overall user experience, making your website more inclusive and user-friendly.</p>
<h3 id="heading-caption-and-transcribe-audio-and-video">Caption and Transcribe Audio and Video</h3>
<p>Providing captions for video content and transcriptions for audio is crucial for accessibility. Captions and transcriptions ensure that deaf or hard-of-hearing users, as well as those who prefer reading to listening, can access audio and video content.</p>
<h3 id="heading-how-to-make-audio-and-video-content-accessible">How to make audio and video content accessible</h3>
<p>For a video on your website, include closed captioning that accurately reflects the spoken content and other auditory cues. You can use HTML5's <code>&lt;track&gt;</code> element to specify caption files. Similarly, for audio content like podcasts or interviews, provide a text transcription.</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">video</span> <span class="hljs-attr">controls</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">source</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"video.mp4"</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"video/mp4"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">track</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"captions_en.vtt"</span> <span class="hljs-attr">kind</span>=<span class="hljs-string">"captions"</span> <span class="hljs-attr">srclang</span>=<span class="hljs-string">"en"</span> <span class="hljs-attr">label</span>=<span class="hljs-string">"English"</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">video</span>&gt;</span>
</code></pre>
<p>In this example, a WebVTT (.vtt) file is used for captions. Ensure the captions are synchronized with the audio and include descriptions of relevant non-speech audio.</p>
<h3 id="heading-why-captions-and-transcriptions-are-useful">Why captions and transcriptions are useful</h3>
<ol>
<li><strong>Accessibility for hearing impaired</strong>: Captions and transcriptions are essential for users who are deaf or hard of hearing, enabling them to access content that would otherwise be inaccessible.</li>
<li><strong>Enhanced comprehension</strong>: They also benefit users who are not fluent in the language of the video or have difficulty understanding the speech.</li>
<li><strong>Flexible viewing</strong>: Captions allow content to be consumed in sound-sensitive environments, like workplaces or libraries.</li>
</ol>
<p>Remember to regularly check the accuracy and readability of your captions and transcriptions. Well-implemented captions and transcriptions not only make your audio and video content accessible but also enhance the overall engagement and reach of your content.</p>
<h3 id="heading-design-consistent-predictable-navigation">Design Consistent, Predictable Navigation</h3>
<p>Designing a website with consistent and predictable navigation is key to accessibility. It allows users, especially those with cognitive disabilities, to learn the navigation pattern quickly, enhancing their ability to find information and navigate your site effectively.</p>
<h3 id="heading-how-to-design-effective-navigation">How to design effective navigation</h3>
<p>Consider a website with a top navigation menu. The menu items should be in a logical order and remain consistent across all pages. Avoid changing the order of menu items or their location on different pages.</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">nav</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">ul</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"/"</span>&gt;</span>Home<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"/about"</span>&gt;</span>About Us<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"/services"</span>&gt;</span>Services<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"/contact"</span>&gt;</span>Contact<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">nav</span>&gt;</span>
</code></pre>
<p>In this example, the navigation structure is simple and straightforward. It's important to maintain this structure and order consistently throughout the website.</p>
<h3 id="heading-why-good-navigation-is-useful">Why good navigation is useful:</h3>
<ol>
<li><strong>Ease of use</strong>: A consistent navigation structure helps users understand and remember how to interact with your website, reducing confusion and frustration.</li>
<li><strong>Improved orientation</strong>: Users can better orient themselves and understand their current location within the website.</li>
<li><strong>Support for assistive technologies</strong>: Consistent navigation is easier for screen readers and other assistive technologies to interpret, providing a smoother browsing experience for users relying on these tools.</li>
</ol>
<p>By ensuring that your website's navigation is consistent and predictable, you enhance the usability for all users, making your website more accessible and user-friendly.</p>
<h2 id="heading-automation-tools-for-accessibility-testing">Automation Tools for Accessibility Testing</h2>
<p>Incorporating automation tools into the accessibility testing process can significantly enhance efficiency and coverage. These tools can swiftly identify areas of non-compliance, allowing for prompt rectifications. </p>
<p>Below are some key tools with link to their websites if you want to explore more:</p>
<h3 id="heading-1-axe-accessibility-checkerhttpswwwdequecomaxe">1. <a target="_blank" href="https://www.deque.com/axe/">Axe Accessibility Checker</a></h3>
<p>Axe is a versatile browser extension and testing tool available for Chrome, Firefox, and Edge. It provides reliable and detailed issue reporting, making it ideal for quick checks and in-depth analysis.</p>
<h3 id="heading-2-wave-web-accessibility-evaluation-toolhttpswavewebaimorg">2. <a target="_blank" href="https://wave.webaim.org/">WAVE (Web Accessibility Evaluation Tool)</a></h3>
<p>WAVE, offered as a browser extension, visually represents potential accessibility problems on web pages, helping to pinpoint issues with color contrast, alt text, and ARIA roles.</p>
<h3 id="heading-3-google-lighthousehttpsdevelopersgooglecomwebtoolslighthouse">3. <a target="_blank" href="https://developers.google.com/web/tools/lighthouse">Google Lighthouse</a></h3>
<p>Integrated into Google Chrome's Developer Tools, Lighthouse features an accessibility audit tool that highlights issues and provides actionable recommendations.</p>
<h3 id="heading-4-tenoniohttpswwwtenonio">4. <a target="_blank" href="https://www.tenon.io/">Tenon.io</a></h3>
<p>Tenon.io is a comprehensive web-based tool for detailed accessibility testing. It can be integrated into development workflows for automated testing during the build process.</p>
<h3 id="heading-5-jaws-inspecthttpswwwtpgicomjaws-inspect">5. <a target="_blank" href="https://www.tpgi.com/jaws-inspect/">JAWS Inspect</a></h3>
<p>JAWS Inspect translates screen reader outputs into a visual format, aiding in the testing of screen reader compatibility and navigability.</p>
<h3 id="heading-6-color-contrast-analyzerhttpswwwpaciellogroupcomresourcescontrastanalyser">6. <a target="_blank" href="https://www.paciellogroup.com/resources/contrastanalyser/">Color Contrast Analyzer</a></h3>
<p>This tool assists in evaluating the contrast between text and its background, ensuring readability for users with visual impairments.</p>
<h3 id="heading-7-accessibility-insightshttpsaccessibilityinsightsio">7. <a target="_blank" href="https://accessibilityinsights.io/">Accessibility Insights</a></h3>
<p>Developed by Microsoft, Accessibility Insights offers a suite of tools, including a web tool for Chrome and Edge, to guide manual testing alongside automated checks.</p>
<h3 id="heading-8-pa11yhttpspa11yorg">8. <a target="_blank" href="https://pa11y.org/">Pa11y</a></h3>
<p>Pa11y is a command-line tool that runs automated accessibility tests on web pages, customizable for integration into development processes.</p>
<p>By leveraging these tools, developers and designers can ensure their websites meet accessibility standards, providing an inclusive experience for all users. Regular use, combined with manual testing and user feedback, creates a comprehensive approach to maintaining and enhancing web accessibility.</p>
<h2 id="heading-embrace-accessibility-as-a-cornerstone-of-web-development">Embrace Accessibility as a Cornerstone of Web Development</h2>
<p>In conclusion, the integration of web accessibility best practices is not just a matter of compliance but a commitment to inclusivity and universal design. The digital world is for everyone, and ensuring that web content is accessible to all, including those with disabilities, is a fundamental responsibility of web developers and designers.</p>
<p>Utilizing tools like Axe, WAVE, Google Lighthouse, and others, combined with manual testing and adherence to guidelines like WCAG, can significantly improve the accessibility of web content. By doing so, we open up our digital spaces to a wider audience, enhance user experience, and foster an environment of inclusivity.</p>
<p>Accessible web design benefits everyone, not just those with disabilities. It leads to cleaner code, better SEO, and a more flexible and resilient website. As the web continues to evolve, prioritizing accessibility will be crucial in creating a more connected and inclusive world. Remember, when we design for accessibility, we improve the web for everyone.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Web Accessibility Tips for Developers – A11y Principles Explained ]]>
                </title>
                <description>
                    <![CDATA[ Accessibility isn't just something you check off as done when you're building websites and web apps. It's a basic part of making the online world a better and fairer place for everyone.  In this article, you'll learn what accessibility means, and why... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/web-accessibility-for-devs/</link>
                <guid isPermaLink="false">66c47922d83968d1c78c3913</guid>
                
                    <category>
                        <![CDATA[ a11y ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Accessibility ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Development ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Adeola Ajiboso ]]>
                </dc:creator>
                <pubDate>Thu, 02 Nov 2023 14:17:51 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/10/51314.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Accessibility isn't just something you check off as done when you're building websites and web apps. It's a basic part of making the online world a better and fairer place for everyone. </p>
<p>In this article, you'll learn what accessibility means, and why it's important to make accessibility a part of your regular workflow. I'll also give you practical tips with examples to make your websites more accessible. </p>
<p>Let's explore the key parts of web accessibility together and help you make a website that includes everyone.</p>
<h2 id="heading-what-is-web-accessibility">What is Web Accessibility?</h2>
<p><a target="_blank" href="https://www.freecodecamp.org/news/accessibility-best-practices-to-make-web-apps-accessible/">Web accessibility</a> refers to the practice of designing and developing websites, applications, and digital content in a way that ensures people with disabilities can perceive, understand, navigate, and interact with them effectively.</p>
<h2 id="heading-principles-of-web-accessibility">Principles of Web Accessibility</h2>
<p>To effectively enhance the accessibility of your websites and apps, you'll want to follow these fundamental principles outlined by the Web Content Accessibility Guidelines (<a target="_blank" href="https://www.w3.org/WAI/WCAG21/quickref/?versions=2.0">WCAG</a>):</p>
<h3 id="heading-is-it-perceivable">Is it Perceivable?</h3>
<p>Content should be displayed in a manner that all users can understand, regardless of their sensory abilities. Here are some ways you can make your content more perceivable:</p>
<p>First, you can provide captions for audio and video materials. Adding captions to your website or application allows those with hearing disabilities to understand the information being shared, and make the content more accessible to everyone.</p>
<p>You can see an example of adding captions to a video in the image below: </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/10/img.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>Image of a video illustrating the use of captions.</em></p>
<p>Next, make sure you use proper color contrast for text and background elements.</p>
<p>Colors are an important part of a website, and we can describe them in terms of hue, lightness, and saturation.  </p>
<p>There are several categories of colors which include warm colors, cool colors, and neutral colors</p>
<p><strong>Warm Colors:</strong> Warm colors include red, orange, and yellow, and variations of<br>those three colors. These are the colors of fire, fall leaves, sunsets, and sunrises, and are generally energizing, passionate, and positive. </p>
<p><strong>Cool Colors:</strong> Cool colors include green, blue, and purple, are often more<br>subdued than warm colors. They are the colors of night, water, of nature, and are usually calming, relaxing, and somewhat reserved.</p>
<p><strong>Neutral Colors:</strong> Neutral colors often serve as the backdrop in design. They’re<br>commonly combined with brighter accent colors. But they can also be used on their own in designs and can create very sophisticated layouts. Neutral colors include black, white, gray, cream, and beige.  </p>
<p>Examples of colors that will make good contrast are white and blue, purple and white, yellow and white, light purple and black, green and white, black and white, and so on – basically any colors that are different enough from each other to create that contrast.  </p>
<p>Examples of colors that will make a bad contrast are gray and white, brown and orange, red and purple, and so on.</p>
<p>Here is an example that shows good color contrast that's easy to read:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/10/1.png" alt="Image" width="600" height="400" loading="lazy">
<em>Image illustrating good contrast using a dark blue background with white text</em></p>
<p>And here's an image with poor color contrast that's hard to read:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/10/2.png" alt="Image" width="600" height="400" loading="lazy">
<em>Image Illustrating bad contrast using a white background with light grey text</em></p>
<p>Also, it's a good idea to include descriptive alternative text (alt text) for images, explaining what they depict and their purpose.</p>
<p>So for example, when you want to add an image to your website, you can add alt text to it explaining what it depicts. </p>
<p>Here is a markup description of how to add alt text to an image:</p>
<pre><code class="lang-HTML">    <span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"Dog.png"</span> <span class="hljs-attr">alt</span>=<span class="hljs-string">"Image of a dog"</span>&gt;</span>
</code></pre>
<p>Here is an example that shows an image of two (2) dogs:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/10/dog.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>Image of two dogs</em></p>
<p>And here's an example of an image that illustrates the use of alt text:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/10/dog1-1.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>Image of dog with alt text displayed</em></p>
<p>You should also describe your icon buttons.</p>
<p>Icons can be easily understood most of the time. It's widely recognized that an x symbol, like this ❌, typically closes a window, a check mark ✅ signifies completion, a forward arrow ▶ signifies send (or play), and a plus sign ➕ represents addition. </p>
<p>But this is clear only for individuals with visual capabilities. For people who aren't able to see the buttons, you'll need to provide a description so they know what that button does.</p>
<p>Let's take a look at this HTML and CSS code that shows how to make buttons access:</p>
<p>&lt;!DOCTYPE html&gt;</p>


    
    
    
    Document




    <i> Delete </i>
    <i> Check </i>
    <i> Send</i>
    <i> Add</i>



<p>Here's the result of the code implemented above:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/10/code1.jpg" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-is-it-operable">Is it Operable?</h3>
<p>Users should be able to navigate and interact with the interface quickly. Consider the following factors:</p>
<p>First, make sure you use clear and consistent headings.</p>
<p>This is what clear and consistent headings look like:</p>
<h1 id="heading-i-am-a-title">I am a Title</h1>
<h2 id="heading-i-am-a-subtitle">I am a Subtitle</h2>
<h3 id="heading-this-is-heading-3">This is heading 3</h3>
<h4 id="heading-this-is-heading-4">This is Heading 4</h4>
<h5 id="heading-this-is-heading-5">This is Heading 5</h5>
<h6 id="heading-this-is-heading-6">This is heading 6</h6>
<p>As you can see, these headings go from largest to smallest in order. We have an H1 heading first, followed by H2, H3, and so on.</p>
<p>Here are some headings that don't follow the proper hierarchy: </p>
<h6 id="heading-this-is-heading-6-1">This is heading 6</h6>
<h5 id="heading-this-is-heading-5-1">This is Heading 5</h5>
<h4 id="heading-this-is-heading-4-1">This is Heading 4</h4>
<h3 id="heading-this-is-heading-3-1">This is heading 3</h3>
<h2 id="heading-i-am-a-subtitle-1">I am a Subtitle</h2>
<h1 id="heading-i-am-a-title-1">I am a Title</h1>
<p>In this example, the headings go in reverse order, starting from H6 and moving up through H5, H4, and so on. </p>
<p>Just remember to use proper heading hierarchy – don't use an H2 and then jump straight to H4 for a subheading, for example, as this is visually jarring and doesn't convey the proper importance or hierarchy of the text.</p>
<p>Here's why heading hierarchy is important:</p>
<ul>
<li>A clear heading hierarchy helps readers easily navigate and understand the content of a document.</li>
<li>Heading hierarchy is crucial for accessibility, as it helps screen readers and assistive technologies interpret the structure of the content. This is important for individuals with visual impairments who rely on such tools to access information.</li>
<li>A well-organized heading hierarchy implement a logical flow of information, ensuring that topics are presented in a coherent order.</li>
</ul>
<p>Also, refrain from using elements that might trigger physical discomfort, like bright flashing lights.</p>
<p>And make sure you think about <a target="_blank" href="https://www.freecodecamp.org/news/designing-keyboard-accessibility-for-complex-react-experiences/">keyboard accessibility</a> so users can navigate and communicate using the keyboard, and not exclusively using a mouse.</p>
<h3 id="heading-is-it-understandable">Is it Understandable?</h3>
<p>Content and functionality should be presented clearly and understandably. Consider the following factors:</p>
<ul>
<li>Organize content using headings, subheadings, and bullet points to enhance readability.</li>
<li>Provide instructions and error messages that are easy to understand.</li>
<li>Use simple and concise language, avoid complex terms.</li>
</ul>
<h3 id="heading-is-it-robust">Is it Robust?</h3>
<p>Websites should be built using robust and widely supported technologies to enable compatibility across devices and assistive technologies. </p>
<p>You'll want to maximize compatibility with current and future user agents, including assistive technologies.</p>
<p>Here are some of the ways you can maximize compatibility with current and future agents, including assistive tools:</p>
<ul>
<li>Use <a target="_blank" href="https://www.freecodecamp.org/news/semantic-html-alternatives-to-using-divs/">HTML5 semantic elements</a> like <code>&lt;header&gt;</code>, <code>&lt;nav&gt;</code>, <code>&lt;main&gt;</code>, and <code>&lt;footer&gt;</code> to enhance the document's structure.</li>
<li>Ensure that your <a target="_blank" href="https://www.freecodecamp.org/news/javascript-performance-async-defer/">JavaScript code is efficient</a> and doesn't block the rendering process.</li>
<li>Utilize <a target="_blank" href="https://www.freecodecamp.org/news/learn-how-to-use-the-chrome-devtools-to-troubleshoot-websites/">browser developer tools</a> and online testing services to identify and fix compatibility issues.</li>
<li>Conduct <a target="_blank" href="https://www.freecodecamp.org/news/10-best-ux-testing-software-tools/">usability testing</a> with a diverse group of users, including those who rely on assistive technologies, to gather feedback and make improvements.</li>
<li>Optimize your website for fast loading times and low data usage using techniques like <a target="_blank" href="https://www.freecodecamp.org/news/a-detailed-guide-to-pre-caching/">caching</a> and <a target="_blank" href="https://www.freecodecamp.org/news/cdns-speed-up-performance-by-reducing-latency/">tools like CDNs</a> to reduce latency. This benefits both accessibility and user experience.</li>
<li>Document your code and accessibility features for future maintainers.</li>
<li>Test <a target="_blank" href="https://www.freecodecamp.org/news/cross-browser-compatibility-testing-best-practices-for-web-developers/">website compatibility across various browsers</a>. Testing website compatibility involves ensuring that your website functions correctly and looks good on a variety of devices, browsers, and assistive technologies. </li>
</ul>
<p>Here are the steps you can follow to test website compatibility effectively:</p>
<ol>
<li><strong>Device Testing</strong>: Test your website on various devices, such as desktop computers, laptops, tablets, and smartphones. This includes both iOS and Android devices.</li>
<li><strong>Browser Testing</strong>: Check your website's performance and appearance on multiple browsers, including but not limited to Google Chrome, Mozilla Firefox, Apple Safari, and  Microsoft Edge.</li>
<li><strong>User Testing</strong>: Conduct usability testing with real users. Ask them to use your website on different devices and browsers and collect feedback on compatibility issues.</li>
<li><strong>Performance Testing</strong>: Assess website loading times, and optimize for speed using tools like Google PageSpeed Insights, GTmetrix, or Lighthouse. Check for compatibility with slow internet connections.</li>
</ol>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Understanding web accessibility can enhance the user experience by creating a smooth and seamless interaction with websites and web applications.</p>
<p>Implementing these tips can improve the overall user-friendliness and navigability of your app. It'll help create a more enjoyable experience for all users, and will also allow people with disabilities to perceive, understand, navigate, and interact with your sites effectively.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Accessibility Resources for Developers ]]>
                </title>
                <description>
                    <![CDATA[ Accessibility is never a "nice-to-have" requirement when it comes to developing websites and apps. It's a "must-have" that should be an integral part of your design and development process. Ensuring good accessibility is a fundamental responsibility ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/accessibilty-websites-for-developers/</link>
                <guid isPermaLink="false">66d45f31f855545810e93458</guid>
                
                    <category>
                        <![CDATA[ a11y ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Accessibility ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Ilknur Eren ]]>
                </dc:creator>
                <pubDate>Tue, 05 Sep 2023 22:49:13 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/08/a11y.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Accessibility is never a "nice-to-have" requirement when it comes to developing websites and apps. It's a "must-have" that should be an integral part of your design and development process.</p>
<p>Ensuring good accessibility is a fundamental responsibility for developers. It can help their applications provide an equitable experience for all users.</p>
<p>But it can be easy to go down a rabbit hole when learning about accessibility best practices.</p>
<p>Fortunately, there are many resources available that teach you how to build accessible websites and apps. In this article, I'll discuss the three websites I frequently go to when I have questions about accessibility: W3C WCAG, WebAIM, and a11yprojects.</p>
<p>Let's look at each one and how you can use them to create more accessible projects.</p>
<h2 id="heading-w3c-wcag">W3C WCAG</h2>
<p>First up, there's <a target="_blank" href="https://www.w3.org/WAI/standards-guidelines/wcag/"><strong>W3C WCAG</strong></a>. As stated in the Web Content Accessibility Guidelines (WCAG) website, WCAG provides, "strategies, standards, resources to make the Web accessible to people with disabilities".</p>
<p>The guidelines listed on this website provide comprehensive frameworks for developers to make the web pages universally accessible.</p>
<p>WCAG helps developers craft digital spaces that are usable, perceivable, operable, and robust.</p>
<p>One great section of W3C is the <a target="_blank" href="https://www.w3.org/WAI/test-evaluate/preliminary/#title">Easy Checks – A First Review of Web Accessibility</a>. In this section, developers can easily learn accessibility rules when it comes to page titles, images, text, and interactions. Easy Checks section is a great place to start navigating W3C.</p>
<p><strong>How to Use W3C WCAG:</strong></p>
<ul>
<li><p>Visit the W3C WCAG website and explore the guidelines and success criteria relevant to your project.</p>
</li>
<li><p>Study the techniques and documents for the technologies you're using.</p>
</li>
<li><p>Check the conformance requirements to set accessibility goals for your website or app.</p>
</li>
</ul>
<p>To learn more about these standards and how to make a website accessible, you can come to W3C and study criteria needed to be considered accessible. W3C WCAG is one of the best websites to go to learn about accessibility rules.</p>
<h2 id="heading-webaim">WebAIM</h2>
<p>On <a target="_blank" href="https://wave.webaim.org/">WebAIM</a>'s website, they state that they, "empower individuals and organizations to create and deliver accessible content".</p>
<p>WAVE is a accessibility evaluation tool. One tool WAVE offers is its Browser Extension. After downloading the WAVE browser extension, you can inspect your pages and log accessibility issues with the page. Then you can easily figure out how to fix these issues.</p>
<p>The WAVE extension is available on FireFox and Chrome and makes it so simple for your to recognize common accessibility issues. You can find instructions on how to download the WAVE extension on the <a target="_blank" href="https://wave.webaim.org/extension/">WAVE's extensions tab</a>.</p>
<p>After downloading the WAVE extension, you can go to your extensions and run it. Finding accessibility issues is as quick as clicking a button. For example, after downloading WAVE, I ran the extension on the New York Times homepage and was alerted to the accessibility issues the website had.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/09/Screenshot-2023-09-02-at-10.17.10-PM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>Screenshot of New York Times Homepage with WAVE extension pointing accessibility errors</em></p>
<p>In the screenshot above, you can see The New York Times homepage with the WAVE extension running. On the left side of the screenshot, you can see WAVE's summary tab pointing out 1 accessibility issue in the homepage with 120 errors. This is WAVE's summary tab, which gives developers a overview of accessibility issues in the page.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/09/Screenshot-2023-09-02-at-10.23.40-PM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>Screenshot of New York Times Homepage with WAVE extension pointing accessibility errors</em></p>
<p>WAVE goes in depth and explains the summary tab even further. Clicking on the details section of the extension lists the accessibility errors in greater details, which you can see in the screenshot above.</p>
<p>The one error that was in the summary page is explained further in the details section. WAVE points out that the accessibility error was a linked image missing alternative text. The 120+ warning are also listed in much more detail, which point out that there are 8 long alternative texts, 1 missing first level heading, 4 redundant link and much more.</p>
<p>The details tab is a great way to find out the accessibility issues your page might have and give you a starting point to fix the accessibility issues.</p>
<p><strong>How to Use WebAIM:</strong></p>
<ul>
<li><p>Install the WAVE browser extension, then run it on your web pages to identify and address accessibility issues.</p>
</li>
<li><p>Explore WebAIM's website for additional resources, articles, and training materials.</p>
</li>
</ul>
<h2 id="heading-a11yproject">a11yproject</h2>
<p><a target="_blank" href="https://www.a11yproject.com/"><strong>a11yproject</strong></a>, pronounced "a-eleven-y-project" (with "11" representing the omitted letters in the word accessibility) "is a community-driven effort to make digital accessibility easier".</p>
<p>This website displays articles that are all about accessibility. The articles are written by developers and approved by the a11yproject team.</p>
<p>Some recent articles published on a11yprojects include, <a target="_blank" href="https://www.a11yproject.com/posts/what-is-semantic-html/">What is Semantic HTML?</a> and <a target="_blank" href="https://www.a11yproject.com/posts/the-power-of-chatgpt-as-a-cognitive-accessibility-assistive-technology-for-traumatic-brain-injury-survivors/">The power of ChatGPT as a cognitive accessibility assistive technology for Traumatic Brain Injury survivors</a>. There are many more interesting topics around accessibility as well.</p>
<p>a11yprojects are divided into different categories, which range from quick tips, background, myths, quick tests and so much more. Readers can go to a11yprojects and filter to a article category they want to see.</p>
<p>a11yproject articles are written by developers that are passionate about accessibility and have a lot of knowledge to share with others. You can go on a11yprojects website to read about latest news about accessibility. The website covers all aspects of accessibility, but mainly focuses on web accessibility.</p>
<p><strong>How to Use a11yproject:</strong></p>
<ul>
<li><p>Visit the a11yproject website to read articles about accessibility best practices and the latest news in the field.</p>
</li>
<li><p>Engage with the accessibility community by participating in discussions and contributing your knowledge.</p>
</li>
</ul>
<h2 id="heading-conclusion">Conclusion</h2>
<p>There are so many resources available online for developers to learn about the latest news on accessibility. There are also many communities of developers that are passionate about accessibility.</p>
<p>W3C WCAG, WebAIM and a11yprojects are just few online resources available for developers to conduct accessibility research. By going to these three websites, developers can learn the latest news on accessibility and study acceptable accessibility criteria.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Why Accessibility Matters in UI/UX Design ]]>
                </title>
                <description>
                    <![CDATA[ Accessibility is a word that is often thrown around in the design field. As a UI/UX/Web Designer, you might have heard this word a few times and you might wonder why it's important.  In this article, you will learn: What accessibility means Some myt... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/why-accessibility-matters-in-ui-ux-design/</link>
                <guid isPermaLink="false">66d03a42a30d09f91d49b78d</guid>
                
                    <category>
                        <![CDATA[ a11y ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Accessibility ]]>
                    </category>
                
                    <category>
                        <![CDATA[ responsive design ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Design ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Faith Olohijere ]]>
                </dc:creator>
                <pubDate>Thu, 25 May 2023 14:18:24 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/05/pexels--------------3077882.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Accessibility is a word that is often thrown around in the design field. As a UI/UX/Web Designer, you might have heard this word a few times and you might wonder why it's important. </p>
<p>In this article, you will learn:</p>
<ul>
<li>What accessibility means</li>
<li>Some myths surrounding accessibility</li>
<li>How to make your work more accessible</li>
<li>Some practical accessibility examples</li>
</ul>
<p>Let's get started!</p>
<h2 id="heading-what-is-accessibility">What is Accessibility?</h2>
<p>There are so many definitions of accessibility on the web. But to me, accessibility in digital/web design simply means designing to make content usable for people with disabilities. </p>
<p>Working with accessibility in mind involves designing websites, applications, and digital interfaces that can be navigated by individuals with visual, hearing, motor, or cognitive impairments.</p>
<h2 id="heading-some-myths-surrounding-accessibility">Some Myths Surrounding Accessibility</h2>
<p>Like every topic under the sun, lots of people have different opinions about accessibility. Some might be true, some might be false. </p>
<p>Below, I'll share some popular misconceptions about accessibility. </p>
<h3 id="heading-myth-people-with-disabilities-dont-use-my-platform">Myth: people with disabilities don't use my platform</h3>
<p>You might be designing for a governmental or corporate platform and think that people with disabilities will not use your platform. </p>
<p>This is an incorrect notion to have. There are different forms of disability, including temporary and permanent disabilities. You have no control over who might use your platform at any time or what they might need.</p>
<h3 id="heading-myth-accessibility-is-only-for-people-with-disabilities">Myth: accessibility is only for people with disabilities</h3>
<p>While accessibility measures are crucial for individuals with disabilities, they also benefit a wide range of people, including the elderly, those with temporary disabilities, individuals with situational limitations, and even people without apparent disabilities.</p>
<p>Accessibility best practices make websites and apps easier for everyone to use in various ways.</p>
<h3 id="heading-myth-accessibility-is-all-about-adding-alt-text">Myth: accessibility is all about adding ALT text</h3>
<p>Alt (alternative) text is an assistive technology which is a valuable tool. But you shouldn't only use alt text as a substitute for general/wider accessibility best practiceds. </p>
<p>Assistive technologies work best when used in conjunction with accessible designs and content. </p>
<h3 id="heading-myth-you-should-build-accessible-sites-just-so-you-dont-get-in-trouble-with-the-law">Myth: you should build accessible sites just so you don't get in trouble with the law</h3>
<p>Although accessibility is a legal and ethical requirement, you shouldn't build it into your designs because of that reason alone.</p>
<p>You should build accessible websites and apps because accessibility helps anyone who comes to your platform interact with it well.</p>
<h2 id="heading-why-is-accessibility-important">Why is Accessibility Important?</h2>
<p>Accessibility is important for a number of reasons. They include:</p>
<ul>
<li>Improved Usability: Accessibility improves the usability of a website or application. Features like clear navigation, intuitive design, and so on benefit all users. They also contribute to user satisfaction, usability and overall engagement with products and services.</li>
<li>Broad User Base: When your platform is accessible, it increases your user base, as people from different backgrounds and situations can use your platform. This expands the reach and customer base of your product.</li>
<li>Enhanced User Experience: Incorporating accessibility in your designs will enhance the experience of your users (disabled or not), making it easier to interact with your platform.</li>
<li>Equal Rights &amp; Inclusion: Accessibility promotes inclusivity and prevents discrimination based on disabilities. Everyone deserves to have equal access to opportunities, information, and social services.</li>
<li>Legal &amp; Ethical Requirements: Legally and ethically, accessibility is a requirement for different domains and platforms. Adhering to these legal requirements ensures compliance and helps your client avoid potential legal issues. </li>
</ul>
<h2 id="heading-how-to-make-your-designs-more-accessible">How to Make Your Designs More Accessible</h2>
<h3 id="heading-understanding-accessibility-guidelines">Understanding Accessibility Guidelines</h3>
<p>Familiarize yourself with accessibility standards such as the Web Content Accessibility Guidelines<a target="_blank" href="https://www.w3.org/TR/WCAG21/">(WCAG)</a>. These guidelines provide comprehensive recommendations for designing accessible digital content.</p>
<h3 id="heading-use-sufficient-color-contrast">Use Sufficient Color Contrast</h3>
<p>Opt for color combinations that are accessible for individuals with color blindness or low vision. Use tools to check the color contrast ratio and ensure that text is easily distinguishable from the background.</p>
<p>Here's an example of creating sufficient color contrast:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/05/Frame-3--2-.png" alt="Image" width="600" height="400" loading="lazy">
<em>Color contrast example</em></p>
<p>In the example above, in the first sentence, the highlighted word (link) does not contrast well with the rest of the sentence. Compare with the second sentence where "link", is perfectly contrasting and has an underline, to create more emphasis. </p>
<p>It's more likely that the second sentence is accessible for individuals with color blindness or low vision.</p>
<h3 id="heading-create-inclusive-forms">Create Inclusive Forms</h3>
<p>Design forms that are user-friendly. Include clear labels, instructions and, error messages. Make sure to enable users navigate and complete the form without relying solely on a mouse.</p>
<p>Here's an example of creating an inclusive form:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/05/Frame-2--1-.png" alt="Image" width="600" height="400" loading="lazy">
<em>User-friendly form example</em></p>
<p>The first form has some issues: </p>
<ul>
<li>It does not have any header (to indicate what the form is for).</li>
<li>It shows an error field without explaining what it indicates.</li>
<li>The form does not specify the number of characters the password should have, all of which are very helpful to the user(s).</li>
</ul>
<p>All these were corrected in the second form, where:</p>
<ul>
<li>A header was added indicating that the form is for "<em>Course Registration</em>".</li>
<li>The error field specifically explains what's wrong – the user entered an invalid email address.</li>
<li>The number of password characters as required by the platform was stated.</li>
</ul>
<h3 id="heading-implement-responsive-design">Implement Responsive Design</h3>
<p>Some designers design for desktop versions only, not considering accessibility. But it's much more helpful to make your design responsive. </p>
<p>Ensuring that your designs are adaptable to different screen sizes and resolutions accommodates individuals who use various devices. This is a great way to make your designs more accessible.</p>
<p>Here's an example of implementing responsive design:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/05/Frame-8922.png" alt="Image" width="600" height="400" loading="lazy">
<em>Responsive Design example</em></p>
<p>Above is an example of a product description page of a website. The first image on the left shows the desktop version only. In the second image, the design has been made more accessible – you can see the mobile responsive version as well.</p>
<p>Designing for different screen sizes shows that your design accommodates individuals who use various devices, as stated earlier.</p>
<h3 id="heading-provide-feedback-and-error-handling">Provide Feedback and Error Handling</h3>
<p>Making sure your designs provide adequate feedback accompanied by the next step to take, gives a great user experience. Error notifications can completely discourage a user if not handled correctly. As such, adequate feedback is necessary to make your design accessible.</p>
<p>These are few ways of making your designs accessible, amongst others. You can make an accessibility checklist to help remind yourself of accessibility when designing. To help further, check out accessibilitychecklist.org to find out.</p>
<p>Here's an example of how to provide feedback and handle errors:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/05/Desktop---3--1-.png" alt="Image" width="600" height="400" loading="lazy">
<em>Error handling example</em></p>
<p>In the example above, the first 404 page tells the user what error occurred, and what might be the cause – but does not suggest a way of fixing the error. Meanwhile, the second 404 page explains the error that occurred and provides a way of fixing it – "<em>Go to homepage</em>".</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Accessibility is important to customer retention and the growth of a business. As a UI/UX/Web designer, it's your responsibility to incorporate accessibility into your product and give your users an awesome experience. Remember, your user is the priority. </p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Web Accessibility – Common ARIA Mistakes to Avoid ]]>
                </title>
                <description>
                    <![CDATA[ Accessible Rich Internet Applications – or ARIA – is a set of attributes and roles defined by the Web Accessibility Initiative. These make the web more accessible to people with disabilities. ARIA is extremely important for building accessible web ap... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/web-accessibility-common-aria-mistakes-to-avoid/</link>
                <guid isPermaLink="false">66d45f3b47a8245f78752a5a</guid>
                
                    <category>
                        <![CDATA[ a11y ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Accessibility ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Development ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Ilknur Eren ]]>
                </dc:creator>
                <pubDate>Wed, 11 Jan 2023 21:58:45 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/01/a11y-image.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Accessible Rich Internet Applications – or ARIA – is a set of attributes and roles defined by the <a target="_blank" href="https://www.w3.org/WAI/">Web Accessibility Initiative</a>. These make the web more accessible to people with disabilities.</p>
<p>ARIA is extremely important for building accessible web applications. But it's very easy to misuse ARIA and make the website less accessible.</p>
<p>This article will demonstrate five common ARIA mistakes and how to fix them.</p>
<h2 id="heading-dont-use-unnecessary-aria-labels">Don't Use Unnecessary ARIA Labels</h2>
<p>The first rule of ARIA is that you should not use ARIA unless you have to. HTML elements already have accessibility built in, and adding unnecessary ARIA labels can break accessibility.</p>
<p>For that reason, it's much better to use HTML elements, instead of constructing code with ARIA labels.</p>
<p><strong>Example of misusing ARIA labels:</strong></p>
<p>⛔ BAD: Below is a <code>button</code> element with <code>aria-label</code>:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">aria-label</span>=<span class="hljs-string">"Send"</span>&gt;</span>Send<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
</code></pre>
<p>✅ GOOD: Below is a <code>button</code> element:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">button</span>&gt;</span>Send<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
</code></pre>
<p>In the examples above, I am creating a button element. In the first code snippet, there is a <code>aria-label</code> with the label, “send”. HTML’s button element already has accessibility built into it. It is not necessary to add an <code>aria-label</code> so it's much better to remove the label.</p>
<p>The <code>button</code> element will read the text inside it already. We do not need to add the <code>aria-label</code> to describe it.</p>
<p><strong>Takeaway:</strong> Don’t add unnecessary ARIA labels if you can use accessible HTML elements instead.</p>
<h2 id="heading-dont-use-the-wrong-aria-attributes">Don't Use the Wrong ARIA Attributes</h2>
<p>There are pre-defined ARIA states and properties defined by the ARIA working group, which is part of World Wide Web Consortium.</p>
<p>Developers should use the states and properties available – you cannot create your own in your code. You can find the list of properties and states on <a target="_blank" href="https://www.w3.org/TR/wai-aria-1.0/states_and_properties">W3's Website</a>.</p>
<p><strong>Example of using incorrect ARIA attributes:</strong></p>
<p>⛔ BAD</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">span</span> <span class="hljs-attr">aria-donotshow</span>=<span class="hljs-string">"true"</span>&gt;</span>Don’t show this<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>
</code></pre>
<p>✅ GOOD</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">span</span> <span class="hljs-attr">aria-hidden</span>=<span class="hljs-string">"true"</span>&gt;</span>Don’t show this<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>
</code></pre>
<p>This means that a new property, like <code>aria-donotshow</code>, is not correct. <code>aria-donotshow</code> is not a property in the W3 website so you shouldn't use it.</p>
<p><strong>Takeaway:</strong> Don’t create your own ARIA attributes. You can only use the ones defined by the ARIA working group.</p>
<h2 id="heading-know-when-to-use-aria-labelledby">Know When to Use <code>aria-labelledby</code></h2>
<p>Another common mistake is when developers use <code>aria-label</code> to describe content inside the DOM.</p>
<p>All interactive elements need an accessible name. If we want to add an accessible name to an element where the name needs some content from elsewhere in the DOM, we should use <code>aria-labelledby</code>. If there is no content that can be referred to to create an accessible name, then we can use <code>aria-label</code>.</p>
<p><strong>Example of when to use</strong> <code>aria-labelledby</code>:</p>
<p>⛔ BAD</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">aria-label</span>=<span class="hljs-string">"Related Content"</span>&gt;</span>                
    <span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span>Related Content<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>        
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>✅ GOOD</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">aria-labelledby</span>=<span class="hljs-string">"nav-title"</span>&gt;</span>                
    <span class="hljs-tag">&lt;<span class="hljs-name">span</span> <span class="hljs-attr">id</span>=<span class="hljs-string">'nav-title'</span>&gt;</span>Related Content<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>        
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>In the example above, the first code snippet uses <code>aria-label</code> and associates it with the text, “Related content”. But the <code>span</code> inside the text already has the correct content we want a screen reader to read.</p>
<p>Instead of using <code>aria-label</code> in this example, we should reference the span content by adding <code>aria-labelledby</code> that is associated with the id of the content we want to reference.</p>
<p><strong>Takeaway:</strong> If you want to reference content from inside the DOM, use <code>aria-labelledby</code> with corresponding id.</p>
<h2 id="heading-know-when-to-use-aria-describedby">Know When to Use <code>aria-describedby</code></h2>
<p>Sometimes, we need to give more information to an element. For example, we might want to tell the user that the button they will press will open a new tab.</p>
<p>This information is important because the user needs to know where they are when navigating websites.</p>
<p>For these types of scenarios, we can use <code>aria-describedby</code> to give additional information.</p>
<p><strong>Example:</strong></p>
<p>⛔ BAD</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">aria-label</span>=<span class="hljs-string">"Close"</span> <span class="hljs-attr">aria-label</span>=<span class="hljs-string">"Opens in a new tab"</span>&gt;</span>    
Show related        
<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
</code></pre>
<p>✅ GOOD</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">aria-label</span>=<span class="hljs-string">"Close"</span> <span class="hljs-attr">aria-describedby</span>=<span class="hljs-string">"description"</span>&gt;</span>            Show related        
<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>        
<span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"description"</span>&gt;</span>Opens in a new tab<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>In the first example above, what engineers expect the screen reader to announce is: “button, Show related, opens in a new tab”.</p>
<p>But the screen reader does not do that. Instead, it says,“button, opens in a new tab”. The screen reader does not read the content inside, because aria-label always overrides the text content of the HTML5 element it has been applied to.</p>
<p>The second code snipped shows the correct way to use <code>aria-describedby</code>. The screen reader will read, “button, Show related, opens in a new tab”.</p>
<p>That information tells the user that the button is to show related content and if they press that button, it will navigate them to another tab.</p>
<p><strong>Takeaway:</strong> Use <code>aria-describedby</code> to add additional information to elements.</p>
<h2 id="heading-dont-use-aria-child-roles-without-parent-roles">Don't Use ARIA Child Roles Without Parent Roles</h2>
<p>There are some ARIA attributes that require a child/parent relationship. This means that you cannot use the ARIA child attribute without wrapping it around its parent ARIA attribute.</p>
<p>It’s easy to forget the child/parent relationship and build code that only uses the parent attribute without the child, or to build code that only uses child attribute without its parent.</p>
<p>If you forget the child/parent relationship, the code becomes more inaccessible, which defeats the purpose of ARIA.</p>
<p><strong>Example:</strong></p>
<p>⛔ BAD:</p>
<p><code>role="listbox"</code> is a parent property. The <code>ul</code> list below does not have <code>role=option</code> which is its child property.</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"listbox"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">ul</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>✅ GOOD:</p>
<p><code>role="listbox"</code> is a parent property. The <code>ul</code> list below has <code>role=option</code> which is its child property.</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">role</span>=<span class="hljs-string">"listbox"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">ul</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">li</span> <span class="hljs-attr">option</span>=<span class="hljs-string">"option"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>In the code example above, the first code has a code snippet that has <code>role=listbox</code> which is a parent element. <code>listbox</code> needs children inside which is <code>option</code>. We cannot use <code>listbox</code> on its own to build accessible web sites.</p>
<p><strong>Takeaway:</strong> Always use child/parent properties together.</p>
<h2 id="heading-summary">Summary</h2>
<p>ARIA is a set of attributes and roles defined by WAI to make the web more accessible to people with disabilities. Although it's necessary to create an accessible web, it is very easy to misuse ARIA and make websites less accessible instead.</p>
<p>Try to avoid these five most common ARIA mistakes:</p>
<ol>
<li><p>Don’t unnecessarily use aria-label. Built-in HTML semantics are always better.</p>
</li>
<li><p>Don’t create your own aria attribute. Only use the ones defined by ARIA.</p>
</li>
<li><p>Use <code>aria-labelledby</code> with an id when you have content that wraps divs and you want to group sections.</p>
</li>
<li><p>Use <code>aria-describedby</code> when you have sections that need more descriptions.</p>
</li>
<li><p>Do not use a child ARIA without a predefined parent ARIA.</p>
</li>
</ol>
<p>ARIA was created to make websites more accessible to people with disabilities. If we avoid common mistakes, we will make sure our websites are accessible.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Accessibility Best Practices – What to Remember When Building Accessible Web Apps ]]>
                </title>
                <description>
                    <![CDATA[ Anyone should be able to use your websites and apps - both people with disabilities and those without. This will make your website accessible. Think about the last site you built, or your favorite site. Are you confident that anyone can use your site... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/accessibility-best-practices-to-make-web-apps-accessible/</link>
                <guid isPermaLink="false">66b99cc84ed1a5964b77008a</guid>
                
                    <category>
                        <![CDATA[ a11y ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Accessibility ]]>
                    </category>
                
                    <category>
                        <![CDATA[ best practices ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Applications ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Shruti Kapoor ]]>
                </dc:creator>
                <pubDate>Fri, 16 Dec 2022 21:01:26 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/12/ben-kolde-bs2Ba7t69mM-unsplash-1.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Anyone should be able to use your websites and apps - both people with disabilities and those without. This will make your website accessible.</p>
<p>Think about the last site you built, or your favorite site. Are you confident that anyone can use your site and perform the critical actions it requires? Have you considered folks with motor disabilities, visual disabilities, cognitive disabilities, and auditory disabilities?</p>
<p>Accessibility is often left as an after-thought. When it is time to ship a feature, we do an accessibility test and find out that our site wasn't accessible and do a hacky fix. </p>
<p>Making a site accessible is a huge undertaking. But if we keep accessibility in mind from the get-go, it makes it much easier to build an accessible web app. </p>
<p>In this post, I will go over 5 things you can keep in mind WHILE building your app so you don't have to do a hacky slap together at the end.</p>
<h2 id="heading-5-things-to-remember-for-good-accessibility">5 Things to Remember for Good Accessibility</h2>
<ol>
<li>Semantinc HTML</li>
<li>Tabindex</li>
<li>Aria attributes</li>
<li>Role</li>
<li>Keyboard navigation and screen readers</li>
</ol>
<p>In short, S.T.A.R.K.</p>
<p>If you need help remembering this, think of Tony Stark. </p>
<p><img src="https://cdn.vox-cdn.com/uploads/chorus_image/image/55400215/ktokatitmir0.0.jpg" alt="TonyStark" width="3000" height="1779" loading="lazy"></p>
<p>Let's go through each of these to understand how to use them in your web apps.</p>
<h3 id="heading-what-is-semantic-html">What is Semantic HTML?</h3>
<p>Using semantic HTML is important for accessibility. This is because assistive technologies such as screen readers are able to interpret what's on the page by parsing the HTML of the page. They enable users to take actions based on the elements. </p>
<p>For example, if a screen reader encounters a <code>button</code>, it signals to the user that they should click on it. </p>
<p>Let's consider some use-cases of what can happen when you don't use semantic HTML:</p>
<h4 id="heading-creating-buttons-by-using-div-instead-of-button">Creating buttons by using <code>div</code> instead of <code>button</code>:</h4>
<p><code>div</code>s are container elements, so when a screen reader encounters a div, it automatically thinks it is a presentational element. </p>
<p>When a screen reader user encounters a <code>div</code> that has content or children within it, the screen reader announces <code>role="group"</code> and the user will completely miss that the <code>div</code> is interactive. So make sure you use the proper semantic element for its purpose. You get accessibility for free.</p>
<h4 id="heading-using-css-to-fake-headings-instead-of-using-h1-6-tags">Using CSS to fake headings instead of using <code>h1-6</code> tags:</h4>
<p>Heading tags such as <code>&lt;h1&gt;</code> and <code>&lt;h2&gt;</code> let an assitive technology know that this is important text, and the screen reader will announce "Heading". </p>
<p>When you use CSS to make a heading instead of using correct semantics, the significance of the text is lost to a screen reader.</p>
<p>So just make sure to use semantic HTML whenever possible.</p>
<h3 id="heading-what-is-tabindex">What is Tabindex?</h3>
<p>Adding a <code>tabindex</code> makes interactive elements keyboard-navigable. When you add <code>tabindex</code> to an element, a user is able to navigate to it using only their keyboard and/or assitive technologies.</p>
<ol>
<li>You use a tabindex of <code>0</code> to set focus to an element in the default tabbing order,</li>
<li>You use a tabindex of <code>-1</code> to programmatically focus an element using JavaScript.</li>
<li>Do not assign a value of &gt; 1 to tabindex.</li>
</ol>
<p>A word of caution though - you should only add <code>tabindex</code> to interactive elements. It is not a good practie to add <code>tabindex</code> to elements such as <code>div</code>. </p>
<p>Instead of adding tabindex in that case, use a semantic element, such as a <code>button</code> since semantic elements already are tabbable and do not need an additional <code>tabindex</code> value.</p>
<h3 id="heading-what-are-aria-attributes">What are ARIA attributes?</h3>
<p>Aria attributes such as <code>aria-checked</code>, <code>aria-label</code> give additional information to assistive technologies.</p>
<p>Aria attributes are a set of HTML attributes that you use to provide additional information about the purpose and state of elements on a web page. These attributes are especially beneficial to assistive technologies to provide more context and better navigation for users.</p>
<p>Some common aria-attributes include:</p>
<ol>
<li><code>aria-label</code>: used to provide a label or name for an element.</li>
<li><code>aria-hidden</code>: used to indicate that an element should be hidden from assistive technologies. This can be useful for elements that are used for layout purposes but are not relevant to the content of the page.</li>
<li><code>aria-describedby</code>: used to associate an element with a description, which helps to provide context of an element.</li>
<li><code>aria-liv</code>e: used to indicate that an element's content may change dynamically, and that assistive technologies should pay attention to changes in the element's content.</li>
</ol>
<p>You can use these attributes in combination with each other and with standard HTML attributes to create more accessible and user-friendly web content.</p>
<h3 id="heading-what-is-the-aria-role-attribute">What is the <code>aria-role</code> attribute?</h3>
<p>You use the <code>aria-role</code> attribute to define the purpose of an HTML element and provide its semantic meaning. </p>
<p>For example, if you are building a grid component with the help of CSS and divs, you can use <code>role="grid"</code> to let assistive technologies know about the semantics of the component.</p>
<p>Some common <code>aria-role</code>s include:</p>
<ol>
<li><code>button</code>: used to indicate that an element should be treated as a button.</li>
<li><code>alert</code>: used to indicate that an element is an alertbox.</li>
<li><code>presentation</code>: used to indicate that an element is only presentational.</li>
</ol>
<p>It is important to exercise caution with <code>aria-role</code>. Remember to not overdo it.</p>
<h3 id="heading-how-to-handle-keyboard-navigation-and-screen-readers">How to handle keyboard navigation and screen readers</h3>
<p>Many users with motor disabilities rely on their keyboard and assitive technologies to navigate the web. So it's critical that every component be navigable using a keyboard and screen reader. </p>
<p>You can test keyboard accessibility by navigating a site using only your keyboard. Here are some common keys:</p>
<ol>
<li><code>tab</code> key to navigate to different sections of the site.</li>
<li><code>spacebar</code> to select elements, such as a checkbox.</li>
<li><code>enter</code> to press buttons.</li>
</ol>
<p>While testing keyboard navigation, make sure you think about the following:</p>
<ol>
<li>Focus remains visible: Ensure that you can clearly see which element is being focused on the page. Focus should always remain visible.</li>
<li>Tab order: When tabbing through sections, the order of tabbing should follow the natural flow and logical structure of the website. It should not jump back and forth between sections.</li>
<li>Keyboard traps: Ensure that when navigating with the keyboard, the focus doesn't get trapped on an element. For example, this could happen when a modal is opened, or the focus is navigated to a widget, such as calendar or emoji picker. Ensure that when you select an element in the widget, you are able to navigate back to the site.</li>
</ol>
<h2 id="heading-wrapping-up">Wrapping Up</h2>
<p>Overall, testing for accessibility during development is an important part of the process that can help to create more usable and accessible software for all users. Testing for accessibility early helps to provide a great user experience for everyone.</p>
<p>In the next article, I will talk about the various accessibility tools and how to debug an accessibility issue. You can <a target="_blank" href="http://tinyletter.com/shrutikapoor">sign up to get it in your inbox here.</a></p>
<p>Until then, enjoy your holidays!</p>
<p>Feliz Navidad.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Web Accessibility – Best Practices and a Checklist for Developers ]]>
                </title>
                <description>
                    <![CDATA[ The World Health Organization reports that about 15% (1.2 billion) of the world's population lives with some form of disability.  This means that as developers, our focus on making websites and applications accessible helps more people use these reso... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/web-accessibility-best-practices-and-checklist/</link>
                <guid isPermaLink="false">66c5a346362cdd3f13c75135</guid>
                
                    <category>
                        <![CDATA[ a11y ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Accessibility ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Development ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Ophy Boamah ]]>
                </dc:creator>
                <pubDate>Wed, 30 Nov 2022 18:40:47 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/11/WebAccessibility.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>The World Health Organization <a target="_blank" href="https://www.who.int/teams/noncommunicable-diseases/sensory-functions-disability-and-rehabilitation/world-report-on-disability">reports</a> that about <strong>15% (1.2 billion)</strong> of the world's population lives with some form of disability. </p>
<p>This means that as developers, our focus on making websites and applications accessible helps more people use these resources. </p>
<p>In this article, I'll point out barriers to web accessibility, discuss the Web Content Accessibility Guidelines (WCAG), and share a basic checklist that all developers can use when building their websites and applications.</p>
<blockquote>
<p>“<em>The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect</em>.” – Tim Berners-Lee, W3C Director and inventor of the World Wide Web.</p>
</blockquote>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/11/a11y.png" alt="Image" width="600" height="400" loading="lazy">
<em>Image credit: <a target="_blank" href="https://blog.interactiveschools.com/">Interactive Schools</a></em></p>
<h2 id="heading-what-is-web-accessibility">What is Web Accessibility?</h2>
<p>A person is said to be disabled when they’re faced with a condition – permanent or temporary – that makes it difficult or impossible for them to achieve a desired task. </p>
<p>In effect, web accessibility involves removing all barriers that prevent any users from accessing the web equally.</p>
<h2 id="heading-what-are-the-barriers-to-accessibility">What are the Barriers to Accessibility?</h2>
<p>The barriers to accessibility include <strong>visual, auditory, cognitive</strong> and <strong>motor</strong>. </p>
<p>Visual barriers constitute conditions which make it difficult for people to view images, videos, and gifs. These conditions can include low vision, colour blindness, or even total vision loss. </p>
<p>Auditory barriers constitute conditions which make it difficult or impossible for people to consume audio content. </p>
<p>Those who have difficulty concentrating, learning or remembering new things are faced with cognitive barriers. </p>
<p>And people who have partial or total loss of function in a body part and find it difficult to navigate websites using devices such as a mouse experience motor barriers.</p>
<p>To resolve these barriers of web or digital accessibility, the Web Accessibility Initiative (WAI) of World Wide Consortium (W3C) created the <strong>Web Content Accessibility Guidelines</strong> (WCAG). </p>
<h2 id="heading-what-are-web-content-accessibility-guidelines">What are Web Content Accessibility Guidelines?</h2>
<p>They are globally accepted standards that guide developers and organisations in building an accessible web.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/11/pour-accessibility.png" alt="Image" width="600" height="400" loading="lazy">
<em>Image credit: <a target="_blank" href="https://www.siteimprove.com/">Site Improve</a></em></p>
<p>Most of the barriers to web accessibility faced by people with disabilities can be put into four categories. The WCAG addresses each category to ensure accessibility is achieved.</p>
<p><strong>Perceivable:</strong> It requires that users can identify content and interface elements using their senses. Most users rely primarily on visual senses, while others rely on sound.</p>
<p><strong>Operable:</strong> It requires that users can use controls, buttons, navigation, and other interactive elements by themselves. It takes into consideration that disabled users will use assistive technology like voice recognition, keyboards, screen readers, and so on.</p>
<p><strong>Understandable:</strong> It requires that users can comprehend the content and learn and remember how to use your site. The site should have a consistent format, predictable design and usage patterns, as well as an appropriate tone.</p>
<p><strong>Robust:</strong> It requires that users of varying abilities and conditions can reliably interpret and interact with content using a technology or device of their choice.</p>
<h2 id="heading-web-accessibility-checklist">Web Accessibility Checklist</h2>
<p>As developers, these are a few of the things to look out for when building websites or application in order to ensure that people of varying abilities can access them equally.  </p>
<h3 id="heading-how-to-make-images-accessible">How to make images accessible</h3>
<p>All images should have descriptive sentence-like alt texts instead of just a word or clause. For example, the image below should have an alt text as shown in the code beneath it.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/11/pizza.jpg" alt="Image" width="600" height="400" loading="lazy">
_Photo by [Unsplash](https://unsplash.com/@hybridstorytellers?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText"&gt;Hybrid Storytellers on &lt;a href="https://unsplash.com/t/food-drink?utm_source=unsplash&amp;utm_medium=referral&amp;utm<em>content=creditCopyText)</em></p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">alt</span>=<span class="hljs-string">"a right hand removing a slice from a whole pizza"</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://unsplash.com/photos/XYyUxXw_oQw"</span>/&gt;</span>
</code></pre>
<p>The code above shows a sentence-like, descriptive alternative text for the image. The goal of the alt text should be to describe the image in such a way that people using screen readers feel like they can visualize or imagine exactly what image is being described.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/11/ImageAlt-1.png" alt="Image" width="600" height="400" loading="lazy">
<em>Image Alt text output</em></p>
<p>The next level of accessibility as seen in the above image, is to write alt texts so that users who may be encountering connectivity issues have an idea of the image before they see it.</p>
<h3 id="heading-how-to-make-links-accessible">How to make links accessible</h3>
<p>Links should be descriptive and suggestive, and you should label all links with exactly what they do. </p>
<p>Avoid embedding your links in vague texts such as ‘here’. For instance, if we wanted to refer to my most recent article, for the sake of users who rely on screen readers, this is how to do it.</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>
Check out my most recent article on <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"https://www.freecodecamp.org/news/web-layouts-use-css-grid-and-flex-to-create-responsive-webpages/"</span>&gt;</span>Web Layouts – How to Use CSS Grid and Flex to Create a Responsive Web Page<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
</code></pre>
<p>In the code above, the link tag is wrapped around the whole title of the article instead of simply making the link text a vague 'here'. This way, everyone who sees, reads, or hears it knows exactly what resource will be found when the link is clicked.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/11/AccessibilityLink.png" alt="Image" width="600" height="400" loading="lazy">
<em>Link output image</em></p>
<p>When screen readers get to a link that is as descriptive as what we have in the image above, it makes it very easy for visually impaired users to know what the link does and, in effect, decide whether or not to visit it. </p>
<h3 id="heading-how-to-make-forms-accessible"><strong>How to make forms accessible</strong></h3>
<p>When creating web forms, you should consider users with visual or motor limitations. Make it easy for users who can't use the mouse to navigate your form with the keyboard and users relying on screen readers to know the exact information needed for each input.</p>
<p>Ensure that your forms are accessible by using <code>&lt;label&gt;</code> or <code>aria-label</code> to communicate the purpose of an input or what information it requires to screen readers. </p>
<p><code>&lt;fieldset&gt;</code> tags tell the form that groups of inputs belong together and <code>&lt;legend&gt;</code> tags act as labels for groups of inputs. These become especially necessary when dealing with questions that involve checkboxes or radio buttons.</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">fieldset</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"first-section"</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">legend</span>&gt;</span>Contact Details<span class="hljs-tag">&lt;/<span class="hljs-name">legend</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">for</span>=<span class="hljs-string">"name"</span>&gt;</span>Name<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"name"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"name"</span> <span class="hljs-attr">autofocus</span> <span class="hljs-attr">placeholder</span>=<span class="hljs-string">"Ophy Boamah"</span> <span class="hljs-attr">autocomplete</span>=<span class="hljs-string">"on"</span> <span class="hljs-attr">required</span>&gt;</span> <span class="hljs-tag">&lt;<span class="hljs-name">br</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">br</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">for</span>=<span class="hljs-string">"email"</span>&gt;</span>Email<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"email"</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"email"</span> <span class="hljs-attr">placeholder</span>=<span class="hljs-string">"ob2@hotmail.com"</span>&gt;</span> <span class="hljs-tag">&lt;<span class="hljs-name">br</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">br</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">for</span>=<span class="hljs-string">"tel"</span>&gt;</span>Phone<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"tel"</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"tel"</span> <span class="hljs-attr">placeholder</span>=<span class="hljs-string">"+233 200001212"</span>&gt;</span> <span class="hljs-tag">&lt;<span class="hljs-name">br</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">br</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">fieldset</span>&gt;</span>
</code></pre>
<p>In the code above, I implement all the form best practices I mentioned. The fieldset tag creates an initial "first-section" group. The legend tag contains text that provides a description for the group of elements. Finally, the label tag identifies each of the inputs and their purpose.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/Fieldset.png" alt="Image" width="600" height="400" loading="lazy">
<em>Accessible form output</em></p>
<p>The image above is the output of the code. To learn more about creating modern and accessible forms, check out my previous article on <a target="_blank" href="https://www.freecodecamp.org/news/create-and-validate-modern-web-forms-html5/">How To Create and Validate Modern Web Forms With HTML5</a>. </p>
<h3 id="heading-video-and-audio-accessibility">Video and audio accessibility</h3>
<p>All videos should have subtitles and captions. Similarly, all audio should have transcripts, so that people with hearing challenges can still follow along and understand.</p>
<pre><code class="lang-html"> <span class="hljs-tag">&lt;<span class="hljs-name">video</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"video"</span> <span class="hljs-attr">controls</span> <span class="hljs-attr">preload</span>=<span class="hljs-string">"metadata"</span>&gt;</span>
     <span class="hljs-tag">&lt;<span class="hljs-name">source</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"assets/samplevideo.mp4"</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"video/mp4"</span> /&gt;</span>
     <span class="hljs-tag">&lt;<span class="hljs-name">track</span>
     <span class="hljs-attr">label</span>=<span class="hljs-string">"English"</span>
     <span class="hljs-attr">kind</span>=<span class="hljs-string">"subtitles"</span>
     <span class="hljs-attr">srclang</span>=<span class="hljs-string">"en"</span>
     <span class="hljs-attr">src</span>=<span class="hljs-string">"assets/samplevideo-en.srt"</span>
     <span class="hljs-attr">default</span> /&gt;</span>
 <span class="hljs-tag">&lt;/<span class="hljs-name">video</span>&gt;</span>
</code></pre>
<p>The code above shows a video element that introduces the track tag for adding subtitles so that users who are not able to hear the accompanying audio can read to follow along.</p>
<div class="embed-wrapper">
        <iframe width="640" height="360" src="https://player.vimeo.com/video/776769878" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="Vimeo embed" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen="" loading="lazy"></iframe></div>
<h3 id="heading-how-to-select-colours-for-accessibility">How to select colours for accessibility</h3>
<p>When selecting colours for your websites, consider people who are colour-blind and those who have issues with sight. </p>
<p>When we use colours with poor contrast, it makes it difficult for users to read or navigate content on a web page. This means that we must always ensure that even in bad lighting conditions, our foreground and background colours have enough contrast between them for button, links, images, icons, texts and so on. </p>
<p>If you're unsure whether two colours complement each other in an accessible way, check using this <a target="_blank" href="https://accessibleweb.com/color-contrast-checker/">online colour checker tool</a>.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/11/wcagcolorcheceker.png" alt="Image" width="600" height="400" loading="lazy">
<em>Use a color checker tool to check color contrast</em></p>
<p>You can also add this <a target="_blank" href="https://chrome.google.com/webstore/detail/accessible-web-helper/gdnpkbipbholkoaggmlblpbmgemddbgb">Web Accessibility Checker Chrome Extension</a> to your browser for onsite accessibility checks.</p>
<h3 id="heading-how-to-make-transitions-and-animations-accessible">How to make transitions and animations accessible</h3>
<p>Use transitions and animations sparingly and only when extremely necessary in order not to trigger some users. </p>
<p>There are those who get dizzy or experience seizures when they encounter elements that move rapidly. Provide a way for such users to pause, hide, or stop the animation by making those controls available. </p>
<h3 id="heading-how-to-create-accessible-page-structure-and-navigation">How to create accessible page structure and navigation</h3>
<p>Use the appropriate HTML tags to semantically structure websites. Your site should be easy to navigate especially with assistive technology. </p>
<p>Page titles should be descriptive so users can easily differentiate between tabs.</p>
<pre><code class="lang-html"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">"en"</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">"UTF-8"</span> /&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">http-equiv</span>=<span class="hljs-string">"X-UA-Compatible"</span> <span class="hljs-attr">content</span>=<span class="hljs-string">"IE=edge"</span> /&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"viewport"</span> <span class="hljs-attr">content</span>=<span class="hljs-string">"width=device-width, initial-scale=1.0"</span> /&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>Web Accessibility Site | Checklist for Developers<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">header</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">nav</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">ul</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>Home<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>About<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>Contact<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">nav</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">header</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">main</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">section</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>
          Welcome to Web Accessibility
        <span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>
          This is semantic structuring with HTML tag
        <span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
      <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">section</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">main</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">footer</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"https://codehemaa.com"</span>&gt;</span>My website<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">footer</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<p>The code above shows a web page with a descriptive title. I've used the right semantic tags to properly structure the page by distinguishing the header from the main body and footer. </p>
<p>I've also properly labelled sections, divs, and headings. This helps screen recorders to properly spell out exactly what element and content is present on the page.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>If the inventor of the web stated emphatically “<em>access by everyone regardless of disability is an essential aspect</em>” of the web, then as developers we must strive to achieve just that. Plus, it's just the right thing to do.</p>
<p>You should consider accessibility even before you start to build your sites – not done after as damage control. Going forward, we ought to strive for inclusion by contributing to build a more a11y-conscious and a11y-friendly web. </p>
<p>Thanks for reading 👋🏾. I hope you found it helpful.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Improve Website Accessibility – 7 Helpful Tips ]]>
                </title>
                <description>
                    <![CDATA[ An accessible website is designed in such a way that anyone can use it without difficulty.  During the website development process, you want to make sure that the end user has the best user experience. And that includes people with disabilities or th... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/improve-website-accessibility-with-these-tips/</link>
                <guid isPermaLink="false">66bf4acb7e26d55179bfa5e2</guid>
                
                    <category>
                        <![CDATA[ a11y ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Accessibility ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Design ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Development ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Tooba Jamal ]]>
                </dc:creator>
                <pubDate>Wed, 26 Oct 2022 18:09:18 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/10/website_accessibility-1.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>An accessible website is designed in such a way that anyone can use it without difficulty. </p>
<p>During the website development process, you want to make sure that the end user has the best user experience. And that includes people with disabilities or those who faces challenges when using a website. </p>
<p>Unfortunately, there are still websites that don't use accessibility best practices. But you can make sure yours does.</p>
<p>If you keep a few things in mind during the web development process, you can improve the user experience for all users, including <a target="_blank" href="https://dictionary.cambridge.org/dictionary/english/differently-abled">differently abled</a> users.<br>Below are some helpful tips you can use to improve website accessibility.</p>
<h2 id="heading-add-alt-text-to-images">Add Alt Text to Images</h2>
<p>You might have heard about the importance of adding alt text on image tags in HTML5. So how do you use them? Do you provide alt text for every image on your webpage? </p>
<p>Image alt text makes it easier for people with visionary disabilities to understand the content of a webpage. But you should include the alt text only for informational images that aid in the understanding of the content. </p>
<p>Decorative images should have empty alt text. This tells screen readers that the information provided by the image is not important and might in fact detract from the user experience.</p>
<p><strong>Informational</strong> images are images that convey important information related to the content. You should be able to describe what they show in a few words of alt text. </p>
<p>Let's suppose we run a fitness blog and are working on creating an article about how to do a workout at home and we use the following image in our article.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/jonathan-borba-lrQPTQs7nQQ-unsplash.jpg" alt="Image" width="600" height="400" loading="lazy">
_Photo by [Unsplash](https://unsplash.com/ja/@jonathanborba?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText"&gt;Jonathan Borba on &lt;a href="https://unsplash.com/s/photos/workout?utm_source=unsplash&amp;utm_medium=referral&amp;utm<em>content=creditCopyText)</em></p>
<p>This image is supposed to convey a message to the blog readers on things you need for a crunch exercise. The alt text for this image could be something like this:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"crunch_exercise.png"</span> <span class="hljs-attr">alt</span>=<span class="hljs-string">"You must have a good quality exercise mat and workout clothing to avoid back injuries and skin allergies"</span>&gt;</span>
</code></pre>
<p>The alt text we provided for our image clearly tells visually impaired users the message our image conveys.</p>
<p><strong>Decorative</strong> images, on the other hand, serve the sole purpose of decoration on the webpage – maybe they just break up the content or complement general descriptions in the text. </p>
<p>Images used as icons are a great example of decorative images. The Airbnb homepage has a navigation bar with multiple icons (like the one in the red circle) indicating different types of living spaces available at Airbnb. The icons used in the navigation bar are for decoration purposes and we can leave their alt text empty.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/decorative_image.png" alt="Image" width="600" height="400" loading="lazy">
<em>Airbnb homepage</em></p>
<pre><code class="lang-html"><span class="hljs-comment">&lt;!-- Example of decorative image --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"decorative_img.png"</span> <span class="hljs-attr">alt</span>=<span class="hljs-string">""</span>&gt;</span>
</code></pre>
<h2 id="heading-maintain-heading-hierarchy">Maintain Heading Hierarchy</h2>
<p>If you don't use headings in the correct hierarchy (from </p><h1 id="heading-the-biggest-to"> – the biggest – to </h1><h6 id="heading-the-smallest-screen-readers-might-assume-theres-some-content-missing-because-of-this-it-is-best-to-use"> – the smallest), screen readers might assume there's some content missing. <p></p>
<p>Because of this, it is best to use </p></h6><h1 id="heading-for-the-main-title-only"> for the main title only, </h1><h2 id="heading-for-headings-that-come-after-the-title-h3-for-subheadings-and-so-on-consider-the-example-below-we-have-a-webpage-with-a-few-headings"> for headings that come after the title, h3 for subheadings, and so on. <p></p>
<p>Consider the example below: we have a webpage with a few headings. </p></h2><h1 id="heading-is-used-for-the-document-title"> is used for the document title, </h1><h2 id="heading-for-the-second-level-document-heading"> for the second level document heading, </h2><h3 id="heading-for-subheadings-and"> for subheadings and </h3><h4 id="heading-for-mini-headlines-headings-that-come-after"> for mini headlines (headings that come after </h4><h3 id="heading-heading-hierarchy-example-below-is-the-code-for-this-web-page-notice-the-different-heading-tags-in-it-facts-about-dogs-what-makes-a-dog-the-best-pet-dogs-are-everyones-favorite-and-there-are-numerous-science-backed-reasons-behind-it-mentioned-below-dogs-can-sense-a-lie-yup-you-read-it-right-dogs-are-smart-enough-to-tell-when-a-praise-is-sincere-they-have-a-pretty-sharp-mind-dogs-have-a-great-sense-of-smell-dogs-have-a-sense-of-small-thats-40x-better-than-ours-and-this-quality-plays-an-important-role-in-building-a-stronger-bond-between-a-human-and-a-dog-the-reasons-to-it-are-given-below-1-they-can-smell-a-stanger-sneaking-into-your-garage-dogs-can-spot-a-stranger-because-of-their-strong-sense-of-smell-and-save-you-from-theft-2-they-can-tell-you-whenever-you-forget-to-put-meat-in-the-fridge-after-a-grocery-run-dogs-might-make-you-give-them-a-half-of-the-meat-you-bought-from-the-supermarket-but-they-can-also-help-you-save-the-remaining-half-thanks-to-their-sense-of-smell">).<p></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/heading_hierarchy.png" alt="Image" width="600" height="400" loading="lazy">
<em>Heading hierarchy example</em></p>
<p>Below is the code for this web page. Notice the different heading tags in it:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>Facts about dogs<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"dog.png"</span> <span class="hljs-attr">alt</span>=<span class="hljs-string">"a cute dog resting under the sun"</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>What makes a dog the best pet?<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Dogs are everyone's favorite and there are numerous science backed reasons behind it mentioned below<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">h3</span>&gt;</span>Dogs can sense a lie<span class="hljs-tag">&lt;/<span class="hljs-name">h3</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Yup! You read it right! Dogs are smart enough to tell when a praise is sincere. They have a pretty sharp mind.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">h3</span>&gt;</span>Dogs have a great sense of smell<span class="hljs-tag">&lt;/<span class="hljs-name">h3</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Dogs have a sense of small that's 40x better than ours and this quality plays an important role in building a stronger bond between a human and a dog. The reasons to it are given below<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">h4</span>&gt;</span>1. They can smell a stanger sneaking into your garage<span class="hljs-tag">&lt;/<span class="hljs-name">h4</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Dogs can spot a stranger because of their strong sense of smell and save you from theft.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">h4</span>&gt;</span>2. They can tell you whenever you forget to put meat in the fridge after a  grocery run<span class="hljs-tag">&lt;/<span class="hljs-name">h4</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Dogs might make you give them a half of the meat you bought from the supermarket but they can also help you save the remaining half. Thanks to their sense of smell!<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
</code></pre>
</h3><h2 id="heading-use-the-aria-property-or-label-tag-for-input-fields">Use the Aria Property or Label Tag for Input Fields</h2>
<p>Aria labels or  tags tell screen readers what type of information an input field expects. Without them, screen readers would not know the purpose of an input field, which would provide a bad user experience to visually disabled users. </p>
<pre><code class="lang-html"><span class="hljs-comment">&lt;!-- Aria label example --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> <span class="hljs-attr">placeholder</span>=<span class="hljs-string">"Enter your name"</span> <span class="hljs-attr">aria-label</span>=<span class="hljs-string">"Enter your name"</span>&gt;</span>

<span class="hljs-comment">&lt;!-- Label tag example --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">label</span>&gt;</span>Full Name: <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> <span class="hljs-attr">placeholder</span>=<span class="hljs-string">"Enter your name"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
</code></pre>
<p>Example one uses the aria property for screen readers to read what the user is expected to enter in the name input field. </p>
<p>Example two uses the  tag with text Full Name which is readable by screen readers.</p>
<h2 id="heading-provide-keyword-functionality">Provide Keyword Functionality</h2>
<p>Not all users can use a pointing device (mouse) yet a lot of websites do not provide keyboard functionality to users. This discourages users who only use the keyboard from returning to your website. </p>
<p>One simple example of this is adding a click event listener to the submit button of a form instead of making use of the onsubmit event (which requires a user to click to submit a form). Have a look at the example below:</p>
<pre><code class="lang-html"><span class="hljs-comment">&lt;!-- Example one --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">form</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">label</span>&gt;</span>Full name: <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> <span class="hljs-attr">value</span>=<span class="hljs-string">""</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">label</span>&gt;</span>Email: <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"email"</span> <span class="hljs-attr">value</span>=<span class="hljs-string">""</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">onclick</span>=<span class="hljs-string">"handleSubmit&gt;Submit&lt;/button&gt;
&lt;/form&gt;

&lt;!-- Example two --&gt;
&lt;form&gt;
    &lt;label&gt;Full name: &lt;input type="</span><span class="hljs-attr">text</span>" <span class="hljs-attr">value</span>=<span class="hljs-string">""</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">label</span>&gt;</span>Email: <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"email"</span> <span class="hljs-attr">value</span>=<span class="hljs-string">""</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">button</span>&gt;</span>Submit<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">form</span>&gt;</span>
</code></pre>
<p>Example one uses a click event listener on the submit button. This means that pressing the enter key on a keyboard would not submit the form. </p>
<p>Example two uses the onsubmit event and assigns a JavaScript function to that event. This way a click or an enter button both run the handleSubmit function.</p>
<h2 id="heading-use-an-accessible-color-palette">Use an Accessible Color Palette</h2>
<p>Bad color contrasts ruin the overall experience for people without disabilities as well as for those with disabilities. So it's important to get the contrast and complementary colors correct when designing your site.</p>
<p>There are tools like <a target="_blank" href="https://webaim.org/resources/contrastchecker/">contrast checker</a> that help you understand whether your colors contrast enough to be properly visible. Accessible color contrast helps disabled people distinguish between elements on a web page. See below the examples of good and bad color combinations.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/color_combination.png" alt="Image" width="600" height="400" loading="lazy">
<em>Example of good and bad color combination</em></p>
<p>The first box has a dark blue background which makes the white easier to read. On the other hand, the second box has a green background with pink text that is not easy to read and causes eye strain.</p>
<h2 id="heading-provide-alternatives-for-audio-and-video-content">Provide Alternatives for Audio and Video Content</h2>
<p>Users who cannot hear or see well might find it difficult to access the audio and video content of a website. </p>
<p>To offer them a better experience, provide transcripts for any audio you use, and add easy-to-read captions on your video content.</p>
<h2 id="heading-make-sure-the-content-is-easy-to-understand">Make Sure the Content is Easy to Understand</h2>
<p>Easy to understand content is free of unexplained jargon and technical phrases. </p>
<p>Suppose you run an analytics firm and are an expert in the field of data science. But your users might include current or potential clients and job seekers. These people might not have enough technical knowledge to understand content stuffed with jargon. </p>
<blockquote>
<p>We are a team of analytics experts who are masters at aggregating data from all the available warehouses, detecting anomalies, performing batch processing on high volumes of data, and applying robust algorithms to solve your business needs.</p>
</blockquote>
<p>The above text is full of analytics jargon that not everyone can understand. This makes you lose your visitors – as why would they invest in you if they can't understand what you do? </p>
<p>Check out the below simplified version of the same text that uses more approachable terms everyone can understand:</p>
<blockquote>
<p>We are a team of experts who specialize in collecting data from all the available sources, identifying errors in that data, handling high volumes of data in less time with greater accuracy, and making predictions to solve your business needs.</p>
</blockquote>
<p>Make sure that your content delivers its purpose in language that everyone can easily understand.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Accessible websites are crucial for a good user experience. An accessible website can not only grab new users but it can also encourage old users return over and over again. </p>
<p>There is a lot more you can do when it comes to website accessibility. But with these tips and tricks, you can improve your site or app's UX significantly. </p>
<p>I hope these tips help you offer a better user experience in your upcoming projects.</p>
<p>Develop accessible websites and make the internet a better place for everyone!</p>
<p>Interested in connecting on LinkedIn? Hit me up at <a target="_blank" href="https://www.linkedin.com/in/tooba-jamal/">Tooba Jamal</a> </p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Add a "Skip to Main Content" Link to Your Website ]]>
                </title>
                <description>
                    <![CDATA[ Websites and web applications have increasingly become more complex. But it's still our responsibility, as web developers, to strive for the highest level of accessibility we possibly can. This isn't always easy, as the range of user accessibility ne... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-add-skip-to-main-content-links-to-a-website/</link>
                <guid isPermaLink="false">66d45f67052ad259f07e4b02</guid>
                
                    <category>
                        <![CDATA[ a11y ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Accessibility ]]>
                    </category>
                
                    <category>
                        <![CDATA[ best practices ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Development ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Joseph Mawa ]]>
                </dc:creator>
                <pubDate>Wed, 20 Jul 2022 16:30:05 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/07/man-sitting-infront-of-conputer.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Websites and web applications have increasingly become more complex. But it's still our responsibility, as web developers, to strive for the highest level of accessibility we possibly can.</p>
<p>This isn't always easy, as the range of user accessibility needs can complicate things even further.</p>
<p>Thankfully, various guidelines exist for designing and building more accessible websites and web applications. This article will look at the seemingly mundane, lesser-known, and often overlooked web accessibility feature: the "skip to main content" link.</p>
<p>Because they are invisible by default, many users navigating a website using the usual point-and-click method won't even notice skip-to-main-content links. But these links are critical, as they make navigating complex and large websites simpler for keyboard-only and some screen reader users.</p>
<p>In the section below, we shall have a detailed look at "skip to main content" links and why you should consider implementing them in your website or web application.</p>
<h2 id="heading-what-are-skip-to-main-content-links">What are "Skip to Main Content" Links?</h2>
<p>Most websites usually come with navigation menus to make navigation easier. But although they make your website or web application navigable for the point-and-click users, navigation menus can also cause a poor user experience for keyboard-only and some screen reader users.</p>
<p>It is not uncommon for a typical website to have a navigation menu with up to ten menu items at the top of each web page. So a keyboard-only user will needlessly tab through all the navigation links before accessing the main content on pages they visit.</p>
<p>Some screen reader users may undergo a similar experience by traversing all the menu items before reaching the main content.</p>
<p>This creates a negative experience for your users. Adding skip-to-content links can make navigating such complex sites easier and less laborious for keyboard-only and some screen reader users.</p>
<p>A "skip to content" link is an ordinary link, usually before the main navigation menu at the top, linking to the main content on the web page. Since a point-and-click user doesn't need it, a "skip to main content link" is usually hidden and made visible when it is in focus.</p>
<p>It helps keyboard-only and screen reader users skip to the main content instead of traversing all the menu items. And this greatly improves their browsing experience.</p>
<p>The image below shows the skip-to-main-content link for the <a target="_blank" href="https://www.a11yproject.com/">a11y project</a>. As mentioned above, the skip-to-main-content link is visible only after being focused on.</p>
<p>To test it, navigate to <a target="_blank" href="https://www.a11yproject.com/">a11yproject.com</a> and hit the Tab key. The skip-to-main-content link immediately becomes visible. After that, you can hit the Enter key to skip the navigation menu.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/07/skip-to-main-content-link.png" alt="Skip to main content link on a11y project website" width="600" height="400" loading="lazy"></p>
<p><em>Skip to main content link on a11y project website</em></p>
<p>In the next section, we shall implement a simple skip-to-main-content link.</p>
<h2 id="heading-how-to-add-a-skip-to-main-content-link-to-your-site">How to Add a Skip to Main Content Link to Your Site</h2>
<p>Now that we know what "skip to main content" links are, let's look at how to implement them and some best practices when using them.</p>
<p>As already mentioned in the introduction, skip-to-main-content links are ordinary links.</p>
<p>But again, they are usually not visible to an ordinary point-and-click user. You can change the visibility of the skip-to-main-content link for the keyboard user when it is in focus.</p>
<p>The code below shows the markup for a typical navigation menu. A real-world application may be more complex with nested menu items in addition to the top-level menu items. But I have kept it simple in the example below.</p>
<pre><code class="lang-html">  <span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"#main"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"skip-to-main-content-link"</span>&gt;</span>Skip to main content<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">nav</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">ul</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"/"</span>&gt;</span>Home<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"/about.html"</span>&gt;</span>About<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"/blog.html"</span>&gt;</span>Blog<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"/contact.html"</span>&gt;</span>Contact<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"/portfolio.html"</span>&gt;</span>Portfolio<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
      <span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">nav</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">main</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"main"</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>Your sweet heading<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>

      <span class="hljs-comment">&lt;!-- Page content goes here! --&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">main</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
</code></pre>
<p>The first element of the <code>&lt;body&gt;</code> tag in the above example is the skip-to-main-content link. Its <code>href</code> attribute points to the <code>main</code> element via its <code>id</code> attribute. Clicking or pressing the Enter key when the skip-to-main-content link is in focus will scroll the main content into view in the viewport.</p>
<p>As pointed out in the previous section, the skip-to-main-content link is primarily for keyboard-only and some screen reader users. So we need to apply some styling to hide it from view when out of focus and display it when it receives focus.</p>
<p>So we select it using the given class and apply the styling below. You can hide and display the skip link with different styling. It doesn't have to be the same code as below.</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.skip-to-main-content-link</span> {
  <span class="hljs-attribute">position</span>: absolute;
  <span class="hljs-attribute">left</span>: -<span class="hljs-number">9999px</span>;
  <span class="hljs-attribute">z-index</span>: <span class="hljs-number">999</span>;
  <span class="hljs-attribute">padding</span>: <span class="hljs-number">1em</span>;
  <span class="hljs-attribute">background-color</span>: black;
  <span class="hljs-attribute">color</span>: white;
  <span class="hljs-attribute">opacity</span>: <span class="hljs-number">0</span>;
}
<span class="hljs-selector-class">.skip-to-main-content-link</span><span class="hljs-selector-pseudo">:focus</span> {
  <span class="hljs-attribute">left</span>: <span class="hljs-number">50%</span>;
  <span class="hljs-attribute">transform</span>: <span class="hljs-built_in">translateX</span>(-<span class="hljs-number">50%</span>);
  <span class="hljs-attribute">opacity</span>: <span class="hljs-number">1</span>;
}
</code></pre>
<p>You can also apply transition animation to your skip-to-main-content link, though I haven't included it in the example above.</p>
<h2 id="heading-good-practices-when-adding-a-skip-to-main-content-link">Good Practices When Adding a Skip to Main Content Link</h2>
<p>Though skip-to-main-content links are easy to implement, there are some potential problems that can easily slip by you.</p>
<p>Follow what I consider good practices below when implementing skip-to-main-content links. I have picked them up from the <a target="_blank" href="https://www.w3.org/TR/WCAG20-TECHS/G1.html">WCAG techniques</a>.</p>
<ul>
<li><p>If the skip to main content link is for skipping the main navigation menu at the top of a web page, it should be the first focusable element on the web page.</p>
</li>
<li><p>The text of the skip link should describe the intent. The text "Skip to main content" will usually suffice.</p>
</li>
<li><p>It is a requirement that the skip-to-content link is either always visible or visible when in focus. Since our skip-to-content link is for keyboard-only and some screen reader users, you can hide it and make it visible as we did in the example above.</p>
</li>
<li><p>The focus should shift to the main content after activating the skip link.</p>
</li>
</ul>
<p>It is worth pointing out that using skip links is not only limited to navigation menus. You can also implement links to help users skip focusable elements that are difficult or laborious to navigate with the keyboard.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>A navigation menu is a handy feature for navigating to different sections or pages of a website. And although it's meant to provide a better user experience, a navigation menu can become an accessibility obstacle for some users who only use the keyboard or who use a screen reader.</p>
<p>This is why it's a good idea to add skip-to-main-content links on each page. When users need to traverse the navigation menu items, they can use that link to bypass the navigation menu.</p>
<p>The skip-to-main-content link is an ordinary link that's invisible to the point-and-click user. It is visible to screen reader users and when in focus. Clicking it will shift focus to the main content on the web page.</p>
<p>Hopefully, this article has given you insights on skip-to-main-content links and how to implement them in your website or web application.</p>
<p>Accessibility is a journey. Every step you take in the right direction makes your site or web application more accessible. Implementing skip-to-main-content links is one such step. Take that step and make the web more accessible if you haven't. By doing so, you are enriching the digital experience for your clients.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Common Accessibility Errors and How To Fix Them ]]>
                </title>
                <description>
                    <![CDATA[ The Web Content Accessibility Guidelines, or WCAG, defines how to make websites accessible for people with disabilities. When we evaluate whether or not website is accessible, we look to see if software meets WCAG 2 standards. Accessibility should no... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/common-accessibility-errors-and-how-to-fix-them/</link>
                <guid isPermaLink="false">66d45f35b6b7f664236cbddb</guid>
                
                    <category>
                        <![CDATA[ a11y ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Accessibility ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Ilknur Eren ]]>
                </dc:creator>
                <pubDate>Wed, 05 Jan 2022 21:15:24 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/01/accessibility-errors-article-image.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>The Web Content Accessibility Guidelines, or WCAG, defines how to make websites accessible for people with disabilities.</p>
<p>When we evaluate whether or not website is accessible, we look to see if software meets WCAG 2 standards.</p>
<p>Accessibility should not be an after thought, but rather a major part of the development process. Still, sadly these days there are many websites with accessibility errors.</p>
<p><a target="_blank" href="https://webaim.org/projects/million/#errors">WCAG's audit</a> shows that many accessibility errors fall into just six areas/categories.</p>
<table><tbody><tr><td><p></p></td><td><p></p></td><td><p></p></td><td><p>Most common types of WCAG 2 failures</p></td></tr><tr><th><p>WCAG Failure Type</p></th><th><p>% of home pages in February 2021</p></th><th><p>% of home pages in February 2020</p></th><th><p>% of home pages in February 2019</p></th></tr><tr><td><p>Low contrast text</p></td><td><p>86.4%</p></td><td><p>86.3%</p></td><td><p>85.3%</p></td></tr><tr><td><p>Missing alternative text for images</p></td><td><p>60.6%</p></td><td><p>66.0%</p></td><td><p>68.0%</p></td></tr><tr><td><p>Missing form input labels</p></td><td><p>54.4%</p></td><td><p>53.8%</p></td><td><p>52.8%</p></td></tr><tr><td><p>Empty links</p></td><td><p>51.3%</p></td><td><p>59.9%</p></td><td><p>58.1%</p></td></tr><tr><td><p>Missing document language</p></td><td><p>28.9%</p></td><td><p>28.0%</p></td><td><p>33.1%</p></td></tr><tr><td><p>Empty buttons</p></td><td><p>26.9%</p></td><td><p>28.7%</p></td><td><p>25.0%</p></td></tr></tbody></table>

<blockquote>
<p>96.7% of all errors detected fall into these six categories. Addressing just these few types of issues would significantly improve accessibility across the web. – <a target="_blank" href="https://webaim.org/projects/million/#errors">WebAIM</a></p>
</blockquote>
<p>If we tackle these six problems, we can make sure more websites are accessible for people who use various of assistive technologies.</p>
<p>Let's look at each of these common accessibility problems in more detail.</p>
<h2 id="heading-update-low-contrast-text">Update Low Contrast Text</h2>
<div class="embed-wrapper">
        <iframe width="100%" height="350" src="https://codepen.io/ilkxeren/embed/qBPVRxL" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="CodePen embed" scrolling="no" allowtransparency="true" allowfullscreen="true" loading="lazy"></iframe></div>
<p> </p>
<p>In the code example above, we can see an example of one background/foreground color combo that meets WCAG standards and one that doesn't.</p>
<p>The low color contrast is the one with blue background and gray text. It's really hard to differentiate the background and foreground colors visually and the color combination does not meet WCAG standards. The foreground text blends into the background.</p>
<p>In the second example, the foreground is whitish color and it's easy to read the text. This color combination meets WCAG standard, and the text stands out on its own and is easy to read.</p>
<p>If the text color is hard to differentiate from the background it's in, we have a low contrast accessibility error. Over the last three years, by far the biggest accessibility error is low contrast text. More than 80% of websites have this accessibility error.</p>
<p>You can fix low contrast accessibility errors by simply auditing your website and changing the color of the text or the background. You can <a target="_blank" href="https://developers.google.com/web/tools/lighthouse">run a lighthouse test</a> to see if color contrast is an issue on your website.</p>
<p>You can also check if the background/foreground color combo meets WCAG standards in the following link: <a target="_blank" href="https://webaim.org/resources/contrastchecker/">https://webaim.org/resources/contrastchecker/</a>.</p>
<h2 id="heading-add-missing-alternative-text-for-images">Add Missing Alternative Text for Images</h2>
<p>In 2021, it was reported that 60.6% of all home page images were missing alternative text.</p>
<p>It's important to add alternative text to images because you need to describe the content of the page to those who cannot see the content. Visually impaired users will use a screen reader, which will read the content of the page back to them.</p>
<p>For example, if we have an image of a basket of Belgium fries, we can add an alternative tag to that image with a simple alt attribute:</p>
<p><code>&lt;img src="example.png" alt="basket of fries"/&gt;</code></p>
<p>With one attribute, <code>alt</code>, we are able to make the image accessible for screen reader users. When a screen reader user tabs over to the image, it will indicate to them that they are focused on an image and that image is a "basket of fries".</p>
<p>If we didn't have an alt attribute, then the screen reader user wouldn't have known that the image they were focusing on was a basket of fries.</p>
<p>It's also important to note that an <code>alt</code> attribute is not enough for 100% accessible images. We also need to make sure that the alt tag is descriptive and lets the user know what the image looks like.</p>
<p>A bad example of an alt tag would be if it's not descriptive enough. Say we have the same image of the basket of fries and we add alt tag to the image like so:</p>
<p><code>&lt;img src="example.png" alt="image"/&gt;</code></p>
<p>In the example above, we would meet accessibility standards by adding the alt tag, but the alt tag is not helpful or descriptive enough for screen reader users. When a screen reader user focuses on this image, it will say, "image, image", which doesn't let the user know what this image is at all.</p>
<p>It's very important to add descriptive alternative tag to images on the page.</p>
<h2 id="heading-add-missing-form-input-labels">Add Missing Form Input Labels</h2>
<p>About half of the websites were missing form input labels in 2021. A form label is an HTML element used in forms to describe what the the various fields in the form are for.</p>
<p>If you have any type of form on the page, whether it's checkbox, radio button or dropdown, you must have a <code>&lt;label&gt;</code> associated with this form.</p>
<p>A common error for missing form input is for search forms. Often search forms on a page usually have only a magnifying glass image to indicate to visual users that they can search with that form, but no label to indicate search. But if we don't add a label to this form, screen reader users will not know what the form is when they focus on it.</p>
<p>We can fix this accessibility error by adding a screen reader label.</p>
<p>HTML example:</p>
<pre><code class="lang-php">&lt;label <span class="hljs-keyword">for</span>=<span class="hljs-string">"searchLabel"</span> <span class="hljs-class"><span class="hljs-keyword">class</span>="<span class="hljs-title">sr</span>-<span class="hljs-title">only</span>"&gt;<span class="hljs-title">Search</span>&lt;/<span class="hljs-title">label</span>&gt;
&lt;<span class="hljs-title">input</span> <span class="hljs-title">type</span>="<span class="hljs-title">text</span>" <span class="hljs-title">name</span>="<span class="hljs-title">search</span>" <span class="hljs-title">id</span>="<span class="hljs-title">searchLabel</span>&gt;
&lt;<span class="hljs-title">input</span> <span class="hljs-title">type</span>="<span class="hljs-title">submit</span>" <span class="hljs-title">value</span>="<span class="hljs-title">Search</span>"&gt;</span>
</code></pre>
<p>CSS example:</p>
<pre><code class="lang-php">.sr-only{
   position:absolute;
   left:<span class="hljs-number">-10000</span>px;
   top:auto;
   width:<span class="hljs-number">1</span>px;
   height:<span class="hljs-number">1</span>px;
   overflow:hidden;
}
</code></pre>
<p>In the example above, we added a label "Search" to the form with the help of CSS. When a user focuses on this particular form, the screen reader will read, "Search", to them. The class <code>sr-only</code> in this form will only make this element readable when on a screen reader.</p>
<h2 id="heading-fix-empty-links">Fix Empty Links</h2>
<p>Links are used to navigate the user to a new page or view. A link is focusable by keyboard and can be triggered by the enter key.</p>
<p>Similar to the missing form label error, another accessibility error is empty links. About half of the websites had empty links in 2021.</p>
<p>For example, if we use the Facebook logo to indicate to sighted users that the link is to go to Facebook, but we don't add any label for screen reader users, then we will get an empty link accessibility error.</p>
<p>If we don't add text for screen readers, then screen reader users will not know that they are focused on a Facebook logo.</p>
<p>A good example of adding a label to a link is below:</p>
<pre><code class="lang-php">&lt;a href=<span class="hljs-string">"/facebook-page"</span>&gt;
   &lt;i aria-hidden=<span class="hljs-string">"true"</span>&gt;&lt;/i&gt;
   &lt;span <span class="hljs-class"><span class="hljs-keyword">class</span>="<span class="hljs-title">sr</span>-<span class="hljs-title">only</span>"&gt;<span class="hljs-title">Facebook</span>&lt;/<span class="hljs-title">span</span>&gt;
&lt;/<span class="hljs-title">a</span>&gt;</span>
</code></pre>
<p>CSS correspondent:</p>
<pre><code class="lang-php">.sr-only{
   position:absolute;
   left:<span class="hljs-number">-10000</span>px;
   top:auto;
   width:<span class="hljs-number">1</span>px;
   height:<span class="hljs-number">1</span>px;
   overflow:hidden;
}
</code></pre>
<p>In the example above, we used a Facebook logo to indicate that this is a Facebook link. We also added "Facebook" text that will be read when users focus on it using a screen reader.</p>
<h2 id="heading-add-missing-document-language">Add Missing Document Language</h2>
<p>For the last three years, between 28% to 33% of homepages have been missing a document language on their page. This is one of the less common accessibility problems but it is still an accessibility error we should pay attention to and fix.</p>
<p>We can add the language to the HTML tag like so:</p>
<pre><code class="lang-php">&lt;html lang=<span class="hljs-string">"en"</span>&gt;
...
&lt;/html&gt;
</code></pre>
<p>The example above indicates that the page is in English. We can use other codes to indicate other languages.</p>
<p>It's important to indicate the language of the page because screen readers use the document language to know how to pronounce the words. Document language is also good for SEO.</p>
<h2 id="heading-fix-empty-buttons">Fix Empty Buttons</h2>
<p>Buttons are used to do things on a page, for example submitting a form or show/hide things. A button is focusable and can be triggered by the space key.</p>
<p>Similar to empty links, we need to make sure that buttons have text for screen readers to read when on focus.</p>
<p>The solution for fixing empty buttons is similar to fixing empty links, which is to make sure text label is present on buttons.</p>
<p>If an image is used inside button, we can add an alt tag to the image. This will ensure that when a user uses a screen reader, the image alt tag is read. Here's an example of how to do this below:</p>
<pre><code class="lang-php">&lt;button type=<span class="hljs-string">"submit"</span>&gt;
   &lt;img src=<span class="hljs-string">"/search.svg"</span> alt=<span class="hljs-string">"Search"</span>/&gt;
&lt;/button&gt;
</code></pre>
<p>Similarly to an image, if you use an SVG inside a button, you can add a title inside the SVG. Here's an example of how to do this below:</p>
<pre><code class="lang-php">&lt;button type=<span class="hljs-string">"submit"</span>&gt;
   &lt;svg id=<span class="hljs-string">"search"</span> role=<span class="hljs-string">"img"</span> aria-describedby=<span class="hljs-string">"search"</span> viewBox=<span class="hljs-string">"0 0 16 16.9"</span>&gt;
      &lt;title id=<span class="hljs-string">"search"</span>&gt;Search&lt;/title&gt;
      &lt;path d=<span class="hljs-string">"M14, 2L8690, 89.1,13,6.5G87"</span>&gt;&lt;/path&gt;
   &lt;/svg&gt;
&lt;/button&gt;
</code></pre>
<p>We need to make sure that buttons are not empty and that screen readers read what the button is to the user.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Accessibility should never be an afterthought, but rather a large part of the development process. Most accessibility errors come from six categories and if we fix them, we will make our websites more accessible to everyone.</p>
<p>Accessibility fixes should not be difficult and should only require basic HTML and CSS knowledge.</p>
<p>If we pay more attention to accessibility, we will open our websites to a wider audience and also make sure our code is good and meets standards. Accessibility not only helps everyone use websites but also improves the foundation of our code.</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
