<data>

Draft

Definition

The <data> HTML element is used to represent machine-readable data within an HTML document. It provides a way to embed custom data values or attributes within an element, making it accessible for scripting and processing by programs or scripts.

Here’s an example of how to use the <data> element:

<p>The current temperature is <data value="25">25°C</data>.</p>

In this example, the <data> element is used to embed the value “25” as machine-readable data within the paragraph. The human-readable representation “25°C” is displayed to the users, while the underlying value can be extracted and processed programmatically.

The <data> element can also have additional attributes, such as value or datetime, to provide more specific information about the data being represented. These attributes can be accessed using JavaScript to retrieve or manipulate the data.

The primary purpose of the <data> element is to allow developers to attach custom data or metadata to HTML elements, making it easier to process or manipulate that data using scripts or programs.

It’s important to note that the <data> element is primarily intended for machine processing and may not have any visual styling by default. You can apply CSS styles to the <data> element if you want to customize its appearance.

In summary, the <data> element is used to embed machine-readable data within an HTML document. It provides a way to associate custom data values or attributes with HTML elements, making the data accessible for scripting and processing.