html基础知识点--表单元素及其相关知识

本文详细介绍了HTML中的表单元素,包括form属性如action、method、enctype等,以及label元素的作用和关联方式。表单用于收集用户数据,通过不同的方法提交到服务器,并提供了与用户交互的控件如文本域、单选按钮、复选框等。通过label元素,可以为这些控件添加标注,提高用户体验和可访问性。
摘要由CSDN通过智能技术生成

表单元素

form

attribute definitions

action = uri [ct]

this attribute specifies a form processing agent. user agent behavior for a value other than an http uri is undefined.

method = get|post [ci]

this attribute specifies which http method will be used to submit the form data set. possible (case-insensitive) values are "get" (the default) and "post". see the section on form submission for usage information.

enctype = content-type [ci]

this attribute specifies the content type used to submit the form to the server (when the value of method is "post"). the default value for this attribute is "application/x-www-form-urlencoded". the value "multipart/form-data" should be used in combination with the input element, type="file".

accept-charset = charset list [ci]

this attribute specifies the list of character encodings for input data that is accepted by the server processing this form. the value is a space- and/or comma-delimited list of charset values. the client must interpret this list as an exclusive-or list, i.e., the server is able to accept any single character encoding per entity received.

the default value for this attribute is the reserved string "unknown". user agents may interpret this value as the character encoding that was used to transmit the document containing this form element.

 

accept = content-type-list [ci]

this attribute specifies a comma-separated list of content types that a server processing this form will handle correctly. user agents may use this information to filter out non-conforming files when prompting a user to select files to be sent to the server (cf. the input element when type="file").

name = cdata [ci]

this attribute names the element so that it may be referred to from style sheets or scripts. note. this attribute has been included for backwards compatibility. applications should use the id attribute to identify elements.

the form element acts as a container for controls. it specifies:

 

the layout of the form (given by the contents of the element).

the program that will handle the completed and submitted form (the action attribute). the receiving program must be able to parse name/value pairs in order to make use of them.

the method by which user data will be sent to the server (the method attribute).

a character encoding that must be accepted by the server in order to handle this form (the accept-charset attribute). user agents may advise the user of the value of the accept-charset attribute and/or restrict the user's ability to enter unrecognized characters.

a form can contain text and markup (paragraphs, lists, etc.) in addition to form controls.

 

the following example shows a form that is to be processed by the "adduser" program when submitted. the form will be sent to the program using the http "post" method.

 

 <form action="http://somesite.com/prog/adduser" method="post">

 ...f

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值