Learning to Use the Input Tag with a Radio Attribute
The Radio portion of the input is used to pick a selected item. Think of this as part of a quiz with a multiple choice being the common answers being a, b, c, or d. It is also used to select an option on whether you are involved with political parties and voting purposes. Thinking about it even further, this is a common trait and doesn’t usually go overboard with the amount of choices. This item has no optional items, as they are all required. The key traits with the <input> tag are the type, name, and value, which is really self-explanatory. I’m going to show you a few examples of these with different options.
| List of <input type=radio> tag's attributes | |
| type=radio | Determines the type of <input> element. |
| name | Gives radiobox a name. |
| value | Set a value of a radiobox. |
| checked | Activate a radiobox. |
| disabled | Disable a radiobox |
Examples
When was the last time the Indians won the World Series?
<input type="radio" name="indians" value="1964"> 1964<br>
<input type="radio" name="indians" value="1948"> 1948<br>
<input type="radio" name="indians" value="Never"> Never
1958
1964
1948
Never
It's a simple set o radioboxes.
<input type="radio" name="radiobox" value="Selected radiobox" checked> Selected radiobox
<input type="radio" name="radiobox" value="Disabled radiobox" disabled> Disabled radiobox
Just radiobox
Selected radiobox
Disabled radiobox
This example shows how you can create pre-selected and disabled radioboxes.
It takes practice but it can be mastered overtime. Remember, you have to have the <form> tag to put it inside. Once you have it mastered, it should be in good shape.
HTML Forms menu.