Click here to Skip to main content
15,845,742 members
Articles / Web Development / HTML
Tip/Trick

How to make text of an html checkbox clickable (like ASP.NET control)

Rate me:
Please Sign up or sign in to vote.
4.88/5 (16 votes)
29 Jun 2011CPOL 53.4K   6   7
Make text of an html checkbox clickable (like ASP.NET control)
If you put a label HTML tag after the checkbox (either HTML check box or Server Side checkbox control), and set the ID of the check box to the "for" attribute of the label tag, clicking the text in the label tag will click the checkbox:

The code will be as below:
<input type="checkbox" id="checkbox1"/>                                                             

<label for="checkbox1">
 label text
</label>

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Iran (Islamic Republic of) Iran (Islamic Republic of)
I hold a BS degree in software engineering and am a Microsoft Certified Solution Developer(MCSD).
I have more than 8 years of experience in .NET developement, mostly web develop using C# and ASP.NET.

Comments and Discussions

 
GeneralReason for my vote of 1 This is basic, all over the internet... Pin
ahmed-itani3-Jan-12 19:26
professionalahmed-itani3-Jan-12 19:26 
GeneralRe: Reason for my vote of 1This is basic, all over the internet... Pin
Carsten V2.024-Aug-12 6:50
Carsten V2.024-Aug-12 6:50 
GeneralReason for my vote of 4 Good Pin
rahulpriyan2-Jan-12 18:29
rahulpriyan2-Jan-12 18:29 
GeneralReason for my vote of 5 Very good Pin
Vano Maisuradze12-Aug-11 5:26
Vano Maisuradze12-Aug-11 5:26 
GeneralReason for my vote of 5 interesting Pin
abdul samathu4-Jul-11 23:59
abdul samathu4-Jul-11 23:59 
GeneralReason for my vote of 5 Looks Good Pin
Toniyo Jackson27-Jun-11 0:08
Toniyo Jackson27-Jun-11 0:08 
QuestionThanks for sharing Pin
Anjum.Rizwi4-Jul-11 19:21
professionalAnjum.Rizwi4-Jul-11 19:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.