Skip to content


Youtube video embed responsive code

youtube video embed responsive code

If you're embedding videos from Youtube or Vimeo, you might find that they don't Paste this snippet into Settings > Code > Javascript. Bootstrap embeds is a utility which helps you to insert a video or slideshow in the page keeping width of the parent and scales on any device. Add CSS Classes for Responsive Video. 1: Grab the embed code from your video provider (we recommend Wistia but you can use YouTube, Vimeo, or.
youtube video embed responsive code

Easily embed Responsive YouTube Videos with Tailwind CSS

How To Embed YouTube Video In WordPress

This is image title

Everyone knows that video is now becoming an essential tool for digital marketing strategy. According to the statistics, over million hours are watched on YouTube every day. YouTube is the 2nd largest search engine in the world. Embedding a video on WordPress helps to enhance the SEO too.

Embedding YouTube Videos is a fantastic way to increase the engagement of website visitors. Adding a video on WordPress has several ways. This blog will explain the most effective and easiest methods to embed YouTube videos on your WordPress website.

Let’s take a quick tour now & embed the videos.

1. Using The OEmbed Method
It is the easiest method to embed the youtube video embed responsive code, texts, and many more by entering just the source URL of it that you want to embed.

Here are some basic steps to embed the YouTube video:

A) Open a YouTube & Find the Video that you want to add to your website.
B) Copy Video URL.
C) Now, Just Go to WordPress Visual Editor and Paste the URL.
D) After that WordPress embed the video automatically.

This is image title

Note: Make sure that you mentioned the video or playlist URL. Do not insert the URL of any YouTube channel.

2. Using An Iframe Method
Iframe Method is mostly used when a user wants more flexibility while embedding a video on the WordPress website. It requires some technical knowledge, but not difficult.

The oEmbed method doesn’t allow any customizations nor you can disable the video’s player controls. For that, the Iframe method is used. It gives many options of customization such as autoplay, captions, privacy settings, full screen, player controls, and so on.

This is image title

You can embed the video in the succeeding ways:
A) Click the Share button.
B) From the popup box, click on the Embed.
C) Here, you’ll get the various options to customize the video like from where you start your video, player controls, privacy enabled mode, etc.
D) After customizing, just copy the code & go to the visual editor.
E) Change Visual Editor to Text Editor and paste the code to add the video.

3. Adding YouTube Videos To WordPress Pages & Posts
The above-mentioned methods are quite common for every online website. Adding YouTube Videos on WordPress pages or posts is quite easy on the WordPress block editor.

WordPress comes with the auto-embed feature. You just need to copy the URL and edit the page and paste the URL where you want to showcase it. Moreover, WordPress comes with certain media settings such as alignment, full-width, aspect ratio, captions, youtube video embed responsive code many other things. But WordPress supports certain white-listed platforms which are YouTube, Vimeo, Giphy, Twitter, and so on. You can get a detailed list of white-listed platforms here.

4. Embedding Videos With Classic Editor
If you use a classic editor for a WordPress website, then embedding the video is just the same as a block editor. Just paste the URL and you’ll get the video on your page or post. But, the point is classic editor doesn’t support the additional setting options that you get on the block editor.

5. Add Videos In Sidebar

  • After the WordPress version, there’s a new video widget that makes it easier to embed the youtube video embed responsive code in the sidebar.
  • To add the video, just need to navigate Appearance >> Customize. And, click on Widgets.
  • If you’ve multiple youtube video embed responsive code areas then just find out the sidebar where you want to showcase the video and click on the Add Widget.
  • From the search box, search for the video widget and click on it. Click on the Add Video button and paste the Video URL into the box. And after that, you’ll be able to see the preview of the video.
  • Click on the Add to Widget button and don’t forget to click to save. And publish it.

Read More

#best way to embed video in wordpress #embed video in wordpress #embed youtube video in wordpress #embedding videos in wordpress #how to embed video in wordpress #how to embed video in wordpress website


Making embedded YouTube videos (1) responsive, (2) accessible, and (3) less YouTube-looking

Today I've learned how to embed a YouTube video on web pages that I'm designing so that it is responsive, accessible, and as little YouTube-looking as possible.

As always with web development, relevant pieces of information are scattered around on the web. Let me put everything together here for future reference.

Make it responsive

