45. What are data attributes?

Data attributes use the data-* naming convention to store custom data associated with an element. JavaScript can read them through the element's dataset property.

Key Takeaways
  • Use data-* for custom element data.
  • dataset provides convenient JavaScript access.
Knowledge Check

How is data-user-id commonly accessed?