How to label checkboxes properly

You, Web developmentForm

Let's learn how to label checkboxes.

To see what I mean click on this checkbox's text label ("Click Me!"):

<input type="checkbox"> Click Me!

Nothing happened, right? Right.

Now click on this checkbox's text label:

<label><input type="checkbox"> Click Me!</label>

Yep, awesome. Here's another way to do it (in case your <label> and <input> tags are far apart):

<input type="checkbox" id="ckbx"> <label for=ckbx">Click Me!</label>
© Heshan Wanigasooriya.RSS

🍪 This site does not track you.