How to embed YouTube and Google Video without breaking validation!

by C.K. Sample III on 9/10/2006 · 119 comments

in Blogging

So, here’s the code for either one:

<object type="application/x-shockwave-flash" data="[INSERT VIDEO URL FROM EMBED CODE PROVIDED HERE]" width="400" height="326"><param name="movie" value="[INSERT VIDEO URL FROM EMBED CODE PROVIDED HERE]" /><param name="FlashVars" value="playerMode=embedded" /></object>

Took a while to figure out, but it works. I originally tried the code mentioned in this article, but it kept breaking my site, so I trimmed it all down to the bare essentials. This works for me and my template. Let me know if it does / doesn’t work for yours in the comments. w00t!

UPDATE: Great post from Ryan over at Hapless band of staff and regulars, where he tweaks my code slightly to avoid YouTube upscaling of the video. Check it out.


Related posts:

  1. How to embed Blip.tv videos without breaking validation!
  2. Embedding YouTube and Google Videos Without Breaking Validation Revisited
  3. Facebook embedded video kicks YouTube’s ass


Advertisements:


{ 28 trackbacks }

tech.no.philia | random musings, but mostly on technology » Blog Archive » The Two Easiest Ways to Embed Videos in WordPress
9/20/2006 at 1:39 pm
Random Insights » Blog Archive » links for 2006-09-23
9/23/2006 at 8:23 am
Embedding Video without XHTML Transitional Validation Errors at Amy Stephen
10/29/2006 at 11:52 pm
Murdoc Online
11/13/2006 at 1:49 pm
Michiblogger
11/13/2006 at 1:53 pm
After the Net » Blog Archive » links for 2006-12-23
12/27/2006 at 6:26 am
eternos.org
2/7/2007 at 3:50 pm
Adding Youtube or Google Video to Blogs at Bee Hive
3/2/2007 at 8:07 pm
tenthofjune
3/9/2007 at 4:47 am
TenthOfMarch.com » Blog Archive » Sucker For Perfection
3/9/2007 at 11:36 am
TenthOfMarch.com » Blog Archive » Tutorial: How to embed flash video in your blog without breaking validation
3/10/2007 at 10:26 am
Sample the Web — Someone wrote up a step by step tutorial…
3/10/2007 at 10:31 am
Блокнот » как красиво встроить YouTube видео в сайт
4/11/2007 at 8:21 am
Tom Cobbaert .eu » Validation
5/10/2007 at 7:15 am
Nida in the parra » Blog Archive » Validando el código de YouTube
5/20/2007 at 2:03 pm
Capitano Uncino » Archivio Blog » Validare il codice di YouTube e simili
9/25/2007 at 8:18 pm
Jake Kasprzak Online › Link to YouTube Video Pages from Embedded YouTube Videos
9/30/2007 at 5:02 pm
XHtml Doğrulamasından Geçebilen Youtube Embed Kodu | Açık kaynak ve kişisel tecrübeler
10/21/2007 at 5:08 am
YouTube Kodları XHTML Doğrulamasından Geçsin - Teknobaz
11/4/2007 at 7:57 pm
Embeding YouTube and Google Video without breaking validation « The Official MartinZ Blog
11/18/2007 at 11:27 am
How to embed Blip.tv videos without breaking validation!
12/2/2007 at 4:28 pm
Make It Up As You Go » Blog Archive » How to Embed YouTube and Google Video with Valid Code
1/11/2008 at 12:02 pm
YouTube & WordPress ist auch eine Zumutung at blog.gauner.org
2/15/2008 at 9:32 am
YouTube Enabled? : a8le.com
2/16/2008 at 12:48 pm
Where does my time go? | lifepassedby.com | Starting again
3/5/2008 at 12:00 am
How to embed YouTube videos directly into your webpage without breaking validation
3/6/2008 at 10:55 pm
Embedding YouTube and Google Videos Without Breaking Validation Revisited | Sample the Web
5/10/2008 at 10:45 pm
YouTube Embed with Valid W3C Markup | Articles and Tutorials
10/19/2009 at 6:11 pm

