Inline
HTML5
The data element links content with a machine-readable translation via the value attribute, making it useful for automated data processing while displaying human-readable content.
Interactive code playground requires JavaScript. Here's the code:
<p>Product: <data value="SKU-12345">Premium Laptop</data></p>
<p>Price: <data value="999.99">$999.99</data></p>
< data value = " machine-readable-value " > Human readable content </ data >
The value attribute contains data in a format suitable for automated processing, while the element content shows what users see.
Attribute Description Example valueMachine-readable value "SKU-12345", "999.99"
Interactive code playground requires JavaScript. Here's the code:
<ul>
<li><data value="SKU-001">Wireless Mouse</data> - $29.99</li>
<li><data value="SKU-002">Mechanical Keyboard</data> - $89.99</li>
<li><data value="SKU-003">USB-C Cable</data> - $12.99</li>
</ul>
Interactive code playground requires JavaScript. Here's the code:
<h3>Shopping Cart</h3>
<ul>
<li>
<data value="PROD-7829">Blue T-Shirt (Large)</data>
- Quantity: 2
</li>
<li>
<data value="PROD-5612">Running Shoes (Size 10)</data>
- Quantity: 1
</li>
</ul>
Interactive code playground requires JavaScript. Here's the code:
<p>Temperature: <data value="23.5">23.5°C</data></p>
<p>Distance: <data value="42.195">42.195 km</data></p>
<p>Score: <data value="95">95%</data></p>
Interactive code playground requires JavaScript. Here's the code:
<p>Order #<data value="ORD-2024-001234">2024-001234</data> has been shipped.</p>
<p>Tracking: <data value="1Z999AA10123456784">1Z999AA10123456784</data></p>
Interactive code playground requires JavaScript. Here's the code:
<article>
<h2>Blog Post</h2>
<p>Author: <data value="user-12345">Jane Smith</data></p>
<p>Category: <data value="cat-tech">Technology</data></p>
</article>
Interactive code playground requires JavaScript. Here's the code:
<ul>
<li><data value="#FF0000">Red</data></li>
<li><data value="#00FF00">Green</data></li>
<li><data value="#0000FF">Blue</data></li>
</ul>
Interactive code playground requires JavaScript. Here's the code:
<p>
Rating:
<data value="4.5">
⭐⭐⭐⭐☆ (4.5 out of 5)
</data>
</p>
<!-- General machine-readable values -->
< data value = " SKU-12345 " > Premium Widget </ data >
< data value = " 99.99 " > $99.99 </ data >
Use for product codes, prices, IDs, and other non-date values.
<!-- Specifically for dates and times -->
< time datetime = " 2024-12-11 " > December 11, 2024 </ time >
< time datetime = " 14:30 " > 2:30 PM </ time >
Use specifically for dates, times, and durations.
The value attribute is accessible via JavaScript:
Interactive code playground requires JavaScript. Here's the code:
<button onclick="showValue()">
<data id="product" value="SKU-99999">Click Me</data>
</button>
<p id="result"></p>
<script>
function showValue() {
const data = document.getElementById('product');
document.getElementById('result').textContent =
'Product ID: ' + data.value;
}
</script>
The <data> element has no default styling:
Interactive code playground requires JavaScript. Here's the code:
<style>
data {
font-weight: 600;
color: #0066cc;
border-bottom: 1px dotted #ccc;
cursor: help;
}
data:hover::after {
content: ' (ID: ' attr(value) ')';
font-size: 0.8em;
color: #666;
}
</style>
<p>Product: <data value="SKU-12345">Laptop Computer</data></p>
Interactive code playground requires JavaScript. Here's the code:
<article class="product">
<h3><data value="PROD-8472">Wireless Headphones</data></h3>
<p>Price: <data value="149.99">$149.99</data></p>
<p>Stock: <data value="25">25 units available</data></p>
<p>Color: <data value="color-black">Matte Black</data></p>
</article>
Screen readers read the visible content, not the value attribute. The machine-readable value is only for automated processing.
Make sure the visible content is meaningful to humans:
<!-- Confusing to users -->
< data value = " PROD-12345 " > 12345 </ data >
<!-- Clear and descriptive -->
< data value = " PROD-12345 " > Premium Wireless Mouse </ data >
Don’t use <data> for purely presentational purposes:
<!-- Wrong: no machine processing benefit -->
< data value = " red " > Red </ data >
<!-- Better: just use plain text or CSS -->
< span class = " color-red " > Red </ span >
Scenario Example Product IDs <data value="SKU-123">Widget</data>Prices <data value="99.99">$99.99</data>Order numbers <data value="ORD-456">Order 456</data>User IDs <data value="user-789">John</data>Color codes <data value="#FF0000">Red</data>Ratings <data value="4.5">⭐⭐⭐⭐☆</data>
Browser Version Notes Chrome 62+ Full support Firefox 22+ Full support Safari 10+ Full support Edge 79+ Full support IE No Not supported
The <data> element is an HTML5 feature with good modern browser support.
For dates, times, and durations with machine-readable format.
Learn more →
For metadata in the document head.
Learn more →