How to Use Custom Data Attributes using HTML5

3 Responses

  1. Selvam says:

    what’s the use of this info? is that help in SEO

    • Hi Selvam,

      No, it won’t be indexed. The attribute itself will be cached with the
      page, but Google has no context of what the attribute or the value
      means, so it is meaningless to search engines.

      The advantage is that you can easily embed some scripting data
      (still semantic, but not for display) with your elements without having
      to insert inline javascript all over the place, and it will be valid

      Also data- is a standardized part of the HTML5 spec. Semantically it’s the best way to go.


  2. Philippe Vincke says:

    How about to load all the data attributes of an element into an array or an object so you don’t have to load them one by one ?

Leave a Reply

Your email address will not be published. Required fields are marked *