Wednesday, July 8, 2026

HTML YOUTUBE | HTML YOUTUBE VIDEOS

HTML YouTube

HTML can be used to add YouTube videos to a webpage using the <iframe> element. This allows a YouTube video to be displayed directly on a website.

Embedding a YouTube Video

<!DOCTYPE html>
<html>
<head>
    <title>YouTube Video</title>
</head>
<body>

<h2>My YouTube Video</h2>

<iframe width="560" height="315"
src="https://www.youtube.com/embed/VIDEO_ID"
title="YouTube video player"
frameborder="0"
allowfullscreen>
</iframe>

</body>
</html>

Explanation:

  • <iframe> – Embeds external content, such as a YouTube video.
  • src – Contains the YouTube video URL.
  • width and height – Set the video size.
  • allowfullscreen – Allows the video to play in full-screen mode.

Example:

If a YouTube video link is:

https://www.youtube.com/watch?v=dQw4w9WgXcQ

The embed URL becomes:

https://www.youtube.com/embed/dQw4w9WgXcQ

and is placed inside the src attribute.

YouTube Video with Options

<iframe 
width="560" 
height="315"
src="https://www.youtube.com/embed/VIDEO_ID?autoplay=1&mute=1"
allow="autoplay">
</iframe>

Common options:

  • autoplay=1 – Starts the video automatically.
  • mute=1 – Starts the video without sound.
  • loop=1 – Repeats the video.

Summary: HTML uses the <iframe> tag to embed and display YouTube videos on web pages.

No comments:

Post a Comment