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

1

8

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?

Ahmedahmedabad answered 13/8, 2011 at 5:44 Comment(0)
G
14

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...

Grown answered 13/8, 2011 at 5:52 Comment(2)
You are correct. The action attribute is not mandatory. Note that the section 4.10.1.3 is marked non-normative, that is, the text is guidance, and does not itself impose any requirements. So your first quote is the relevant one. Good answer. +1Osher
Is 'specifiction' a deliberate misspelling? ;)Chloromycetin

© 2022 - 2024 — McMap. All rights reserved.