Mastering Form Controls: A Comprehensive Guide to Filset, Legend, Radio Buttons, and Checkboxes

Mastering Form Controls: A Comprehensive Guide to Filset, Legend, Radio Buttons, and Checkboxes
What are Filset and Legend?
In web development, aFilsetis a container used to group all controls in a form visually into a category. ALegendis used to set a caption for this Filset.
Syntax:
```html
```
When to use Filset and Legend?
Use Filset and Legend when you want to visually group related form controls in a cohesive unit. A common example is the<gender>field, where both radio buttons and checkboxes can be used.
What are Radio Buttons?
Radio buttonsenable the user to select one or multiple options. Once checked, a radio button cannot be unchecked to uncheck the process or define mutual exclusion.
Attributes:
- Name: Specifies a different reference name for radio buttons (e.g., Gender).
- Value: The default value submitted by the form is usually off. Define another value to submit the value on selection of specific radio buttons.
- Checked: Makes the radio button selected by default.
What are Checkboxes?
Checkboxesare a form element that allows the user to select one or multiple options. They can be checked and unchecked as needed.
Attributes:
- Name: Defines a common name for checkboxes in a group (e.g., course).
- Value: The value associated with each checkbox option (e.g., HTML, JavaScript, or Python).
How to use Filset, Legend, Radio Buttons, and Checkboxes?
- Create a new HTML file and save it as control.html.
- Write the basic HTML structure.
- In the body section, create a form element.
- Inside the form, create a fieldset element.
- Give the fieldset a legend with an appropriate name (e.g., gender).
- Inside the fieldset, add radio buttons or checkboxes as needed.
- Include appropriate labels for each control.
- Add a submit button at the end.
- Save and open the file in a browser.
Examples:
Here's an example of using Filset, Legend, Radio Buttons, and Checkboxes:
```html
Control ExamplesGenderMaleFemaleCoursesHTMLJavaScriptSubmit
```
When to use a Checkbox?
Use a checkbox when you want the user to be able to select multiple options from a list. In this example, we're using it for selecting courses.