{ 91 comments… read them below or add one }

1 PhotoFiltre Studio 5/31/2008 at 1:47 am

hey, great work, thanks

Reply

2 Rob C 6/28/2008 at 3:07 am

Thanks for the quick fix.

Reply

3 çocuk oyunları 7/3/2008 at 7:42 am

thanks for fix

Reply

4 bearshare 7/9/2008 at 3:30 am

thanks, great work

Reply

5 oyun 7/15/2008 at 4:57 am

thanks alot

Reply

6 oyunlar 7/15/2008 at 4:58 am

merhaba ho? geldiniz te?ekkürler

Reply

7 kral oyun 7/15/2008 at 4:59 am

thanks

Reply

8 oyun 7/26/2008 at 2:10 pm

Thanks so much.

Reply

9 toner 8/3/2008 at 5:08 pm

Thanks a lot.

Reply

10 3rbsc.com 8/8/2008 at 8:04 pm

thx alot

Reply

11 kartu? 8/11/2008 at 6:14 pm

Thanks for that. Your method validates in XHTML 1.1 and that’s the one I needed.

Reply

12 aljuk 8/25/2008 at 2:53 pm

OMFG! Thankyou SO much!

Reply

13 Thomas 8/30/2008 at 11:54 pm

will google adsense ban me if i paste youtube videos in my site?

Reply

14 c.k. 9/4/2008 at 5:18 am

Thomas,

No. YouTube is owned by Google, so it’s all good.

Reply

15 North Cyprus Holiday 9/26/2008 at 4:00 pm

Your web site is really nice if we think the others
I think you had worked about that web site, hardly.
Like I see. Thank you for information tht i get.

Reply

16 hikaye 9/27/2008 at 10:56 am

Yes Thats is a good idea

Reply

17 diyet 10/2/2008 at 4:03 am

ty

Reply

18 Dizi izle 10/19/2008 at 5:50 am

No. YouTube is owned by Google, so it’s all good.

Reply

19 simon bullock 11/6/2008 at 2:39 am

Another awesome way to embed video is to use VideoSwiper a web 2.0 online application that can mass populate your websites and wordpress blogs with niche targeted video content. The application also allows you to edit the embed codes title, description and tags before posting it to your website to keep the content unique.

http://www.videoswiper.com

Reply

20 Tony Oravet 11/7/2008 at 7:42 am

This worked great! Thanks so much! IE can be such a pain sometimes!

Reply

21 hdtv antenna 11/11/2008 at 4:12 pm

For some reason I have the hardest time ever when dealing with this type of code. Still learning though!
Thanks for the article

Reply

22 sohbet 11/11/2008 at 7:20 pm

Thank you
sohbet

Reply

23 sohbet 11/11/2008 at 7:21 pm

Another awesome way to embed video is to use VideoSwiper a web 2.0 online application that can mass populate your websites and wordpress blogs with niche targeted video content. The application also allows you to edit the embed codes title, description and tags before posting it to your website to keep the content unique.

Reply

24 film izle 11/21/2008 at 7:19 pm

I had the same problem but that did the work! great.

Reply

25 Joe 11/23/2008 at 6:41 am

Thanks a lot I’ve been trying to get this to work on an script it was able to remove all errors except one.

Duplicate specification of attribute “class”.

…alue=”" size=”22″ tabindex=”1″ class=”styled” />

You have specified an attribute more than once. Example: Using the “height” attribute twice on the same “img” tag.

Reply

Leave a Comment

Previous post:

Next post:

Note: If you are an iPhone application developer and you would like me to review your app, please see this post. If you liked this post, consider subscribing to my feed in the RSS reader of your choosing, following me on Twitter, or subscribing to my YouTube channel.
My Artwork for sale on Etsy