Embedding Content
Embedding Content
Embedding Audio
To embed audio content on a web page using HTML, you can use the
<audio> tag, specifying the audio file's source using the "src" attribute.
<audio> -The <audio> tag is used to embed audio content on a web page.
Syntax:
<audio controls>
<source src="audiofile.mp3" type="audio/mp3">
Your browser does not support the audio element.
</audio>
Attributes:
● src: Specifies the URL of the audio file to be embedded.
● controls: Adds playback controls (play, pause, volume, etc.) to the
audio player.
● autoplay: Automatically starts playing the audio when the page is
loaded.
● loop: Specifies that the audio will start over again, every time it is
finished.
● preload: Specifies whether the audio should be loaded when the page
loads. It can take values such as "auto", "metadata", or "none".
● muted: Specifies that the audio output should be muted by default.
● volume: Specifies the default volume of the audio player, ranging from
0.0 to 1.0.
● type:The ‘type’ attribute specifies the MIME type of the media file.
Note: Within the <audio> tag, you can use one or more <source> tags to
specify different audio files in different formats. This allows the browser to
choose the most suitable format based on its capabilities.
1|Page
Embedding Video
Syntax:
Attributes:
● src: Specifies the URL of the video file to be embedded.
● controls: Adds playback controls (play, pause, volume, etc.) to the video
player.
● autoplay: Automatically starts playing the video when the page is
loaded.
● loop: Specifies that the video will start over again, every time it is finished.
● preload: Specifies whether the video should be loaded when the page
loads. It can take values such as "auto", "metadata", or "none".
● muted: Specifies that the video output should be muted by default.
● poster: Specifies an image to be displayed while the video file is
downloading, or until the user hits the play button.
● width: Specifies the width of the video player.
● height: Specifies the height of the video player.
● autoplay: Specifies that the video will start playing automatically,
without requiring any user input.
Note: The <source> tag specifies the source file and its type.
HTML Code
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<title>Audio and Video Example</title>
</head>
<body>
<h2>Embedded Audio</h2>
2|Page
<audio controls>
<source src="audio/sample.mp3" type="audio/mp3">
Your browser does not support the audio element.
</audio>
<h2>Embedded Video</h2>
<video width="640" height="360" controls>
<source src="video/sample.mp4" type="video/mp4">
Your browser does not support the video element.
</video>
</body>
Embedding iframes
iframes:
Syntax:
Attributes:
● src (source): Specifies the URL of the content you want to embed within
the iframe.
● width and height: Set the dimensions (width and height) of the iframe.
● frameborder: Defines whether or not to display a border around the
iframe. A value of "0" means no border.
● allowfullscreen: Enables the iframe to be displayed in fullscreen mode.
This is often used for embedded videos.
3|Page
Embedding an External Website
This HTML code snippet embeds a Google Map of the Golden Gate Bridge
into a web page using an iframe element. The src attribute of the iframe
specifies the URL of the Google Maps page with parameters defining the
location of the Golden Gate Bridge.
4|Page