<fieldset> instead of <div>?

Can I use the <fieldset> element to group, align and style <form> elements in place of a <div>? Removing the default style (border) and not using <legend>?
7 Replies
ἔρως
ἔρως2y ago
not only you could, but you should it's a more semantic tag than a div however, if you don't want to use the legend tag, i would still use it, but make it only visible to screen readers by the way, fieldsets have a default border and other default styles, so, keep that in mind too
Chaves
ChavesOP2y ago
So if I use a <legend> and style it off-screen, I don't need to use an aria-label or aria-labelledby?
ἔρως
ἔρως2y ago
on the fieldset? i don't think so
Chaves
ChavesOP2y ago
Yes
ἔρως
ἔρως2y ago
but accessibility isn't my strongest suit
Chaves
ChavesOP2y ago
Ok
ἔρως
ἔρως2y ago
by the way, keep in mind that you can nest fieldsets and you can disable an entire fieldset instead of disabling individual fields

Did you find this page helpful?