1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
---
title: '<fieldset>: O elemento "Field Set"'
slug: Web/HTML/Elemento/fieldset
tags:
- Elemento
- Formulários HTML
- HTML
- Referencia
- Web
- formulários
translation_of: Web/HTML/Element/fieldset
---
<p>O <strong>elemento HTML <code><fieldset></code> </strong>é utilizado para agrupar vários controlos, bem como as etiquetas ({{HTMLElement("label")}}) dentro de um formulário da Web.</p>
<div>{{EmbedInteractiveExample("pages/tabbed/fieldset.html", "tabbed-standard")}}</div>
<p class="hidden">The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples </a> and send us a pull request.</p>
<p>As the example above shows, the <code><fieldset></code> element provides a grouping for a part of an HTML form, with a nested {{htmlelement("legend")}} element providing a caption for the <code><fieldset></code>. It takes few attributes, the most notable of which are <code>form</code>, which can contain the <code>id</code> of a {{htmlelement("form")}} on the same page, allowing you to make the <code><fieldset></code> part of that <code><form></code> even if it is not nested inside it, and <code>disabled</code>, which allows you to disable the <code><fieldset></code> and all its contents in one go.</p>
<h2 id="Atributos">Atributos</h2>
<p>This element includes the <a href="/en-US/docs/HTML/Global_attributes">global attributes</a>.</p>
<dl>
<dt>{{htmlattrdef("disabled")}} {{HTMLVersionInline(5)}}</dt>
<dd>If this Boolean attribute is set, all form controls that are descendants of the <code><fieldset></code>, are disabled, meaning they are not editable but will be submitted along with <code><form></code> in comparison with {{htmlattrdef("disabled")}} attribute on form controls. They won't receive any browsing events, like mouse clicks or focus-related events. By default browsers display such controls grayed out. Note that form elements inside the {{HTMLElement("legend")}} element won't be disabled.</dd>
<dt>{{htmlattrdef("form")}} {{HTMLVersionInline(5)}}</dt>
<dd>This attribute takes the value of the <code>id</code> attribute of a {{HTMLElement("form")}} element you want the <code><fieldset></code> to be part of, even if it is not inside the form.</dd>
<dt>{{htmlattrdef("name")}} {{HTMLVersionInline(5)}}</dt>
<dd>The name associated with the group.
<div class="note"><strong>Note</strong>: The caption for the fieldset is given by the first {{HTMLElement("legend")}} element nested inside it.</div>
</dd>
</dl>
<h2 id="Estilizar_com_CSS">Estilizar com CSS</h2>
<p>There are several special styling considerations for <code><fieldset></code>.</p>
<p>Its {{cssxref("display")}} value is <code>block</code> by default, and it establishes a block formatting context. If the <code><fieldset></code> is styled with an inline-level <code>display</code> value, it will behave as <code>inline-block</code>, otherwise it will behave as <code>block</code>. By default there is a 2px groove border surrounding the contents, and a small amount of default padding. The element has <code>min-inline-size: min-content</code> by default.</p>
<p>If a <code><legend></code> is present, it is placed over the block-start border. The <code><legend></code> shrink-wraps, and also establishes a formatting context. The <code>display</code> value is blockified (for example, <code>display: inline</code> behaves as <code>block</code>).</p>
<p>There will be an anonymous box holding the contents of the <code><fieldset></code>, which inherits certain properties from the <code><fieldset></code>. If the <code><fieldset></code> is styled with <code>display: grid</code> or <code>display: inline-grid</code>, then the anonymous box will be a grid formatting context. If the <code><fieldset></code> is styled with <code>display: flex</code> or <code>display: inline-flex</code>, then the anonymous box will be a flex formatting context. Otherwise it establishes a block formatting context.</p>
<p>You can feel free to style the <code><fieldset></code> and <code><legend></code> in any way you want to suit your page design.</p>
<div class="note">
<p><strong>Nota: </strong>as of this writing, there are bugs in Microsoft Edge and Google Chrome which prevent <a href="/en-US/docs/Glossary/Flexbox">flexbox</a> and <a href="/en-US/docs/Web/CSS/CSS_Grid_Layout">grid </a>layouts from being used inside a {{HTMLElement("fieldset")}}. <a href="https://github.com/w3c/csswg-drafts/issues/321">This GitHub issue</a> provides bug tracking links.</p>
</div>
<h2 id="Exemplo">Exemplo</h2>
<h3 id="Simple_fieldset">Simple fieldset</h3>
<p>This example shows a really simple <code><fieldset></code> example, with a <code><legend></code>, and a single control inside it.</p>
<pre class="brush: html"><form action="#">
<fieldset>
<legend>Simple fieldset</legend>
<input type="radio" id="radio">
<label for="radio">Spirit of radio</label>
</fieldset>
</form></pre>
<p>{{ EmbedLiveSample('Simple_fieldset', '100%', '80') }}</p>
<h3 id="fieldset_desativado">"fieldset" desativado</h3>
<p>This example shows a disabled <code><fieldset></code> with two controls inside it. Note how both the controls are disabled due to being inside a disabled <code><fieldset></code>.</p>
<pre class="brush: html"><form action="#">
<fieldset disabled>
<legend>Disabled fieldset</legend>
<div>
<label for="name">Name: </label>
<input type="text" id="name" value="Chris">
</div>
<div>
<label for="pwd">Archetype: </label>
<input type="password" id="pwd" value="Wookie">
</div>
</fieldset>
</form></pre>
<p>{{ EmbedLiveSample('Disabled_fieldset', '100%', '110') }}</p>
<h2 id="Resumo_técnico">Resumo técnico</h2>
<table class="properties">
<tbody>
<tr>
<th scope="row"><a href="/en-US/docs/HTML/Content_categories">Categorias de conteúdo</a></th>
<td><a href="/en-US/docs/HTML/Content_categories#Flow_content">Flow content</a>, <a href="/en-US/docs/Sections_and_Outlines_of_an_HTML5_document#sectioning_root">sectioning root</a>, <a href="/en-US/docs/HTML/Content_categories#form_listed">listed</a>, <a href="/en-US/docs/HTML/Content_categories#form-associated_content">form-associated</a> element, palpable content.</td>
</tr>
<tr>
<th scope="row">Conteúdo permitido</th>
<td>An optional {{HTMLElement("legend")}} element, followed by flow content.</td>
</tr>
<tr>
<th scope="row">Omissão de etiqueta</th>
<td>{{no_tag_omission}}</td>
</tr>
<tr>
<th scope="row">Permitted parents</th>
<td>Any element that accepts <a href="/en-US/docs/HTML/Content_categories#Flow_content">flow content</a>.</td>
</tr>
<tr>
<th scope="row">Permitted ARIA roles</th>
<td>{{ARIARole("group")}}, {{ARIARole("presentation")}}</td>
</tr>
<tr>
<th scope="row">Interface DOM</th>
<td>{{domxref("HTMLFieldSetElement")}}</td>
</tr>
</tbody>
</table>
<h2 id="Especificações">Especificações</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Especificação</th>
<th scope="col">Estado</th>
<th scope="col">Comentário</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName('HTML WHATWG', 'forms.html#the-fieldset-element', '<fieldset>')}}</td>
<td>{{Spec2('HTML WHATWG')}}</td>
<td>Definition of the <code>fieldset</code> element</td>
</tr>
<tr>
<td>{{SpecName('HTML5 W3C', 'forms.html#the-fieldset-element', '<fieldset>')}}</td>
<td>{{Spec2('HTML5 W3C')}}</td>
<td></td>
</tr>
<tr>
<td>{{SpecName('HTML4.01', 'interact/forms.html#h-17.10', '<fieldset>')}}</td>
<td>{{Spec2('HTML4.01')}}</td>
<td>Initial definition</td>
</tr>
</tbody>
</table>
<h2 id="Compatibilidade_de_navegador">Compatibilidade de navegador</h2>
<p>{{Compat("html.elements.fieldset")}}</p>
<h2 id="Consulte_também">Consulte também:</h2>
<ul>
<li>Other form-related elements:
<ul>
<li>{{HTMLElement("form")}}</li>
<li>{{HTMLElement("legend")}}</li>
<li>{{HTMLElement("label")}}</li>
<li>{{HTMLElement("button")}}</li>
<li>{{HTMLElement("select")}}</li>
<li>{{HTMLElement("datalist")}}</li>
<li>{{HTMLElement("optgroup")}}</li>
<li>{{HTMLElement("option")}}</li>
<li>{{HTMLElement("textarea")}}</li>
<li>{{HTMLElement("keygen")}}</li>
<li>{{HTMLElement("input")}}</li>
<li>{{HTMLElement("output")}}</li>
<li>{{HTMLElement("progress")}}</li>
<li>{{HTMLElement("meter")}}</li>
</ul>
</li>
</ul>
<div>{{HTMLRef}}</div>
|