The <fieldset>
tag is used to group related form elements together. It is used to create a visual grouping of form elements and is often used in combination with the <legend>
tag to provide a title or description for the group.
The <fieldset>
tag is a container element that is used to group related form elements together. It is used to create a visual grouping of form elements and is often used in combination with the <legend>
tag to provide a title or description for the group.
The <fieldset>
tag is commonly used in forms to group related input fields together. For example, a form that collects personal information may use a <fieldset>
tag to group the fields for name, address, and phone number together. This makes it easier for users to understand the purpose of each field and to fill out the form correctly.
The <fieldset>
tag can also be used to group related radio buttons or checkboxes together. This is useful when you have a set of options that are related to each other, such as a set of radio buttons that allow the user to select a payment method.
Here are some examples of how the <fieldset>
tag can be used:
In this example, we use the <fieldset>
tag to group together a set of input fields:
<form> <fieldset> <legend>Personal Information</legend> <label for="name">Name:</label> <input type="text" id="name" name="name"><br> <label for="email">Email:</label> <input type="email" id="email" name="email"><br> <label for="phone">Phone:</label> <input type="tel" id="phone" name="phone"><br> </fieldset> </form>
In this example, we use the <fieldset>
tag to group together a set of radio buttons:
<form> <fieldset> <legend>Payment Method</legend> <label> <input type="radio" name="payment" value="credit-card"> Credit Card </label><br> <label> <input type="radio" name="payment" value="paypal"> PayPal </label><br> <label> <input type="radio" name="payment" value="bitcoin"> Bitcoin </label><br> </fieldset> </form>