Alright, I know how the fieldset
/legend
works out in HTML. Say you have a form with some fields:
<form>
<fieldset>
<legend>legend</legend>
<input name="input1" />
</fieldset>
</form>
What should I use the legend
for? It's being displayed as a title, but isn't a legend semantically an explanation of the contents? In my view, preferably you'd do something like this:
<form>
<fieldset>
<legend>* = required</legend>
<label for="input1">input 1 *</label><input id="input1" name="input1" />
</fieldset>
</form>
But that doesn't really work out with how fieldsets are rendered. Is this just a ambigious naming in HTML, or is it my misunderstanding of the English word 'legend'?
Edit: fixed some errors ;-)
Yes, the naming is ambiguous. It’s best to consider it as a caption for the fieldset.
See the HTML spec on FIELDSET
and LEGEND
elements if you haven’t already:
The
LEGEND
element allows authors to assign a caption to aFIELDSET
. The legend improves accessibility when theFIELDSET
is rendered non-visually.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With