Looks like that message comes from AChecker. (Sometimes it helps to tell people what accessibility tool you're using.)
The error is not complaining that the <label> is not associated with the <input>. Your code structure is using an implicit label by embedding the <input> inside the <label>, which is valid (see "The label element" spec).
The label element represents a caption in a user interface. The caption can be associated with a specific form control, known as the label element’s labeled control, either using the for attribute, or by putting the form control inside the label element itself.
Now, having said that, there used to be (and there might still be) some combination of screen reader and browser that would not honor the implicit label and required you to specify the for
attribute on the <label>, but an accessibility checker tool should not flag that as an error. It could flag it as an issue to manually check but it's not an error.
Anyway, back to the original question. Error 188 says that the label itself does not have any text. You have a class="screen-reader-text"
on a <span> which is the only source of text inside the label. If that class has a display:none
or visibility:hidden
, then that might cause the error because the text would be hidden to all users. However, if your screen-reader-text
class just visually hides the text (similar to What is sr-only in Bootstrap 3?), then the text would be available to screen readers but might be invisible to sighted users. I'm not sure if that would cause AChecker to flag it in error.