This is my Day 6 of learning HTML. Today, I learned about the *Form Attributes and Input Attributes. *
Form Attributes:
- target
- action
- method
Target:
Target attribute is used specify where to display the response after submitting the form.
The values of target attribute and their meaning:
_blank - Opens in a new window or tab
_self - Opens in the same tab
_parent - Opens in the parent frame
_top - Opens in the full body of the window
Action:
The action attribute contains the URL that defines where to send the data after submitting the form.
If the action attribute is omitted, then the action is set to the current page.
Method:
The method attributespecifies the HTTP method to be used when submitting the form data.
There are two methods: 1.GET 2.POST
The default method is GET.
GET:
GET is not suitable for sensitive information or passwords.
Because, when the form is submitted the data is shown in the URL.
GET is good for non-secure data.
POST:
POST is a secure method, we can send sensitive information and passwords using POST method.
POST is preferred while sending the large amount of data.
POST sends the data in the http request body.
INPUT ATTRIBUTES:
1.VALUE:
Value attribute used to set a default value for the input field.
2.NAME:
The name attribute specifies the name for the input field.
When the form is submitted, the browser stores the data as key(name) and value pair.
If an input field, which does not have name attribute, it's data is not stored in the form data when the form is submitted.
3.AUTOCOMPLETE:
The autocomplete attribute is used to enable or disable the browser's automatic suggestions for form fields based on previously entered values.
When autocomplete="on", the browser may suggest saved information such as names, email addresses, and phone numbers.
When autocomplete="off", the browser will not provide those suggestions.
4.READONLY:
The readonly attribute is used to allow the user to read the data only. The user can't modify the data in that input field.
5.AUTOFOCUS:
Autofocus attribute is used to automatically focus to the input field when the page is loaded.
6.MULTIPLE:
Multiple attribute is used to allow the user to **enter more than one data **in the input field.
7.MAXLENGTH:
Maxlength attribute specifies the maximum number of characters that a user can enter in the input field.
8.MINLENGTH:
Minlength attribute specifies the minimum number of characters that a user must enter in the input field.
9.PLACEHOLDER:
Placeholder attribute is used to give a hint to the user about what should be entered in an input field.
10.REQUIRED:
Required attribute makes a field mandatory, meaning the user must provide a value before submitting the form.
If the required field is empty, the browser will display a error message and prevent form submission.
Top comments (0)