Syntax
<object data="file.pdf" type="application/pdf" width="600" height="400"></object>Examples
Embedding a PDF
Displaying a PDF file directly in the page using object.
<object data="/docs/guide.pdf" type="application/pdf" width="100%" height="500">
<p>Your browser cannot display PDFs. <a href="/docs/guide.pdf">Download it instead</a>.</p>
</object>Embedding with embed
A simpler embed of a PDF with no fallback content.
<embed src="/docs/report.pdf" type="application/pdf" width="100%" height="500">Embedding an SVG File as an Object
Loading an external SVG file as interactive content.
<object data="/icons/logo.svg" type="image/svg+xml" width="120" height="120"></object>Attributes
- data (URL): Used on object; the URL of the resource to embed
- src (URL): Used on embed; the URL of the resource to embed
- type (string): The MIME type of the embedded resource
- width (number): Display width in pixels
- height (number): Display height in pixels
Best practices
- Prefer object over embed when you need fallback content for unsupported browsers
- For embedding other web pages specifically, use iframe instead, which is more widely supported and flexible
- Always provide a direct download link as a fallback when embedding documents like PDFs
- Test embedded content across browsers, since plugin-dependent behavior for embed/object varies more than other media elements
At a glance
- Purpose
- Structure and meaning for web content
- File extension
- .html · .htm
- Runs in
- Web browsers
- Usually used with
- CSS and JavaScript
Specifications & further reading
Related HTML documentation
<img>
The <img> element embeds images into web pages. Images enhance visual communication and user engagement. The src attribute specifies the image source, while alt provides alternative text for accessibility and SEO. Images are inline-replaced elements, meaning they display in the flow of text but are replaced with the actual image content.<figure>, <figcaption>
The <figure> element wraps self-contained content — typically an image, illustration, diagram, code snippet, or chart — along with an optional caption provided by <figcaption>. Content in a figure is meant to be referenceable independently of the main flow; a reader should be able to move it elsewhere on the page (or even to an appendix) without breaking the document's meaning.<video>
The <video> element embeds video content directly in a web page without needing a third-party plugin. It supports built-in playback controls, multiple source formats via nested <source> elements for browser compatibility, and various attributes for controlling autoplay, looping, and muting.<audio>
The <audio> element embeds sound content — music, podcasts, or sound effects — directly in a page. Like <video>, it supports multiple <source> elements for format fallback and built-in playback controls, without needing Flash or other plugins.
The <img> element embeds images into web pages. Images enhance visual communication and user engagement. The src attribute specifies the image source, while alt provides alternative text for accessibility and SEO. Images are inline-replaced elements, meaning they display in the flow of text but are replaced with the actual image content.<figure>, <figcaption>
The <figure> element wraps self-contained content — typically an image, illustration, diagram, code snippet, or chart — along with an optional caption provided by <figcaption>. Content in a figure is meant to be referenceable independently of the main flow; a reader should be able to move it elsewhere on the page (or even to an appendix) without breaking the document's meaning.<video>
The <video> element embeds video content directly in a web page without needing a third-party plugin. It supports built-in playback controls, multiple source formats via nested <source> elements for browser compatibility, and various attributes for controlling autoplay, looping, and muting.<audio>
The <audio> element embeds sound content — music, podcasts, or sound effects — directly in a page. Like <video>, it supports multiple <source> elements for format fallback and built-in playback controls, without needing Flash or other plugins.