Can I add a custom attribute to an HTML tag?
You can add custom attributes to your elements at will. But that will make your document invalid. In HTML 5 you will have the opportunity to use custom data attributes prefixed with data-.
You can add custom attributes to your elements at will. But that will make your document invalid. In HTML 5 you will have the opportunity to use custom data attributes prefixed with data-.
HTML 5 explicitly allows custom attributes that begin with data. So, for example, <p data-date-changed=”Jan 24 5:23 p.m.”>Hello</p> is valid. Since it’s officially supported by a standard, I think this is the best option for custom attributes. And it doesn’t require you to overload other attributes with hacks, so your HTML can stay semantic. Source: … Read more