html fieldset标签

<form>
	<fieldset>
	<legend>Contact</legend>
	<label for='fullname'>Name </label>
	<input id="fullname" name="fullname" /type="text"/>
	<input name="contactForm" type="submit"  value="submit"/>
	</fieldset>
</form>
	

  定义和用法

fieldset 元素可将表单内的相关元素分组。

<fieldset> 标签将表单内容的一部分打包,生成一组相关表单的字段。

当一组表单元素放到 <fieldset> 标签内时,浏览器会以特殊方式来显示它们,它们可能有特殊的边界、3D 效果,或者甚至可创建一个子表单来处理这些元素。

<fieldset> 标签没有必需的或唯一的属性。

<legend> 标签为 fieldset 元素定义标题。

    The for attribute in the <label> tag links to the <input> tag’s id. The name attribute on the
<input> tag is the name that is used to identify the data. The for, name, and id attributes are often
the same, but only the for and the id need to match.

for属性链接到input的id,不会name属性链接

看这段代码很清楚:

<fieldset>
<legend>what is your gender? </legend>
<input type="radio" id="genderf" name="gender" value="f" checked="checked"/>
<label for="genderf">Female</label>
<input type="radio" id="genderm" name="gender" value="m"/>
<label for="genderm">Male</label>
</fieldset>
The name attribute matches for each of the radio buttons name相同,
This groups the radio buttons together so only one value is sent for the group. The value attribute is the value that is submitted, not what is inthe label. Because you cannot have duplicate id attributes, this is one place where your for and id

attributes do not match your name attribute.


    The <input> tag of type=”submit” is the Submit button. When the user clicks that button, the form

is submitted for processing. This is often used to identify the form. The data is named by the name
attribute and the value is from the value attribute, which is also what is displayed on the button.

     Use the <input> tag to create the submit buttons in forms. <input  type=”submit”> automatically submits the form. <input type=”button”> does  not automatically submit the form. You need to use JavaScript to submit it.
If you use the <button> tag instead of the <input> tag, be aware that Internet Explorer passes the information between the button tags and all the other   browsers use the value.



原文地址:https://www.cnblogs.com/youxin/p/2329412.html