Opened 43 hours ago
Last modified 31 hours ago
#36828 assigned Bug
Django form fields render into invalid HTML — at Initial Version
| Reported by: | Johannes Maron | Owned by: | |
|---|---|---|---|
| Component: | Forms | Version: | dev |
| Severity: | Normal | Keywords: | accessibility |
| Cc: | Johannes Maron, Antoliny | Triage Stage: | Unreviewed |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Howdy,
Django 6 introduced unannounced changes to the default form rendering. Forms render with a fieldset, not a label, by default now.
I just noticed that fields render a for-attribute into a legend-tag. This isn't valid HTML5 according to spec: https://html.spec.whatwg.org/#the-legend-element
Furthermore, the use of a fieldset/legend replaces the label-tag. However, input labels are required as of WCAG 2.1.
Since Django must be WCAG2.2 AAA compliant, we might even want to patch all supported versions.
This bug was introduced only in Django 6.0, which is wild, since the release notes don't even mention any rendering changes. After some research, the change was introduced in #35892. I will open a separate issue about the missing release documentation and breaking change.
Cheers!
Joe