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=""></param>
<param name="wmode" value="transparent"></param>
<embed src="" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355">

I changed it to

<object type="application/x-shockwave-flash" style="width:425px; height:355px;" data="">
<param name="movie" value="" />
<param name="wmode" value="transparent" />

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