Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does HTML5 require an action attribute for forms? [duplicate]

I've just run a webpage of mine through the W3C HTML5 validator, and it validates completely, even though the form in it doesn't have an action attribute, which the HTML 4 validator always complains about. Considering the fact that the HTML5 validator is still experimental, is the fact that the form validating despite not having an action attribute a problem with the validator, or has the HTML5 spec changed to not require that attribute any more?

like image 687
asdfasdf Avatar asked Aug 13 '11 05:08

asdfasdf


People also ask

Does HTML form require action?

Yes, the form is required to have an action attribute in HTML4. If it's not set, the browser will likely use the same method as providing an empty string to it. You really should set action="" which is perfectly valid HTML4, follows standards, and achieves the same exact result.

What does action attribute do in HTML form?

The HTML | action Attribute is used to specify where the formdata is to be sent to the server after submission of the form. It can be used in the <form> element. Attribute Values: URL: It is used to specify the URL of the document where the data to be sent after the submission of the form.

What does an action attribute of form take as a value?

The action attribute is used to specify where we want to send the form data when the form is submitted. So the value of the action is the page that will process the form.

What is the purpose of form action?

The HTML form action attribute defines where to send the form data when a form is submitted in an HTML document.


1 Answers

According to the specification action is not mandatory:

The action and formaction content attributes, if specified, must have a value that is a valid non-empty URL potentially surrounded by spaces.

Although, section 4.10.1.3 Configuring a form to communicate with a server states that:

You also have to specify the URL of the service that will handle the submitted data, using the action attribute.

So, the specification says that if you want your form to communicate with a server it shall provide the action attribute. Which, in my opinion, is not the only truth as you can specify actions on buttons as well.

EDIT: I must admit that I can't finally answer your question with Yes or No...

like image 59
home Avatar answered Oct 21 '22 03:10

home