The type attribute on an <object> tag specifies the media type of the embedded resource.
A media type indicates the format and nature of the resource.
A type attribute on an <object> element. The attribute specifies the media type (formerly MIME type) of the pdf file.
<object data="/media/sample.pdf" type="application/pdf"
style="width:100%;height:500px;">
PDF cannot be displayed.
</object>
The type attribute specifies the media type of the embedded resource.
A media type, formerly known as a MIME type, indicates the format and nature of a resource.
Browsers don't look at a resource's file extension, but rather what media type it is.
A list with common media types is available on this site.
Tip: The IANA organization maintains a full list of official media types.
There are hundreds of media types.
These are some common types that are used on the web.
Media Type | Description |
---|---|
text/html | HTML |
image/png | PNG |
application/pdf | |
application/vnd.ms-excel | Excel |
text/csv | Comma Separated Values |
video/mp4 | MP4 |
Tip: Check our HTTP Media Types Reference for a more complete list of common media types.
<object type="media-type" />
Value | Description |
---|---|
media-type | The media type of the linked page. |
Here is when type support started for each browser:
Chrome
|
1.0 | Sep 2008 |
Firefox
|
1.0 | Sep 2002 |
IE/Edge
|
1.0 | Aug 1995 |
Opera
|
1.0 | Jan 2006 |
Safari
|
1.0 | Jan 2003 |
Back to <object>