I have seen it on several webpages (cannot recall where exactly atm) where I am able to check or uncheck checkboxes by clicking on the text in front of the checkbox. I know how to do it in JavaScript (create a span with onclick()) , but I want to know if there is any way I can do it without JavaScript.
Asked
Active
Viewed 1,642 times
0
-
1You are looking for the [`label`](https://developer.mozilla.org/en/docs/Web/HTML/Element/label) tag. – Boaz Aug 01 '16 at 05:57
-
2See http://stackoverflow.com/questions/6293588/how-to-create-an-html-checkbox-with-a-clickable-label – Stéphane Aug 01 '16 at 05:57
1 Answers
5
You can achieve this functionality using label
tag as given below.
<input type="checkbox" id="option">
<label for="option">Select this option</label>

niyasc
- 4,440
- 1
- 23
- 50
-
Thanks. Yes this is what I was looking for. Sometimes even little straightforward things get out of mind and are hard to recall :A (y) – Youstay Igo Aug 01 '16 at 06:04
-