Home > Abakada: Back to Basics > Language References > HTML Elements > DATA Element
Adds a machine-readable version for a given piece of content. | HTML 5 |
HTML Syntax
<data value=machine-readable_translation>
...
</data>
NOTE: Both start and end tags are required.
The <data
> element is used to annotate a representation of a related element’s content in machine-readable format.
The value attribute must be present, and must contain the machine-readable translation.
The element serves to provide both a machine-readable value for the purposes of data processors, and a human-readable value for the purposes of rendering in a web browser.
When the value is date- or time-related, the more specific <time> element can be used instead.
The <data>
element supports the following attributes, in addition to global attributes common to all HTML elements.
value | machine-readable format | Specifies the machine-readable translation of the content of the element |
Here, a simple table has its numeric values encoded using the <data
> element, so that a script can provide a sorting mechanism on each column despite the numbers being presented in textual form.
<script src="sort.js"></script>
<table id="sortable">
<thead>
<tr><th>Game
<th>Corporations
<th>Map Size
<tbody>
<tr><td>1830
<td><data value="8">Eight</data>
<td><data value="93">19+74 hexes</data>
<tr>
<td>1856
<td><data value="11">Eleven</data>
<td> <data value="99">12+87 hexes</data>
<tr>
<td>1870
<td><data value="10">Ten</data>
<td><data value="149">4+145 hexes</data>
</table>
TIME