Can you add a class to a 'label' tag?

Jake Scervino picture Jake Scervino · Feb 21, 2017 · Viewed 17.2k times · Source

This is probably a stupid question but I was just wondering if it's possible add a class to a 'label' tag instead of having to wrap it in a 'span' tag to style it. I'm reading "CSS: The Missing Manual" and it's telling me that in order to style a bunch of label tags, I should wrap each one I wanted to style with a 'span' tag.

<label class="name">Name:</label>

Answer

Ronald picture Ronald · Feb 21, 2017

Yes. The label tag supports all the global attributes specified in the HTML Attribute Reference.

https://www.tutorialspoint.com/html/html_label_tag.htm

Global attributes list: https://www.tutorialspoint.com/html/html_attributes_reference.htm