IDREF attributes are fragile and painful to use #2
Labels
Area: HTML
Issue: a11y
This gap creates a11y issues.
Issue: ergonomics
This is a web platform usability issue
TAG consensus: ❓Unknown
The issue has been filed but not yet discussed in a meeting.
(An earlier version of this was posted in whatwg/html#10143)
Pain points
Many HTML attributes need to reference one or more HTML elements in the document. This includes:
for
, in<label>
and<output>
list
in<input>
aria-describedby
,aria-labelledby
,aria-activedescendant
,aria-controls
,aria-details
,aria-flowto
,aria-owns
etc.)popovertarget
)invoketarget
)anchor
attributeCurrently, the only way to specify such references is to give these elements ids (if they don't already have them) and use these ids to link to them in these attributes.
This is problematic in several ways:
This is a very common author pain point around ARIA, and authors are pretty vocal about it: DX-related complaints were the 3rd biggest a11y complaint in the preliminary State of HTML results. It especially hurts a11y, since the effects of broken references in the a11y tree are not always obvious, and the more effort it takes to make HTML accessible, the less likely authors are to do it. While for
<label>
this is somewhat mitigated by the option to make the association implicitly by nesting the form control within the<label>
, for the other cases there is no similar option. New features like popovers, invokers, or theanchor
attribute exacerbate the problem further.The IDL attributes for these are also inconsistent:
element.htmlFor
returns a string, corresponding to the textual value of thefor
attribute. The actual element can be accessed viaelement.control
.element.list
returns the actual<datalist>
element linked. The string value is only accessible viagetAttribute()
.popoverTargetElement
returns the elementpopovertarget
corresponds to. The string value is only accessible viagetAttribute()
.ariaDescribedByElements
returns the elementsaria-describedby
corresponds to (and similar for other ARIA attributes). The string value is only accessible viagetAttribute()
.Potential solutions
part
.Some considerations are:
list
need both (e.g. a "country" field would need to autocomplete to the same list of countries everywhere).The text was updated successfully, but these errors were encountered: