Tip: use wrapping label tags instead of "for"

If you are building an app that displays form elements with labels, avoid the <label for="..."> syntax. Instead, use <label><input.../></label> . The problem with the for version is that it relies on unique DOM element IDs on the page. Apps that can be installed multiple times per help desk will end up writing multiple elements with the same ID to the DOM, and the browser will have no way to know which form element to tie to which label.


Please sign in to leave a comment.