Manage HTML5/JS metadata using custom data attributes
HTML5 introduces custom data attributes for tags - these are attributes that starts with "data-". These will be treated as a storage area for private data . If you rely on element class names or rel attributes to store arbitrary snippets of metadata and still look for "hooks", these data attributes will come as a relief. Prefixing the custom attributes with data- ensures that they will be completely ignored by the user agent. As far as the browser and indeed the website’s end user are concerned, this data does not exist. Every HTML element may have any number of custom data attributes specified, with any value. Data attributes can be used in the following scenarios - To store the initial height or opacity of an element which might be required in later JavaScript animation calculations To store parameters for a Flash movie that’s loaded via JavaScript To store custom web analytics tagging data To store data about the health, ammo, or lives of an e...