Validating YouTube Embed Code
You are the validation freak or not (but you just want to have xhtml valid page) and every time you embedding some YouTube videos, you don’t want to brake validation? Problem is EMBED tag which don’t pass xhtml validation. You need to remove it and you can do it on this way…
Take the embed code YouTube gives you:
1 2 3 4 5 6 7 | <object width="425" height="344"> <param name="movie" value="http://www.youtube.com/v/neV8bEotgZ0&hl=en&fs=1"></param> <param name="allowFullScreen" value="true"></param> <param name="allowscriptaccess" value="always"></param> <embed src="http://www.youtube.com/v/neV8bEotgZ0&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"> </embed> </object> |
And copy the value parameter
http://www.youtube.com/v/neV8bEotgZ0&hl=en&fs=1
instead of INSERT HERE
1 2 3 4 5 | <object type="application/x-shockwave-flash" data="INSERT_HERE" width="425" height="344"> <param name="movie" value="INSERT_HERE"></param> <param name="allowFullScreen" value="true"></param> <param name="allowscriptaccess" value="always"></param> </object> |
So you get code like this:
1 2 3 4 5 | <object type="application/x-shockwave-flash" data=" http://www.youtube.com/v/neV8bEotgZ0&hl=en&fs=1" width="425" height="344"> <param name="movie" value=" http://www.youtube.com/v/neV8bEotgZ0&hl=en&fs=1"></param> <param name="allowFullScreen" value="true"></param> <param name="allowscriptaccess" value="always"></param> </object> |
You can adjust your width – height in needed proportion (if source video is 16:9 or 4:3 then your new size must have same proportion. Notice that according to xhtml 1.1 width and height attributes are allowed for OBJECT tag.
If you are using Opera browser, then you can download Video Validation Widget, which easily convert embed codes from next video sites (YouTube, Dailymotion, GoogleVideo, YahooVideo, Hulu, Revver, Brightcove, Veoh, Metacafe, Libero, Megavideo, Deezer).
No related posts.
Thanks for the great tip! I’ll have to remember to do this when I start embedding videos in my site (no not the contest one another site
Comment by SULUMITS RETSAMBEW — March 21, 2009 @ 5:30 am
You are the validation freak or not (but you just want to have xhtml valid page) and every time you embedding some YouTube videos, you don’t want to brake validation?
Comment by seamless steel pipe — February 22, 2010 @ 9:34 am