Opened 2 months ago

Last modified 2 months ago

#36828 assigned Cleanup/optimization

Django form fields render into invalid HTML — at Version 2

Reported by: Johannes Maron Owned by:
Component: Forms Version: 6.0
Severity: Normal Keywords: accessibility, label, wcag, fieldset
Cc: Johannes Maron, Antoliny Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Johannes Maron)

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. However, this would mean shippping a rendering change in a bugfix.

My current impulse would be to drop the for attribute in all supported versions for valid HTML and to enforce labels for WCAG compliance in 6.1

Cheers!
Joe

Change History (2)

comment:1 by Johannes Maron, 2 months ago

Keywords: accessibility added

comment:2 by Johannes Maron, 2 months ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top