HTML dataformatas Attribute

The obsolete dataformatas attribute was a Microsoft Internet Explorer extension used with its data-binding system to specify whether bound data should be treated as plain text or HTML.

Historical Syntax

The dataformatas attribute was used with other Internet Explorer data-binding attributes such as datasrc and datafld:

<span datasrc="#example-data"
      datafld="description"
      dataformatas="text"></span>

The attribute historically accepted values that indicated how the bound data should be interpreted:

Value Historical Purpose
text Treated the bound value as text.
html Allowed the bound value to be interpreted as HTML markup.

Historical Elements

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

Element Type Historical Purpose
Data-bound HTML elements Specified whether data inserted into the element was handled as text or interpreted as HTML.

Historical Use

Internet Explorer's proprietary data-binding system allowed elements in a webpage to display values obtained from a data source. The datasrc attribute identified the source, and datafld selected a field from that source.

The dataformatas attribute provided additional instructions about how the selected field should be placed into the document. A text value was handled as text, while an HTML value could be interpreted as markup.

This distinction was important because displaying markup as text and allowing markup to become part of the document produce very different results.

Why It Became Obsolete

The dataformatas attribute was not part of standard HTML and depended on Internet Explorer's proprietary data-binding system. Other browsers could not be expected to provide the same behavior.

Modern web applications use standardized DOM APIs and other web technologies to decide how retrieved data is inserted into a document. This provides explicit control without relying on browser-specific HTML attributes.

Modern Alternative

There is no direct modern HTML replacement for dataformatas. JavaScript provides separate DOM features for inserting plain text and HTML content.

When a value should be displayed as text, the textContent property can be used:

<p id="description"></p>

<script>
const description = "<strong>Example text</strong>";

document.getElementById("description").textContent = description;
</script>

Because textContent treats the value as text, the HTML tags in the string are displayed rather than interpreted as markup.

JavaScript also provides ways to insert HTML markup, such as innerHTML:

<div id="description"></div>

<script>
const description = "<strong>Example text</strong>";

document.getElementById("description").innerHTML = description;
</script>

When HTML is inserted with innerHTML, the browser interprets the string as markup. Only trusted or properly sanitized content should be inserted this way because untrusted HTML can introduce security risks.

The modern approach therefore makes the choice explicit: use text-oriented DOM methods when content should remain text, and only interpret content as HTML when doing so is intentional and safe.

Legacy Browser Support

The dataformatas attribute was associated with Microsoft Internet Explorer and its proprietary data-binding features. It was not a standard cross-browser HTML attribute.

Modern browsers do not provide the old Internet Explorer data-binding environment required for dataformatas. Legacy applications that depend on this feature need to be updated using standard HTML, JavaScript, server-side processing, or other 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 in a bound data source.
  • datasrc - Historically used to identify the data source associated with an element.
  • datapagesize - Historically used to control the number of records displayed at a time.

Specifications

The dataformatas attribute was a proprietary Microsoft Internet Explorer extension rather than a standard HTML attribute. It should not be used in modern webpages. Standard HTML and web APIs should be used to control how data is added to a document.