Data Attribute Use
suggest changeHTML5 data-*
attributes provide a convenient way to store data in HTML elements. The stored data can be read or modified using JavaScript
<div data-submitted="yes" class="user_profile">
… some content …
</div>
- Data attribute structure is
data-*
, i.e. the name of the data attribute comes after thedata-
part. Using this name, the attribute can be accessed. - Data in string format (including
json
) can be stored usingdata-*
attribute.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents