🔰data attributes
Custom Attributes
Problem with custom attributes: What if we use a non-standard attribute and later the standard introduces it and makes it do something? ... To avoid conflicts, there exist data-* attributes.
dataset
All attributes starting with “data-” are reserved for programmers’ use. They are available in the dataset property.
data-xxx attribute (⭐️ kebab-cased)
dataset property (⭐️ camel-cased)
data-about="Elephants"
dataset.about = "Elephants"
data-order-state="new"
dataset.orderState = "new"
Last updated
Was this helpful?