HTML YouTube Videos

HTML Tutorial

HTML YouTube Videos

You can embed HTML YouTube Videos directly into your web page using the <iframe> tag. This allows visitors to watch videos without leaving your site.


Basic Syntax


 

  • Replace VIDEO_ID with the unique ID of the YouTube video.

  • width and height → Video size on your page.

  • allowfullscreen → Allows full-screen mode.

  • allow → Permissions for autoplay, clipboard, and other features.


Example HTM YouTube Videos


 


Responsive YouTube Video

To make the embedded video responsive on all devices:


 

  • padding-bottom: 56.25% → Maintains 16:9 aspect ratio.

  • width: 100%; height: 100% → Makes video scale with screen size.


Key Points

  • <iframe> is the standard way to embed YouTube videos.

  • Always use responsive containers for mobile-friendly pages.

  • You can control autoplay, controls, loop, and start time using YouTube URL parameters:

    • ?autoplay=1 → Auto-start video

    • ?start=30 → Start at 30 seconds

    • ?controls=0 → Hide controls

You may also like...