Embed YouTube videos with XHTML 1.0 Strict code
Being a bit of a web geek, I like to keep my sites running in Strict mode for whatever HTML/XHTML version I happen to be working in. So, I was saddened to discover that the Embed code that YouTube gives doesn’t pass XHTML 1.0 Strict, due to their use of the now deprecated embed tag. Happily, there’s a way to fix this. As a bonus, the code required is much nicer than the code YouTube gives you:
<object type="application/x-shockwave-flash" style="width:480px; height:385px;" data="http://www.youtube.com/v/p1QMoQ3jbjc">
<param name="movie" value="http://www.youtube.com/v/p1QMoQ3jbjc" />
</object>You just need to replace the two URLs with the one for your video, and set the appropriate width/height. YouTube’s defaults are 320×265, 425×344, 480×385 and 640×505.
There you have it! It’s a simple as that. And to prove it works, here’s the same code from above:
Comments
2 Responses to “Embed YouTube videos with XHTML 1.0 Strict code”
Leave a Reply



Thanks for posting this code. It works perfectly, and was exactly what I was looking for.
THANK U EXCELLENT