Learning to Use the Input Tag with a Checkbox
The checkbox mainly is used for selecting multiple options at one time. It’s used in surveys online and can be used for any type of form. If you have interests of course, fill free to make them and have them filled out. I mainly see this used for surveys because companies research to improve products or to get information to see if they qualify for a particular study. I’m going to give you a few examples on how it looks and how it works code wise.
Just look at your favorite sports.
| List of <input type=checkbox> tag's attributes | |
| type=checkbox | Determines the type of <input> element. |
| name | Gives checkbox a name. |
| value | Set a value of a checkbox. |
| checked | Activate a checkbox. |
| disabled | Disable a checkbox |
Examples
<input type="checkbox" name="sports" value="nfl"> NFL<br>
<input type="checkbox" name="sports" value="nba"> NBA<br>
<input type="checkbox" name="sports" value="nhl"> NHL
MLB
NFL
NBA
NHL
You see how it works and how it looks correct? This has to have to be in the <form> tag as that is the theme of this lesson. You can interchange the names of the items and values. What you will get will be just about nearly identical and can be as little or as much as needed. I recommend not going over the top and add too many because some viewers will not want to spend time clicking on items.
<input type="checkbox" name="check" value="Activated Checkbox" checked> The activated checkbox
<input type="checkbox" name="check" value="Disabled checkbox" disabled> The disabled checkbox
<input type="checkbox" name="check" value="Checkbox 1" checked disabled> The activated and disabled checkbox
Just the checkbox
The activated Checkbox
The disabled checkbox
The activated and disabled checkbox
This example shows how you can make a different state of checkboxes.
HTML Forms menu.