HTML Checkbox Tag - HTML Tutorial

HTML Checkbox Tag

BLUF: Mastering HTML Checkbox Tag is a fundamental step in becoming a web developer. This guide covers the structure, syntax, and best practices for using this HTML element effectively.
Key Lesson: HTML Checkbox Tag

Web structure starts with solid HTML. Learn how HTML Checkbox Tag contributes to accessible and semantic web pages in the tutorial below.

The HTML <checkbox> tag is employed to specify rectangular containers. This element in forms enables users to choose single or multiple choices from the provided selection.

It is generated by the type attribute of the <input> tag as illustrated in the syntax below:

Example

<input type="checkbox" name="field name" value="Initial value">

If there is a need to preselect a checkbox by default, the checked attribute should be assigned a value of "yes" as outlined in the following syntax:

Example

<input type="checkbox" name="field name" value="Initial value" checked="yes">

Example

Example

<html>

<head>

</head>

<body>

<form>

Programming Languages: <br>  

              <input type="checkbox" id="C" name="C" value="C"/>  

                 <label>C</label> <br>  

              <input type="checkbox" id="Java" name="Java" value="Java" checked=?yes?/>  

                 <label>Java</label> <br>  

              <input type="checkbox" id="Python" name="Python" value="Python"/>  

                 <label>Python</label> <br>

	     <input type="checkbox" id="PHP" name="PHP" value="PHP"/>  

                 <label>PHP</label>

</form>

</body>

</html>

Output:

Browser Support

Element Chrome IE Firefox Opera Safari
<checkbox> Yes Yes Yes Yes Yes

Input Required

This code uses input(). Please provide values below:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience