How to indicate a class in HTML label tag

Solution 1:

HTML provides no means to associate a label with elements using a class.

A label is designed to label a single form control.

An ID identifies a single element.

A class groups multiple elements.

It makes sense for labels to use IDs for association, but it wouldn't make sense to use class for that.

If you want to group multiple form controls with a "label" then use a fieldset with a legend instead.

<fieldset>
    <legend>Name</legend>
    <input name="given-name" id="given-name"> <label for="given-name">Given name</label> 
    <br>
    <input name="family-name" id="family-name"> <label for="family-name">Family name</label> 
</fieldset>

(Although I use names for this example, it is a bit contrives and you should be aware of some of the issues programmers have dealing with names before doing anything involving them).