Saturday, October 20, 2012

How to Make HTML Labels Clickable on iOS Safari

In most web browsers, the label element which refers to a clickable input element, such as input[type="checkbox"] or input[type="radio"], is also clickable on the whole area.

label – caption for a form control
http://www.w3.org/TR/html-markup/label.html

However, it seems that the action is blocked on iOS Safari. Adding an empty onclick="" attribute to the label element makes it possible.

<label onclick=""><input type="checkbox" ... />"I Agree to ...</label>