Skip to content
T
Tools.Town
Free Online Tools for Everyone
Youtube Tools

YouTube Embed Code: Responsive iframe Guide

How to build a responsive YouTube iframe, which URL parameters control autoplay and privacy, and when to use youtube-nocookie.com.

24 June 2026 4 min read By Tools.Town Team Fact Checked

Key Takeaways

  • Modern browsers block autoplay with sound to protect users
  • It is YouTube's privacy-enhanced embed domain

The minimal embed

Every YouTube embed is an iframe pointing at:

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

Replace VIDEO_ID with the part after watch?v= or youtu.be/. Add title, allowfullscreen, and an allow attribute for modern permissions.

Make it responsive

Fixed width and height break on mobile. Wrap the iframe in a 16:9 box:

<div style="position:relative;padding-top:56.25%;height:0;overflow:hidden">
  <iframe style="position:absolute;inset:0;width:100%;height:100%;border:0"
    src="https://www.youtube.com/embed/VIDEO_ID"
    title="YouTube video player" allowfullscreen></iframe>
</div>

The 56.25% padding is 9÷16 — the widescreen aspect ratio.

Useful query parameters

ParameterPurpose
autoplay=1Auto-start (needs mute=1)
mute=1Start muted
start=90Begin at 90 seconds
loop=1&playlist=VIDEO_IDLoop single video
controls=0Hide controls
rel=0Fewer off-channel suggestions

Join parameters with & after ?.

Generate code in one click

The YouTube Embed Code Generator parses your URL, applies toggles, and outputs copy-paste HTML with a live preview — all client-side.

SEO note

Embedded videos can increase time-on-page when the content matches search intent. They do not replace good titles, descriptions, or canonical URLs on your own page — see the Canonical Tag Generator if you syndicate content across domains.

Advertisement

Try YouTube Embed Code Generator — Free

Apply what you just learned with our free tool. No sign-up required.

Try YouTube Embed Code Generator

Frequently Asked Questions

Why does autoplay require mute?
Modern browsers block autoplay with sound to protect users. If you set autoplay=1, also set mute=1 or the video will not start automatically.
What is youtube-nocookie.com?
It is YouTube's privacy-enhanced embed domain. Cookies are deferred until the viewer interacts with the player — useful for GDPR-conscious sites.

Was this guide helpful?

Your feedback helps us improve our content.

Get the best Youtube Tools tips & guides in your inbox

Join 25,000+ users who get our weekly youtube tools insights.