Sets the encoding in which the server can receive and process data. The address of the program or document that processes the form data. Enables auto-filling of form fields. The method for encoding form data. HTTP protocol method. Form name. Overrides the built-in check of form data for correctness of input. The name of the window or frame where the handler will load the returned result.
Closing tag
Required.
HTML5 IE Cr Op Sa Fx
FORM tag
The result of this example is shown in Fig. 1.
Rice. 1. View of form elements in a browser window
An HTML form is a part of a document that allows the user to enter information of interest, which can subsequently be accepted and processed on the server side. In other words, forms are used to collect information entered by users.
To determine which form element the current label belongs to, you must use the for attribute of the tag
Let's look at an example of use:
Example of using a tag Yes No >
In this example we:
Inside first forms:
Posted two radio buttons ( ) to select one of a limited number of options. Note again that for radio buttons within the same form the same name must be specified, we specified different values. For first checked , which specifies that the element should be preselected when the page loads (in in this case radio button with the value yes ). In addition, we have specified global attributes for the radio buttons, which define a unique identifier for the element.
Placed two elements , which define the text labels for our text fields. Note that we used the for attribute to determine which form element the current label belongs to. The value of the for attribute corresponds to the value of the global attribute of the radio button we need.
Inside second forms:
Posted two radio buttons ( ) to select one of a limited number of options. For second For radio buttons, we have specified a checked attribute, which indicates that the element should be pre-selected when the page loads (in this case, a radio button with the value no ). In addition, we specified unique values for the radio buttons within the form and the same names.
Placed two elements , we placed our radio buttons inside them. Unlike the previous method, there is no need to specify global attributes (identifier for the element) for radio buttons, and use the for attribute for text labels to refer to them (make a binding).
In the browser, both options (methods) for using text labels look identical:
Tooltip for input fields
Let's look at an example of use:
Example of using the placeholder attribute
In this example, we specified for the element with type text (a single-line text field) and type password (password field), a text hint for the user (the placeholder attribute) that describes the expected value for the input.
The result of our example:
Questions and tasks on the topic
Before moving on to the next topic, complete the practice assignment:
Using the knowledge you have gained, create the following order form:
A caveat: in fields where selection is expected, it should be possible to select by clicking on the text, and not just on the element itself.
After you complete the exercise, inspect the page code by opening the example in a separate window to make sure you did everything correctly.
HTML tags that define HTML forms on the site
We create websites and individual pages on the Internet to communicate with visitors.
HTML forms are used to register visitors on the site, for interactive surveys and voting, allow you to send messages, make purchases, and so on. HTML The form is created for one purpose: collecting and subsequently transmitting information for processing by a software script or via email.
Example HTML form | Login to the site
Tags, attributes and values
- determine the shape.
name="" - defines the name of the form.
method="" - defines the method of sending data from the form. Values: "get" (default) and "post" . The "post" method is often used, as it allows large amounts of data to be transferred.
action="" - defines the url at which the data is sent for processing. In our case - enter_data.php ..
- define such form elements as buttons, switches, text fields for data entry.
type="text" - defines a text field for data entry.
type="password" - defines a field for entering a password, with the text displayed in the form of asterisks or circles.
type="checkbox" - defines a radio button.
type="hidden" - defines a hidden form element - used to transmit additional information to the server.
size="25" - length of the text field in characters.
maxlength="30" - the maximum allowed number of entered characters.
value="" - defines the value that will be sent for processing if it relates to radio buttons or switches. The value of this attribute as part of a text field or button will be shown as, for example, Vasya or Login in the example above.