Can an HTML element have arbitrary attributes?

Yes, but they must be prefixed with data-.

A custom data attribute is an attribute in no namespace whose name starts with the string "data-", has at least one character after the hyphen, is XML-compatible, and contains no characters in the range U+0041 to U+005A (LATIN CAPITAL LETTER A to LATIN CAPITAL LETTER Z).

W3C HTML5 Spec: http://dev.w3.org/html5/spec/single-page.html?utm_source=dlvr.it&utm_medium=feed#embedding-custom-non-visible-data-with-the-data-*-attributes


Yes, you can have custom attributes:

<div imMakingUpAnAttribute="whatever"></div>

To differentiate between element and custom attributes, a good practice is to prefix it with data-.

<div data-imMakingUpAnAttribute="whatever"></div>

Tags:

Html