HTML(XHTML)基础知识(六)——【form】

<form>

<form>
  <p><label for="email">Enter you E-mail address to subscribe to our mailing list.</label></p>
  <p><input type="text" name="email" id="email" /><input type="submit" name="subscribe" value="subscribe" /></p>
</form>

    form 元素为块级元素,其中只允许直接包含块级元素。    

    必需属性:action,指定表单处理器的 URL,即数据提交到哪里。

    可选属性:accept,使用表单上传文件时可接受的文件类型;accept-charset,通过表单提交的数据使用的字符编码;enctype,指定用于递交表单的内容类型,默认为application/x-www-form-urlencoded,如果上传的数据为文件,则为 multipart/form-data;method,提交表单时使用的 http 方法,默认为 get。

    标准属性:class、dir、id、lang、name、style、title、xml:lang

    <input>

        input 的类型可以为 text、password、checkbox、radio、file、submit、reset、button、image、hidden

        必需属性:name,用于标识控件,在表单被提交时与控件值组成 KV 对。

        可选属性:alt,type 为 image 时设置的替代图片的文字;accept,使用表单上传文件时可接受的文件类型;accesskey,快捷的键盘访问方式;checked="checked",type 为 CheckBox 或 radio 时表示是否选中;disabled=“disabled”,是否禁用,被禁用的控件的值不会被提交;ismap="ismap",type 为 image 时声明是否为服务端图像映射;maxlength,type 为 text 或 password 时输入框中允许输入的最大字符个数;readonly="readonly",是否只读,只读的控件可以获得焦点,其值也将被提交;size,type 为 text 或 password 时控件的尺寸(单个字符宽度×字符个数);src,type 为 image 时指示图像文件的来源;tabindex;type,默认为text;usemap,type 为 image 时指定客户端图像映射的 URL;value,控件的值。

        标准属性:class、dir、id、lang、name、style、title、xml:lang

    <button>

    <select>、<option>、<optgroup>    

    <textarea>

组织表单

    <fieldset>、<legend>

    <label>

CSS 控制表单样式

/* 左侧右对齐显示 */
label {
float: left;
 200px;
text-align: right;
margin-right: 15px;
}
/* 单独一行显示 */
label {
display: block;
}
原文地址:https://www.cnblogs.com/shilxfly/p/9436962.html