2

I'm designing a form like this, where the bottom of the labels in that row align in straight line and the top of the input fields in that row align in straight line.

Owing to some restriction in CSS (we can't fix the height as it will vary), I've to place the labels of the form elements in first row and then place their respective input fields in the next row (such that the input fields are placed just below their labels).

I tested the keyboard & the tab order with this html structure, it works fine. I'm wondering that the reading order in JAWS or any other screen reader is not going to be right.

Any recommendations for any method to change the reading order or is it ok to go ahead with this html structure since the tab order is anywys working ?

Community
  • 1
  • 1
code.tweetie
  • 614
  • 1
  • 6
  • 16

2 Answers2

1

In the HTML structure each input should be preceded by its label, rather than having labels on one row and inputs on the next.

However, you have a very particular display you want, and you are supporting IE7 (without display: table), so I think you are best off actually using a table.

You can do this accessibly, if you take these things into account:

Use a basic layout table for your form, and include an extra attribute on the table tag:

<table role="presentation">

That means the table is not a table from an accessibility point of view. (I only ever recommend this when supporting IE7 layouts!) Do not use <th> tags either.

The main thing for screen readers when filling it in would be an explicit label-input relationship.

<label for="input_id">My label</label>
<input type="text" id="input_id">

You can tell if this works by clicking on the label, it should put the cursor in the input.

However, your reading view needs a different approach. When you've got a row of items at the top that relate to a row of items underneath, that is the definition of a data table. So when the page is saved (or however it converts to the reading view), use a data table e.g:

<table>
 <tr>
   <th>Customer account number</th>
   [other <th>s]
 </tr>
 <tr>
 <tr>
   <td>023456353434</td>
 ...

When read out by a screen reader it will read the 'header' (e.g. customer account number) before the content (023...). So the changes are:

  • Remove the role
  • Convert the top row into <th>s

It has to be said this is a hack, it is not particularly robust, and I certainly wouldn't recommend it for a responsive site. It is purely the required layout and browser support that lead to this.

AlastairC
  • 3,277
  • 21
  • 15
  • While that answers the edit mode of the page, I now have trouble in displaying the form field name & submitted values in the same kind of layout. I'm not sure how I'll related the name & the values when they are displayed in different rows ? – code.tweetie Oct 10 '13 at 12:32
  • Could you post the HTML source please? Or a snippet that shows the rows/columns/inputs/labels at least. – AlastairC Oct 10 '13 at 15:41
  • Please find the updated fiddle http://fiddle.jshell.net/YwMEu/7/show/ which shows both form (edit) mode and form-submitted (readonly) mode. – code.tweetie Oct 11 '13 at 09:12
  • I was reading about some aria attributes like aria-flowto/aria-flowfrom , aria-describedby / aria-labelledby, wondering if I can use these to relate the labels in the 1s row to their respective values in the 2nd row, to make the readonly layout logical and accessible. – code.tweetie Oct 11 '13 at 09:14
  • I'm still trying to work out why you can't use the source order, like this example; http://jsfiddle.net/46QaQ/1/show/ I'm not sure there is a good way of associating the label with the content otherwise. – AlastairC Oct 17 '13 at 22:34
  • Reason is in IE7 it doesnt work. Can you see how that source order looks in IE7 plese ? – code.tweetie Oct 18 '13 at 10:23
0

without viewing your markup its impossible to tell exactly, but it sounds like you have a tow of inputs and then a row of labels....that's not ideal for accessibility.

you could nest the form control inside the label element, setting the form control's display to block to achieve the same effect, while also increasing usability and clickability.

albert
  • 8,112
  • 3
  • 47
  • 63