If you just copy the embed code from YouTube such as this one:

its width won't change according to the screen width.

A quick solution (in the context of React) is provided by bravemaster (). It is an application of the well-known technique of keeping the aspect ratio with (Koblentz ; jose luis hernandez also Coyier ).

To this solution, I would add the correction of and attributes, to remove any letterbox or pillarbox frames around the video. The pair of values provided by YouTube may not reflect the actual aspect ratio of the video, especially if the video is an old one with the aspect ratio With MacOS, you can measure the original video screen width and height with screen capture: pressing cmd + shift + 5 (Apple ) and drag the box that shows the width and height values.

In the above example, the actual video size is x By using this pair of youtube video embed responsive code, the black columns on both sides disappear.

Revise the attributes

To figure out what all those attributes mean, refer to MDN (a). But don't follow its advice that we replace the deprecated attribute of with the use of CSS to control the width of borders. Removing attribute will draw a rather thick border around the embedded video. Keep it as it is.

To understand the attribute value ofsee MDN (b).

The attribute is for accessibility (MDN a). Replace its value with the description of the embedded video.

Customize the appearance of YouTube video player

Google Developers () provides how to embed YouTube videos on web pages (in case you forgot as I did, Google owns YouTube since NBC News ).

By adding a query string to the end of the video URL, you can customize the appearance of YouTube video player up to some extent. I would go with this:

  • : hides the fullscreen button.
  • : hides YouTube's logo.
  • : prevents iOS from playing the video full-screen.
  • : shows the related videos only from the same channel (i.e. the YouTube user who uploaded the video to be embedded) when the video ends or when the user stops the video. By default, YouTube will show the videos related to the user's recent video-watching behaviour, which may be completely irrelevant to the content of your website.

In addition, will hide the progress bar and the stop button while playing the video. But this is not recommended as the user is likely to have no clue how to stop the video. I don't think many people know the answer is to press the Space key (or you can add this instruction below the embedded video).

That's the best we can do to make the embedded video look less like part of YouTube. We cannot remove the video title to be shown: the parameter was deprecated in

The definition of these and other parameters has been quite frequently changed in the past. Always refer to the latest edition of Google Developers (), rather than relying on articles written by someone in the past.

JavaScript solutions

Instead of usingyou can use JavaScript to embed YouTube videos. Google Developers () and Agarwal () show how. The latter hotels near tiaa bank field jax it reduces the amount of data downloaded before playing the video. If the speed of loading your website is a real concern, it may be worth checking it out.

I myself didn't try, because I'd rather not use JavaScript if HTML/CSS alone can do the job.

Hope this quick note helps you embed YouTube videos smoothly on your website!


How to embed YouTube video in Bootstrap modal

Topic: Bootstrap / SassPrev Avex Designs

Tutorial on how to make Youtube videos responsive using CSS & HTML. Responsive Youtube embeds use iframes, CSS & HTML to make your Youtube videos responsive.

You May Also Like to Read:
Another example would be that if you go to YouTube and click share button and select Embed. It gives you a code, if you copy and paste it in your code editor you will see its wrapped around an iFrame Refresh the screen and you see the video is right on the iFrame, this is an external link For More Information Please Refer: You May Also Like to Read:

How to add responsive video to your website

The web design industry is evolving at a rapid pace. So, sometimes, we need to adjust our design and development techniques to account for new technologies.

Responsive web design (RWD) has become almost a necessity in our modern design process. While it's growing and maturing fast, it's still in its infancy.

Take video. You would expect that the embed codes we grab from YouTube or Vimeo would be responsive, just like our images. The code below is what YouTube provides for embedding videos into web pages; it's a pretty standard iframe.

But, if we put this markup into our HTML, the video will maintain a fixed width of px by px, regardless of the browser or device screen size. If we're working with native HTML5 video or an image, a simple fix would be to add the following CSS:

See the tutorial files for a working example. Here we're targeting the iframe with a width of % to span our container and a height of auto. If you try this for yourself, you'll notice that the video is full width, but the height doesn't follow the ratio. We can fix this with a simple, pure CSS solution.

First, we will need to wrap our embed code in an extra HTML element, as shown below. Add the following div container to your iframe.

Next, we add the following to our CSS file:

