Images & Media
HTML <object> element
Embeds an external resource and can contain fallback HTML when the resource cannot be used. The example uses illustrative local asset paths; supply matching files before running it. The browser determines how to represent the resource using its data URL and media type. Provide a useful fallback link when rendering fails; embedded resources have security and format-specific constraints. It accepts global HTML attributes; individual global features may be inapplicable or restricted.
Formal Syntax & Structure
html syntaxhtml
<object data="manual.pdf" type="application/pdf">Fallback</object>Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| data | URL | Specifies the resource embedded by an object element. Unlike data-* attributes, it is not a storage mechanism for arbitrary author metadata. |
| type | element-dependent keyword or MIME type | Selects an element-specific kind: input control state, button behavior, ordered-list numbering, script interpretation or resource media type. Consult the element's own allowed values. |
| name | string | Provides an element-specific name: a form field key, radio group name, named frame, metadata key, slot name or other defined purpose. Its meaning depends on the element; it is not a unique DOM identifier. |
| form | form element ID | Associates an eligible control with a form elsewhere in the same document, overriding an ancestor form where applicable. Does not automatically associate descendants of a fieldset. |
| width | non-negative integer | Defines element-specific width, commonly in CSS pixels. On images it can establish an intrinsic aspect ratio together with height; on canvas it sets the bitmap width. |
| height | non-negative integer | Sets an element-specific height, commonly in CSS pixels. On images, pair it with width matching the intrinsic aspect ratio to reserve layout space. It is not a CSS length with units. |
Return Value
HTMLObjectElement
Content model: Transparent fallback content, subject to restrictions.
Working Example
Example Snippethtml
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <title>HTML example</title> </head> <body> <object data="manual.pdf" type="application/pdf"> <a href="manual.pdf">Open manual</a> </object> </body></html>