MOCKSTACKS
EN
Questions And Answers

More Tutorials









HTML Form Attribute

The form attribute specifies the form the element belongs to. The value of this attribute must be equal to the id attribute of a <form> element in the same document.

Types of attributes:

  • Action
  • method
  • Target
  • autocomplete
  • nonvalidate

The action Attribute

The action attribute defines the action to be performed when the form is submitted. Usually, the form data is sent to a file on the server when the user clicks on the submit button.


<form action="index_page.php">
    <label> name </label>
    <input type="text">
    <label> city </label>
    <input type="text">
    <input type="button" value="submit">
</form >

The Method Attribute

The method attribute specifies the HTTP method to be used when submitting the form data.

There are 2 types of method attributes

  1. method="GET"

  2. <form action="index_page.php" method="GET"> </form >

  3. method="POST"

  4. <form action="index_page.php" method="POST"> </form >


The target Attribute

The target attribute specifies where to display the response that is received after submitting the form.

Target attribute values:

  1. _blank A new window or tab.
  2. _self Current window.
  3. _parent A parent frame.
  4. _top full body of the window.
  5. framename A named Iframe.

_self target example

<form action="index_page.php" target="_self"> </form >

The autocomplete Attribute

The autocomplete attribute specifies wheather a form and input field should have autocomplete or not.

when autocomplete is on browser automatically complete the input field as user entered before.


<form action="index_page.php" autocomplete="on"> </form >

The nonvalidate Attribute

The nonvalidate attribute specifies that the submitted form data should not be valid when submitted.

This is a boolean atribute.


<form action="index_page.php" nonvalidate> </form >


Conclusion

In this page (written and validated by ) you learned about HTML Form Attributes . What's Next? If you are interested in completing HTML tutorial, your next topic will be learning about: HTML Form Elements.



Incorrect info or code snippet? We take very seriously the accuracy of the information provided on our website. We also make sure to test all snippets and examples provided for each section. If you find any incorrect information, please send us an email about the issue: mockstacks@gmail.com.


Share On:


Mockstacks was launched to help beginners learn programming languages; the site is optimized with no Ads as, Ads might slow down the performance. We also don't track any personal information; we also don't collect any kind of data unless the user provided us a corrected information. Almost all examples have been tested. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. By using Mockstacks.com, you agree to have read and accepted our terms of use, cookies and privacy policy.