Contents

Embedded Content

Embedding content into web pages allows you to include external resources like videos, documents, maps, and interactive media directly on your website. HTML provides various tags to embed this content, including <iframe>, <object>, <embed>, and <param>. Each tag serves different purposes and offers various functionalities.

Embedding External Content with

The <iframe> tag is used to embed external web content within a page. It’s commonly used for embedding videos (like YouTube), maps (like Google Maps), and other webpages.

Basic Syntax:
				
					<iframe src="https://www.example.com" width="600" height="400"></iframe>

				
			
Attributes:
  • src: URL of the content to be embedded.
  • width and height: Specifies the size of the embedded content.
  • title: Provides an accessible name for the iframe content.
  • allowfullscreen: Allows the embedded content to be viewed in fullscreen mode.
  • frameborder (Deprecated): Sets the border around the iframe. Use CSS for this purpose in modern HTML.
 
Example: Embedding a YouTube Video:
				
					<iframe width="560" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ" 
        title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>


				
			

The <iframe> is versatile and widely supported, making it a common choice for embedding various types of external content.

The < object > Element

The <object> element can embed different types of content, such as images, videos, PDFs, and even web pages. Unlike <iframe>, <object> is designed to handle different types of media and can act as a fallback mechanism if the content fails to load.

Basic Syntax:
				
					<object data="document.pdf" type="application/pdf" width="600" height="400">
  <p>By clicking on download you can download the PDF. Download the PDF to view it: <a href="document.pdf">Download PDF</a>.</p>
</object>

				
			
Attributes:
  • data: Specifies the URL of the resource to be embedded.
  • type: Defines the MIME type of the content (e.g., application/pdf for PDFs).
  • width and height: Sets the size of the embedded content.
  • Fallback Content: You can provide fallback content inside the <object> tag if the browser does not support the embedded content.
 
Example: Embedding an Image as Fallback:
				
					<object data="image.svg" type="image/svg+xml">
  <img decoding="async" src="fallback-image.jpg" alt="Fallback Image">
</object>

				
			

The <object> tag is useful when you need to embed content that might have a fallback option for older or less capable browsers.

The Element

The <embed> element is a self-closing tag used to embed external content like videos, PDFs, Flash content, and more. Unlike <object>, <embed> does not allow for fallback content.

Basic Syntax:
				
					<embed src="video.mp4" width="600" height="400">

				
			
Attributes:
  • src: URL of the resource to be embedded.
  • type: Defines the MIME type of the embedded content.
  • width and height: Specifies the size of the embedded content.
 
Example: Embedding Audio:
				
					<embed src="audio.mp3" type="audio/mpeg" width="300" height="50">

				
			

The <embed> tag is straightforward but less versatile than <object> since it doesn’t support fallback content. However, it’s quick for simple embedding tasks.

The Element

The <param> tag is used within the <object> element to define parameters for the embedded content. It’s typically used for older technologies like Flash or media players that require specific configurations.

Basic Syntax:
				
					<object data="movie.swf" type="application/x-shockwave-flash" width="600" height="400">
  <param name="autoplay" value="true">
  <param name="loop" value="false">
</object>

				
			
Attributes:
  • name: The name of the parameter to be set (e.g., autoplay, loop).
  • value: The value for the specified parameter.

The <param> tag is primarily associated with older media types (like Flash), which are becoming less common due to the rise of modern media embedding techniques (e.g., HTML5 <audio> and <video>).

Summary

Embedding external content in web pages can greatly enhance user interaction and functionality. HTML provides several tags for embedding:

  • <iframe> is versatile and commonly used for embedding web content like videos and maps.
  • <object> can handle multiple media types and allows for fallback content, making it suitable for a wider range of uses.
  • <embed> is used for directly embedding external media but lacks the ability to include fallback content.
  • <param> is used with <object> to configure settings for embedded content, though it is less commonly used with modern web technologies.

Each of these elements has its strengths and is suited for different use cases, allowing web developers to embed a variety of media types into web pages effectively.