<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
ἔρως
ἔρως14mo 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
ChavesOP14mo ago
So if I use a <legend> and style it off-screen, I don't need to use an aria-label or aria-labelledby?
ἔρως
ἔρως14mo ago
on the fieldset? i don't think so
Chaves
ChavesOP14mo ago
Yes
ἔρως
ἔρως14mo ago
but accessibility isn't my strongest suit
Chaves
ChavesOP14mo ago
Ok
ἔρως
ἔρως14mo ago
by the way, keep in mind that you can nest fieldsets and you can disable an entire fieldset instead of disabling individual fields
Want results from more Discord servers?
Add your server