You can throw your own attribute ( element.setAttribute (name, value) ), but it will fail with a validation from any normal code validator. We also expect glitches and incorrect work, especially in older browsers.
Storing data for a particular attribute has always been a thorn in ... under the nails of developers.
In HTML, the fifth edition, in addition to solving a heap of other equally pressing problems, an attribute was invented that meets the standards and allows you to store arbitrarily user-defined data (but it’s not necessary to overdo it — moveton).
" Data : Yes, the savior will come (or come :)) "!
Example:
HTML5: <span data-id='123' data-group-name='Terminators'>Group 123</span> JS: var data = document.querySelector('span').dataset; var idGroup = data.id; var nameGroup = data.groupName;
The code will be completely valid (with the corresponding doctype, of course).