-
Notifications
You must be signed in to change notification settings - Fork 8k
/
index.md
389 lines (333 loc) · 11.6 KB
/
index.md
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
---
title: <fieldset>
slug: Web/HTML/Element/fieldset
---
{{HTMLSidebar}}
O **elemento HTML `<fieldset>`** é usado para agrupar elementos, assim como labels ({{HTMLElement("label")}}), dentro de um formulário web.
<table class="properties">
<tbody>
<tr>
<th scope="row">
<a href="/pt-BR/docs/HTML/Content_categories">Categorias de Conteúdo</a>
</th>
<td>
<a href="/pt-BR/docs/HTML/Content_categories#Flow_content"
>Conteúdo de fluxo</a
>,
<a
href="/pt-BR/docs/Sections_and_Outlines_of_an_HTML5_document#sectioning_root"
>sectioning root</a
>, <a href="/pt-BR/docs/HTML/Content_categories#form_listed">listed</a>,
<a href="/pt-BR/docs/HTML/Content_categories#form-associated_content"
>form-associated</a
>
element, palpable content.
</td>
</tr>
<tr>
<th scope="row">Conteúdo permitido</th>
<td>
Um elemento {{HTMLElement("legend")}} opcional, seguido por
conteúdo de fluxo.
</td>
</tr>
<tr>
<th scope="row">Omissão deTag</th>
<td>{{no_tag_omission}}</td>
</tr>
<tr>
<th scope="row">Elementos pai permitidos</th>
<td>
Qualquer elemento que aceita
<a href="/pt-BR/docs/HTML/Content_categories#Flow_content"
>conteúdo de fluxo</a
>.
</td>
</tr>
<tr>
<th scope="row">Interface DOM</th>
<td>{{domxref("HTMLFieldSetElement")}}</td>
</tr>
</tbody>
</table>
> **Note:** diferente de quase todo outro elemento, a especificação do WHATWG HTML Rendering sugere `{{cssxref("min-width")}}: min-content` como parte do padrão de estilo para {{HTMLElement("fieldset")}}, e muitos navegadores implementam tal estilização (ou algo que se aproxima disto).
## Atributos
Este elemento inclui os [atributos globais](/pt-BR/docs/HTML/Global_attributes).
- `disabled`
- : Se este atributo Booleano está definido, os controles de formulario que são seus descendentes, exceto os descendentes de seu primeiro elemento opcional {{HTMLElement("legend")}}, estarão desativados, i.e., não editável. Eles não receberão qualquer evento de navegação, como clique do mouse ou relacionado com focus. Frequentemente os navegadores mostram tais controles em cinza.
- `form`
- : Este atributo tem o valor do atributo **id** do elemento {{HTMLElement("form")}} com que se relaciona. Seu valor padrão é o **id** do elemento {{HTMLElement("form")}} mais próximo.
- `name`
- : O nome associado com o grupo.
> **Note:** O label para o fieldset é dado pelo primeiro elemento {{HTMLElement("legend")}} que é um filho do fieldset.
## Exemplos
### Example #1: Formulário com fieldset, legend, e label
```html
<form action="test.php" method="post">
<fieldset>
<legend>Title</legend>
<input type="radio" id="radio" /> <label for="radio">Click me</label>
</fieldset>
</form>
```
### Example #2: Simulando um editável {{HTMLElement("select")}} através de um `fieldset` de [radioboxes](/pt-BR/docs/HTML/Element/Input) e [textboxes](/pt-BR/docs/HTML/Element/Input)\*
O exemplo a seguinte é feito de puro HTML e CSS. Não contém javascript.
**Esteja avisado** que leitores de tela (utilizados por cegos) e dispositivos de assistência não interpretarão o seguinte formulário corretamente; este exemplo seria um html invalido se os corretos elementos fossem usados.
```html
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Editable [pseudo]select</title>
<style type="text/css">
/* Generic form fields */
fieldset.elist,
input[type="text"],
textarea,
select,
option,
fieldset.elist ul,
fieldset.elist > legend,
fieldset.elist input[type="text"],
fieldset.elist > legend:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
input[type="text"] {
padding: 0 20px;
}
textarea {
width: 500px;
height: 200px;
padding: 20px;
}
textarea,
input[type="text"],
fieldset.elist ul,
select,
fieldset.elist > legend {
border: 2px #cccccc solid;
border-radius: 10px;
}
input[type="text"],
fieldset.elist,
select,
fieldset.elist > legend {
height: 32px;
font-family: Tahoma;
font-size: 14px;
}
input[type="text"]:hover,
textarea:hover,
select:hover,
fieldset.elist:hover > legend {
background-color: #ddddff;
}
select {
padding: 4px 20px;
}
option {
height: 30px;
padding: 5px 4px;
}
option:not(:checked),
textarea:focus {
background-color: #ffcccc;
}
fieldset.elist > legend:after,
fieldset.elist label {
height: 28px;
}
input[type="text"],
fieldset.elist {
width: 316px;
}
input[type="text"]:focus {
background: #ffcccc
url("data:image/gif;base64,R0lGODlhEAAQANU5APnoxuvr6+uxPdvb2+rq6ri4uO7qxunp6dPT06SHV+/rx8vLy+nezLO0sbe3t9Ksas+qaaCEV8rKyp2dnf39/QAAAK6ursifZHFxcc/Qzu3mxYyMjExCJnV1dc6maO7u7o+Pj2tXNoaGhtfDpKCDVu3lxM+tcaKEV9bW1qOFVWNjY8KrisTExNra2nBbObGxsby8vO/mu7Kyso9ZAuzs7MSgAIiKhf///8zMzP///wAAAAAAAAAAAAAAAAAAAAAAACH5BAEAADkALAAAAAAQABAAAAaXwJxwSCwOYzWkMpkkZmoAqDQaJdpqAqw2m53NRjlboAarFczomcE0C99o8DgNMVM8Tm3bbYDr9x11DwkzDG5yc2oQJIRCenx/MxoeETM2Q3pxATMlF4MYlo17OAsdLispMyAioIY0BzMcITMTKBasjgssFTMqGxItMjYUoTQBBAQHxgE0wZcfMtDRMi/QrA022NnaNg1CQQA7")
no-repeat 2px center !important;
}
input[type="text"]:focus,
textarea:focus,
select:focus,
fieldset.elist > legend {
border: 2px #ccaaaa solid;
}
fieldset {
border: 2px #af3333 solid;
border-radius: 10px;
}
/* Editable [pseudo]select (i.e. fieldsets with [class=elist]) */
fieldset.elist {
display: inline-block;
position: relative;
vertical-align: middle;
overflow: visible;
padding: 0;
margin: 0;
border: none;
}
fieldset.elist ul {
position: absolute;
width: 100%;
max-height: 320px;
padding: 0;
margin: 0;
overflow: hidden;
background-color: transparent;
}
fieldset.elist:hover ul {
background-color: #ffffff;
border: 2px #af3333 solid;
left: 2px;
overflow: auto;
}
fieldset.elist ul > li {
list-style-type: none;
background-color: transparent;
}
fieldset.elist label {
display: none;
width: 100%;
}
fieldset.elist input[type="text"] {
width: 100%;
height: 30px;
line-height: 30px;
border: none;
background-color: transparent;
border-radius: 0;
}
fieldset.elist > legend {
display: block;
margin: 0;
padding: 0 0 0 5px;
position: absolute;
width: 100%;
cursor: default;
background-color: #ccffcc;
line-height: 30px;
font-style: italic;
}
fieldset.elist:hover > legend {
position: relative;
overflow: hidden;
}
fieldset.elist > legend:after {
width: 20px;
content: "\2335";
float: right;
text-align: center;
border-left: 2px #cccccc solid;
font-style: normal;
cursor: default;
}
fieldset.elist:hover > legend:after {
background-color: #99ff99;
}
fieldset.elist ul input[type="radio"] {
display: none;
}
fieldset.elist input[type="radio"]:checked ~ label {
display: block;
width: 292px;
background-color: #ffffff;
}
fieldset.elist:hover input[type="radio"]:checked ~ label {
width: 100%;
}
fieldset.elist:hover label {
display: block;
height: 100%;
}
fieldset.elist label:hover {
background-color: #3333ff !important;
}
fieldset.elist:hover input[type="radio"]:checked ~ label {
background-color: #aaaaaa;
}
</style>
</head>
<body>
<form method="get" action="test.php">
<fieldset>
<legend>Order a T-Shirt</legend>
<p>Write your name (simple textbox): <input type="text" /></p>
<p>
Choose your size (simple select):
<select>
<option value="s">Small</option>
<option value="m">Medium</option>
<option value="l">Large</option>
<option value="xl">Extra Large</option>
</select>
</p>
<div>
What address do you want to use? (editable pseudoselect)
<fieldset class="elist">
<legend>Address…</legend>
<ul>
<li>
<input
type="radio"
value="1"
id="address-switch_1"
checked /><label for="address-switch_1"
><input
type="text"
value="19 Quaker Ridge Rd. Bethel CT 06801"
/></label>
</li>
<li>
<input type="radio" value="2" id="address-switch_2" /><label
for="address-switch_2"
><input
type="text"
value="1000 Coney Island Ave. Brooklyn NY 11230"
/></label>
</li>
<li>
<input type="radio" value="3" id="address-switch_3" /><label
for="address-switch_3"
><input
type="text"
value="2962 Dunedin Cv. Germantown TN 38138"
/></label>
</li>
<li>
<input type="radio" value="4" id="address-switch_4" /><label
for="address-switch_4"
><input
type="text"
value="915 E 7th St. Apt 6L. Brooklyn NY 11230"
/></label>
</li>
</ul>
</fieldset>
</div>
<p>
Write a comment:<br />
<textarea></textarea>
</p>
<p>
<input type="reset" value="Reset" />
<input type="submit" value="Send!" />
</p>
</fieldset>
</form>
</body>
</html>
```
[Veja este exemplo em ação](/files/4563/editable_select.html)
## Especificações
{{Specifications}}
## Compatibilidade com navegadores
{{Compat}}
## Erros
- [Erro do Firefox 504622](https://bugzil.la/504622) - Fieldsets nunca diminui abaixo de sua largura min-intrinsic
- [WebKit bug 123507](https://bugs.webkit.org/show_bug.cgi?id=123507) - `min-width: {{cssxref("-webkit-min-content")}}` sobre fieldset
- [StackOverflow discussão com soluções alternativas para os bugs acima](http://stackoverflow.com/questions/17408815/fieldset-resizes-wrong-appears-to-have-unremovable-min-width-min-content)
## Veja também
- Outros elementos de formlários relacionados: {{HTMLElement("form")}}, {{HTMLElement("legend")}}, {{HTMLElement("label")}}, {{HTMLElement("button")}}, {{HTMLElement("select")}}, {{HTMLElement("datalist")}}, {{HTMLElement("optgroup")}}, {{HTMLElement("option")}}, {{HTMLElement("textarea")}}, {{HTMLElement("input")}}, {{HTMLElement("output")}}, {{HTMLElement("progress")}} e {{HTMLElement("meter")}}.
- Artigo de como usar o fieldset para [ajudar na validação do seu formulário html](https://blog.alura.com.br/formulario-com-form-validation-do-html5/)