What is the Difference Between Data Attribute and Data Attribute in HTML

I recently stumbled upon a data item and understood the purpose clearly. I believe even a data attribute can be used to fetch and extract data in a machine readable format.

Data item:

<p>New Products</p>
<ul>
 <li><data value="3967381398">Mini Ketchup</data></li>
 <li><data value="3967381399">Jumbo Ketchup</data></li>
 <li><data value="3967381400">Mega Jumbo Ketchup</data></li>
</ul>

      

Data Attribute:

<p>New Products</p>
<ul>
 <li data-value="3967381398">Mini Ketchup</li>
 <li data-value="3967381399">Jumbo Ketchup</li>
 <li data-value="3967381400">Mega Jumbo Ketchup</li>
</ul>

      

When should I use an item and when should I use data?

+3


source to share


2 answers


From this link: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/data



Dispatched to associate a data value with a human-readable equivalent. Like the name of the book, and this is the ISBN.

+1


source


Yes, but sometimes that value can appear inside other text, so if you want to use an attribute data-*

on a value, you'll have to wrap it in an element <span>

or similar element. The item <data>

is useful in these situations.



0


source







All Articles