a novelty choking hazard

YouTube embed code does not validate

I’ve just run the front page of the blog through the W3C validator, and discovered that although my own code is cool, the page won’t validate as long as there’s a YouTube embedded movie on here, because “embed” is not, in the view of the W3C, an element, even though it’s now supported in most browsers. It happens that this post will actually knock the last post of that nature off the front page, which I’m confident will be valid again. Yo.
It’s late and I’m tired, but maybe tomorrow I’ll look further into this. I expect that if the YouTube code is invalid, someone must have noticed, like a year ago. There would have been some outcry, somewhere.
It strikes me that the smart-alecky thing to do now – assuming for the moment that it isn’t possible to embed YouTubes with valid code, which I doubt, actually – would be to wrap the Valid buttons (in the meta links section of the sidebar) in a script which displays them providing there is no YouTube present… understanding that when I said “now” just then, I didn’t mean now
(UPDATE: as I suspected, the problem has been solved already. Replace YouTube’s embed spew with either:

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

or:

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

where n is the ID number of the relevant YouTube video. Thanks to this post and comments on Bernie Zimmerman’s blog. Now, what would it cost YouTube to amend their scripts to produce valid code in the first place?)

Posted in Dev | Tagged , , , , , | 9 Comments

9 Responses to YouTube embed code does not validate

  1. simon says:

    hi i real want to know the code for yotube

  2. 411 New York says:

    We believe YouTube (owned by Google) won’t fix it as it will cause problems with FireFox (which defaults to Google Search).

    If it was the other way around, we feel it would be done in a heart beat but that is just just.

    Can you blame them?

    Hopefully, your tis will work for our home page at http://www.411newyork.org or we will be back to rant. :)

  3. Mike Lee says:

    Hey, thanks for the code! I was annoyed that my site stopped validating when I embedded a video.

  4. 411 New York says:

    Well, It’s working okay but we made one change. We changed [ width="425" height="350" ]to [ style="width:425px; height:350px;" ] then made it smaller (by 50%) to fit on our page.

    Thanks! We’ll link to your site as a thanks.

  5. Dan says:

    Thanks for this helpful tip. It made all the difference in my code validating as HTML 4.01! (My posted website is in development.)

  6. 411 New York says:

    Update. Playlist is also availabe.

    data="http://www.youtube.com/p/XXXXXXXXXXXXXXXX

    The ‘v’ is replaced by a ‘p’ and the playlist id is added.

  7. Pingback: YouTube and Vimeo embed code will not validate « OneBigMug

  8. Pingback: Valid code for YouTube embedding « pxlcr – design and development notebook

  9. Achmad Sobary says:

    It is pleasing to look you express from the heart and your clarity on this significant content can be easily looked.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>