fieldset 標簽 -- 對表單進行分組
在form表單中,我們可以對form中的信息進行分組歸類,如注冊表單的form,我們可以將注冊信息分組成
基本信息(一般為必填)
詳細信息(一般為可選)
那我們如何更好的來實現呢?我們可考慮在表單form中加入下面兩個標簽:
fieldset:對表單進行分組,一個表單可以有多個fieldset。
legend:說明每組的內容描述。
格式:
<fieldset>
<legend>health information</legend>
height: <input type="text"/>
weight: <input type="text"/>
</fieldset>
html:
<HTML>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<form action="http://www.dreamdu.com/dreamdu.php" method="post" enctype="multipart/form-data" id="dreamduform">
<fieldset>
<legend>用戶名與密碼:</legend>
<input name="hiddenField" type="hidden" value="hiddenvalue" />
<label for="username">用戶名:</label>
<input type="text" id="username" value="www.dreamdu.com" />
<label for="pass">密碼:</label>
<input type="password" id="pass" />
</fieldset>
<fieldset>
<legend>性別:</legend>
<label for="boy">男</label>
<input type="radio" value="1" id="sex" />
<label for="girl">女</label>
<input type="radio" value="2" id="sex" />
<label for="sex">保密</label>
<input type="radio" value="3" id="sex" />
</fieldset>
<fieldset>
<legend>我最喜愛的:</legend>
<label for="computer">計算機</label>
<input type="checkbox" value="1" id="fav" />
<label for="trval">旅游</label>
<input type="checkbox" value="2" id="fav" />
<label for="buy">購物</label>
<input type="checkbox" value="3" id="fav" />
</fieldset>
</form>
</body>
</HTML>
result:

html_1:
<fieldset style="width:300;height:150;border:1px dashed red" align="center">
<legend style="width:100px;border:1px dashed #ff9966;background-color:#ff0000;text-align:center;font-family:arial;font-weight:bold">
1234
</legend>
</fieldset>
result_1:

