Checkboxes and buttons

This example uses the input types checkbox and button.

The checked attribute (checked) can be used to preset a box to be checked. Like for the autofocus attributeAn attribute of a form control to specify the focus., no value is provided, just the term checked.

As before, the reset button can be used to return the form to the original state.

The line break elementAn element that inserts a line break. has been used so that the buttons appear on different lines.

Our example provides the layout of the form and the functionality of the reset button, but to provide further actions based on the input to the form (and in particular to make the first button do something), we'll need to use JavaScript, as taught in the JavaScript lesson on checkboxes.

Like for reset, using the value input attributeAn attribute of an input element specifying information depending on the type of input, such as text for a button or a value used by JavaScript for a checkbox. for a button defines the text on the button. For a checkbox, the same attribute attaches a value that can be used by JavaScript.

Note:

Hints:

  • undefined
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
<!DOCTYPE html>
<html lang="en">
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX