cartoon: 2 people wearing MAGA hats,one says 'I hate thinking', other says 'me too!'.

Unlike hidden text content in the DOM which does provide an accessible name via aria-labelledby, hidden CSS ::before/::after text content does not.

Important Note!

I made the mistake of only checking in my browser of choice (Firefox). In Chrome and Edge the situation is worse. Neither provide an accessible name for a control where the aria-labelledby references an element that has visible CSS ::before text content. And in fact, unlike Firefox, the presence of the aria-labelledby pointing to an empty element results in the child text of the control being ignored as source of the accessible name.

In summary: Don't

See the Pen css content as label test by steve faulkner (@stevef) on CodePen.