HTML <fieldset>แท็ก
ตัวอย่าง
จัดกลุ่มองค์ประกอบที่เกี่ยวข้องในรูปแบบ:
<form action="/action_page.php">
<fieldset>
<legend>Personalia:</legend>
<label for="fname">First
name:</label>
<input type="text" id="fname" name="fname"><br><br>
<label for="lname">Last name:</label>
<input
type="text" id="lname" name="lname"><br><br>
<label
for="email">Email:</label>
<input type="email"
id="email" name="email"><br><br>
<label
for="birthday">Birthday:</label>
<input type="date"
id="birthday" name="birthday"><br><br>
<input
type="submit" value="Submit">
</fieldset>
</form>
ตัวอย่าง "ลองใช้เอง" เพิ่มเติมด้านล่าง
ความหมายและการใช้งาน
แท็ ก<fieldset>
ใช้เพื่อจัดกลุ่มองค์ประกอบที่เกี่ยวข้องในแบบฟอร์ม
แท็ ก<fieldset>
จะวาดกล่องรอบๆ องค์ประกอบที่เกี่ยวข้อง
เคล็ดลับและหมายเหตุ
เคล็ดลับ: แท็ ก<legend>ใช้เพื่อกำหนดคำอธิบายสำหรับ
<fieldset>
องค์ประกอบ
รองรับเบราว์เซอร์
Element | |||||
---|---|---|---|---|---|
<fieldset> | Yes | Yes | Yes | Yes | Yes |
คุณลักษณะ
Attribute | Value | Description |
---|---|---|
disabled | disabled | Specifies that a group of related form elements should be disabled |
form | form_id | Specifies which form the fieldset belongs to |
name | text | Specifies a name for the fieldset |
คุณสมบัติสากล
แท็ ก<fieldset>
ยังสนับสนุน Global Attributes ในHTML
คุณสมบัติของเหตุการณ์
แท็ ก<fieldset>
ยังสนับสนุนแอตทริบิวต์เหตุการณ์ใน HTML
ตัวอย่างเพิ่มเติม
ตัวอย่าง
ใช้ CSS เพื่อจัดรูปแบบ <fieldset> และ <legend>:
<html>
<head>
<style>
fieldset {
background-color: #eeeeee;
}
legend {
background-color: gray;
color: white;
padding: 5px 10px;
}
input {
margin: 5px;
}
</style>
</head>
<body>
<form action="/action_page.php">
<fieldset>
<legend>Personalia:</legend>
<label for="fname">First
name:</label>
<input type="text" id="fname" name="fname"><br><br>
<label for="lname">Last name:</label>
<input
type="text" id="lname" name="lname"><br><br>
<label
for="email">Email:</label>
<input type="email"
id="email" name="email"><br><br>
<label
for="birthday">Birthday:</label>
<input type="date"
id="birthday" name="birthday"><br><br>
<input
type="submit" value="Submit">
</fieldset>
</form>
</body>
</html>
หน้าที่เกี่ยวข้อง
การอ้างอิง HTML DOM: Fieldset Object
การตั้งค่า CSS เริ่มต้น
เบราว์เซอร์ส่วนใหญ่จะแสดง<fieldset>
องค์ประกอบด้วยค่าเริ่มต้นดังต่อไปนี้:
fieldset {
display: block;
margin-left: 2px;
margin-right: 2px;
padding-top: 0.35em;
padding-bottom: 0.625em;
padding-left: 0.75em;
padding-right: 0.75em;
border: 2px groove (internal value);
}