Valid YouTube and Vimeo code
November 12, 2008 | In Developer, Web 2.0Death to the EMBED tag!
YouTube and Vimeo currently provide invalid embedding code to video with OBJECT tag. There are four steps to modify this:
1. Original code.
<object width="425" height="344">
<param name="movie" value="http://www.youtube.com/v/AfAc41Pvn5o&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/AfAc41Pvn5o&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed>
</object>
2. Copy the ’src’ and ‘type’ attributes, adding these to the OBJECT declaration.
<object width="425" height="344" src="http://www.youtube.com/v/AfAc41Pvn5o&hl=en&fs=1" type="application/x-shockwave-flash"></object>
3. Change the ’src’ attribute to ‘data’.
<object width="425" height="344" data="http://www.youtube.com/v/AfAc41Pvn5o&hl=en&fs=1" type="application/x-shockwave-flash"></object>
4. Delete the ‘EMBED’ tags.
Here is what you should end up with:
<object width="425" height="344" data="http://www.youtube.com/v/AfAc41Pvn5o&hl=en&fs=1" type="application/x-shockwave-flash">
<param name="movie" value="http://www.youtube.com/v/AfAc41Pvn5o&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
</object>
This code is now valid XHTML 1.0 markup.
Markup to special character conversion thanks to HTMLizer.