Bookmark and Share

HTML - Checkbox Forms

Checkboxes are another type of <input /> form. We set the type attribute to check and we also must set a name and value attribute for them to be at all helpful.

Advertise on Tizag.com

HTML Code:

<p>Please select every sport that you play.</p>
Soccer: <input type="checkbox" name="sports" value="soccer"  /><br />
Football: <input type="checkbox" name="sports" value="football"  /><br />
Baseball: <input type="checkbox" name="sports" value="baseball"  /><br />
Basketball: <input type="checkbox" name="sports" value="basketball"  />

Checkboxes:

Please select every sport that you play.
Soccer:
Football:
Baseball:
Basketball:

Checkboxes are used for instances where a user may wish to select multiple options, a sort of check all that apply question.

HTML Checkboxes Selected

It is possible to precheck the input boxes for your viewers using the checked attribute. Simply set the checked attribute to yes or no.

HTML Code:

<p>Please select every sport that you play.</p>
Soccer: <input type="checkbox" checked="yes"
 name="sports" value="soccer" />
<br />
Football: <input type="checkbox" 
name="sports" value="football" />
<br />
Baseball: <input type="checkbox" 
name="sports" value="baseball" />
<br />
Basketball: <input type="checkbox" checked="yes" 
name="sports" value="basketball" />

Checked Checkboxes:

Please select every sport that you play.
Soccer:
Football:
Baseball:
Basketball:


Bookmark and Share




Found Something Wrong in this Lesson?

Report a Bug or Comment on This Lesson - Your input is what keeps Tizag improving with time!

New - Tizag.com Forums!
Recent Forum Topics:

Advertise Here

More Tutorials!
Microsoft Office Tutorials Artist Tutorials