-
Hajipur, Bihar, 844101
YouTube embedding allows you to display and play a YouTube video directly inside your web page using the <iframe>
tag. This method is commonly used to show tutorials, product videos, and more.
<iframe width="560" height="315"
src="https://www.youtube.com/embed/VIDEO_ID"
title="YouTube video player"
frameborder="0"
allowfullscreen></iframe>
Replace VIDEO_ID
with the actual YouTube video ID.
<iframe width="560" height="315"
src="https://www.youtube.com/embed/tgbNymZ7vqY"
title="YouTube Video Player" frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen></iframe>
Go to the YouTube video.
Click the Share button.
Click on Embed.
Copy the <iframe>
code provided.
Paste it into your HTML page.
Width and Height: Control the size.
allowfullscreen
: Enables full-screen mode.
Add Parameters:
?autoplay=1
: Auto-plays the video.
?controls=0
: Hides controls.
?loop=1&playlist=VIDEO_ID
: Loops the video.
Example with Autoplay and Loop:
<iframe width="560" height="315"
src="https://www.youtube.com/embed/tgbNymZ7vqY?autoplay=1&loop=1&playlist=tgbNymZ7vqY"
frameborder="0" allowfullscreen></iframe>
Use a wrapper with CSS to make it scale on all devices:
<style>
.responsive-video {
position: relative;
padding-bottom: 56.25%;
height: 0;
overflow: hidden;
}
.responsive-video iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
</style>
<div class="responsive-video">
<iframe src="https://www.youtube.com/embed/tgbNymZ7vqY" frameborder="0" allowfullscreen></iframe>
</div>
Q1. Embed a YouTube video using the <iframe>
tag.
Q2. Set a video size to 800px width and 450px height.
Q3. Enable fullscreen for the video.
Q4. Make the video autoplay on page load.
Q5. Remove controls from the video player.
Q6. Embed a YouTube video with looping enabled.
Q7. Make the embedded video responsive using CSS.
Q8. Display multiple YouTube videos on one page.
Q9. Use a YouTube embed code copied from the YouTube site.
Q10. Use the title
attribute to describe the embedded video.
Q1: Which HTML tag is used to embed a YouTube video?
Q2: What attribute allows fullscreen playback of a YouTube video?
Q3: What YouTube feature adds the video player’s ability to autoplay?
Q4: How do you loop a YouTube video in embed?
Q5: Where can you find the embed code for a YouTube video?
Q6: What does frameborder="0" do in an <iframe>?
Q7: What tag wraps a responsive YouTube video layout using CSS?
Q8: What parameter hides the YouTube player controls?
Q9: Which CSS technique is used to make YouTube embeds responsive?
Q10: Which attribute is used to describe the iframe content for accessibility?