Text entry

Our example uses two different controlsA way to collect information in forms., each using an input element (tag name input). The type attribute (type) indicates the type of input element being used; here the values used text for text input (which is also the default if you omit the type attribute) and reset for resetting the values to the original ones.

The information given in the value input attribute (value) depends on the value of the type attribute. For reset, the information given is the text on the button.

Here the original value is entered using the placeholder attribute (placeholder) to show the format of what is to be entered. You can set up your form so that users can start typing right away by using the autofocus attribute (autofocus) in one of the controls. Notice that there is no value provided, just the term autofocus.

In our example, notice how name is used as the value of both the label elementAn element used to provide a caption for a control in a form. and the ID of the input element.

Note:

Hints:

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