/

HTML / CSS / JavaScript Tutorial

HTML Element: <data>

[this page | pdf | back links]

The HTML <data> element links content with a machine-readable translation. It is new in HTML 5. If the content is date or time based then an alternative is to use a <time> element.

 

The attributes it can take (other than HTML global attributes and HTML event attributes) include:

 

Attribute

Description

More

value

Value of element

Here

 

To create or access such an element in JavaScript see here. The corresponding HTML DOM object supports standard DOM properties and methods, and additional properties with the same name and meaning as the attributes of the underlying HTML element referred to above. The default style applicable to this element is shown here.

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head></head>
<body>
Created using HTML:<br>
<data value="1">text, with an associated value</data>

<br><br>Created using JavaScript:<br>
<span id="element"></span>

<script>
var x = document.createElement("DATA");
x.textContent = "text, with an associated value";
// or use var txt = document.createTextNode("text, with an associated value");
// x.appendChild(txt);
x.setAttribute("value","1")
document.getElementById("element").appendChild(x);
</script>

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | HTML Elements


Desktop view | Switch to Mobile