Youtube videos and XHTML

May 14th, 2006 Chris Posted in Uncategorized |

Youtube gives you a nice little snippet of code that allows you to embed a movie in your own webpage. (As I did below, with the X3 trailer). Unfortunately, the code they provide doesn’t validate as XHTML compliant. Luckily, there’s a pretty easy fix.

The code they give you:

<object width=”425″ height=”350″>

<param name=”movie” value=”http://www.youtube.com/v/OLTdN-BbOok”> </param>

<embed src=”http://www.youtube.com/v/OLTdN-BbOok” type=”application/x-shockwave-flash” width=”425″ height=”350″> </embed> </object>

You sould modify this code to look like this, keeping all the URLs the same:

<object data=”http://www.youtube.com/v/OLTdN-BbOok” type=”application/x-shockwave-flash” height=”350″ width=”425″>
<param name=”movie” value=”http://www.youtube.com/v/OLTdN-BbOok” /> </object>

Easy enough.

3 Responses to “Youtube videos and XHTML”

  1. You need to close your param tag, or else it still won’t validate.

  2. Good call. I validated it, then made a typo in my posting. Thanks for the heads up.

  3. Thanks for the code, btw! It works perfectly.