Developers
What developers should take into consideration when writing code.
Testing
Adding Tables
Add "
summary
" to table tag. A summary conveys information about the organization of the data in a table and helps users navigate it.Add "
scope
" to tables with headers. Thescope
attribute can be set torow
orcol
to denote that a header applies to the entire row or column, respectively.Add "
captions
". A caption functions like a heading for a table. Most screen readers announce the content of captions.
Adding SVGs
If it is used as an
img
, must addtitle
attribute to it.If
svg
is use as a button, must add atabindex
attribute
iFrames
iFrames needs to have a
title
attribute
images vs background images
Images must have an
alt
attributeImages can also have a
title
attributeIf an image gives a better understanding or context to a content, that images should not be a background image but an actual image.
Summary
Developers can emulate links with other elements, such as <div>
or <span>
elements and JavaScript click listeners. But, these kinds of emulated links need care. Developers wishing to emulate links must include the following:
Add
tabindex=”0”
so that the link becomes keyboard focusableAdd
role=”link”
so that assistive technology recognizes the element as a linkAdd the styling cursor: pointer so that mouse users will recognize the element as a link.
Same applies to html elements used as buttons instead of the actual
<button>
or<input>
element.
For example, the markup for an accessible emulated link might look like the following:
To avoid needing to implement the above, developers should prefer to use the <a>
tag instead.
Focus vs Focus-within
What is css :focus and :focus-within
? How do you know when to use them? Read more about how to use :focus
here.
Note: If using role="button" instead of the semantic <button>
or <input type="button">
elements, you will need to make the element focusable and have to define event handlers for click
and keydown
events, including the Enter and Space keys, in order to process the user's input. See the official WAI-ARIA example code.
Semantic HTML5
Remember that most browser will automatically validate correctly written HTML for you. Keep them simple with less layers of html tags wrapping them endlessly.
Last updated