Data (<data>)

When To Use

  • To make the content visible to the user and also provide a version of the data that can be interpreted by scripts. 1

Rules

  • This example demonstrates the usage of the element where the content enclosed within the element is visible to the user, while scripts can retrieve this content using the "value" attribute. 1
  • This element does not offer any additional advantages in terms of accessibility

Examples

Associate a product number with a T-Shirt in a list:

<ul>
    <li><data value="1">Small T-Shirt</data></li>
    <li><data value="2">Medium T-Shirt</data></li>
    <li><data value="3">Big T-Shirt</data></li>
</ul>

Sources 

  1. MDN: <data>: The Data element by Mozilla contributors is licensed under CC-BY-SA 2.5
  2. Quackit: HTML 5 <data> Tag © Copyright Quackit.com
Created at: 19.04.2023, Last updated at: 11.06.2023