HTML declare Attribute
The obsolete HTML declare attribute was historically used with the <object> element to declare an embedded object without immediately creating or loading that object for use.
declare attribute is obsolete and should not be used in modern HTML. There is no direct modern attribute that replaces its historical object declaration behavior.
Historical Syntax
The declare attribute was a Boolean attribute used on an <object> element:
<object id="example-object"
data="example-file"
type="application/example"
declare>
Fallback content
</object>
Because declare was a Boolean attribute, its presence indicated that the object was only being declared rather than instantiated immediately.
Historical Elements
The declare attribute was associated with the <object> element.
| Element | Historical Purpose |
|---|---|
<object> |
Declared an object without immediately instantiating it. |
Historical Use
The historical <object> model was designed to support a wide range of external resources and embedded technologies. Normally, an <object> element represented content that the browser could attempt to instantiate when processing the document.
Adding the declare attribute changed that behavior. Instead of immediately instantiating the object, the element served as a declaration that could be referenced for later use.
This mechanism belonged to an older model of embedded objects and was not widely useful in the way modern webpages handle images, audio, video, documents, and other external resources.
Why It Became Obsolete
The declare attribute was tied to an older object declaration and instantiation model that did not become a practical part of modern web development. Current HTML provides more specialized elements and APIs for common types of embedded content.
Modern webpages generally describe the resource that should be displayed or embedded directly rather than declaring an inactive object for later instantiation.
Modern Alternative
There is no direct modern HTML replacement for the declare attribute. Instead, choose the HTML element appropriate for the type of content being embedded.
| Content | Modern Approach |
|---|---|
| Image | Use the <img> or <picture> element. |
| Audio | Use the <audio> element. |
| Video | Use the <video> element. |
| Another webpage or document | Use an appropriate element such as <iframe> when embedding that content is suitable. |
External resource supported by <object> |
Use the modern <object> element without the obsolete declare attribute. |
For example, an external resource that is appropriate for the modern <object> element can be embedded directly:
<object data="document.pdf" type="application/pdf">
<p>The document could not be displayed.</p>
</object>
If an application needs to delay creating or loading particular content until a user performs an action, that behavior is application logic rather than a replacement HTML attribute. The appropriate technique depends on the type of resource and the application's requirements.
Legacy Browser Support
The declare attribute came from older HTML specifications, but browser implementation of its intended object declaration behavior was limited and inconsistent.
Modern webpages should not depend on browsers recognizing the obsolete declare attribute. Existing content should instead use the modern embedding element appropriate for the resource.
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 obsolete attributes historically associated with embedded objects include:
classid- Historically used to identify an implementation for an embedded object.codebase- Historically used to specify a base location for resources associated with embedded content.codetype- Historically used to identify the content type of object code.standby- Historically used to provide a message while an object was loading.typemustmatch- Historically used to require an object's declared type to match the resource type.
Specifications
The declare attribute is obsolete and should not be used on the modern <object> element. See the WHATWG HTML Living Standard for information about obsolete and non-conforming features.
