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 thoughts on “Valid XHTML YouTube Embedding”

  1. I’m not completely sure if it was an update to newer version of WordPress or Veryplaintext (I did both at the same time), but I changed <p>…</p> to <div>…</div> and page formatting problems were corrected.

  2. 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.

Comments are closed.