April 2013
Intermediate to advanced
264 pages
7h 44m
English
A further way that HTML5 extends the meaning that elements have is through the use of data attributes. These are user-defined attributes, the values of which are intended to provide information related to an element but without giving any extra semantic meaning to either machines or humans. Let me explain that in a little more detail.
Say you want to output a set of data, each item of which has two values—a name and a number (a unique database ID, for example). You want the name to be shown in the document, but you also want to make the number available for running scripts on. As it stands, no relevant attribute is available to store that information; you’d probably have to use a class:
<p class="id-123">Peter</p>
Data attributes ...
Read now
Unlock full access