YouTube and standards — avoiding the illegal “embed” tag
Posted Friday, December 29th, 2006 at 11:45am by StephenThe other day I embedded a YouTube video in one of my blog posts, using the HTML code that YouTube provides on their site.
Trouble is, YouTube’s code uses the “embed” tag, which is not HTML 4 standards-compliant. There’s no such tag as “embed” (even though Firefox and IE know how to display it — but that’s a rant for another day).
I experimented a bit with trying to make it just an object instead, but wasn’t able to get the right parameters so that it would be embedded properly and use the flash player that YouTube provides.
Just now I ran across a post by Bernie Zimmerman that explains the trick. So now Zeigen’s Blog is once again valid HTML code and standards-compliant.
In case Bernie’s web site ever goes down, the trick is to use this HTML code instead of the junky invalid HTML code that YouTube provides:
<object type="application/x-shockwave-flash" style="width:425px; height:350px;" data="http://www.youtube.com/v/foo"><param name="movie" value="http://www.youtube.com/v/foo" /></object>
(where “foo” is replaced with the video’s unique code assigned by YouTube, found at the end of the URL for the video)
Why does this matter? Increasingly we use different types of browsers to read the World Wide Web — Treos, toasters, braille-readers, Opera, you name it. The W3C standards are the rules for how the Web works; if you play by the rules, then you can predict that most people should be able to read your page. YouTube doesn’t play by the rules. The end results of not playing by the rules are ultimately anarchy and chaos, my friend, anarchy and chaos.
I co-wrote a book on this sort of thing — woah, that’s coming up on 10 years ago.