Znacznik HTML <zestaw pól>
Przykład
Pogrupuj powiązane elementy w formie:
<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>
Więcej przykładów „Wypróbuj sam” poniżej.
Definicja i użycie
Tag <fieldset>
służy do grupowania powiązanych elementów w formularzu.
Znacznik <fieldset>
rysuje ramkę wokół powiązanych elementów.
Wskazówki i uwagi
Wskazówka: znacznik <legend> służy do definiowania podpisu
<fieldset>
elementu.
Obsługa przeglądarki
Element | |||||
---|---|---|---|---|---|
<fieldset> | Yes | Yes | Yes | Yes | Yes |
Atrybuty
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 |
Atrybuty globalne
Znacznik <fieldset>
obsługuje również atrybuty globalne w HTML .
Atrybuty wydarzenia
Tag <fieldset>
obsługuje również Atrybuty Zdarzeń w HTML .
Więcej przykładów
Przykład
Użyj CSS do stylizacji <fieldset> i <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>
Powiązane strony
Dokumentacja HTML DOM: obiekt Fieldset
Domyślne ustawienia CSS
Większość przeglądarek wyświetla <fieldset>
element z następującymi wartościami domyślnymi:
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);
}