form

The HTML <form> element represents a container for interactive controls for submitting information.

code result
<!-- simple form -->
<form action="/mysite.com/api/action" method="post" >
   <p>Nickname <input type="text" 
           name="nickname" id="nickname" required /> 
   </p>
   <p>Email  <<nput type="email" 
           name="email" id="email" required /> </p>
    <input type="submit" value="Subscribe!">
</form>

Nickname

Email

attributes

attribute description
action

The URL that handles the form action. Can be overridden by a formaction attribute on a <button>, <input type=submit>, or <input type=image> element.

method

The HTTP method of action. Can be overridden by formmethod attribute on <button>, <input type="submit">, or <input type="image"> elements. Possible values:

  • post - the POST method, form data sent as the request body
  • get - the GET method, form data appended to the action URL with a ? separator.
  • dialog - when the form is inside a <dialog>, closes the dialog on submission
enctype

The MIME type of the form submission for method post. Can be overridden by formenctype attribute on <button>, <input type=submit>, or <input type=image> element. Possible values:

  • application/x-www-form-urlencoded the default value
  • multipart/form-data used for uploading files
  • text/plain used for debugging purposes
autocomplete

Possible values:

  • off - disallow to browser automatically complete entries
  • on - allow to browser automatically complete entries
target

Specifies where to display the response after submitting the form. Can be overridden by a formtarget attribute on <button>, <input type=submit>, or <input type=image> element. Possible values:

  • _self - load into the same browsing context as the current one.
  • _blank - load into a new unnamed browsing context.
  • _parent - load into the parent browsing context of the current one. If no parent, behaves the same as _self.
  • _top - load into the top-level browsing context. If no parent, behaves the same as _self.