Saturday, January 21, 2023 at 5:03 PM
To the best of my knowledge, semantic HTML is for developers to better understand the website from the code level, as well as for the search engine to better interpreted. I've heard semantic HTML can improve the UX, but didn't really take it into account.
Until, I've read some articles on accessibility recently, and I feel like it's quite neccessary to get an overview of it. Hopefully, it I can take care of these details later on.
A11y
is the abbreviation of Accessibility, and the 11
represents the 11 characters in between. The idea of A11y
is to ensure the website is accessible to all people.
It wouldn't be easy for people who never experienced the pain to understand what it looks like for visually impaired people to access the web, and so do I. Therefore, let's dive into it and mimic the experience. Here I'll use the screen reader NVDA
by NV Access
.
I also tried out ChromeVox
, but it wasn't easy to navigate around, I'm not sure but the hot keys are not working properly.
Basically, the user can access the content via a screen reader, the screen reader read out the text whether it's on a software or website. The user will navigate through the keyboard's shortcut keys, and the screen reader will notify the user by reading out the content and related info.
After trying out the screen reader to access some of the websites, I wanna summarize parts of the experiences I've undergone. First off, it takes some time to get used to the shortcut keys to browse the website. Furthermore, it's quite confused in a lot of time, for say, the image that has no description, so as the links. Many of these are literally ruining my experience, and this is what really motivates me to learn more about it.
To taste it, you can install NVDA
from the official website, and here are a few settings that helped me a lot in using the screen reader.
Mouse
-> uncheck Enable mouse tracking
; The reader won't keep reading aloud everything when you use the mouse.Vision
-> check Enable Highlighting
; It can then visually see a rectangle around the content that the reader is reading.Browser Mode
-> change the value Maximum number of characters on one line
to 250 characters; The reader might stop reading when the paragraph is too long, changing the max value can void it.Here's the result after enable the setting 2 above. There's no anything other visual aids other than the default CSS by default.
Here are some shortcut keys that I found useful during my trial, learning more shortcut keys can help you be more efficient in browsing web content.
Control + Alt + N
: Open NVDA when closedNVDA + Q
: Turn off NVDA↓
: Read the next lineNVDA + ↓
: Read the current lineControl
: Stop readingNVDA + N
: Open the setting panelThe following keys are mainly used when browsing websites, it's applying to the next element when solely used, to navigate back to the previous element, combine it with a Shift
.
Tab
: Next interactable element(Button, Link, Input)Space
/ Enter
: Trigger the current interactable element(Click)H
: Next heading(h1、h2...) D
: Next LandmarkF
: Next FormT
: Next TableB
: Next ButtonK
: Next LinkG
: Next ImageThere're more hotkeys than those, for more details, you can hop over to this guide.
Here I'll share how the screen reader interprets different types of web elements with text records, mainly on the commonly used elements and with or without the particular attributes.
Website titles, headings, paragraphs, links, buttons, forms, and tables are the elements that are widely used in all websites. In general, the screen reader will read out the element's content, then the type of the element, as well as some of the related information.
<title>
The website title is what we can see in the top bar of the browser, when the user loads the website, the first context read out by the screen reader is the website title, followed by other elements in order.
<title>Learn more on Accessibility | A11y, on KaLok's Blog</title>
# Read out:learn more on accessibility a11y on kalok's blog
<h1>
- <h6>
Headings are the most important element to help the users to figure out what's the main idea of the following blocks. If the website has a bad heading that does not match the related content, it'll confuse the user and contribute to a very bad user experience.
Notice here, the reading order of the screen reader is depending on the order of the source code, it's not depending on the level of headings!
<h1>How title are interpreted by screen reader</h1>
# Read out:how title are interpreted by screen reader, heading level one
<h2>Title is way more important</h2>
# Read out:title is way more important, heading level two
<p>
For the paragraph element, the screen reader will directly read out the content of it, there'll be no any other information, so I'll just pass it here.
<a>
Normally, when we are coding the link elements, we tend to keep the link content as short as possible for the sake of the outlook (for example: read more, click here...), and the reader will only read out the link content:
<a href="https://google.com">Read More</a>
# Read out:link, read more
# if link has been visited, Read out:visited link, read more
From the code and result above, we can tell if the near content block did not provide any useful information, the user can barely know where the link will head to, which makes the user not really sure whether to click the link or not. There're two solutions, either we provide the context around or use the aria-label
attribute as follows:
<a href="https://apple.com/..." aria-label="to Order MacBook Pro 14 now">Order</a>
# Read out:link, to order macbook pro 14 now
# if link has been visited, Read out:visited link, to order macbook pro 14 now
When we used the aria-label attribute, the screen reader will ignore the link content and read out what's inside the attribute. In this case, we keep the website clean and also provide the necessary information for the user.
<button>
Basically, the result or effect of the button is the same as the link element, what the screen reader read out is the same, except the type of the element will be read out differently.
<button onClick="fn()" aria-label="Display user image">Display</button>
# Read out:button, display user image
# if button has been visited, Read out:visited button, display user image
<ul>
/ <ol>
By default, the list elements can be recognized by the screen reader and read out the list info with every list item, something the screen reader will also provide the position of the list item (x out of y).
The screen reader will go through the whole list at once, the user needs to use ↓
proceed to the next list item element.
<ol>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ol>
# Read out:list with 3 items, one html
# Next item:two css
# Next item:three javascript
We know there're some slightly different between unorder list and the order list, which also results in the screen reader, the reader will read out the prefix symbol of the item differently.
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
# Read out:list with 3 items, bullet html
# Next item:bullet css
# Next item:bullet javascript
<ul style="list-style: square;">
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
# Read out:list with 3 items, black square html
# Next item:black square css
# Next item:black square javascript
What I've mentioned above is just some obvious and common knowledge of web accessibility, it will take far more time to learn beyond that. But it's also worth learning these knowledge since it's really necessary to enhance the user experience.
Hopefully, I can do more studies on this topic and implement more advanced approaches with aria
.
Accessibility | MDN Web Docs - https://developer.mozilla.org/en-US/docs/Web/Accessibility
How visually impaired people navigate the web - https://uxdesign.cc/how-visually-impaired-people-navigate-the-web-7f9eab9d9c37
Screen Reader Basics: NVDA -- A11ycasts #09 - https://www.youtube.com/watch?v=Jao3s_CwdRU&list=PLNYkxOF6rcICWx0C9LVWWVqvHlYJyqw7g&index=9
Headings that reflect the page organization | W3C - https://www.w3.org/WAI/tutorials/page-structure/headings/#headings-that-reflect-the-page-organization
The Top 5 Website Accessibility Failures - https://www.lrswebsolutions.com/Blog/Posts/97/Website-Accessibility/The-Top-5-Website-Accessibility-Failures/blog-post/#image
Disability: let’s say the word - https://www.a11yproject.com/posts/lets-say-the-word-disability/
Intro to ARIA -- A11ycasts #13 - https://www.youtube.com/watch?v=g9Qff0b-lHk
Introduction to WAI-ARIA - https://www.youtube.com/watch?v=-ZO3QVgs-sk
Stops reading midway through sentence - https://github.com/nvaccess/nvda/issues/9482