HTML <data> Element and the value Attribute

The HTML <data> element connects visible text with a machine-readable value through its value attribute. Use it when the machine value is useful to scripts or applications but is not itself the text you want users to read.

<data value="SKU-1042">Blue notebook</data>

When to use <data> Top ↑

Common examples include product IDs, internal codes or normalized values that differ from the human-readable label.

<ul>
  <li><data value="398">Mini Ketchup</data></li>
  <li><data value="399">Jumbo Ketchup</data></li>
</ul>

Use <time> for dates and times Top ↑

If the content represents a date, time or duration, use the <time> element instead.

Reading the value with JavaScript Top ↑

<data id="product" value="1042">Notebook</data>
<script>
const product = document.getElementById('product');
console.log(product.value);
</script>
HTML data element example
Using a visible label with an associated machine-readable value.

What <data> does not do Top ↑

The element does not automatically create schema.org structured data, search rich results, calculations or special screen-reader announcements. It simply provides a semantic machine-readable translation of its content.

HTML5 Tags HTML tag types





plus2net.com










✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer