##-- google adsense --##
My WorkWeb/Tech

Embedding YouTube Videos as Valid XHTML 1.0

By February 22, 2009 No Comments

If you’ve ever validated an otherwise XHTML 1.0 compliant website that embedded a video from YouTube, you’ve probably seen validation errors related to YouTube‘s use of the <embed> tag, which has been deprecated in XHTML 1.0.

If you’re looking to embed a YouTube video in your website’s code and want to retain your validity, instead of using their suggested format:

<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/7_6B6vwE83U"></param><embed src="http://www.youtube.com/v/7_6B6vwE83U" type="application/x-shockwave-flash" width="425" height="350"></embed></object>

Use the following format:

<object type="application/x-shockwave-flash" style="width:425px; height:350px;" data="http://www.youtube.com/v/7_6B6vwE83U"><param name="movie" value="http://www.youtube.com/v/7_6B6vwE83U" /></object>

You’ll notice that the new format leaves out the <embed> tag and still functions correctly when embedded in your web page.

Props to the K2 Community Forums for pointing me to the Spanish explanation of this technique.

Share
%d bloggers like this: