HTML typemustmatch Attribute
The obsolete HTML typemustmatch attribute was historically used on the <object> element to require the actual media type of an external resource to match the type declared by the type attribute.
typemustmatch attribute is obsolete and should not be used in modern HTML. There is no direct modern HTML attribute that replaces it.
Historical Syntax
The typemustmatch attribute was a Boolean attribute placed on an <object> element that also specified a resource with data and a media type with type.
<object data="example.pdf"
type="application/pdf"
typemustmatch>
<p>The document could not be displayed.</p>
</object>
As a Boolean attribute, its presence enabled the requirement. It did not need a separate value such as true.
Historical Elements
The obsolete typemustmatch attribute was associated with the <object> element.
| Element | Historical Purpose |
|---|---|
<object> |
Required the resource's actual media type to match the media type specified by the type attribute. |
Historical Use
The type attribute on an <object> element identifies the expected MIME type of the external resource. The historical typemustmatch attribute added a requirement that the resource's actual type match that declared value.
<object data="document.pdf"
type="application/pdf"
typemustmatch>
<p><a href="document.pdf">Download the PDF document</a></p>
</object>
If the resource did not have the required type, the browser was not supposed to use it as the object's resource. Fallback content inside the <object> element could then be available when the resource could not be represented.
Why It Became Obsolete
The typemustmatch attribute is no longer part of conforming HTML authoring. Modern HTML does not provide another Boolean attribute that performs the same function.
Servers should send resources with the correct HTTP Content-Type, and authors can continue to use the current type attribute when specifying the expected media type of an <object> resource.
Modern Alternative
There is no direct replacement for typemustmatch. Remove the obsolete attribute and make sure the resource is served with the correct media type.
Historical HTML
<object data="example.pdf"
type="application/pdf"
typemustmatch>
<p>The document could not be displayed.</p>
</object>
Modern HTML
<object data="example.pdf"
type="application/pdf">
<p>The document could not be displayed.</p>
</object>
The type="application/pdf" attribute identifies the expected type of the embedded resource. The server should also deliver the PDF using the appropriate Content-Type HTTP header.
type attribute is not a replacement for typemustmatch. It identifies the expected media type of the resource, but it does not recreate the additional requirement represented by the obsolete Boolean attribute.
Legacy Browser Support
The typemustmatch attribute was defined for the <object> element but was not a feature authors could depend on consistently across browsers.
Modern webpages should omit the attribute. Use current <object> markup when appropriate and make sure embedded resources are delivered with the correct media type.
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.
Related Attributes
Other current and obsolete attributes associated with the <object> element include:
data- Specifies the URL of the resource used by an<object>element.type- Specifies the expected MIME type of the external resource.archive- Historically identified archives containing resources associated with an object.classid- Historically identified an implementation for an embedded object.codebase- Historically provided a base URL for object-related resources.codetype- Historically specified the content type of an object's implementation.declare- Historically declared an object without immediately instantiating it.standby- Historically provided a message while an object resource was loading.
Specifications
The typemustmatch attribute on the <object> element is obsolete and must not be used by authors. Modern HTML does not provide a direct replacement for the attribute. See the WHATWG HTML Living Standard for information about obsolete and non-conforming features.
