8767 shaares
195 private links
195 private links
Store content that should be accessible. If the content should be seen or read on a page, don’t only put them in data attributes, but make sure that content is in the HTML content somewhere.
A use case is to style components based on their data attribute values.
Data attributes can be accessed in JS with tag.dataset.attributeName
. It can also store JSON.