dataset
Safe to use with fallbackapielem.dataset is unsupported in Internet Explorer <= 10 and older mobile browsers.
- Verdict
- Safe to use
- Category
- JavaScript APIs
- Browser support
- Can I Use
- Works in
- IE11+
Should you use dataset in 2026?
Using data-* attributes will be totally fine in all browsers, but instead of using elem.dataset.foo just use elem.getAttribute('data-foo'). A polyfill is available if you want terser syntax.
How to use it
<button data-product-id="42">Buy</button>
<script>
const id = document.querySelector('button').dataset.productId; // "42"
</script>
Please