Student-friendly HTML, CSS, and JavaScript reference with examples
Custom attributes starting with data- that store information on elements.
HTML:
<button data-tab="home">Home</button>
<button data-color="red">Red</button>
JavaScript:
const button = document.querySelector('button');
const tabName = button.getAttribute('data-tab');
Use data attributes to store IDs, settings, or any custom information you need to access with JavaScript.