当前位置: 首页 > 网络学院 > 网页制作基础教程 > HTML > HTML <form>标签
The form element creates a form for user input. A form can contain textfields, checkboxes, radio-buttons and more. Forms are used to pass user-data to a specified URL.
form元素可建立针对用户输入的表单。表单中可以包含文字输入,复选框,单选按钮以及更多一些。表单可以将用户数据发送到指定的URL。
NONE
无
代码 | 输出 |
---|---|
<form action="form_action.asp" method="get"> First name: <input type="text" name="fname" value="Mickey" /> <br /> Last name: <input type="text" name="lname" value="Mouse" /> <br /> <input type="submit" value="Submit" /> </form> <p> If you click the "Submit" button, you will send your input to a new page called form_action.asp.<br /> 当你按了Submit,你会到达一个新的页面(form_action.asp),上面会有你输入的信息 </p> | If you click the "Submit" button, you will send your input to a new page called form_action.asp. |
DTD indicates in which DTD the attribute is allowed. S=Strict, T=Transitional, and F=Frameset.
下表中的DTD列指明了被支持的DTD属性。S=Strict(精确的),T=Transitional(传统的),F=Frameset(框架)
属性 | Value | 描述 | DTD |
---|---|---|---|
action | URL | A URL that defines where to send the data when the submit button is pushed 定义当按下提交后将信息数据发送到的页面URL | STF |
属性 | Value | 描述 | DTD |
---|---|---|---|
accept | list of contenttypes | A comma separated list of content types that the server that processes this form will handle correctly 用逗号分隔内容类型以便服务器能更准确的处理表单 | STF |
accept-charset | charset_list | A comma separated list of possible character sets for the form data. The default value is "unknown" 用逗号分隔表单数据中可能出现的字符类型。默认的值为"未知" | STF |
enctype | mimetype | The mime type used to encode the content of the form 使用mime类型可以将表单内容进行加密。 | STF |
method | get post | The HTTP method for sending data to the action URL. Default is get. HTTP发送数据的方式。默认为get method="get": This method sends the form contents in the URL: method="post": This method sends the form contents in the body of the request. Note: Most browsers are unable to bookmark post requests. | STF |
name | form_name | Defines a unique name for the form 给表单定义唯一的name | TF |
target | _blank _self _parent _top | Where to open the target URL.
| TF |
id, class, title, style, dir, lang, xml:lang |
For a full description, go to Standard Attributes.
查看完整的属性
onsubmit, onreset, onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup |
For a full description, go to Event Attributes.
查看完整的属性
Form with input fields and a submit button
How to add a form to a page. The form contains two input fields and a submit button.
如何为页面加入表单。表单包含两个输入框和一个提交按钮
Form with checkboxes
This form contains two checkboxes, and a submit button.
包含两个复选框以及一个提交按钮的表单
Form with radiobuttons
This form contains two radio buttons, and a submit button.
包含两个单选按钮以及一个提交按钮的表单
Send e-mail from a form
How to send e-mail from a form.
用表单发送电子邮件