data
data attribute
The data
attribute in HTML is used to store custom data associated with an element. It allows developers to embed extra information that can be accessed and manipulated using JavaScript or other scripting languages.
Syntax
<object data="URL">
Example
Here’s an example of using the data
attribute in HTML:
Example
<object data="images/earth.mp4" type="video/mp4"></object>
Definition and Usage
The data
attribute allows you to store custom data specific to a page or application.
It lets you embed custom data attributes in any HTML element.
This data can then be accessed via JavaScript to enhance the user experience without the need for Ajax calls or server-side queries.
Values
- URL
- A URL that indicates the location of the object's data.
Applies To
The data
attribute can be applied to the following HTML elements.
Conclusion
The data
attribute in HTML allows developers to embed external resources within elements, accessible through JavaScript or other scripts. It helps store custom data for a page or application, enhancing interactivity. This attribute is primarily used with the <object>
element.
colspan
The colspan attribute in HTML allows a table cell to span multiple columns, merging them for clearer organization and broader categories.
datetime
The datetime attribute in HTML defines a date and time in a machine-readable format for elements like <time>, improving recognition by browsers and search engines.