

#
“form”属性について
“form”属性は“form”要素の外にある“fieldset”要素を“form”要素と関連付ける属性です。
“form”属性の値には“fieldset”要素を関連付ける“form”要素の“id”属性の値を指定します。同じ文書にある“form”要素であれば配置場所にかかわらず関連付けることができます。
“form”属性で“form”要素に関連付けられるのは“fieldset”要素のみです。“fieldset”要素の中にある入力欄やボタンなどを“form”要素に関連付けるにはそれぞれに“form”属性を指定する必要があります。
“form”属性を省略した場合は“fieldset”要素は祖先要素となる“form”要素に関連づけられます。
#
#
サンプルコード
<fieldset form="sample-form">
<legend>猫は好きですか?</legend>
<p><label><input type="checkbox" name="cat" value="Yes" required form="sample-form">好き</label></p>
</fieldset>
...
<form method="post" action="sample-inputtag7.php" id="sample-form" target="_blank">
<fieldset>
<legend>好きな果物</legend>
<p>
<label><input type="radio" name="fruit" value="甘蕉">甘蕉</label>
<label><input type="radio" name="fruit" value="林檎">林檎</label>
<label><input type="radio" name="fruit" value="甜瓜">甜瓜</label>
<label><input type="radio" name="fruit" value="苺">苺</label>
<label><input type="radio" name="fruit" value="桃">桃</label>
</p>
</fieldset>
<fieldset>
<legend>好きな果物</legend>
<p>
<label><input type="radio" name="vege" value="南瓜">南瓜</label>
<label><input type="radio" name="vege" value="甘藍">甘藍</label>
<label><input type="radio" name="vege" value="甘藷">甘藷</label>
<label><input type="radio" name="vege" value="西瓜">西瓜</label>
<label><input type="radio" name="vege" value="茄子">茄子</label>
</p>
</fieldset>
<p><input type="submit" value="送信する"></p>
</form>
...
*送信すると入力内容が表示されます。