I'm currently trying to come up with a good and accessible way to format a status indicator which should be rendered within a set of wizard-like pages on a website. The website should provide a multipage form with a status indicator on top of it as demonstrated in the wireframe below:
Given the new progress-tag in HTML my first thought was to do something like this:
<progress value="2" max="3">
<ul>
<li>Beginning</li>
<li class="now">Right now</li>
<li>End</li>
</ul>
</progress>
... but since <progress> only accepts phrasing content using a list is not really an option. So right now I would probably go with something like this, integratinng the ARIA progressbar-role:
<ul aria-role="progressbar" aria-valuenow="2" aria-valuemin="1" aria-valuemax="3" aria-describedby="state2" aria-valuetext="Right now">
<li id="state1">Beginning</li>
<li id="state2" class="now">Right now</li>
<li id="state3">End</li>
</ul>
But again, I'm not really sure if the progressbar role can be applied in such a way to a list.
Another problem is, that <progress> is rendered as progress bar in Opera, for instance, so >progress> itself is probably not really a viable solution altogether :-(
Can anyone perhaps recommend an accessible status bar that does not only rely on using a single image?
Current solution
For now I will go with following markup:
<section class="progress">
<h1 class="supportive">Your current progress</h1>
<ol>
<li><span class="supportive">Completed step:</span> Login</li>
<li class="now"><span class="supportive">Current step:</span> Right now</li>
<li><span class="supportive">Future step:</span> End</li>
</ol>
</section>
All elements of the class "supportive" will be positioned off-screen. IMO this way we should have a nice compromise of semantic markup (the state succession is in my opinion really an ordered list ;-)) and accessibility thanks to the additional header and status text for each step.
According to whatwg, you're not supposed to assign progressbar role to <ul> elements.
I'd just ditch <ul> and describe progress using (surprise) phrasing content:
<section role="status">
<h2>Task Progress</h2>
<p>You're now at <progress value=2 max=3>"Right now" step</progress>.
</section>
Update: You're right, progress doesn't suit here, it's more like an interactive form widget. I should've checked first, before taking it from your first example. But anyway, the point is there's no need to use a list (even more so, unordered list), when you can just describe what's going on in plain text. In the case that the list of past and future steps is necessary, I'd just add two more paragraphs, one before the status (‘You've completed the "Beginning" step’), and one after (‘Next step will be the "End" step’).
However, I admit that this isn't a complete answer to your question.
Also, I'd say some aria attributes look redundant to me. For example, aria-valuetext perhaps would make more sense in the context of interactive widget, when there's no other human-friendly description of its state. Though I may be wrong here.
Related
For my accessibility related question, I googled "accessibility shopping cart" and visited many popular online stores but didn't find a clear answer on my question. From the accessibility point of view, for the shopping cart, should I add a tabindex="0" (the code is slightly simplified) for
<ul>
<li><span tabindex="0">Merchandise: $40</span></li>
<li><span tabindex="0">Shipping: $10</span></li>
<li><span tabindex="0">Taxes: $0.40</span></li>
<li><span tabindex="0">Total: $50.40</span></li>
</ul>
or simply
<ul>
<li><span>Merchandise: $40</span></li>
<li><span>Shipping: $10</span></li>
<li><span>Taxes: $0.40</span></li>
<li><span>Total: $50.40</span></li>
</ul>
, or separate merchandise and $40 as
<li><span tabindex="0">Merchandise</span>: <span tabindex="0">$40</span></li>
, or even add (if Twitter Bootstrap is used with its sr-only class)
<li><span tabindex="0">Merchandise</span>:
<span tabindex="0">
<span aria-hidden="true">$</span>40<span class="sr-only"> American dollars</span>
</span>
</li>
The main question you should ask is: are all these list items interactive ? Does it happen something when they are clicked ?
If your answer to this question is yes, then you should add tabindex=0 so to make the interactive element usabe by keyboard only users. If you don't do it, then your site isn't accessible for them.
If your answer to this question is no, then tabindex=0 useless and even counter-productive. Keyboard only users will have to press tab more times to skip your elements which do nothing, and reach actual useful elements. That's a waste of time and usabiility.
Of course, in reality, it's more complex than just that. For example, an element may be interactive at some moment, but not at some other moment, in which case tabindex=-1 should be used to disable focusability when it isn't desired.
But here are the basics.
If you don't have any good reason to add a tabindex="0" (some custom interaction with these elements that is not explained in the question), you must not add tabindex="0" to your elements.
Screen readers provide controls to simply read within a page, instead of interacting with components. Interacting with list items that simply show prices would be unexpected.
<ul>
<li>Merchandise: $40</li>
<li>Shipping: $10</li>
<li>Taxes: $0.40</li>
<li>Total: $50.40</li>
</ul>
I deleted the <span>, it's not necessary for accessibility (you can keep it if you need it for any other reason).
Regarding the .sr-only question, it's also not necessary. For example, Voice Over reads $40 as "forty dollars".
You should simply leave the list as-is, without tabindex, but could help users skip the list of products in the cart by providing headlines:
<h2>Products</h2>
…
<h2>Summary</h2>
<ul>
<li>Merchandise: $40</li>
<li>Shipping: $10</li>
<li>Taxes: $0.40</li>
<li>Total: $50.40</li>
</ul>
The expectations for a shopping cart are the same for screen reader users and non-sr users: Some interaction is available to remove products or change their number, but mainly they read to make sure they got everything.
Screen readers provide controls to read within a page, instead of interacting with components (that would be tab). Even tables are not read in an interactive or form mode.
They also provide shortcuts to jump to the next headline.
If there is interaction
Should you actually provide interaction on these <span> elements, by binding keydown and click handlers, you’ll need to communicate the nature of that interaction, by assigning a proper role to these spans, like role="button".
On providing different texts to screen readers
In most cases it’s not recommended to make screen readers announce texts in a certain way. They do have logic implemented already, and their users are accustomed to that. VoiceOver announces $40 as ‘fourty dollars’, for example. Users can also customize how certain things are announced, which should be respected.
First, you should add the <ul> or <ol> tag around the list. The screen reader will then announce how many elements that are inside the list. Jaws will announce the example list as: "list with 5 elements". tabindex only makes the elements tabbable with the "TAB" key, remember to add a focus indicator as well.
<ul>
<li><span tabindex="0">Merchandise: $40</span></li>
<li><span tabindex="0">Shipping: $10</span></li>
<li><span tabindex="0">Taxes: $0.40</span></li>
<li><span tabindex="0">Total: $50.40</span></li>
</ul>
It can be wise to separate the product and price for each list element:
<ul>
<li><span tabindex="0">Merchandise</span>: <span tabindex="0">$40</span></li>
</ul>
The user can then TAB to get the price information instead of listening to the product description before getting the price. You should try to only use tabindex="0" for tabbable elements or tabindex="-1" for elements that should not get focus
Example: https://stackblitz.com/edit/angular-fecmdv?file=src/app/app.component.html
I've learned to make the main navigation with a list like that:
<ul>
<li>nav-item</li>
</ul>
Now additionally, I need two top navigations, one left for social buttons and another right for other things. Someone told me better to build those top navigations by 2 like that:
<div>
top-nav-item
</div>
And I'm confused. Why is that better? Could someone tell me the advantage of the second way?
Thank you~
I would recommend using <nav> elements, which is HTML5 spec (see also here). Semantically it fits better with navigational elements, and it might help understand search engines better what elements of your website they are looking at. You can put <a> elements inside the <nav>. A search engine might be able to better understand that those are links to other pages, because that is what anchor elements are made for (linking to other pieces of content).
For how it looks, it doesn't matter; pretty much all elements can be made to look like a menu with buttons. Furthermore, search engines are pretty smart nowadays, and they will probably understand most of your website anyway, even if you don't use the proper elements all the time.
That being said, those elements are there for a reason, so why not use them?
The mozilla developer network's example that I reference above uses the following, but to me personally it does not necessarily always make sense to put everything in a <ul> element.
<nav class="menu">
<ul>
<li>Home</li>
<li>About</li>
<li>Contact</li>
</ul>
</nav>
Why is that better?
It isn't.
HTML is a semantic markup language. It is designed to describe the semantics of your data.
You have a list of links.
The markup should express that it is a list of links not a series of generic blocks with links in them.
I have created example that you want please check below link.
Click on Run.
.nav{float:left;}
.nav li,.social li{float: left;margin-right: 22px;list-style: none;}
.social{float:right;}
<header>
<ul class="nav">
<li>Home</li>
<li>About us</li>
<li>Contact</li>
</ul>
<ul class="social">
<li>Facebook</li>
<li>Google</li>
</ul>
</header>
Our project usually has a professional web developer that handles this sort of thing. But ours left, and we're still looking, so this weirdness falls to me. We have a situation where a list of lines under a node has to affect the parent node's look.
<span class="feedback">
<ul>
<li class="info">Just an info message</li>
<li class="error">This is an error</li>
</ul>
</span>
In the above, if all the li's are not error, we want one look, but if there's even ONE error, we want a different look. Is that something CSS can do? if so, how? Is there something I can do on feedback that makes it show one way under no errors, and a different way if there are?
Appending class has-errors to span.feedback on the back-end is not an option? If you have control over what comes from the back-end I'd try to do something like such approach instead (it's somehow simpler):
<span class="feedback has-errors">
<ul>
<li class="info">Just an info message</li>
<li class="error">This is an error</li>
</ul>
</span>
Otherwise, as far as I know, it's not possible to accomplish precisely what you're asking only through CSS. But if you use JS, you could also make it happen (far from ideal), IMO.
What would the most relevant HTML tags be for a numbered progress bar such as:
(1) Step 1: do something
(2) Step 2: do something else
(3) Step 3: complete
I considered using an <ol> but in this case, the '1', '2', '3', will need styling.
Also to indicate which step the user is currently on.
As you've already decided, an ordered list is the most semantic way to show a progress bar. Unfortunately there isn't a specific HTML element or attribute for "current step" or anything similar (I wish I knew why!). So you'll need to make something yourself. The simplest way I've used before is to use an image of the step number with an alt attribute, e.g.
<li><img src='step1.png' alt='Step 1: Current step'>Do something</li>
But you could use visually-hidden text instead. The image would need to be visually distinct from the other steps so that colour-blind users are informed as well.
Probably nothing more semantic currently than:
<ol>
<li class='currentStep'>
<span>1</span>
<span>do something</span>
</li>
<li>
<span>2</span>
<span>do something else</span>
</li>
</ol>
Semantically I agree with the use of ol but I believe you can achieve the desired effect with a bit of css and use of data-attributes
The markup would look something like this
<ul>
<li data-step="1">Do something</li>
</ul>
Here's a sample of the implementation: http://jsbin.com/gifisireku/edit?html,css,output
The benefit of using this is you can have clean and accessible markup which is great for SEO as well ;)
As it's valid markup, I have done the following;
<div class="list">
Link 1
Link 2
</div>
My question is, does it have to be written as this;
<ul class="list">
<li>Login to Broker Site</li>
<li>Register</li>
</ul>
what are the + and - of doing one than the other? And are these both correct according to semantic web?
Thanks.
It totally depends on the greater context, but seeing as it seems to be a navigational sub-menu, a ul is indeed the most semantically correct element to use.
The clue is in the class name you chose.
As you see it as a list then use a list. This is a lot more semantic and is helpful for screen readers, which will then treat the contents as a list of links.