Toggle navigation
☰
HTML
CSS
Scripting
Database
<!DOCTYPE html> <html> <head> <title>Responsive YouTube Embed Example</title> <style> .video-container { position: relative; width: 100%; /* 16:9 Aspect Ratio */ aspect-ratio: 16 / 9; } .video-container iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } </style> </head> <body> <h2>Responsive YouTube Embed</h2> <p>Resize your browser window to see the video scale while maintaining its 16:9 aspect ratio.</p> <div class="video-container"> <iframe src="https://www.youtube.com/embed/Y2mNQ3adNKw?si=KQt2O0lOHYgSv98K" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe> </div> <p>The container uses <code>aspect-ratio: 16 / 9;</code> to maintain the correct proportions, and the iframe follows the container's width and height.</p> </body> </html>