webdevlinux - logo Web Dev Linux

Checkboxes

We use the checkboxes to choose multiple options from a group of options. Here you will understand how to use checkboxes in an HTML document.

HTML checkboxes Checkboxes

Try the example given below.

FILE : checkboxes.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Checkboxes</title>
</head>
<body>
<form>
<p>Select the operating systems you have used.</p>
<label><input type="checkbox"> Arch</label><br>
<label><input type="checkbox"> Debian</label><br>
<label><input type="checkbox" checked> Fedora</label><br>
<label><input type="checkbox"> Gentoo</label><br>
<label><input type="checkbox"> Mint</label><br>
<label><input type="checkbox"> Ubuntu</label><br>
</form>
</body>
</html>

Explanation

Take a look at the explanation of elements & attributes used in the example.

<input type="checkbox">
The input element with the type value checkbox defines a toggled option.
checked
The checked attribute is used to represents a pre-selected option.