Jump to: navigation, search

HTML form checkbox

From w3cyberlearnings

Contents

HTML - Checkbox

Checkbox uses for multiple selection at a time.

HTML - Syntax Checkbox Tag

<input type="checkbox" name="NAME_VALUE" value="VALUE"/>Label<br/>

Checkbox - Attributes

Attributes Value Example Description
name text <input type="checkbox" name="GSU">GSU-School name the checkbox field
value text <input type="checkbox" name="GSU" value="GSU-School">Gsu School value of the checkbox when submit
checked checked <input type="checkbox" name="GSU" checked="checked">GSU School Default checked for the checkbox

Example TRY-IT

  • We use label for each checkbox name, when user clicks on the label name it will trigger the checkbox to check.

<html>
<head>
<title>checkbox Button</title>
</head>
<body>
<form>
<input type="checkbox" name="fruits" value="apple" checked="checked" id="appleid" />
<label for="appleid">Apple</label><br/>

<input type="checkbox" name="fruits" value="banana" id="bananaid" />
<label for="bananaid">Banana</label><br/>

<input type="checkbox" name="fruits" value="coconut" id="coconutid"/>
<label for="coconutid">Coconut</label><br/>

<input type="checkbox" name="fruits" value="mango" checked="checked" id="mangoid"/>
<label for="mangoid">Mango</label><br/>

<input type="checkbox" name="fruits" value="Orange" id="orangeid"/>
<label for="orangeid">Orange</label><br/>

</form>
</body>
</html>

Output

Html form checkbox 1.png

Related Link


Navigation
Web
SQL
MISC
References