3 ms·
Why can't assistive technology figure out what a label with a single nested control refers to? The browsers seem to do it just fine. Once a website reaches a c
by crazygringo 14y ago
Why can't assistive technology figure out what a label with a single nested control refers to? The browsers seem to do it just fine.
Once a website reaches a certain scale (especially with rich web apps), global DOM id's become an almost impossible headache to deal with (because of multiple views which duplicate id's, coordination of global names across hundreds of files, etc.).
Global id's are basically an antipattern, whereas labels with nested controls have always seemed pretty workable.
- mistercow 14y ago>Once a website reaches a certain scale (especially with rich web apps), global DOM id's become an almost impossible headache to deal with (because of multiple views which duplicate id's, coordination of global names across hundreds of files, etc.). The most effective way I've found to deal with them in those circumstances is to have them generated automatically at runtime when they are absolutely required. It's still a terribly backwards way of doing things, but at least you can ensure their uniqueness that way.
- Too 14y agoOnce a website reaches a certain scale you better have a backend that generates your forms already. Since input elements already have unique names/values, otherwise the backend wouldn't know what you've posted. You can use a (scrambled) version of this, plus a sequence number if required in case of multiple inputs with same name. Remembering to manually insert the label for every radio input is just bound to fail.
- sherm8n 14y agoJust treat labels like remembering the closing tag of any html element.
- crazygringo 14y agoOn a large-scale rich webapp, input elements don't have to have unique names, because you're not posting forms directly to the backend. Instead, you identify your input elements with classes, use something like jQuery to read the values from elements with certain classes from inside a specific DOM element only (not globally), and then POST to the server using AJAX. Nowadays, user interface elements have no need to be tightly coupled with HTTP parameters. ID's worked in the era of non-JavaScript. But for large dynamic sites where JavaScript is required (webapps, etc.), I haven't used ID's anywhere for years, thank God (like I said, an antipattern).
- Joeri 14y agoYou could probably write a library that did smart renaming of id's. For example, <label id="R_../../checkbox1+_label"> would be renamed to the id of the first checkbox on the parent's parent with _label appended to it. The library could be smart enough to only recognize the R_ prefix as needing to be renamed. Not saying that you should do that, just that you could.