Bad: Shein
Good: H&M
As an engineer, while you are designing or developing a product, you should always:
What's wrong with this code?
<div class="button">Button Label</div>
Why is this correct?
<button>Button Label</button>
What's wrong with this code?
<img src="/images/frog.jpg" />
Why is this correct?
<img src="/images/frog.jpg" alt="A green frog resting on a palm frond" />
What's wrong with this code?
<div class="header"> <div class="nav"></div> </div> <div class="main"> <div class="announcement"></div> <div class="offers"></div> </div> <div class="footer"></div>
Why is this correct?
<header> <nav></nav> </header> <main> <section class="announcement"></section> <section class="offers"></section> </main> <footer ></footer>
What's wrong with this code?
Name:
I am a human
<p>Name: <input type="text" /> </p> <p> <input type="checkbox" /> I am a human </p>
Why is this correct?
<p> <label for="name"> Name: </label> <input id="name" type="text" /> </p> <p> <input id="human" type="checkbox" /> <label for="human"> I am a human </label> </p>
What's wrong with this code?
Loan Type:
Spaceship<p>Loan Type:</p> <input name="loanType" id="loan_car" type="radio" value="Car" /><label for="loan_car">Car</label> <input name="loanType" id="loan_car" type="radio" value="House" /><label for="loan_house">House</label> <input name="loanType" id="loan_spaceship" type="radio" value="Spaceship" /> <label for="human" class="loan_spaceship" style="display: none;"> Spaceship </label> <span class="custom-label">Spaceship</span>
Why is this correct?
<fieldset> <legend>Loan Type:</legend> <input name="loanType_correct" id="loan_car_correct" type="radio" value="Car"/><label for="loan_car_correct">Car</label> <input name="loanType_correct" id="loan_house_correct" type="radio" value="House"/><label for="loan_house_correct">House</label> <input name="loanType_correct" id="loan_spaceship_correct" type="radio" value="Spaceship"/> <label for="loan_spaceship_correct" class="sr-only">Spaceship</label> <span class="custom-label" onclick="checkRadioButton('loan_spaceship_correct')" style="background: ...">Spaceship</span> </fieldset>
ARIA roles are predefined designations that provide meaning to content, specifically on elements that are not codified by native HTML or not fully supported by the browser. This assures interactions with the element is consistent. Roles are in place to support, not replace semantic HTML.
Loan Type:
<div role="radiogroup" aria-labelledby="legend_aria_group"> <p is="legend_aria_group">Loan Type:</p> <span class="fake-radio" role="radio" aria-checked="false" tabindex="0" aria-labelledby="loan_car_aria" data-value="Car"></span><label id="loan_car_aria">Car</label> <span class="fake-radio" role="radio" aria-checked="false" tabindex="0" aria-labelledby="loan_house_aria" data-value="House"></span><label id="loan_house_aria">House</label> </div>
Here are some of the most commonly used ARIA roles:
Remember, the correct use of semantic HTML elements often reduces the need for ARIA roles, as many HTML elements have implicit roles that are automatically recognized by assistive technologies. For instance, <nav> implicitly has the navigation role, and <main> implicitly has the main role. Use ARIA roles primarily when semantic HTML does not provide an equivalent.
Is this right or wrong?
<button role="button">I am a button</button>
<img role="img" src="..." alt="" />
<svg role="img" alt="" />...</svg>
<nav role="navigation">Main Navigation</nav>
<div role="heading" aria-level="1" >Main heading of a page</div>
ARIA attributes enable modifying an element's states and properties as defined in the accessibility tree.
<button aria-label="Close"> <svg aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg"> <path d="m.967 14.217 5.8-5.906-5.765-5.89L3.094.26l5.783 5.888L14.66.26l2.092 2.162-5.766 5.889 5.801 5.906-2.092 2.162-5.818-5.924-5.818 5.924-2.092-2.162Z" /> </svg> </button>
<button aria-expanded="false" aria-controls="widget1">Show Widget</button>
Focusable Elements: Only specific elements can receive focus, which is why it is imperative to use semantic html and not remove focusability via css.
Focus indicator:The focus indicator is a visual aid which indicates which element currently has focus.
TabIndex: The tabindex attribute indicates that its element can be focused, and where it participates in sequential keyboard navigation. Be wary of setting tabindex! Much like ARIA Roles, by choosing to manually set tabindex, means you have to account for ALL tab instances.
Focusable:
We offer a variety of services including web development, digital marketing, and graphic design. Our team of experts ensures top-quality and innovative solutions for your business needs.
Non-focusable:
Sign up to be on the AAT!
Keep accessibility in mind
Be a proponent for improving our process.
Thank you. Any questions?