Is it a good practice storing related information in the HTML
tag?
$("#my_div").append("<span id='info' boo='foo'/>");
$("#info").attr("boo");
I've encountered with such technique (and slightly borrowed it) in TAL
(in ZPT
) where you could use tal:attributes
statement to modify HTML
tags (e.g. passing the value of boo
variable from backend to be rendered in the final document as attribute value):
<span id='info' tal:attributes='boo view/boo'>
result:
<span id='info' boo='foo'>
Will this technique break a document someday, or it is safe by the spec?
The right way to do it is to use data-* attributes:
http://www.w3.org/TR/2011/WD-html5-20110525/elements.html#embedding-custom-non-visible-data-with-the-data-attributes
Tangentially, jQuery has a special method for working with these as well. For example: