HTML <form> tag

HTML <form> tag

The <form> tag is used to create an HTML form for user input.

The <form> element does not actually create form fields, but is used as a parent container to hold the following form elements:

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <form action="/user-name.php"> Name: <input type="text" name="name"> <button type="submit">Submit</button> </form> </body> </html>

Attributes

The following are the attributes of <form> tag. Also try Global attributes.

AttributeValueExplanation
accept-charsetcharacter_setSpecifies the character encodings that the server accepts.
actionURLSpecifies where to send a form data when the user clicks on the submit button.
autocomplete
  • on
  • off
Specifies whether the value of the <input> elements in the form can be automatically completed by the browser.
enctype
  • application/x-www-form-urlencoded
  • multipart/form-data
  • text/plain
Specifies how to encode a form-data before sending it to a server.
method
  • get
  • post
Specifies the HTTP method that the browser uses to submit the form.
nametextSpecifies a name for the form.
novalidate-Specifies the form should not be validated when the user clicks on the submit button.
target
  • _blank
  • _self
  • _parent
  • _top
Specifies where to display the response after submitting the form.

Deprecated Attributes

The following attributes should not be used in any case.

AttributeValueExplanation
acceptfile_typeSpecifies a comma-separated list of file types that the server accepts.
autocapitalize
  • none
  • sentences
  • words
  • characters
  • on
  • off
Specifies a user typed value should be auto capitalized as per its attribute value.

Reminder

Hi Developers, we almost covered 99.5% of HTML Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in HTML.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Meet the Author