| Coding Tutorials
Add Responsive YouTube and Vimeo Videos to Any Website

YouTube, Vimeo and other video hosts make it easy to embed their players in your own website.

However, Youtube, Vimeo and others don't provide responsive videos by default.

In this short tutorial, we'll show you how to make YouTube, Vimeo and other videos responsive in your website, using just a few lines of CSS.

EmbedPress - WordPress Embed Facebook Embeds If you're using WordPress, we highly recommend you check out the EmbedPress plugin. You can create responsive YouTube and Facebook video embeds, using just the URL.

Download EmbedPress

Step #1. Get the YouTube Embed Code

  • Go to Youtube.
  • Find the video you want to use on your website.
  • Click on Share >> Embed >> Right click and copy the HTML code.
responsivevideos 1

Step #2. Use the Embed Code

Paste this embed code in your website. It will look similar to this:

    <iframe width="420" height="315" src="/
" frameborder="0" allowfullscreen></iframe>

Step #3. Modify the Embed Code

Add a div tag around the embed code. Use the CSS class video-responsive so that your code now looks like this:

<div class="video-responsive">
    <iframe width="420" height="315" src="/
" frameborder="0" allowfullscreen></iframe> </div>

Step #4. Add the CSS

Now add some CSS properties inside one of your stylesheet files:

.video-responsive iframe{

Your videos now will be responsive. Try resizing your browser to see it in action.

This same process works for Vimeo videos and any other service that uses an iframe tag.

About the author

Valentín creates beautiful designs from amongst the tequila plants of Jalisco, Mexico. You can see Valentín's design work all over this site and you can often find him helping members in support.