The video-container class that we wrapped around the iframe has some positioning and padding applied to it. Position relative will set the enclosed iframe, which is positioned absolutely, to the most relative parent container. We use padding-top to fine-tune the position our video where we need it to be, depending on the design.

The padding-bottom percentage is determined from the aspect ratio. If you divide nine by 16, you get %. You'll notice we're using padding-bottom, height: 0 and overflow: hidden. These are mainly Internet Explorer fixes, which will help our solution work across all browsers.

Now, we'll target the iframe, object and embed with the following:

Since we have positioned the frame to absolute, we will set top and left to 0. This will set the video to the top left corner of our container. You can tweak these settings to match your design.

Let's test our example and see the results. Refer to the tutorial files for a working example.

We now have a fully fluid YouTube video embedded in our responsive design. This solution will also work with Vimeo (although it hasn't been tested on other vendors' platforms). This is extremely effective, easily implemented and is also cross-browser-friendly.

JavaScript solutions

While our solution doesn't rely on JavaScript, there are other options that require the support of JavaScript. Todd Motto's is written in vanilla JavaScript. To get started, download it and add the JavaScript to your website.

Adding a fallback

Sometimes, users may have JavaScript disabled, especially on some mobile devices. A simple fallback would be the following:

Another popular JavaScript solution is, which is described as "a lightweight, easy-to-use jQuery plug-in for fluid width video embeds". FitVids was created by CSS-Tricks founder Chris Coyier and Paravel.

This will work the same way as Todd Motto's FluidVids, relying on JavaScript. For example:

The website says, "This will wrap each video in a and apply the necessary CSS. After the initial JavaScript call, it's all percentage-based CSS magic." FitVids currently supports YouTube, Vimeo,, Viddler and Kickstarter.

Add a custom video vendor

FitVids has an option to add a custom vendor. As detailed in the documentation, add the following to the JavaScript file:


Responsive web design is still growing and will continue to do so. As web designers and developers, we need to make sure our content is accessible across all platforms, operating systems, browsers and devices. Sometimes we need to go the extra mile to achieve this. Simple solutions, like the ones described in this youtube video embed responsive code, whether in JavaScript or CSS, are very easy to implement and make a huge difference to our users. As technology progresses, new easier-to-implement solutions will arise, or even be baked into vendors' products. Until then, we need to find workarounds. Every project is different, so the solution you choose will depend on your goals.

Words: John Surdakowski

This article originally appeared in net magazine issue


How to embed a responsive YouTube video into a website

If you&#;ve ever found yourself having to embed a YouTube video (or even worse, many YouTube videos) into any web page, highway service area near me you know how this seemingly simple operation can be very frustrating, and hindering the user experience. Let&#;s find out why.

The &#;classic&#; method (the one officially provided by YouTube) to embed a video is the usage of the iframe tag.
The code we all know looks something like this:

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

As short and easy to include as it is, you would be surprised to find out how many extra resources are loaded for each single video embedded through this method: between images, CSS and Javascript needed to render the YouTube player the web page must download more or less kb of data even before the user has a way to get to the video &#; not to mention that he may even decide not to watch it at all.

This translates into an inevitable expansion of the page loading time, especially when there is a need to upload more than one video or even a video gallery. And it is well known that a wait time of more than a second often leads users to leave the page before they have even viewed its content.

The Pingdom tool screen is more eloquent than ever:

Youtube pingdom

Files and resources called via iframe

Another huge problem generated by this type of embedding consists in the fact that the video uploaded via iframe tag is not mobile friendly, as the player will not adapt to the size of the user&#;s screen &#; having a fixed height and width, declared in the same iframe tag.
Have you ever tried resizing the browser window after including a YouTube video with this code?
You would soon realize how frustrating it is not being able to watch a video from your smartphone and seeing the page design completely messed up.

It goes without saying that these two problems are indisputably critical in terms of user experience and can really lead to a dizzying increase in bounce rate.
Fortunately, there is a much more effective method of incorporating videos from YouTube, created by Google&#;s Amit Agarwal: loading them asynchronously only if the user decides to click the play button and making the player totally responsive thanks to a few lines of CSS and javascript.
Let&#;s see how.

How to upload a YouTube video more efficiently

