Creating valid xhtml strict code for embedded youTube videos

Embedded Flash objects, from HTML to valid XHTML Strict depreciated because Google changed their embedded formatting code for youTube videos.

The linked page above was once a tremendous resource. But unfortunately, whenever you rely on others and the code they produce things can change without any warning. Fortunately in this situation already used code is not broken as is sometimes the case, but you can no longer easily convert invalid code to valid using this once favored resource. So what is someone to do? Seek out new alternatives of course if you are still interested in maintaining valid code while using all the neat bells and whistles available today. You would think that industry giants like Google would take an interest in producing valid solutions. Oh well, I'm grateful they allow us mere peons the freedom to use the very neat things they do. Things can always get worse.

Note: There is a check box a little ways below the embed code that can be checked to produce the old object code that can still be run through the converter. Alleluia! Kind of makes this exercise a little null and void for the moment except for the entertainment value for those with a geeky mindset.

Maintaining valid html code can be difficult with all the items available for portraying on a web page these days. Taking the time to see if some of the largest websites of industry giants validate can be enlightening.,,, etc. can prove somewhat interesting. And included here are two of our computing giants with a major online retailer to boot, and they hire the industry's so called professionals, so why bother with code validation? Well that is a whole another topic I won't cover here, but if you are interested in knowing you can try this.

So, what shall we do to ameliorate our current situation? Current as of 27 January 2011 anyway.

Here is an embedded video that won't break your site's strict xhtml validation:

This is the code that validates highlighted in yellow:
<object type="application/x-shockwave-flash" data=";hl=en_US" width="95%" height="321px" style="max-width:480px"><param name="movie" value=";hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param> </object>

It can be copied as is and pasted into any xhtml strict page that validates and the page will still validate baring any unforeseen accidentally injected errors.

Here is youTube's currently offered embed code for the same video highlighted in black that will break xhtml strict validation:

<iframe title="YouTube video player" class="youtube-player" type="text/html" width="640" height="390" src="" frameborder="0" allowFullScreen></iframe>

If this code highlighted in black is copied and pasted into your xhtml strict valid page the video will display, but the code will break your validation. The code is a little simpler than the old code, and youTube has its reasons for the switch found here. But, who wants code that doesn't validate?

I would take the time to build a nice new converter to xhtml strict for the new code format, but I don't know if it is possible yet, and you never know who far down the rabbit hole you have to chase that beast before you will find success. Also, since there is a checkbox for retrieving the old code the original converter which was well made can still be used, so we don't need to go there. There is a minor problem with the original converted code I have noticed: although it validates the video does not appear in a firefox browser. Interesting anomaly. The price you pay for valid code. . .

Okay, so lets say there wasn't that convenient checkbox for choosing the old format. (I'm not sure it was there when I first encountered the new format, but I can't prove it.) What could be done without too much trouble?

  1. First you have to retain some embed code that validates:
  2. Second, you have to be able to locate the exact code that identifies the specific youTube video:
  3. Third, you have to retrieve the url that identifies the new video you wish to embed:
  4. Finally, you have to paste the new video's modified url: minus the portion cut out and replaced with the added portion into the valid code where the old url was located.

And there you have it: Brand new xhtml strict valid code that can be pasted into your website to maintain xhtml strict validation!

Valid XHTML 1.0 Strict © 2011