How to embed YouTube and Google Video without breaking validation!

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.


About C.K. Sample III

I am a father, a husband, a blogger, a parrot owner, a pug owner, and the VP of Technology/Engineering for Chaotic Moon. This site has no comments. If you want to talk to me, send me an @cksample on Twitter. If you like this post, feel free to send me a micropayment via Bitcoin.
This entry was posted in Blogging and tagged , , , . Bookmark the permalink.

120 Responses to How to embed YouTube and Google Video without breaking validation!

  1. film izle says:

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

  2. Joe says:

    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.

  3. I had no idea that you could break validation with a youtube embed. I sure am glad that I ran across this. I guess I need to spend more time in this blog!

    Thanks,
    Really!

  4. Ed says:

    Brilliant, cheers mate! time for a mass embedded vid editing session!

  5. Dan says:

    Hi, I tried this in Google groups and it strips the code – should this work in Groups, or only Google pages?

    Thanks!

  6. Vesko says:

    Thanks guys for your hard work. I've tried Ryans' code. It works with IE, Firefox, Opera. Can you please, tell me other browsers about…Finaly I fixed that mess. Here it is at http://www.jewelry-engraver.com

  7. Guillaume says:

    this is the you tube valid embedding code

  8. I also though all the coding to embed videos is a little excessive, alot of the tags are repeated and not needed

  9. thank grice nice

  10. hdtv antenna says:

    Everything seems to be working just fine!

  11. kualahoo says:

    I don't see the reason why you have to go through that. The embed code is good enough.
    what''s new with this code? am I missing something?!

  12. tony says:

    thanks for that info m really good

  13. loyal fan says:

    I go along with everything you say. Which was? Huh?

  14. Israel says:

    Can you plaese give a valid xhtml with full screen option?

    Thanks helena.

  15. Pingback: YouTube Embed with Valid W3C Markup | Articles and Tutorials

  16. Thanks mate, works like a charm. I was searching to solve this for a while !

  17. Kagero says:

    Thank you very much! It works perfectly!
    “This document was successfully checked as XHTML 1.0 Strict!” : YESS

  18. Joseph says:

    Awesome! Thanks!

  19. Radi says:

    Full screen dosen’t work =(

Comments are closed.