You have surely noticed that in some websites and social networks YouTube videos are displayed in a slightly different way: it is a workaround that allows you to avoid a direct embed (with the consequent loading of unnecessary resources ) and instead only youtube video embed responsive code a still image that serves as a preview of the video. The overlay icon of the &#;play&#; button makes it look as a player, and clicking on it actually loads the desired video.

Here is an example:

The code to achieve this result is slightly different from the classic one: the video is called up within a responsive div that will make the player mobile friendly, and the iframe will be loaded only when the user clicks on the play button.

1. Code to embed youtube video embed responsive code HTML

The HTML code to be pasted where you want the video to appear is as follows:

<div class="youtube-player" data-id="VIDEOID"></div>

Where instead of &#;VIDEOID&#; the ID of the video you youtube video embed responsive code to upload will be inserted. To get it, just take a look at the video URL: the id is the alphanumeric code that comes immediately after watch?v=.

As you see in the code, a fixed width and height are not established, as they will be calculated automatically through CSS and JS.

2. Javascript

The javascript code must be inserted immediately before the closing of the body of the page.
The function will scan the entire content of the page in search of embed codes for YouTube videos and automatically add the preview image and the onclick event that will actually make the real video appear in autoplay mode.

<script> (function() { var v = mynewextsetup.usmentsByClassName("youtube-player"); for (var n = 0; n <; n++) { var p = mynewextsetup.usElement("div"); mynewextsetup.usTML = labnolThumb(v[n]; mynewextsetup.usk = labnolIframe; v[n].appendChild(p); } })(); function labnolThumb(id) { return '<img class="youtube-thumb" src="//' + id + '/"><div class="play-button"></div>'; } function labnolIframe() { var iframe = mynewextsetup.usElement("iframe"); mynewextsetup.usribute("src", "//" + + "?autoplay=1&autohide=2&border=0&wmode=opaque&enablejsapi=1&controls=1&showinfo=1"); mynewextsetup.usribute("frameborder", "0"); mynewextsetup.usribute("id", "youtube-iframe"); mynewextsetup.useChild(iframe, this); } </script>

3. CSS

The last step to achieve the desired result is to include CSS, which will make the image and video perfectly adaptable to the width of the page, in addition to making the &#;play&#; button appear above the preview image.
Insert it in your stylesheet, or inline using the style tag.

.youtube-container { display: block; margin: 20px auto; width: %; max-width: px; } .youtube-player { display: block; width: %; /* assuming that the video has a ratio */ padding-bottom: %; overflow: hidden; position: relative; width: %; height: %; cursor: hand; cursor: pointer; display: block; } mynewextsetup.use-thumb { bottom: 0; display: block; left: 0; margin: auto; max-width: %; width: %; position: absolute; right: 0; top: 0; height: auto } { height: 72px; width: 72px; left: 50%; top: 50%; margin-left: px; margin-top: px; position: absolute; background: url("") no-repeat; } #youtube-iframe { width: %; height: %; position: absolute; top: 0; left: 0; }

Et voila! Through these three steps you can include any number of YouTube videos you want, by uploading only a very light preview image that will not affect the page loading speed.
Both the image and the iframe loaded after the click will be totally responsive.

How to use this embedding method on WordPress

For those who use WordPress and need to embed a YouTube video in a page or article, this operation may appear more difficult, due to the basic difficulty in including scripts in the WordPress footer.

Fortunately there is a plugin that allows you to do exactly that: OH Add Script Header Footer, specially designed to create a fast and immediate method of adding javascript code only to the desired page or post.
Once installed and activated, just open the WordPress editor on the article that interests us and scroll to the bottom of the page, where you will find a tab like this:
aggiungere script
Paste the script mills v board of education of the district of columbia the footer section, not forgetting to include the script tags, and you&#;re done.
In this way you will also avoid having to load javascript on all pages of the site, limiting it only to those that contain a YouTube video.


Related Posts


Do you need a responsive YouTube video embed code?

Post a Reply

A Areen

Therefore, we needed a responsive YouTube video embed code. One would think that videos that with % width would automatically resize to the surrounding container. Well, that is not the case. Surprisingly, Youtube does not automatically have a responsive embed code. The fix was actually quite simple. Here’s how to make a youtube video mobile:
For More Information Please Refer:

Responsive Youtube Embed
youtube video embed responsive code
youtube video embed responsive code


Leave a Reply

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