I was going through HTML5 and I found data-* attribute is new to HTML5. But I didn't understand its importance. As per its definition from w3schools I understood:
- The data-* attributes is used to store custom data private to the page or application.
Question: What does it mean by custom data? How we can use data-* to store custom data?
- The data-* attributes gives us the ability to embed custom data attributes on all HTML elements.
The stored (custom) data can then be used in the page's JavaScript to create a more engaging user experience (without any Ajax calls or server-side database queries).
Question: We already can add attributes to an element and use it in JavaScript, then why use data-* attribute?