How to add a checkbox in HTML?
Updated On: 2024-06-02
Try it
xxxxxxxxxx
<fieldset>
<legend>Choose your monster's features:</legend>
<div>
<input type="checkbox" id="scales" name="scales" checked />
<label for="scales">Scales</label>
</div>
<div>
<input type="checkbox" id="horns" name="horns" />
<label for="horns">Horns</label>
</div>
</fieldset>
Value
xxxxxxxxxx
<div>
<input type=" checkbox"="" id="subscribeNews" name="subscribe" value="newsletter"> <label for="subscribeNews">Subscribe to newsletter?</label>
<button type="submit">Subscribe</button>
Handling multiple checkboxes
xxxxxxxxxx
<fieldset>
<legend>Choose your interests</legend>
<div>
<input type="checkbox" id="coding" name="interest" value="coding">
<label for="coding">Coding</label>
</div>
<div>
<input type="checkbox" id="music" name="interest" value="music">
<label for="music">Music</label>
</div>
</fieldset>
Related Resources
For more information, you can use the following resources:
Write Reference