HTML YouTube Videos

HTML YouTube Videos

You can embed 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 HTML Page with YouTube Video


 


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

CodeCapsule

Sanjit Sinha — Web Developer | PHP • Laravel • CodeIgniter • MySQL • Bootstrap Founder, CodeCapsule — Student projects & practical coding guides. Email: info@codecapsule.in • Website: CodeCapsule.in

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *