Checkboxes in HTML

Checkboxes in HTML
 
Checkboxes in HTML
  • Currently 0 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Rating: 0/5 (0 votes cast)

Thank you for rating!

You have already rated this page, you can only rate it once!

Your rating has been changed, thanks for rating!

Log in or create a user account to rate this page.


Checkboxes are used to select two or more optional items. If only one item needs to be selected, then it's better to use radio buttons.

How to create a checkbox element.

<input type="checkbox" parameters>

Field parameters are listed in table 1.

Table 1. Checkbox parameters.

Parameter

Description

name

Name of the field. Designed for the form handler to identify the field.

value

The specified value of the field defines what will be sent to the server if the box element is checked.

checked

If this parameter is present, then the box element will be checked automatically.

Example 1 shows how to create and use checkboxes. Please note that the value of each box in the checkbox element differs. This way the server program can determine which item is checked.

Example 1. Using checkboxes.

<form action="/cgi-bin/handler.cgi">
  <b>Which of the operating systems do you know?</b><br>
  <input type="checkbox" name="option1" value="a1" checked>Windows 95/98<br>
  <input type="checkbox" name="option2" value="a2">Windows 2000<br>
  <input type="checkbox" name="option3" value="a3">System X<br>
  <input type="checkbox" name="option4" value="a4">Linux<br>
  <input type="checkbox" name="option5" value="a5">X3-DOS
</form>

The result is shown below.

Which of the operating systems do you know?
Windows 95/98
Windows 2000
System X
Linux
X3-DOS

 

Read also

Adding a form to a page in HTML

Adding a form to a page in HTML

Text field in HTML

Text field in HTML

Buttons in HTML

Buttons in HTML

Form elements in HTML

Form elements in HTML

Post comment

basicuse.net
html5_css
106160485398655174790

Quick navigation

General navigation