Form Attributes in HTML
? Form Attributes in HTML
HTML <form> elements use various attributes to control their behavior, data submission, and appearance.
Common Form Attributes
| Attribute | Description | Example |
|---|---|---|
action | URL where the form data is sent on submit | <form action="/submit"> |
method | HTTP method to send data: GET or POST | <form method="POST"> |
enctype | Encoding type for form data (used with file uploads) | enctype="multipart/form-data" |
name | Name of the form (used in scripts) | <form name="myForm"> |
target | Where to display the response (_self, _blank, etc.) | <form target="_blank"> |
autocomplete | Enable/disable autocomplete for inputs | <form autocomplete="off"> |
novalidate | Disable HTML5 form validation on submit | <form novalidate> |
accept-charset | Character sets the server can handle | <form accept-charset="UTF-8"> |
Example Form
<form action="/submit" method="POST" enctype="multipart/form-data" autocomplete="on" novalidate> <label for="email">Email:</label> <input type="email" id="email" name="email" required> <input type="submit" value="Send"></form>Explanation
action: where form data is sent after submission
method: usually
GET(appends data in URL) orPOST(secure data transfer)enctype: needed for file uploads (
multipart/form-data)autocomplete: can turn on/off browser autofill
novalidate: skips built-in HTML5 validation (useful if validating with JS)
Want me to provide examples of specific input types or advanced form handling?