Skip to content

Latest commit

 

History

History
28 lines (11 loc) · 641 Bytes

Custom Data Attributes.md

File metadata and controls

28 lines (11 loc) · 641 Bytes

Custom Data Attributes

s

HTML allows you to define custom data attributes on HTML elements using the data- prefix. These attributes can store additional information that can be accessed using JavaScript. Here's an example:

<script> const element = document.getElementById("myElement"); const color = element.dataset.color; const size = element.dataset.size; console.log(color); // Output: blue console.log(size); // Output: large </script>