The <data> element
The <data> tag links a piece of human-readable content to a machine-readable value. Readers see the text, such as a product name or a price written out, while the required value attribute holds something scripts can use, such as a product code or a plain number (here, each price in cents). For dates and times, use <time> instead.
Last updated: October 3, 2026
Quick facts
| Category | Flow content, phrasing content, palpable content |
| Content model | Phrasing content |
| Tag omission | Neither the start nor the end tag can be omitted |
| Permitted parents | Any element that accepts phrasing content |
| DOM interface | HTMLDataElement |
Syntax
Live example
Edit the code below and watch the preview update instantly.
Attributes
| Attribute | Description |
|---|---|
| value | Required. The machine-readable value for the content, such as a product ID or a number. |
Common examples
Product codes in a list
Shoppers read the product name; scripts and tools read the code in value.
Sortable numbers in a table
Show a formatted price but keep a plain number for sorting.
Reading the value with JavaScript
The value property gives you the machine-readable value as text.
Words that stand for numbers
Ratings or sizes written as words can still carry a number.
<data> vs <span>
A <span> is a meaningless wrapper — fine for styling a few words. <data> says “this text stands for a specific machine-readable value” and stores that value in its value attribute.
Use data when a script, a sorting function or a search tool needs the exact value behind friendly text. Use span when you only need a hook for CSS or JavaScript and there’s no hidden value.
| <data> | <span> | |
|---|---|---|
| Meaning | Text with a machine value | None |
| Key attribute | value | — |
| Best for | Codes, numbers, IDs | Styling hooks |
Common mistakes to avoid
- Leaving out
value. The value attribute is required — without it the element has no purpose. - Using data for dates and times. Use <time> with a
datetimeattribute instead. - Formatting the value. Keep it raw:
1299.99, not$1,299.99. - Expecting it to look different. Data has no default style; it looks like normal text.
Accessibility & SEO tips
- Screen readers read the visible text, not the value, so make sure the visible text makes sense on its own.
- For rich search results such as product prices, use schema.org structured data — the data element alone isn’t used for that by Google.
- Data is a good, honest way to make tables sortable without parsing currency symbols or commas in JavaScript.
- Keep values consistent across the page, such as always using the same SKU format, so scripts can rely on them.
- When the value is an identifier from your shop or database, keep the visible text human-friendly — a product name reads far better for visitors and screen readers than a raw code.
Browser support
Supported in all modern browsers, including Chrome, Edge, Firefox, Safari and their mobile versions. Older browsers simply show the text.