Reputation: 99
Is it legal to add data- attribute to the style tag in head?
I have found not much on the internet on using attributes with styles in head. I thought it is more for the body elements.
I am trying to be able to identify different style tags with data-style-id="randomid" for js/jquery easier usage.
Upvotes: 5
Views: 1602
Reputation: 224921
Yes, data-*
attributes are legal on all HTML elements. From the spec:
Every HTML element may have any number of custom data attributes specified, with any value.
As @Alohci notes, there are elements in HTML documents that aren’t HTML elements, though: SVG and MathML elements.
Upvotes: 5