Skip to Content

Custom Data Attributes in HTML 5

If you’ve ever tried to store machine data in your html, you know it’s a pain. The HTML 5 draft gives us a clever solution: create your own arbitrary attributes prefixed with data-.

 <ol>
     <li data-length="2m11s">Beyond The Sea</li>
     ...
  </ol>

…a tidy mechanism that is also backwards compatible: browsers will ignore attributes they don’t recognize.