In HTML, the <form>
element is used to create a form for collecting user input, which is then sent to a server for processing. Forms can contain various types of input elements like text fields, checkboxes, radio buttons, and submit buttons.
Try it yourself
<form>
Element:Action:
action
: Specifies the URL where the form data will be sent for processing.
Method:
method
: Defines how the form data is sent to the server. Common values:
GET
: Appends form data to the URL (visible in the URL).POST
: Sends form data as a separate request body (not visible in the URL).Enctype:
enctype
: Specifies how form data should be encoded when submitting it to the server (relevant when method="POST"
). Common values:
application/x-www-form-urlencoded
: Default encoding.multipart/form-data
: Required when the form includes file uploads.text/plain
: Sends data without any encoding.Target:
target
: Specifies where to display the response after submitting the form. Common values:
_self
: Opens in the same tab (default)._blank
: Opens in a new tab or window._parent
, _top
: For controlling frames.Autocomplete:
autocomplete
: Enables or disables autocomplete for the form (on
or off
).