Responsive embed code
<div style="position:relative;aspect-ratio:16 / 9;width:100%;overflow:hidden;"> <iframe src="https://www.youtube.com/embed/dQw4w9WgXcQ" title="Featured creator video" loading="lazy" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen style="position:absolute;inset:0;width:100%;height:100%;border:0;"></iframe> </div>
Copy the complete HTML block into a page that permits iframe embeds.
Share links include only numbers and choices. Local saves remain in this browser until you delete them.
Saved on this device0 of 6 saved
Save a fresh result to compare or reuse it later on this device.
Formula or method
Responsive wrapper + youtube.com/embed/video-id iframeAssumptions
- Only public, embeddable videos will play.
- The generated iframe uses lazy loading and a descriptive title.
How to use the responsive embed
Generate a responsive YouTube iframe wrapper from a valid video URL or ID. The code preserves an aspect ratio, includes a descriptive title, and uses lazy loading so the embed can fit modern page layouts without fixed desktop dimensions.
Verify the code with a real public video
Paste a YouTube watch, Shorts, youtu.be, or embed URL and provide an accessible title that identifies the video. Copy the complete wrapper into a page that permits iframes, then test at narrow and wide widths to confirm the player resizes without overflowing its container.
The generator accepts only recognized YouTube hosts or a valid 11-character ID. It escapes the title attribute and does not paste arbitrary URL parameters into the iframe, reducing accidental malformed or unsafe markup.
Review accessibility, consent, and site policy
The iframe title should describe the embedded video, not repeat generic text such as video player. Provide nearby context or a transcript when the video carries essential information, and confirm keyboard access and captions in the final page.
Embedding loads a third-party player and may require consent or vendor disclosure depending on configuration and region. Use the privacy-enhanced generator when appropriate, review the destination site's Content Security Policy, and never treat responsive sizing as a privacy guarantee.
Questions about this tool
Why is my YouTube video not playing in the embed?
The video must be public or otherwise embeddable, the ID must be valid, and the destination site must allow YouTube frames in its security policy.
What should the iframe title say?
Use a concise description of the specific video, such as the published title or its purpose on the page, so assistive-technology users can identify the frame.
Does lazy loading prevent all third-party requests?
No. It generally delays loading until the frame approaches the viewport. Consent and privacy behavior still depend on the player, browser, site configuration, and region.