Home > Article > Web Front-end > A brief discussion on name, value in input and for in label
This article will briefly talk about name, value in input and for in label. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
Input has many attributes, the more commonly used ones are type, value, name, placeholder, multiple, checked, etc. I have always been confused about the name, value, label and the text outside the label, but I finally figured it out today.
1) name attribute
Definition: The name attribute specifies the name of the input element.
Usage: The name attribute is used to identify the form data after it is submitted to the server, or to reference the form data through JavaScript on the client.
Note: Only form elements with the name attribute set can pass their values when submitting the form.
In other words, name is of no use for page display (adding it or not does not affect page display), but is used for easy reference when interacting with the server or writing js.
2) value attribute
Definition: The value attribute sets the value for the input element.
Usage: For different input types, the usage of the value attribute is also different:
type="button", "reset", " submit" - Define the text displayed on the button
<input>按钮文字
type="text", "password", "hidden" - Defines the initial value of the input field
<input>标签外
<input>按钮文字
Note: The value attribute must be set in and .
3) label
The above is the detailed content of A brief discussion on name, value in input and for in label. For more information, please follow other related articles on the PHP Chinese website!