johnbillion / query-monitor

The developer tools panel for WordPress
https://querymonitor.com
GNU General Public License v2.0
1.6k stars 211 forks source link

Change orphaned label to a span #731

Closed joedolson closed 1 year ago

joedolson commented 1 year ago

Label element has no meaning without being associated with a form field. Buttons are self-labeling through their internal content or aria-label, and don't need a label associated.

lkraav commented 1 year ago

Label element has no meaning without being associated with a form field.

I've found nothing inherently wrong with using <label> outside of form context. It certainly clarifies intent much cleaner than random descendant inventions like <span class="label">.

Buttons are self-labeling through their internal content or aria-label, and don't need a label associated.

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label#interactive_content also recommends against placing interactive content inside <label>.

joedolson commented 1 year ago

Using label outside of a form context doesn't have any real impact on real-world usage, either positive or negative. It doesn't clarify intent in any meaningful way, because its semantics are connective (binding fields to name). In this usage, where the sole usage of the container is in providing a CSS hook, there's no benefit to using label.

johnbillion commented 1 year ago

The original intention of this label was that the whole column header should be clickable to sort it, but that's handled by the JavaScript handler for the header cell, so we're all good.

johnbillion commented 1 year ago

Thanks for the PRs @joedolson! 👍