A real reason to use the data- * attribute in the html element?

5

Can anyone mention a single case of using the data-* attribute (in the standard suggested by W3C) for the html root element? If a real reason is not possible, then at least imagine a situation in which its use will make little or no difference in this element? Thank you.

    
asked by anonymous 16.03.2016 / 02:38

1 answer

6

When I used HTML4 and its "ancestors" so to speak I used to declare non-existent attributes that syntactically presented no error, but semantically.

W3C realized that there were many cases in which these statements left the html polluted and therefore created the data-whatever.

Example:

If you were to define an input, usually the behavior of it, by default it would just have a value. Now, if you had a menu, and you need to define multiple behaviors, you could declare them like this:

data-toggle="true"
data-width="500"
data-height="200"
data-resize="true"

Another cool thing, and that developers used to use input type='hidden' to store values so that nobody could access them, today you could already put them in the same input by inserting data-valor , these two cases are used in a number of frameworks and plugins, what they bring with them and more semantics and reliability in terms of conflict with existing attributes.

Compatibility Can I Use data-

    
16.03.2016 / 03:43