Valid XHTML YouTube Embedding

I was checking validation on my pages and found the only XHTML errors were from the suggested YouTube embedding code. A quick search revealed several XHTML valid code examples, and here is what I am using to center the frame under XHTML 1.0 Transitional (this fails 1.0 Strict validation – to make this validate under Strict, just remove align=”center”..):

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

Update:
I am now using div’s to solve page formatting issues..:

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

4 responses to “Valid XHTML YouTube Embedding”

  1. Matthew

    Thanks, I used this to fix the errors on my site.

  2. mahud

    Thanks for the valid code. I had no idea that the code YouTube provided was invalid.

  3. sg

    hi, thanks for this. I used it to fix my code which also includes borders and related videos (obtained via youtube’s “customise embed” option).

    This is what I did, and it validates fine to xhtml 1.0 transitional.

Leave a Reply