CheckBox Control in HTML

Checkboxes are used when more than one option is required to be selected. It is created using an <input> element whose type attribute has a value of checkbox. Example :
<!DOCTYPE html>
	  <title>Checkbox Control</title>
     <form action="login_page.php" method="post">
	Select Your Subjects : <br /><br />
	<input type="checkbox" name="maths" value="maths" checked/> Maths <br />
	<input type="checkbox" name="physics" value="physics" /> Physics <br />
	<input type="checkbox" name="chemistry" value="chemistry" /> Chemistry <br />
The output of above code will be :

Attributes :

The attributes used in the checkbox control are as follows :

  • type : Indicates the type of input control and for checkbox input control it will be set to checkbox.
  • name : Used to give a name to the control which is sent to the server to be recognized and get the value.
  • value : The value that will be used if the checkbox is checked.
  • checked : Set to checked if you want to select it by default.

Next Topic :