HTML datasrc Attribute

The obsolete datasrc attribute was a Microsoft Internet Explorer extension used with its data-binding system to identify the data source that supplied information to an HTML element.

Historical Syntax

The datasrc attribute referenced a data source by its identifier. Other data-binding attributes could then select and control information from that source:

<span datasrc="#example-data" datafld="name"></span>

In this example, #example-data identified the data source and the datafld attribute selected the name field from the current record.

Historical Elements

The proprietary datasrc attribute could be used with various elements that participated in Internet Explorer's data-binding system.

Element Type Historical Purpose
Text and container elements Connected an element to a data source so values from records could be displayed.
Form controls Allowed supported controls to participate in Internet Explorer's data-binding system.
Table-related elements Allowed records from a data source to be displayed as repeated table content.

Historical Use

Internet Explorer's data-binding system was designed to connect HTML elements directly to structured data. The datasrc attribute identified the source from which the browser should obtain the records.

Several proprietary attributes could work together. The datasrc attribute selected the data source, datafld identified a field within a record, dataformatas controlled how a value was interpreted, and datapagesize could control how many records were displayed at one time.

This allowed some data-driven pages to be created declaratively, but the mechanism depended on Internet Explorer rather than a standard supported across browsers.

Why It Became Obsolete

The datasrc attribute was not part of standard HTML and depended on Microsoft's proprietary data-binding technology. Pages built around the feature could not rely on the same behavior in other browsers.

Modern web technologies provide standardized methods for retrieving, processing, and displaying data. Data can be incorporated into the document on the server or retrieved in the browser with JavaScript and standard web APIs.

Modern Alternative

There is no direct modern HTML replacement for datasrc. The appropriate modern approach depends on where the data comes from and how the webpage or application needs to use it.

JavaScript can retrieve data from a server using the Fetch API:

<p>Customer: <span id="customer-name">Loading...</span></p>

<script>
fetch("/data/customer.json")
  .then(response => response.json())
  .then(customer => {
    document.getElementById("customer-name").textContent = customer.name;
  });
</script>

In this example, JavaScript retrieves the data, selects the required value, and places that value into the document using a standard DOM property.

A server-side application can also retrieve data from a database or another source and generate the completed HTML before sending the page to the browser.

The modern HTML data-* attributes should not be confused with datasrc. Custom data-* attributes store additional information directly on an HTML element. They do not automatically connect an element to an external data source.

Legacy Browser Support

The datasrc attribute was primarily associated with Microsoft Internet Explorer and its proprietary data-binding technology. It was not a standard cross-browser HTML feature.

Modern browsers do not provide the old Internet Explorer data-binding environment required for datasrc. Legacy applications that depend on the feature need to retrieve and display their data using current web technologies.

For additional information about historical browser compatibility, visit Can I Use? . Search for the HTML element or attribute you want to check. Search results can include related HTML features, element attributes, APIs, and other technologies, so select the result that most closely matches the legacy feature you are researching.

Other obsolete proprietary attributes associated with Internet Explorer's data-binding system include:

  • datafld - Historically used to identify a field or column within the bound data source.
  • dataformatas - Historically used to indicate how bound data should be interpreted.
  • datapagesize - Historically used to control how many bound records were displayed at one time.

Specifications

The datasrc attribute was a proprietary Microsoft Internet Explorer extension rather than a standard HTML attribute. It should not be used in modern webpages. Standard HTML, JavaScript APIs, and server-side technologies should be used when working with external data sources.