For those who scour the net for a simple solution for a problem called “Make my YouTube embed code pass w3c HTML validation“, your in the PERFECT place, because what you’re about to read is not only simple, but the perfect solution!
Very confident me will now show you how its done
…
The usual Youtube embed code(do not pass w3c HTML validation)
NOTE: where ($vid) is your Youtube video ID
<object width="430" height="347">
<param name="movie" value="http://www.youtube.com/v/($vid)&hl=en_US&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/($vid)&hl=en_US&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="430" height="347"></embed>
</object>
Ok you see, when using this code to display video, it will never pass validation but instead will render validation error such as “there is no attribute allowfullscreen”, “width” among others.
But with the code below, you can perfectly validate your Youtube pages
see below and test it yourself.
NOTE: ($vid) is = to your Youtube video ID, for example http://www.youtube.com/v/RHzC7YOxkVY&hl=en_US&fs=1 the emphasized letters is your Youtube ID, So now presenting the code…
<object type="application/x-shockwave-flash" width="430" height="347" data="http://www.youtube.com/v/($vid)">
<param name="movie" value="http://www.youtube.com/v/($vid)" /></object>
Oh my, yes its much shorter, and its better!!!