nazly.me

Weblog of Nazly Ahmed

Nazly Ahmed

Nazly Ahmed

Web Developer. PHP Addict. Wordpress Hacker. FOSS Enthusiast. (Micro)Blogger. Photo Hobbyist. Cricket Fanatic. Husband. Dad.

I always wanted to embed YouTube videos to my blog posts. But when I add the YouTube code to embed videos in my blog posts, I get validation errors from the W3C Markup Validation Service. I have been very careful on maintaining my blog to be XHTML 1.0 compliant. So finally I have found the solution to sort out the issue. The main reason being YouTube's use of the <embed> tag, which has been deprecated in XHTML 1.0. So I had to modify that code a bit to suit my need to be XHTML 1.0 compliant.

This is the code that YouTube gives to embed a video to a page

<object width="425" height="355">
<param name="movie" value="http://www.youtube.com/v/rybb85zc5yY"></param>
<param name="wmode" value="transparent"></param>
<embed src="http://www.youtube.com/v/rybb85zc5yY" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355">
</embed>
</object>

I changed it to

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

I tested the code on all popular browsers and it works fine. If you come across any browser versions that has any problem with this code not displaying the video please do let me know with the browser and its version.

Posted on 11th March 2008 07:46:22