Using the input Element to Create Fixed Choices
The type='radio' of the input element creates a group of radio buttons. Each input element with the type radio represents a single option to the user. The following table describes the additional attributes supported for type='radio'.
Attribute | Description | New in HTML5 |
---|---|---|
checked | if the radio button is selected | No |
required | required field for input validation. | Yes |
value | Specifies the data value that is submitted to the server. | No |
<!DOCTYPE HTML>
<html>
<head>
<title>Example</title>
</head>
<body>
<form method="post" action="http://yourServer/form">
<p>
<label for="name"> Name: <input value="Mark" id="name"
name="name" />
</label>
</p>
<p>
<label for="password"> Password: <input type="password"
placeholder="Min 6 characters" id="password" name="password" />
</label>
</p>
<p>
<fieldset>
<legend>Vote for your favorite:</legend>
<label for="apples">
<input type="radio" checked value="Apples" id="apples" name="fave" /> Apples
</label>
<label for="oranges">
<input type="radio" value="Oranges" id="oranges" name="fave" /> Oranges
</label>
<label for="cherries"> <input type="radio" value="Cherries" id="cherries" name="fave" /> Cherries
</label>
</fieldset>
</p>
<input type="submit" value="Submit Vote" />
</form>
</body>
</html>
Home
HTML CSS Book
HTML
HTML CSS Book
HTML
input Restricted:
- Using the input Element to Restrict Data Entry
- Using the input element to obtain a number
- Using input Element to Obtain a Number in a Given Range
- Using the input Element to Obtain a Boolean Response
- Using the input Element to Create Fixed Choices
- Using the input Element to Obtain email address
- Using the input element to obtain telephone number
- Using the input Element to Obtain url
- Using the input element to obtain times and dates
- Using the input Element to Obtain a Color
- Using the input Element to Obtain Search Terms
- Using the input element to create hidden data items
- Using the input Element to Create Image Buttons and Maps
- Using the input element to upload files
Related: