Closed joedolson closed 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>
.
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.
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.
Thanks for the PRs @joedolson! 👍
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.