Etiqueta HTML <fieldset>
Ejemplo
Elementos relacionados con el grupo en una forma:
<form action="/action_page.html">
<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>
Try it Yourself »
Más ejemplos de "Try it Yourself" ("Pruébalo tú mismo") a continuación.
Definición y uso
La etiqueta <fieldset>
se utiliza para agrupar elementos relacionados en un formulario.
La etiqueta <fieldset>
dibuja un cuadro alrededor de los elementos relacionados.
Consejos y notas
Consejo: La etiqueta <legend> se utiliza para definir un título para el elemento <fieldset>
.
Soporte del navegador
Elemento | |||||
---|---|---|---|---|---|
<fieldset> | Sí | Sí | Sí | Sí | Sí |
Atributos
Atributo | Valor | Descripción |
---|---|---|
disabled | disabled | Especificar que un grupo de elementos de formulario relacionados debe deshabilitarse |
form | form_id | Especifica a qué forma pertenece el FieldSet |
name | text | Especifique un nombre para el fieldset |
Atributos globales
La etiqueta <fieldset>
también admite los Atributos globales en HTML.
Atributos del evento
La etiqueta <fieldset>
también admite los Atributos de evento en HTML.
Más ejemplos
Ejemplo
Utilice CSS para diseñar <fieldset> y <legend>:
<html>
<head>
<style>
fieldset {
background-color: #eee;
}
legend {
background-color: gray;
color: white;
padding: 5px 10px;
}
input {
margin: 5px;
}
</style>
</head>
<body>
<form action="/action_page.html">
<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>
Try it Yourself »
Páginas relacionadas
HTML DOM referencia: Fieldset Objeto.
Configuración CSS predeterminada
La mayoría de los navegadores mostrarán el elemento <fieldset>
con los siguientes valores predeterminados:
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);
}