YouTube's shiny new HTML5 embed code is now live
Most of you have probably embedded a YouTube video at one time or another, even if it's just to share it on Facebook. Because copying and pasting is so easy, you might not have paid much attention to the embed code itself, though. Well, now's a good time to start looking, because YouTube is changing to a shorter, more compatible embed code, using the <iframe> tag. What does that mean to the average YouTube user? Well, for one thing, the new code adapts to users' viewing environments, serving HTML5 or Flash videos depending on your browser and settings. It's also a big step toward showing embedded YouTube videos on mobile devices that don't have a dedicated YouTube player.
If you want to try out this enhanced embedding capability on your own site, you can just copy-paste this block of code, and fill in the video ID for the video you want to embed:
<iframe class="youtube-player" type="text/html" width="640" height="385" src="http://www.youtube.com/embed/VIDEO_ID" frameborder="0">
</iframe> 











Comments
7
Subscribe to commentsstinlen56Jul 26th 2010 4:06PM
iframe seems like a dumb way to go. It is blocked by default in too many corporations even when flash embeds are not.
Good JobJul 27th 2010 1:36PM
php proxy...
stinlen56Jul 27th 2010 2:01PM
It's not blocked for me, it's blocked for plenty of people I know in corporate environments. Too much hassle to educate them all.
Doug BJul 26th 2010 4:30PM
I thought iframe was depreciated and not a good code to use due to popups and spam?
J5892Jul 26th 2010 5:34PM
A rather interesting typo.
In the first paragraph you wrote "Facebook" instead of "YouTube"...
Jay HathawayJul 26th 2010 5:42PM
Thanks for the catch. I guess it was because I had just written a post about Facebook, and then mentioned Facebook sharing. I have social networking on the brain!
Anyway, I made the correction. Gracias!
JayenkaiJul 27th 2010 1:02AM
lol
iframe
Here comes the 90s!
To be fair, there weren't a whole lot of routes they could go with this.