Latest web development tutorials

HTML form action attribute

Tag Reference HTML form HTML <form> tag

Examples

When submitting a form, send the form data to a file named "demo_form.html" file (process input):

<form action="demo_form.html" method="get">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="submit" value="提交">
</form>

try it"

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the action attribute.


Definition and Usage

Attribute specifies the action when the form is submitted, where to send the form data.


Differences between HTML 4.01 and HTML5

In HTML5, action property is no longer necessary.


grammar

<form action="URL">

Property Value

描述
URL 当表单提交时向何处发送表单数据。

可能的值:

  • 绝对 URL - 指向另一个网站(比如 action="http://www.example.com/example.htm")
  • 相对 URL - 指向网站内的一个文件(比如 action="example.htm")


Tag Reference HTML form HTML <form> tag