7
I am developing a system aimed at managing public tenders and I need it to be compatible with as many devices as possible.
In some situations it was necessary to use custom attributes, example:
<span qtd='20'>Alguma coisa...</span>
In this case, I take the value of Qtd through the Jquery.attr()
and use as necessary, works well in the most modern browsers, but the question is:
Is it good practice? What problems can I have in older browsers?
Related: https://www.w3.org/TR/2011/WD-html5-20110525/elements.html#embedding-custom-non-visible-data-with-the-data-Attributes
– Woss
In fact, this can cause problems in newer browsers, which do not yet exist. That is, if in the future there is a new HTML attribute with the same name you used, it will be a problem. That’s why they created the prefix
data-
in HTML5.– bfavaretto
Well noted @bfavaretto, exactly
– Miguel
Thanks @bfavaretto, I’ve always seen this prefix but I had no idea that was the reason why.
– edson alves