DATA element is used to define selections of content that are data that have a machine-readable format or translation. For example, a date can be written in many ways:
December 16, 2011
Dec 16, 2011
And while computers can be trained to read any of those formats correctly, there is an ISO standard for dates which reads YYYY-MM-DD or
2011-12-16. By enclosing any of those dates with a
DATA element you can define the ISO value so that a computer can read the date reliably.
DATA element is new in HTML5.
DTD: HTML5: <!doctype html>
DATA Web Browser Support:
DATA End Tag:
DATA element is a semantic element that represents computer data and contains a machine-readable form of the contents in the
Tags valid as content: Phrasing elements and character data
Tags valid as container: Phrasing elements
DATA Special Notes:
DATA element can be used along with microformats or microdata to make the contents both machine-readable for data processors and human-readable. In this case the
value attribute would be determined by the microformats or microdata vocabulary in use.
DATA element can also be used along with scripts on the page for scripts that have a literal value to store along with a human-readable value. In this case the format of the
value attribute and the contents of the
DATA element depend upon what the script needs.
DATA Element and the
Another way you can embed machine-readable data into your HTML5 documents is with the
data-* attribute. This is different from the
DATA element because it is an attribute that goes on an existing element. It also does not semantically define the enclosed content as data.