Thanks to the data- attributes we’ve added to our
  • elements, we can now display this information instantly without having to worry about making any Ajax calls and without having to make any server-side database queries. Wow, like expando properties avail since IE4?
  • You should include the content in actual html text, not in your attributes. 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). For ex: I have a span element which displays a text as ‘Employee name is John! The data-* attributes is used to store custom data private to the page or application. We can get the value of the data attribute using the dataset property or the getAttribute() method on the messageEl template reference variable.. A new feature being introduced in HTML 5 is the addition of custom data attributes. Since the "data" attribute is the brainchild of HTML 5, your page should carry a doctype that informs the W3C validator of this if you want the page to validate (after all, isn't that the whole point? The extension needs some form of additional markup to let it know that the script can be replaced, what the script is, and what the version is.
    @Andres – data-* is only for storing data which is to be used within your own website. The step attribute works with the following input types: number, range, date, datetime-local, month, time and week. please I have this doubt. localstore by pairs. }, a[data-sort-dir="desc"] { period… simple right? Tip: This attribute can be used together with the max and min attributes to create a range of legal values. A custom data attribute starts with data-and would be named based on your requirement. My code, on the other hand, has support for actually udpating the attribute values, but it does not support adding new attributes. When using this approach, rather than using the full attribute name, you can ditch the data- prefix and refer to the custom data directly using the name you have assigned to it. As far as the browser and indeed the website’s end user are concerned, this data does not exist. Data attributes can also be stored to contain information that is constantly changing, like scores in a game. Thank you, I like to come in here again and again. The data- attributes were introduced in the HTML5 standard because there wasn’t any good solution for adding unique data to HTML elements. Notify me of followup comments via e-mail. The main issues to consider are Internet Explorer support and performance. Conclusion. Nice article, perhaps it needs a slight modification to be understandable by some of the very fresh and new entries into JS and HTML5. The idea is that there are other extension points for your use case (such as custom attributes in other namespaces (in XHTML), RDFa, Microdata, Meta tags, whatnot). All such custom data are available via the HTMLElement interface of the element the attribute is set on. Data Attributes are Awesome. If I got the gt and lt right, it’d be something like: Carrots